/var/www/vhosts/ihelp.ro/httpdocs/src/Controller/Dashboard
NameSizeModeActions
DashboardController.php21390644editdlrm
GalleryImagesController.php36690644editdlrm
OrdersController.php38060644editdlrm
ProductFavoritesController.php65610644editdlrm
ProductsController.php63100644editdlrm
ProfilesController.php34670644editdlrm
UserAddressesController.php50090644editdlrm
UsersController.php24020644editdlrm
Edit: /var/www/vhosts/ihelp.ro/httpdocs/src/Controller/Dashboard/OrdersController.php (3806B)
paginate = [ 'contain' => ['OrderStatuses', 'OrderProducts', 'OrderProducts.Products'], ]; $orders = $this->paginate($this->Orders->find()->where(['Orders.user_id' => $this->userAuth->id]))->toArray(); $this->set(compact('orders')); } /** * ordersSent method */ public function ordersReceived() { $this->loadModel('OrderProducts'); $items = $this->paginate( $this->OrderProducts->find() ->select(['OrderProducts.id', 'Orders.id', 'Orders.uuid', 'Orders.created', 'OrderStatuses.id', 'OrderStatuses.name']) ->contain(['Orders', 'Orders.OrderStatuses']) ->group(['Orders.id']) ->where(['OrderProducts.product_user_id' => $this->userAuth->id]) )->toArray(); $this->set(compact('items')); } /** * View method */ public function viewMyOrders($uuid = null) { if (!empty($uuid)) { $order = $this->Orders->find() ->contain([ 'OrderStatuses', 'UserAddresses', 'OrderProducts', 'OrderProducts.Products', 'PaymentMethods', 'Awbs' ]) ->where(['Orders.uuid' => $uuid, 'Orders.user_id' => $this->userAuth->id]) ->first(); } else { $this->Flash->error(__('A apărut o problemă. Vă rugăm să încercați din nou')); return $this->redirect(['prefix' => 'Dashboard', 'controller' => 'Orders', 'action' => 'index']); } $this->set(compact('order')); } /** * View method */ public function viewOrdersReceived($uuid = null) { if (!empty($uuid)) { $order = $this->Orders->find() ->contain([ 'UserAddresses', 'OrderStatuses', 'OrderProducts' => function ($q) { return $q->where(['OrderProducts.product_user_id' => $this->userAuth->id]); }, 'PaymentMethods', 'Awbs' => function ($q) { return $q->where(['Awbs.sender_user_id' => $this->userAuth->id]); } ]) ->where(['Orders.uuid' => $uuid]) ->first(); } else { $this->Flash->error(__('A apărut o problemă. Vă rugăm să încercați din nou')); return $this->redirect(['prefix' => 'Dashboard', 'controller' => 'Orders', 'action' => 'index']); } $this->set(compact('order')); } /** * Disable/Activate */ public function delete($uuid = null) { if (!empty($uuid)) { $this->request->allowMethod(['post']); $order = $this->Orders->find() ->where(['Orders.uuid' => $uuid, 'Orders.user_id' => $this->userAuth->id]) ->first(); $order->is_active = ($order->is_active === true) ? false : true; if ($this->Orders->save($order)) { $this->Flash->success(__('Comanda a fost anulata.')); } else { $this->Flash->error(__('Comanda nu a fost anulata. Va rugam incercati mai tarziu.')); } } else { $this->Flash->error(__('A apărut o problemă. Vă rugăm să încercați din nou')); } return $this->redirect(['prefix' => 'Dashboard', 'controller' => 'Orders', 'action' => 'index']); } }