public function saleviewAction() { $id = $this->getRequest()->getParam('id'); $db = new report_Model_DbTable_DbReport(); $db_global = new Application_Model_DbTable_DbGlobal(); $row_sale_order = $db->getSaleOrderView($id); $row_sale_order_item = $db_global->getSaleOrderDetail($id); $this->view->row_sale_order = $row_sale_order; $this->view->row_sale_order_item = $row_sale_order_item; }
public function editOrder($data, $id) { $db = $this->getAdapter(); $db_globle = new Application_Model_DbTable_DbGlobal(); $db->beginTransaction(); $session = new Zend_Session_Namespace('auth'); $GetUserId = $session->user_id; $user_type = $session->level; try { $arr_order = array('customer_id' => $data["customer"], 'location_id' => 1, 'user_id' => $GetUserId, 'currency_id' => $data["currency"], 'net_total' => $data["gran_total"], 'all_total' => $data["gran_total"], 'paid' => $data["gran_pay"], 'balance' => $data["balance"], 'date' => $data["date"], 'status' => 1); $where = $db->quoteInto("so_id=?", $id); $this->_name = "tb_sale_order"; $this->update($arr_order, $where); $arr_order_his = array('customer_id' => $data["customer"], 'so_id' => $id, 'type' => 2, 'location_id' => 1, 'order_no' => $data["saleorder_no"], 'user_id' => $GetUserId, 'currency_id' => $data["currency"], 'sub_total' => $data["gran_total"], 'paid' => $data["gran_pay"], 'balance' => $data["balance"], 'date' => $data["date"], 'status' => 1); $this->_name = "tb_sale_order_history"; $sale_order_his = $this->insert($arr_order_his); $row_old_product = $db_globle->getSaleOrderDetail($id); if ($row_old_product) { foreach ($row_old_product as $rs_old_product) { $row_product_exist = $db_globle->getQtyProductExist($rs_old_product["pro_id"]); $arr_product_update = array('qty_onhand' => $row_product_exist["qty_onhand"] + $rs_old_product["total_qty"], 'qty_available' => $row_product_exist["qty_available"] + $rs_old_product["total_qty"], 'qty_onsold' => $row_product_exist["qty_onsold"] - $rs_old_product["total_qty"]); $this->_name = "tb_product"; $where = $db->quoteInto("pro_id=?", $rs_old_product["pro_id"]); $this->update($arr_product_update, $where); $row_prolocation_exist = $db_globle->getQtyProLocationExist($rs_old_product["pro_id"]); if ($row_prolocation_exist) { $arr_prolocation = array('qty_onhand' => $row_prolocation_exist["qty_onhand"] + $rs_old_product["total_qty"], 'qty_available' => $row_prolocation_exist["qty_available"] + $rs_old_product["total_qty"], 'qty_onsold' => $row_prolocation_exist["qty_onsold"] - $rs_old_product["total_qty"]); $this->_name = "tb_prolocation"; $where = array("pro_id=?" => $rs_old_product["pro_id"], "location_id=?" => 1); $this->update($arr_prolocation, $where); } } } $arr_order_detail_update = array('status' => 0); $this->_name = "tb_sale_order_detail"; $where = $db->quoteInto("so_id=?", $id); $this->update($arr_order_detail_update, $where); $identify = $data["identity"]; $ids = explode(',', $identify); foreach ($ids as $i) { $arr_order_detail = array('so_id' => $id, 'pro_id' => $data["item_id" . $i], 'qty' => $data["qty" . $i], 'total_qty' => $data["total_qty" . $i], 'price_per_unit' => $data["price_per_qty" . $i], 'total_price' => $data["total_price" . $i], 'sub_total' => $data["total_price" . $i], 'status' => 1); $this->_name = "tb_sale_order_detail"; $this->insert($arr_order_detail); $arr_order_his_detail = array('hs_id' => $sale_order_his, 'pro_id' => $data["item_id" . $i], 'qty' => $data["qty" . $i], 'total_qty' => $data["total_qty" . $i], 'price_per_unit' => $data["price_per_qty" . $i], 'total_price' => $data["total_price" . $i], 'sub_total' => $data["total_price" . $i]); $this->_name = "tb_sale_order_history_detail"; $this->insert($arr_order_his_detail); $row_product_exist = $db_globle->getQtyProductExist($data["item_id" . $i]); if ($row_product_exist) { print_r($row_product_exist); $arr_product = array('qty_onhand' => $row_product_exist["qty_onhand"] - $data["total_qty" . $i], 'qty_available' => $row_product_exist["qty_available"] - $data["total_qty" . $i], 'qty_onsold' => $row_product_exist["qty_onsold"] + $data["total_qty" . $i]); $this->_name = "tb_product"; $where = $db->quoteInto("pro_id=?", $data["item_id" . $i]); $this->update($arr_product, $where); } $row_prolocation_exist = $db_globle->getQtyProLocationExist($data["item_id" . $i]); if ($row_prolocation_exist) { $arr_prolocation = array('qty_onhand' => $row_prolocation_exist["qty_onhand"] - $data["total_qty" . $i], 'qty_available' => $row_prolocation_exist["qty_available"] - $data["total_qty" . $i], 'qty_onsold' => $row_prolocation_exist["qty_onsold"] + $data["total_qty" . $i]); $this->_name = "tb_prolocation"; $where = array("pro_id=?" => $data["item_id" . $i], "location_id=?" => 1); $this->update($arr_prolocation, $where); } } //exit(); $db->commit(); } catch (Exception $e) { $db->rollBack(); $e->getMessage() . "in" . $e->getFile() . "code" . $e->getCode() . "on line" . $e->getLine(); exit; } }
public function poseditAction() { $id = $this->getRequest()->getParam('id'); $db = new saleorder_Model_DbTable_DbSaleOrder(); $db_global = new Application_Model_DbTable_DbGlobal(); $session = $session_user = new Zend_Session_Namespace('auth'); $user_id = $session_user->fullname; $this->view->user = $user_id; $qty_warning = $db_global->getSettingByCode(6); $this->view->qty_warning = $qty_warning; $row_sale_order = $db_global->getSaleOrderById($id); $row_sale_order_detail = $db_global->getSaleOrderDetail($id); $this->view->data_sale_order = $row_sale_order_detail; $form = new saleorder_Form_FrmSaleOrder(); $this->view->frm = $form->FrmSaleOrder($row_sale_order); $currency_setting = $db_global->getSettingByCode(1); $company_name = $db_global->getSettingByCode(4); $slogan = $db_global->getSettingByCode(5); $address = $db_global->getSettingByCode(2); $tel = $db_global->getSettingByCode(3); $this->view->currency_setting = $currency_setting; $this->view->company_name = $company_name; $this->view->slogan = $slogan; $this->view->address = $address; $this->view->tel = $tel; $itemRows = $db->getProductOption(); $this->view->itemsOption = $itemRows; if ($this->getRequest()->isPost()) { $data = $this->getRequest()->getPost(); if (isset($data["save"])) { // print_r($data);exit(); $db->editOrder($data, $id); Application_Form_FrmMessage::redirectUrl('/index/pos'); } elseif (isset($data["km"]) == 2) { $dbs = new Application_Model_DbTable_DbSiteLanguages(); $ids = 2; $lang = $dbs->getbyid($ids); $session_lang = new Zend_Session_Namespace('lang'); $session_lang->unlock(); $session_lang->lang_id = $lang['id']; $session_lang->lang = $lang['language']; //print_r($lang);exit(); } elseif (isset($data["en"]) == 1) { $dbs = new Application_Model_DbTable_DbSiteLanguages(); $ids = 1; $lang = $dbs->getbyid($ids); $session_lang = new Zend_Session_Namespace('lang'); $session_lang->unlock(); $session_lang->lang_id = $lang['id']; $session_lang->lang = $lang['language']; //$this->_redirect('/login'); //exit(); } } }