public function editAction() { $id = $this->getRequest()->getParam("id"); $db = new Product_Model_DbTable_DbProduct(); $row = $db->getProductByID($id); if ($this->getRequest()->isPost()) { $data = $this->getRequest()->getPost(); $db->edit($data, $id); if (isset($data["save_new"])) { Application_Form_FrmMessage::Sucessfull("Product was updateed!", "/product/index/add"); } else { Application_Form_FrmMessage::Sucessfull("Product was updateed!", "/product/index"); } } $frm = new Product_Form_FrmProduct(); $frm = $frm->FrmProduct($row); Application_Model_Decorator::removeAllDecorator($frm); $this->view->form = $frm; }
public function productDetailAction() { if ($this->getRequest()->getParam('id')) { $id = $this->getRequest()->getParam('id') ? $this->getRequest()->getParam('id') : '0'; //if user type wrong url $user = $this->GetuserInfoAction(); $gb = new Application_Model_DbTable_DbGlobal(); if ($user["level"] != 1 and $user["level"] != 2) { $exist = $gb->productLocation($id, $user["location_id"]); if ($exist == "") { $this->_redirect("product/index/index"); } } else { $pro_exist = $gb->myProductExist($id); if (!$pro_exist) { $this->_redirect("product/index/index"); } } $session_stock = new Zend_Session_Namespace('stock'); $productinfo = new Product_Model_DbTable_DbProduct(); //get product info detail $getpro_info_rows = $productinfo->getProductInfoDetail($id); if ($getpro_info_rows['photo'] == "") { $getpro_info_rows['photo'] = "no-img.gif"; } $this->view->photo = $getpro_info_rows['photo']; $this->view->form = $getpro_info_rows; //for view product loaction 22/8/13 $orderDetail = $productinfo->getOrderItemVeiw($id); $this->view->lostItemDetail = $orderDetail; //for product in stock 22/8/13 if ($user["level"] == 1 or $user["level"] == 2) { $rowproduct = $productinfo->getProductStock($id); $this->view->pro_qty = $rowproduct; } //get product move history 23/8/13 $rows = $productinfo->moveproduct($id); $list = new Application_Form_Frmlist(); $glClass = new Application_Model_GlobalClass(); $rows = $glClass->getTransactionType($rows, BASE_URL, true); $columns = array("TRANSACTION_TYPE_CAP", "DATE_CAP", "LOCATION_NAME_CAP", "QTY_CAP", "QTY_BEFORE_CAP", "QTY_AFTER_CAP", "REMARK_CAP", "BY_USER_CAP"); $link = array('module' => 'product', 'controller' => 'index', 'action' => 'update'); $this->view->list_history = $list->getCheckList(1, $columns, $rows); //view sale order history $row_sale_history = $productinfo->getSaleHistory($id); $glClass = new Application_Model_GlobalClass(); $row_sale_history = $glClass->getTypeHistory($row_sale_history, BASE_URL, true); $row_sale_history = $glClass->getStatusType($row_sale_history, BASE_URL, true); $columns1 = array("TYPE_CAP", "ORDER_ADD_CAP", "CUSTOMER_CAP", "ORDER_DATE_CAP", "ORDER_STATUS_CAP", "TOTAL_PRICE_CAP", "QTY_CAP", "UNIT_PRICE_CAP", "SUB_TOTAL_CAP"); $link1 = array('module' => 'product', 'controller' => 'index', 'action' => 'update'); $list = new Application_Form_Frmlist(); $this->view->list_order_history = $list->getCheckList(1, $columns1, $row_sale_history, array('item_name' => $link1, 'Name' => $link1), "", "items", "left", false, "move_history"); //for purchase history $row_purchase_history = $productinfo->getPurchaseHistory($id); $glClass = new Application_Model_GlobalClass(); $row_purchase_history = $glClass->getTypeHistory($row_purchase_history, BASE_URL, true); $row_purchase_history = $glClass->getStatusType($row_purchase_history, BASE_URL, true); $columns1 = array("TYPE_CAP", "ORDER_ADD_CAP", "VENDOR_CAP", "ORDER_DATE_CAP", "ORDER_STATUS_CAP", "TOTAL_PRICE_CAP", "QTY_CAP", "UNIT_PRICE_CAP", "SUB_TOTAL_CAP"); $link_pur = array('module' => 'product', 'controller' => 'index', 'action' => 'update'); $list = new Application_Form_Frmlist(); $this->view->list_purchase_history = $list->getCheckList(1, $columns1, $row_purchase_history, array('item_name' => $link_pur, 'Name' => $link_pur), "", "items", "left", false, "purchase_history"); } }
public function viewTransferAction() { $id = $this->getRequest()->getParam('id') ? $this->getRequest()->getParam('id') : '0'; $transfer = new Product_Model_DbTable_DbUpdateTransfer(); $exist = $transfer->transferExist($id); $user = $this->GetuserInfoAction(); if ($exist == "") { //redirect if no transfer this id $this->_redirect("product/adjust-stock/index"); } else { $user_exist = $transfer->transferUserExist($id, $user["location_id"]); if ($user_exist == "") { //redirect if no transfer this id $this->_redirect("product/adjust-stock/index"); } } if ($this->getRequest()->getPost()) { // $post= $this->getRequest()->getPost(); // print_r($post);exit(); Application_Form_FrmMessage::message("You Haven't Permission To Change !"); Application_Form_FrmMessage::redirectUrl("/product/adjust-stock/index"); // $post = $this->getRequest()->getPost(); // $update = new Product_Model_DbTable_DbUpdateTransfer(); // $update->updateTransferStockTransaction($post); // $this->_redirect("product/adjust-stock/index"); } $db = new Application_Model_DbTable_DbGlobal(); $productinfo = new Product_Model_DbTable_DbProduct(); $rows = $productinfo->getTransferInfo($id); $row_item = $productinfo->getTransferItem($id); $this->view->transfer_item = $row_item; $frm = new Product_Form_FrmTransfer(); $frm_transfer = $frm->transferItem($rows); Application_Model_Decorator::removeAllDecorator($frm_transfer); $this->view->form_transfer = $frm_transfer; ///view on select location form table $getOption = new Application_Model_GlobalClass(); $locationRows = $getOption->getLocationOption(); $this->view->locationOption = $locationRows; ///view on select location form table $toLocationRows = $getOption->tolocationOption(); $this->view->tolocationOption = $toLocationRows; $itemRows = $getOption->getProductOption(); $this->view->productOption = $itemRows; //for add product; $formpopup = new Application_Form_FrmPopup(null); $formproduct = $formpopup->popuProduct(null); Application_Model_Decorator::removeAllDecorator($formproduct); $this->view->form = $formproduct; //for add location $formAdd = $formpopup->popuLocation(null); Application_Model_Decorator::removeAllDecorator($formAdd); $this->view->form_addstock = $formAdd; }
public function FrmProduct($data = null) { $db = new Product_Model_DbTable_DbProduct(); $pro_code = $db->getProductCode(); $code = new Zend_Dojo_Form_Element_TextBox("code"); $code->setAttribs(array('dojoType' => $this->text, 'class' => 'fullside', 'readonly' => 'readonly', 'style' => 'color:red;')); $code->setValue($pro_code); $name_en = new Zend_Dojo_Form_Element_TextBox('name_en'); $name_en->setAttribs(array('dojoType' => $this->text, 'class' => 'fullside')); $name_kh = new Zend_Dojo_Form_Element_TextBox('name_kh'); $name_kh->setAttribs(array('dojoType' => $this->text, 'class' => 'fullside')); $db_brand = new Product_Model_DbTable_DbBrand(); $row = $db_brand->getBrand(); $brand = new Zend_Dojo_Form_Element_FilteringSelect('brand'); $brand->setAttribs(array('dojoType' => $this->filter, 'class' => 'fullside')); $opt_parent = array('0' => $this->tr->translate("SELECT")); if ($row) { foreach ($row as $rs) { $opt_parent[$rs["id"]] = $rs["name"]; } } $brand->setMultiOptions($opt_parent); $db_cate = new Product_Model_DbTable_DbCategory(); $row = $db_cate->getCategory(); $category = new Zend_Dojo_Form_Element_FilteringSelect('category'); $category->setAttribs(array('dojoType' => $this->filter, 'class' => 'fullside')); $opt_cat = array('0' => $this->tr->translate("SELECT")); if ($row) { foreach ($row as $rs) { $opt_cat[$rs["id"]] = $rs["name"]; } } $category->setMultiOptions($opt_cat); $pro_size = new Zend_Dojo_Form_Element_TextBox("pro_size"); $pro_size->setAttribs(array('dojoType' => $this->text, 'class' => 'fullside')); $db_measure = new Product_Model_DbTable_DbMeasure(); $row = $db_measure->getMeasure(); $measure = new Zend_Dojo_Form_Element_FilteringSelect('measure'); $measure->setAttribs(array('dojoType' => $this->filter, 'class' => 'fullside')); $opt_measure = array('0' => $this->tr->translate("SELECT")); if ($row) { foreach ($row as $rs) { $opt_measure[$rs["id"]] = $rs["name"]; } } $measure->setMultiOptions($opt_measure); $qty_onhand = new Zend_Dojo_Form_Element_TextBox("qty_onhand"); $qty_onhand->setAttribs(array('dojoType' => $this->t_num, 'class' => 'fullside')); $opt_statu = array(1 => $this->tr->translate("Active"), 0 => $this->tr->translate("Deactve")); $status = new Zend_Dojo_Form_Element_FilteringSelect('status'); $status->setAttribs(array('dojoType' => $this->filter, 'class' => 'fullside')); $status->setMultiOptions($opt_statu); $this->addElements(array($name_en, $name_kh, $brand, $status, $code, $category, $pro_size, $qty_onhand, $measure)); if ($data) { $name_en->setValue($data["name_en"]); $name_kh->setValue($data["name_kh"]); $brand->setValue($data["brand_id"]); $category->setValue($data["cate_id"]); $code->setValue($data["code"]); $pro_size->setValue($data["size"]); $measure->setValue($data["measure_id"]); $qty_onhand->setValue($data["qty_onhand"]); $status->setValue($data["status"]); } return $this; }