Esempio n. 1
0
 public function getListByCategoryId($category)
 {
     $rowSet = $this->getDbTable()->fetchAll("c_id = {$category}");
     $products = array();
     foreach ($rowSet as $row) {
         $product = new Application_Model_Product();
         $product->setId($row->p_id);
         $product->setLabel($row->p_label);
         $product->setDesc($row->p_desc);
         $products[] = $product;
     }
     return $products;
 }
Esempio n. 2
0
 public function save(Application_Model_Product $model)
 {
     $return = 0;
     $data = array('ID' => $model->getId(), 'name' => $model->getName(), 'description' => $model->getDescription(), 'productNo' => $model->getProductNo(), 'quantity' => $model->getQuantity(), 'sellingprice' => $model->getSellingprice(), 'costprice' => $model->getCostprice());
     if (null === ($id = $model->getId())) {
         unset($data['ID']);
         $return = $this->getDbTable()->insert($data);
     } else {
         $return = $this->getDbTable()->update($data, array('ID=?' => $id));
     }
     return $return;
 }
 public function find($id)
 {
     $result = $this->getDbTable()->find($id);
     if (0 == count($result)) {
         return;
     }
     $row = $result->current();
     $product = new Application_Model_Product();
     $product->setId($row->id);
     $product->setName($row->name);
     $product->setCategoryId($row->category_id);
     $product->setFile($row->file);
     $product->setImage($row->image);
     $product->setDescription($row->description);
     $product->setCurrency($row->currency_id, $row->price);
     return $product;
 }
Esempio n. 4
0
 public function getListByCategoryId($id)
 {
     $where = 'c_id = ' . $id;
     $rowSet = $this->getDbTable()->fetchAll($where);
     $products = array();
     foreach ($rowSet as $row) {
         $product = new Application_Model_Product();
         $product->setId($row->p_id);
         $product->setLabel($row->p_label);
         $product->setDescription($row->p_description);
         $product->setPrice($row->p_price);
         $product->setCid($row->c_id);
         $products[] = $product;
     }
     return $products;
 }
Esempio n. 5
0
 public function updateAction()
 {
     // action body
     $form = new Application_Form_Product();
     $this->view->form = $form;
     $id = $this->getRequest()->getParam('id');
     $model = new Application_Model_Product();
     $form_data = $model->getProductById($id)->toArray();
     $form->populate($form_data[0]);
     if ($this->getRequest()->isPost()) {
         if ($form->isValid($this->getRequest()->getParams())) {
             $data_to_edit = $form->getValues();
             $model = new Application_Model_Product();
             $model->updateProduct($id, $data_to_edit);
             $this->redirect('Product/list');
         }
     }
     /*
      $con = new Application_Model_Product();
     
      $data = array(
      'name'=>'ahmed',
      'price'=>50
     
     
      );
     
      $con->updateProduct(7,$data);
     * 
     */
 }
Esempio n. 6
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;
 }