public function returnInAction()
 {
     $formFilter = new purchase_Form_FrmSearch();
     $this->view->formFilter = $formFilter->frmRetrunIn();
     Application_Model_Decorator::removeAllDecorator($formFilter);
     $list = new Application_Form_Frmlist();
     $db = new Application_Model_DbTable_DbGlobal();
     $vendor_sql = "SELECT ri.returnin_id, ro.return_no, ri.returnin_no, ri.date_return_in,  ri.all_total\n\t\tFROM tb_return_vendor_in AS ri,tb_return AS ro WHERE ri.returnout_id= ro.return_id ";
     // 		$user = $this->GetuserInfoAction();
     // 		$str_condition = "INNER JOIN tb_return_vendor_item  As rv ON r.return_id = rv.return_id WHERE rv.location_id" ;
     // 		$vendor_sql .= $db->getAccessPermission($user["level"], $str_condition, $user["location_id"]);
     if ($this->getRequest()->isPost()) {
         $post = $this->getRequest()->getPost();
         //echo $post["order"];
         if ($post['invoice_in'] != '') {
             $vendor_sql .= " AND ri.returnin_no LIKE '%" . trim($post['invoice_in']) . "%'";
         }
         if ($post['invoice_out'] != '') {
             $vendor_sql .= " AND ro.return_no LIKE '%" . trim($post['invoice_out']) . "%'";
         }
         $start_date = trim($post['search_start_date']);
         $end_date = trim($post['search_end_date']);
         if ($start_date != "" && $end_date != "" && strtotime($end_date) >= strtotime($start_date)) {
             $vendor_sql .= " AND ri.date_return BETWEEN '{$start_date}' AND '{$end_date}'";
         }
     }
     $vendor_sql .= " ORDER BY ri.returnin_id DESC";
     $rows = $db->getGlobalDb($vendor_sql);
     $columns = array("RETURN_NO", "INVOICE_NO", "RETURN_DATE_CAP", "TOTAL_CAP_DOLLAR");
     $link = array('module' => 'purchase', 'controller' => 'return', 'action' => 'detail-return-itemin');
     $urlEdit = BASE_URL . "/purchase/return/update-return-item-in";
     $this->view->list = $list->getCheckList(1, $columns, $rows, array('returnin_no' => $link), $urlEdit);
 }
 protected function ActionPurchaseAction()
 {
     $id = $this->getRequest()->getParam('id') ? $this->getRequest()->getParam('id') : '0';
     if ($this->getRequest()->isPost()) {
         $data = $this->getRequest()->getPost();
         //    		if($data["status"]!=="Paid"){
         //    			if(@$data['payment']=='payment'){
         //     				$update_payment_order = new purchase_Model_DbTable_DbPurchaseVendor();
         //     				$update_payment_order-> updateVendorOrderPayment($data);
         //    			}
         //    			elseif(@$data['Update']=='Update'){
         //    				$update_order = new purchase_Model_DbTable_DbPurchaseVendor();
         //    				$update_order->updateVendorOrder($data);
         //    			}
         //    			$this->_redirect("purchase/index/index");
         //    		}
         //    		else{
         //    			Application_Form_FrmMessage::message("Cann't Edit!Purchase Order Has Been Payment Already");
         //    		    Application_Form_FrmMessage::redirectUrl("/purchase/index/index");
         //    		}
         $update_order = new purchase_Model_DbTable_DbPurchaseVendor();
         if (isset($data["cancel_order"])) {
             if ($data["oldStatus"] != 6) {
                 $update_order->cancelPurchaseOrder($data);
                 Application_Form_FrmMessage::message("You have been cancel purchase order success! ");
                 Application_Form_FrmMessage::redirectUrl("/purchase/index/index");
             } else {
                 Application_Form_FrmMessage::message("Cannot cancel again! Becuase cancel order has been cancel already! ");
                 Application_Form_FrmMessage::redirectUrl("/purchase/index/index");
             }
         } else {
             if (isset($data["Update"]) or $data["update"]) {
                 if ($data["oldStatus"] == 6) {
                     if ($data["status"] == 6) {
                         Application_Form_FrmMessage::message("Cannot cancel again! Becuase cancel order has been cancel already! ");
                     } else {
                         $update_order->updateVendorCancellOrder($data);
                         Application_Form_FrmMessage::message("You has been re-order success!");
                         Application_Form_FrmMessage::redirectUrl("/purchase/index/index");
                     }
                 } else {
                     $update_order->updateVendorStock($data);
                     Application_Form_FrmMessage::message("You have been Update order success! ");
                     //print_r($data);exit();
                     //Application_Form_FrmMessage::redirectUrl("/purchase/index/index");
                 }
             }
         }
         // 		if($data["Update"]=="Update"){
         // 			Application_Form_FrmMessage::message("Cann't Edit!Purchase Order Has Been Payment Already");
         // 			Application_Form_FrmMessage::redirectUrl("/purchase/index/index");
         // 		}
     }
     $user = $this->GetuserInfoAction();
     if ($user["level"] != 1 and $user["level"] != 2) {
         if ($user["level"] == 4) {
             $this->_redirect("purchase/index/index");
         }
         $gb = new Application_Model_DbTable_DbGlobal();
         $exist = $gb->userSaleOrderExist($id, $user["location_id"]);
         if ($exist == "") {
             $this->_redirect("purchase/index/index");
         }
     }
     $purchase = new purchase_Model_DbTable_DbPurchaseOrder();
     $rows = $purchase->purchaseInfo($id);
     $db = new Application_Model_DbTable_DbGlobal();
     $formStock = new Application_Form_purchase();
     $formpurchase_info = $formStock->productOrder($rows);
     Application_Model_Decorator::removeAllDecorator($formpurchase_info);
     // omit default zend html tag
     $this->view->form = $formpurchase_info;
     $this->view->status = $rows["status"];
     //veiw sales order left 23/8/13
     $row_purchase = $purchase->showPurchaseOrder();
     $this->view->product = $row_purchase;
     //get item of this lost
     $orderModel = new purchase_Model_DbTable_DbPurchaseOrder();
     $orderDetail = $orderModel->getPurchaseID($id);
     $this->view->rowsOrder = $orderDetail;
     $session_record_order = new Zend_Session_Namespace('record_order');
     $session_record_order->orderDetail = $orderDetail;
     $session_vendor_info = new Zend_Session_Namespace('vendor_info');
     $session_vendor_info->vendorinfo = $rows;
     //for check if status update
     if ($rows["status"] != 0) {
         $this->_redirect("purchase/advance/advance/id/" . $id);
     }
     // item option in select
     $items = new Application_Model_GlobalClass();
     $itemRows = $items->getProductOption();
     $this->view->itemsOption = $itemRows;
     $formControl = new Application_Form_FrmAction(null);
     $formViewControl = $formControl->AllAction(null);
     Application_Model_Decorator::removeAllDecorator($formViewControl);
     $this->view->control = $formViewControl;
     //for search left
     $search = new purchase_Form_FrmSearch();
     $frmsearch = $search->formSearch();
     Application_Model_Decorator::removeAllDecorator($frmsearch);
     $this->view->get_frmsearch = $frmsearch;
     //for add product;
     $formpopup = new Application_Form_FrmPopup(null);
     $formproduct = $formpopup->popuProduct(null);
     Application_Model_Decorator::removeAllDecorator($formproduct);
     $this->view->form_add_product = $formproduct;
     //for add vendor
     $formvendor = $formpopup->popupVendor(null);
     Application_Model_Decorator::removeAllDecorator($formvendor);
     $this->view->form_vendor = $formvendor;
     //for add location
     $formAdd = $formpopup->popuLocation(null);
     Application_Model_Decorator::removeAllDecorator($formAdd);
     $this->view->form_addstock = $formAdd;
     //for link advane
     $this->view->getorder_id = $id;
 }
 public function updateCustomerQuoteAction()
 {
     $session_stock = new Zend_Session_Namespace('stock');
     $id = $this->getRequest()->getParam('id') ? $this->getRequest()->getParam('id') : '0';
     if ($this->getRequest()->isPost()) {
         $data = $this->getRequest()->getPost();
         $update_to_quote = new sales_Model_DbTable_DbSalesOrder();
         if (@$data["quote"] != "") {
             $update_to_quote->updateCustomerQuote($data);
         } elseif (@$data['Update'] != "") {
             $update_to_quote->quoteUpdate($data);
         }
         $this->_redirect("sales/sales-order/index");
     }
     $sql = "SELECT o.order_id,o.customer_id,o.LocationId,o.order,o.sales_ref,o.date_order,o.status,o.payment_method,o.currency_id,\n\t\to.remark,o.net_total,o.discount_type,o.discount_value,o.paid,o.all_total,o.balance,\n\t\tc.contact_name,c.phone,c.add_name,c.add_remark\n\t\tFROM tb_sales_order AS o\n\t\tINNER JOIN tb_customer AS c ON c.customer_id= o.customer_id\n\t\tINNER JOIN tb_sales_order_item AS so ON so.order_id=o.order_id\n\t\tWHERE o.order_id=" . $id;
     $db = new Application_Model_DbTable_DbGlobal();
     $row = $db->getGlobalDbRow($sql);
     $formStock = new Application_Form_purchase();
     $formStockEdit = $formStock->SalesOrder($row, $session_stock->stockID);
     Application_Model_Decorator::removeAllDecorator($formStockEdit);
     // omit default zend html tag
     $this->view->form = $formStockEdit;
     //get item of this lost
     $orderModel = new sales_Model_DbTable_DbOrder();
     $orderDetail = $orderModel->getSalesOderID($id);
     $this->view->rowsOrder = $orderDetail;
     // item option in select
     $items = new Application_Model_GlobalClass();
     $itemRows = $items->getProductOption($session_stock->stockID);
     $this->view->itemsOption = $itemRows;
     $formControl = new Application_Form_FrmAction(null);
     $formViewControl = $formControl->AllAction(null);
     Application_Model_Decorator::removeAllDecorator($formViewControl);
     $this->view->control = $formViewControl;
     //for search left
     $search = new purchase_Form_FrmSearch();
     $frmsearch = $search->formSearch();
     Application_Model_Decorator::removeAllDecorator($frmsearch);
     $this->view->get_frmsearch = $frmsearch;
     //for add product;
     $formpopup = new Application_Form_FrmPopup(null);
     $formproduct = $formpopup->popuProduct(null, $session_stock->stockID);
     Application_Model_Decorator::removeAllDecorator($formproduct);
     $this->view->form_product = $formproduct;
     //for customer
     $formpopup = $formpopup->popupCustomer(null, $session_stock->stockID);
     Application_Model_Decorator::removeAllDecorator($formpopup);
     $this->view->form_customer = $formpopup;
     //for add location
     $formAdd = $formpopup->popuLocation(null, $session_stock->stockID);
     Application_Model_Decorator::removeAllDecorator($formAdd);
     $this->view->form_addstock = $formAdd;
 }