public function addAction()
 {
     if ($this->getRequest()->isPost()) {
         try {
             $add_product = new Product_Model_DbTable_DbAddProduct();
             $post = $this->getRequest()->getPost();
             $add_product->addProduct($post);
             //
             Application_Form_FrmMessage::message("INSERT_SUCCESS");
             if (@$post['Save'] != "") {
                 Application_Form_FrmMessage::redirectUrl('/product/index/index');
             }
         } catch (Exception $e) {
             Application_Form_FrmMessage::messageError("INSERT_ERROR", $err = $e->getMessage());
         }
     }
     $formProduct = new Application_Form_FrmProduct(null);
     $formStockAdd = $formProduct->AddProductForm(null);
     Application_Model_Decorator::removeAllDecorator($formStockAdd);
     $this->view->form = $formStockAdd;
     //control
     $formAddProdcut = new Application_Form_FrmAction(null);
     $FrmAdd = $formAddProdcut->AllAction(null);
     Application_Model_Decorator::removeAllDecorator($FrmAdd);
     $this->view->control = $FrmAdd;
     ///view on select form
     $items = new Application_Model_GlobalClass();
     $locationRows = $items->getLocationOption();
     $this->view->locations = $locationRows;
     //for add location
     $formpopup = new Application_Form_FrmPopup(null);
     $formAdd = $formpopup->popuLocation(null);
     Application_Model_Decorator::removeAllDecorator($formAdd);
     $this->view->form_addstock = $formAdd;
     $form_branch = $formpopup->popupBranch(null);
     Application_Model_Decorator::removeAllDecorator($form_branch);
     $this->view->form_brand = $form_branch;
     $form_measure = $formpopup->popuMeasure(null);
     Application_Model_Decorator::removeAllDecorator($form_measure);
     $this->view->form_measure = $form_measure;
     $form_category = $formpopup->popupCategory(null);
     Application_Model_Decorator::removeAllDecorator($form_category);
     $this->view->form_category = $form_category;
     $db = new Application_Model_DbTable_DbGlobal();
     $row = $db->getSettingById(12);
     $this->view->setpricebybranch = $row['key_value'];
 }
 public function updatePurchaseOrderAction()
 {
     $id = $this->getRequest()->getParam('id') ? $this->getRequest()->getParam('id') : '0';
     $db_global = new Application_Model_DbTable_DbGlobal();
     $sql = "SELECT * FROM tb_purchase_order WHERE order_id =" . $id;
     $rs = $db_global->getGlobalDbRow($sql);
     //print_r($rs);exit();
     if ($rs["status"] == 4 or $rs["status"] == 5) {
         $db = new Application_Model_DbTable_DbGlobal();
         $row = $db->getSettingById(15);
         if ($row['key_value'] == 0) {
             Application_Form_FrmMessage::message("You don't have permission to update purchase that recieved already");
             Application_Form_FrmMessage::redirectUrl("/purchase/index/index");
         } else {
             $this->ActionPurchaseAction();
         }
     } else {
         $this->ActionPurchaseAction();
     }
 }