Exemplo n.º 1
0
 public function adduserorderAction()
 {
     $product_model = new Application_Model_Product();
     $user_model = new Application_Model_User();
     $order = new Application_Model_Order();
     $order_details_model = new Application_Model_OrderDetails();
     //$this->view->products = $product_model->listProducts();
     $allproducts = $product_model->availableProducts('"1"');
     $allRooms = $user_model->listRooms();
     //get last  order id ,, max
     $userid = $this->user_id;
     $user_order = $order->getUserOrders($userid);
     if (count($user_order)) {
         //3shan mmkn tkon lsa new user has no orders&order detailss
         $max = $user_order[0]['id'];
         for ($i = 0; $i < count($user_order); $i++) {
             if ($user_order[$i]['id'] > $max) {
                 $max = $user_order[$i]['id'];
             }
         }
         // get order details fr table 2 .. prod ids
         $order_details = $order_details_model->getOrderDetails($max);
         ///var_dump($order_details);
         $productsid = array();
         for ($i = 0; $i < count($order_details); $i++) {
             array_push($productsid, $order_details[$i]['product_id']);
         }
         // get prods info
         $productdetails = array();
         for ($i = 0; $i < count($productsid); $i++) {
             array_push($productdetails, $product_model->getProductById($productsid[$i]));
         }
         $this->view->latestorder = $productdetails;
     }
     //mskt araay fiha info kl prod fe a5r order
     $this->view->products = $allproducts;
     $this->view->rooms = $allRooms;
     $this->view->myname = $this->user_name;
     $this->view->myimg = $this->user_image;
 }