public function advanceAction()
 {
     $db = new Application_Model_DbTable_DbGlobal();
     $id = $this->getRequest()->getParam('id') ? $this->getRequest()->getParam('id') : '0';
     // 		$r = new purchase_Model_DbTable_DbPurchaseVendor();
     // 		$r->updatePurcaheToInProgress($id);
     if ($this->getRequest()->isPost()) {
         $data = $this->getRequest()->getPost();
         //print_r($data);
         if (isset($data["payment"]) == "UPDATE") {
             $update_purchase = new purchase_Model_DbTable_DbAdvance();
             $get_result = $update_purchase->updatePurchaseOrder($data);
         } elseif (isset($data["recieve_paid"])) {
             $recieve_paid = new purchase_Model_DbTable_DbAdvance();
             $result = $recieve_paid->receivePaidOrder($data);
             Application_Form_FrmMessage::message("Product have been recieved Success!!");
             Application_Form_FrmMessage::redirectUrl("/purchase/advance/advance/id/" . $id);
         } elseif (isset($data["reorder"])) {
             $reorder = new purchase_Model_DbTable_DbAdvance();
             $update_reoder = $reorder->rePurchaseOrder($data);
             Application_Form_FrmMessage::message("Product have been reoder Success!!");
         }
     }
     ///link left not yet get from DbpurchaseOrder
     // 		$session_vendor_info = new Zend_Session_Namespace('vendor_info');
     // 		$rows= $session_vendor_info->vendorinfo;
     //		print_r($rows);exit();
     $purchase = new purchase_Model_DbTable_DbPurchaseOrder();
     $rows = $purchase->purchaseInfo($id);
     $formStock = new Application_Form_purchase();
     $formpurchase_info = $formStock->productOrder($rows);
     Application_Model_Decorator::removeAllDecorator($formpurchase_info);
     // omit default zend html tag
     $this->view->form_purchase = $formpurchase_info;
     $this->view->status = $rows["status"];
     //get item of this order
     // 		$orderModel = new purchase_Model_DbTable_DbPurchaseOrder();
     // 		$orderDetail = $orderModel->getPurchaseID($id);
     // 		$this->view->rowsOrder = $orderDetail;
     $session_record_order = new Zend_Session_Namespace('record_order');
     //create in update purchase order in page indexcontroller action update
     $orderDetail = $session_record_order->orderDetail;
     $this->view->rowsOrder = $orderDetail;
     $sql = "SELECT si.order_id,CONCAT(p.item_name,' (',p.item_code,' )') AS item_name,p.qty_perunit ,p.pro_id,si.remark as pi_remark,si.qty_order,si.price,si.total_befor,si.disc_type,\n\t\tsi.disc_value,si.is_free,si.sub_total,s.discount_value,s.`remark`,s.`discount_value`,s.`paid`,s.net_total,s.`all_total`,s.`balance`\n\t\tFROM tb_purchase_order_item AS si,tb_product AS p ,tb_purchase_order AS s\n\t\t WHERE p.pro_id = si.pro_id AND si.order_id = s.order_id AND  si.order_id={$id}";
     $result = $db->getGlobalDb($sql);
     $this->view->orderItem = $result;
     // 		 if($rows['status']==4){
     // 		 	Application_Form_FrmMessage::message("You Can't Access Advance! Order Is Payment Already");
     // 		 	//$this->_redirect("/purchase/index/detail-purchase-order/id/".$id);
     // 		 }
     //for get item receive qty order
     $qty_receive = new purchase_Model_DbTable_DbPurchaseAdvance();
     $row_receive = $qty_receive->getProductReceived($id);
     //print_r($row_receive);
     $this->view->rowsreceived = $row_receive;
     // item option in select
     $items = new Application_Model_GlobalClass();
     $itemRows = $items->getProductOption();
     $this->view->itemsOption = $itemRows;
     $items = new Application_Model_GlobalClass();
     $itemRows = $items->getProductOption();
     $this->view->items = $itemRows;
     //get control
     $formControl = new Application_Form_FrmAction(null);
     $formViewControl = $formControl->AllAction(null);
     Application_Model_Decorator::removeAllDecorator($formViewControl);
     $this->view->control = $formViewControl;
     //for add product;
     $formpopup = new Application_Form_FrmPopup(null);
     $formproduct = $formpopup->popuProduct(null);
     Application_Model_Decorator::removeAllDecorator($formproduct);
     $this->view->form = $formproduct;
     //for add vendor
     $formStockAdd = $formpopup->popupVendor(null);
     Application_Model_Decorator::removeAllDecorator($formStockAdd);
     $this->view->form_vendor = $formStockAdd;
     //for add location
     $formAdd = $formpopup->popuLocation(null);
     Application_Model_Decorator::removeAllDecorator($formAdd);
     $this->view->form_addstock = $formAdd;
     // item option in select
     // 		$items = new Application_Model_GlobalClass();
     // 		$itemRows = $items->getProductOption();
     // 		$this->view->itemsOption = $itemRows;
 }
 public function advanceTestAction()
 {
     $db = new Application_Model_DbTable_DbGlobal();
     $id = $this->getRequest()->getParam('id') ? $this->getRequest()->getParam('id') : '0';
     $r = new purchase_Model_DbTable_DbPurchaseVendor();
     $r->updatePurcaheToInProgress($id);
     if ($this->getRequest()->isPost()) {
         $data = $this->getRequest()->getPost();
     }
     ///link left not yet get from DbpurchaseOrder
     $session_vendor_info = new Zend_Session_Namespace('vendor_info');
     $rows = $session_vendor_info->vendorinfo;
     //		print_r($rows);exit();
     // 		$purchase = new purchase_Model_DbTable_DbPurchaseOrder();
     // 		$rows = $purchase->purchaseInfo($id);
     $formStock = new Application_Form_purchase();
     $formpurchase_info = $formStock->productOrder($rows);
     Application_Model_Decorator::removeAllDecorator($formpurchase_info);
     // omit default zend html tag
     $this->view->form_purchase = $formpurchase_info;
     //get item of this order
     // 		$orderModel = new purchase_Model_DbTable_DbPurchaseOrder();
     // 		$orderDetail = $orderModel->getPurchaseID($id);
     // 		$this->view->rowsOrder = $orderDetail;
     $session_record_order = new Zend_Session_Namespace('record_order');
     //create in update purchase order in page indexcontroller action update
     $orderDetail = $session_record_order->orderDetail;
     $this->view->rowsOrder = $orderDetail;
     if ($rows['status'] == 4) {
         Application_Form_FrmMessage::message("You Can't Access Advance! Order Is Payment Already");
         //$this->_redirect("/purchase/index/detail-purchase-order/id/".$id);
     }
     //for get item receive qty order
     $qty_receive = new purchase_Model_DbTable_DbPurchaseAdvance();
     $row_receive = $qty_receive->getProductReceived($id);
     //print_r($row_receive);
     $this->view->rowsreceived = $row_receive;
     // item option in select
     $items = new Application_Model_GlobalClass();
     $itemRows = $items->getProductOption();
     $this->view->itemsOption = $itemRows;
     $items = new Application_Model_GlobalClass();
     $itemRows = $items->getProductOption();
     $this->view->items = $itemRows;
     //get control
     $formControl = new Application_Form_FrmAction(null);
     $formViewControl = $formControl->AllAction(null);
     Application_Model_Decorator::removeAllDecorator($formViewControl);
     $this->view->control = $formViewControl;
     //for add product;
     $formpopup = new Application_Form_FrmPopup(null);
     $formproduct = $formpopup->popuProduct(null);
     Application_Model_Decorator::removeAllDecorator($formproduct);
     $this->view->form = $formproduct;
     //for add vendor
     $formStockAdd = $formpopup->popupVendor(null);
     Application_Model_Decorator::removeAllDecorator($formStockAdd);
     $this->view->form_vendor = $formStockAdd;
     //for add location
     $formAdd = $formpopup->popuLocation(null);
     Application_Model_Decorator::removeAllDecorator($formAdd);
     $this->view->form_addstock = $formAdd;
     // item option in select
     $items = new Application_Model_GlobalClass();
     $itemRows = $items->getProductOption();
     $this->view->itemsOption = $itemRows;
 }