public function getFullUserProfile()
 {
     try {
         if (!$this->id) {
             throw new Exception('Не задан id пользователя');
         }
         $user['profile'] = $this->userTableModel->readRecordsById();
         $this->userTableModel->readUserAddress();
         $this->userTableModel->readUserPhones();
         $user['contacts'] = $this->userTableModel->getUserContacts();
         $orderModel = new OrderTableModel();
         $orderModel->setTable('order_body as b, order_type as t, order_status as s, order_delivery_type as d');
         $orderModel->setId($this->id);
         $user['orders'] = $orderModel->readRecordsById('user_id', '*', 'AND b.status_id = s.id AND b.delivery_type = d.id AND s.type_id = t.id');
         if (!empty($user['orders'])) {
             foreach ($user['orders'] as $key => $order) {
                 if ($key !== 'rowCount') {
                     $user['orders'][$key]['body'] = Basket::getProductsList($order['body']);
                 }
             }
         }
         $user['profile']['photo'] = !empty($user['profile'][0]['photo']) ? $user['profile'][0]['photo'] : \app\helpers\Path::DEFAULT_USER_AVATAR;
         $this->fullProfile = $user;
         return $user;
     } catch (Exception $ex) {
         $ex->getMessage();
     }
 }
Esempio n. 2
0
 public function checkoutAction()
 {
     $fc = FrontController::getInstance();
     $model = new FrontModel();
     if ($_SERVER['REQUEST_METHOD'] === 'POST') {
         $orderModel = new OrderTableModel();
         $orderModel->setData();
         $orderModel->addRecord();
         Basket::deleteBasket();
         \app\services\Session::setMsg('Ваш заказ принят. Наш менеджер свяжется с вами в ближайшее время', 'success');
         header('Location: /');
         exit;
     } else {
         $output = $model->render('../views/order/order.php', 'withoutSliderAndSidebar');
         $fc->setPage($output);
     }
 }
Esempio n. 3
0
 public function getAllOrders($fields = '*', $condition = '')
 {
     $model = new OrderTableModel();
     $model->setTable('order_body');
     $model->readAllRecords($fields, $condition);
     $records = $model->getAllRecords();
     $userModel = new UserTableModel();
     foreach ($records as $key => $record) {
         $userModel->setId((int) $record['user_id']);
         $userModel->setTable('user');
         $records[$key]['user_name'] = $userModel->readRecordsById('id', 'username')[0]['username'];
         $records[$key]['delivery'] = $model->getDeliveryForId((int) $record['delivery_type']);
         $records[$key]['status'] = $model->getStatusForId((int) $record['status_id']);
     }
     return $records;
 }
Esempio n. 4
0
 public function setDeliveryTypeAction()
 {
     header('Content-type: text/plain; charset=utf-8');
     header('Cache-Control: no-store, no-cache');
     header('Expires: ' . date('r'));
     $orderId = Validate::validateInputVar('orderId', 'INPUT_GET', 'int');
     $typeId = Validate::validateInputVar('typeId', 'INPUT_GET', 'int');
     if (!$orderId || !$typeId) {
         throw new Exception('Неверный id для смены типа доставки');
     }
     $model = new OrderTableModel();
     echo $model->setDeliveryType($orderId, $typeId);
 }