Ejemplo n.º 1
0
 public function preDispatch(Zend_Controller_Request_Abstract $request)
 {
     //clear session from search session
     //$this->clearSession();
     $session_user = new Zend_Session_Namespace('auth');
     $module = $request->getModuleName();
     $controller = $request->getControllerName();
     $action = $request->getActionName();
     $url = $module . "/" . $controller . "/" . $action;
     $_url = "";
     //have login
     if (isset($session_user->arr_acl)) {
         $arr_acl = $session_user->arr_acl;
         $valid_action = FALSE;
         foreach ($arr_acl as $acl) {
             if ($module == $acl["module"] && $controller == $acl["controller"]) {
                 $valid_action = TRUE;
                 break;
             } elseif ($module === "rsvAcl" && $controller === "user" && $action === "change-password") {
                 //all user level can change password all
                 $valid_action = TRUE;
                 break;
             } elseif ($module === "rsvAcl" && $session_user->level === "1") {
                 //user level 1 can access all action in module "rsvAcl"
                 $valid_action = TRUE;
                 break;
             }
         }
         //redirect to homepage
         if (!$valid_action) {
             //just open block below
             if ($url !== "default/index/index" && $url !== "default/error/error" && $url !== "default/index/changepassword" && $url !== "default/index/logout") {
                 $_url = '/';
             }
             $_have = false;
             foreach ($this->_exception_url as $i => $val) {
                 if ($url === $val) {
                     $_have = true;
                     break;
                 }
             }
             if (!$_have) {
                 $_url = '/';
             }
         } else {
             $_url = $this->rewriteUrl($url);
         }
     } else {
         //no login
         //redirect to login page
         if ($url !== "default/index/index") {
             $_url = "/";
         }
     }
     if (!empty($_url)) {
         // 	 		echo"url here". $_url;exit();
         $_url = "/home";
         Application_Form_FrmMessage::redirectUrl($_url);
     }
 }
Ejemplo n.º 2
0
 public function editAction()
 {
     if ($this->getRequest()->isPost()) {
         $data = $this->getRequest()->getPost();
         $db = new Callecterall_Model_DbTable_DbCallecterall();
         try {
             if (isset($data['btn_save'])) {
                 $db->updatcallecterall($data);
                 Application_Form_FrmMessage::message('ការ​បញ្ចូល​​ជោគ​ជ័យ');
             }
             if (isset($data['btn_save_close'])) {
                 $db->updatcallecterall($data);
                 Application_Form_FrmMessage::message('ការ​បញ្ចូល​​ជោគ​ជ័យ');
                 Application_Form_FrmMessage::redirectUrl('/callecterall/Callecterall');
             }
         } catch (Exception $e) {
             Application_Form_FrmMessage::message("INSERT_FAIL");
             $err = $e->getMessage();
             Application_Model_DbTable_DbUserLog::writeMessageError($err);
         }
     }
     $id = $this->getRequest()->getParam('id');
     $db = new Callecterall_Model_DbTable_DbCallecterall();
     $row = $db->getcallecterallbyid($id);
     $fm = new Callecterall_Form_Frmcallecterall();
     $frm = $fm->Frmcallecterall($row);
     Application_Model_Decorator::removeAllDecorator($frm);
     $this->view->Form_Frmcallecterall = $frm;
 }
Ejemplo n.º 3
0
 function editAction()
 {
     $db_deposite = new Capital_Model_DbTable_DbCapital();
     if ($this->getRequest()->isPost()) {
         $_data = $this->getRequest()->getPost();
         try {
             if (isset($_data["save"])) {
                 $db_deposite->updateCapital($_data);
                 Application_Form_FrmMessage::Sucessfull("ការ​បញ្ចូល​ជោគ​ជ័យ !", '/capital/capital/add');
             } elseif (isset($_data["save_close"])) {
                 $db_deposite->updateCapital($_data);
                 Application_Form_FrmMessage::Sucessfull("ការ​បញ្ចូល​ជោគ​ជ័យ !", '/capital/capital');
             } else {
                 Application_Form_FrmMessage::redirectUrl("/capital/capital");
             }
         } catch (Exception $e) {
             Application_Form_FrmMessage::message("ការ​បញ្ចូល​មិន​ជោគ​ជ័យ");
             $err = $e->getMessage();
             Application_Model_DbTable_DbUserLog::writeMessageError($err);
         }
     }
     $id = $this->getRequest()->getParam("id");
     $row = $db_deposite->getpartnerById($id);
     $deposite = new Capital_Form_FrmCapitale();
     $frm = $deposite->frmCapital($row);
     Application_Model_Decorator::removeAllDecorator($frm);
     $this->view->frm = $frm;
 }
Ejemplo n.º 4
0
    public function editAction()
    {
    if($this->getRequest()->isPost()){
			$data=$this->getRequest()->getPost();
			$db = new Group_Model_DbTable_DbCallecteralltype();
			try {
				$db->updatcallecterall($data);
				Application_Form_FrmMessage::message($this->tr->translate('EDIT_SUCCESS'));
				Application_Form_FrmMessage::redirectUrl('/other/callecteralltype');
			} catch (Exception $e) {
				Application_Form_FrmMessage::message("INSERT_FAIL");
				$err = $e->getMessage();
				Application_Model_DbTable_DbUserLog::writeMessageError($err);
			}
		
    	}
    	$id = $this->getRequest()->getParam('id');
    		
    	$db = new Callecterall_Model_DbTable_DbCallecterall();
    	$row  = $db->getcallecterallbyid($id);
    	$fm = new Callecterall_Form_Frmcallecterall();
	    $frm = $fm->Frmcallecterall($row); 
	    Application_Model_Decorator::removeAllDecorator($frm);
	    $this->view->Form_Frmcallecterall = $frm;
    		
    
    }
Ejemplo n.º 5
0
 public function addAction()
 {
     $db = new saleorder_Model_DbTable_DbSaleOrder();
     $datas = $db->getAllProduct();
     $saleorder = $db->getAllSaleOrder();
     if ($this->getRequest()->isPost()) {
         $data = $this->getRequest()->getPost();
         $db->addSaleOrder($data);
         Application_Form_FrmMessage::redirectUrl('/saleorder/index/add');
     }
     $this->view->getdata = $datas;
     $this->view->saleorder = $saleorder;
     $form = new saleorder_Form_FrmSaleOrder();
     $this->view->frm = $form->FrmSaleOrder();
     $this->view->FrmSaleOrderUpdate = $form->FrmSaleOrderUpdate();
     $itemRows = $db->getProductOption();
     $this->view->itemsOption = $itemRows;
 }
Ejemplo n.º 6
0
 public function preDispatch(Zend_Controller_Request_Abstract $request)
 {
     //clear session from search session
     $this->clearSession();
     $session_user = new Zend_Session_Namespace('auth');
     $module = $request->getModuleName();
     $controller = $request->getControllerName();
     $action = $request->getActionName();
     $url = $module . "/" . $controller . "/" . $action;
     $_url = "";
     //have login
     if (isset($session_user->arr_acl)) {
         $arr_acl = $session_user->arr_acl;
         $valid_action = FALSE;
         foreach ($arr_acl as $acl) {
             if ($module == $acl["module"] && $controller == $acl["controller"]) {
                 $valid_action = TRUE;
                 break;
             } elseif ($module === "rsvAcl" && $session_user->level === "1") {
                 //user level 1 can access all action in module "rsvAcl"
                 $valid_action = TRUE;
                 break;
             }
         }
         //redirect to homepage
         if (!$valid_action) {
             if ($url !== "default/index/home" && $url !== "default/index/web-elements" && $url !== "default/error/error") {
                 $_url = '/default/index/home';
             }
         } else {
             $_url = $this->rewriteUrl($url);
         }
     } else {
         //no login
         //redirect to login page
         if ($url !== "default/index/index") {
             $_url = "/default/index/index";
         }
     }
     if (!empty($_url)) {
         Application_Form_FrmMessage::redirectUrl($_url);
     }
 }
Ejemplo n.º 7
0
    function editAction(){
    if($this->getRequest()->isPost()){
			$data=$this->getRequest()->getPost();
			$db = new Group_Model_DbTable_DbClientBlackList();
			try {
					$db->updatClientBlackList($data);
					Application_Form_FrmMessage::message($this->tr->translate('EDIT_SUCCESS'));
					Application_Form_FrmMessage::redirectUrl('/group/Clientblacklist');
			} catch (Exception $e) {
				Application_Form_FrmMessage::message("EDIT_FAIL");
				$err = $e->getMessage();
				Application_Model_DbTable_DbUserLog::writeMessageError($err);
			}
		}
		$db = new Group_Model_DbTable_DbClientBlackList();
    	$id = $this->getRequest()->getParam("id");
    	$row = $db->getBlackListById($id);
    	$fm = new Group_Form_FrmClientBlackList();
    	$frm = $fm->FrmClientBlackList($row);
    	Application_Model_Decorator::removeAllDecorator($frm);
    	$this->view->Form_client_blacklist = $frm;
    	
    }
Ejemplo n.º 8
0
 public function editAction()
 {
     $id = $this->getRequest()->getParam('id');
     $db = new Callecterall_Model_DbTable_DbCallecteralllist();
     $row = $db->getcallecteralllistbyid($id);
     $is_fund = $db->checkisFun($id);
     if ($is_fund['is_fund'] == 0) {
         Application_Form_FrmMessage::Sucessfull('កាបពាំ្ចនេះបានសងរួចហើយ', '/callecterall/Callecteralllist');
     }
     if ($this->getRequest()->isPost()) {
         $data = $this->getRequest()->getPost();
         $db = new Callecterall_Model_DbTable_DbCallecteralllist();
         //print_r($data);exit();
         try {
             if (isset($data['save_close'])) {
                 $db->updatcallecteralllist($data);
                 //print_r($data);exit();
                 Application_Form_FrmMessage::message('ការ​បញ្ចូល​​ជោគ​ជ័យ');
                 Application_Form_FrmMessage::redirectUrl('/callecterall/Callecteralllist/');
             }
             if (isset($data['save_new'])) {
                 $db->updatcallecteralllist($data);
                 Application_Form_FrmMessage::message('ការ​បញ្ចូល​​ជោគ​ជ័យ');
                 Application_Form_FrmMessage::redirectUrl('/callecterall/Callecteralllist/add');
             }
         } catch (Exception $e) {
             Application_Form_FrmMessage::message("INSERT_FAIL");
             $err = $e->getMessage();
             Application_Model_DbTable_DbUserLog::writeMessageError($err);
         }
     }
     $fm = new Callecterall_Form_Frmcallecteralllist();
     $frm = $fm->callecteralllist($row);
     Application_Model_Decorator::removeAllDecorator($frm);
     $this->view->Form_Frmcallecterall = $frm;
 }
Ejemplo n.º 9
0
 public function deleteoweAction()
 {
     if ($this->getRequest()->isPost()) {
         $_data = $this->getRequest()->getPost();
         $_db = new Application_Model_DbTable_DbMoneyTransactions();
         $_db->updateOwerbyTran($_data);
         Application_Form_FrmMessage::redirectUrl('/reports/index/rptowe');
         exit;
     }
 }
Ejemplo n.º 10
0
 public function updatePurchaseOrder($data)
 {
     try {
         $db = $this->getAdapter();
         $db->beginTransaction();
         $db_global = new Application_Model_DbTable_DbGlobal();
         $session_user = new Zend_Session_Namespace('auth');
         $userName = $session_user->user_name;
         $GetUserId = $session_user->user_id;
         //for update order by id\
         $id_order_update = $data['id'];
         //print_r($id_order_update);exit();
         //$recieved_id = $data["recieve_id"];
         //update info of order in tb_purchase order
         // Select all qty in tb_product and tb_purchase_order_item for compare product exist or not for update qty to old qty
         $sql_itm = "SELECT\n\t\t\t\t\t\t(SELECT p.pro_id FROM tb_product AS p WHERE p.pro_id = po.`pro_id`) AS pro_id\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t,(SELECT p.qty_onorder FROM tb_product AS p WHERE p.pro_id = po.`pro_id`) AS qty_onorder\n\t\t\t\t\t\t\n\t\t\t\t\t\t,(SELECT p.qty_onhand \tFROM tb_product AS p WHERE p.pro_id = po.`pro_id`) AS qty_onhand\n\t\t\t\t\t\t\n\t\t\t\t\t\t,(SELECT p.qty_available \tFROM tb_product AS p WHERE p.pro_id = po.`pro_id`) AS qty_available\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t, SUM(po.`qty_order`) AS qty_order FROM\n\t\t\t\t\t\n\t\t\t\t\ttb_purchase_order_item AS po WHERE po.order_id = {$id_order_update} GROUP BY po.pro_id";
         $rows_order = $db_global->getGlobalDb($sql_itm);
         if ($rows_order) {
             foreach ($rows_order as $row) {
                 $row_get = $db_global->porductLocationExist($row["pro_id"], $data["old_location"]);
                 $qty_onorder = $row["qty_onorder"] - $row["qty_order"];
                 $qty_available = $row["qty_available"] - $row["qty_order"];
                 $qty_onorder_prolo = $row_get["qty_onorder"] - $row["qty_order"];
                 $qty_available_prolo = $row_get["qty_avaliable"] - $row["qty_order"];
                 if ($qty_onorder <= 0 or $qty_onorder_prolo <= 0) {
                     Application_Form_FrmMessage::message("The Main Stock or Location Stock is Not enough ");
                     Application_Form_FrmMessage::redirectUrl("/purchase/advance/advance/id/" . $id_order_update);
                     exit;
                 } else {
                     $update_product = array("qty_onorder" => $qty_onorder, "qty_available" => $qty_available);
                     $this->_name = "tb_product";
                     $where = $this->getAdapter()->quoteInto("pro_id=?", $row["pro_id"]);
                     $this->update($update_product, $where);
                     unset($update_product);
                     $update_prolocation = array("qty_onorder" => $qty_onorder_prolo, "qty_avaliable" => $qty_available_prolo);
                     $this->_name = "tb_prolocation";
                     $where = $this->getAdapter()->quoteInto("ProLocationID=?", $row_get["ProLocationID"]);
                     $this->update($update_prolocation, $where);
                 }
             }
         }
         $info_purchase_order = array("vendor_id" => $data['v_name'], "LocationId" => $data["LocationId"], "order" => $data['txt_order'], "date_order" => $data['order_date'], "status" => $data["status"], "remark" => $data['remark'], "user_mod" => $GetUserId, "timestamp" => new Zend_Date(), "discount_value" => $data["dis_value"], "discount_real" => $data["global_disc"], "paid" => $data['paid'], "net_total" => $data["net_total"], "all_total" => $data['all_total'], "payment_method" => $data["payment_name"], "currency_id" => $data["currency"], "balance" => $data['balance']);
         $this->_name = "tb_purchase_order";
         $where = $this->getAdapter()->quoteInto("order_id=?", $id_order_update);
         $this->update($info_purchase_order, $where);
         //$db_global->updateRecord($info_purchase_order,$id_order_update,"order_id","tb_purchase_order");
         $sql = "DELETE FROM tb_purchase_order_item WHERE order_id IN ({$id_order_update})";
         $db_global->deleteRecords($sql);
         unset($sql);
         $sql_history = "DELETE FROM tb_purchase_order_history WHERE `order` IN ({$id_order_update})";
         $db_global->deleteRecords($sql_history);
         unset($sql_history);
         /// update
         $ids = explode(',', $data['identities']);
         //	print_r($ids);
         foreach ($ids as $i) {
             if (@$data["pricefree_" . $i]) {
                 $is_free = 1;
             } else {
                 $is_free = 0;
             }
             // Insert New purchase order item in old order_id
             $data_item[$i] = array('order_id' => $id_order_update, 'pro_id' => $data['item_id_' . $i], 'qty_order' => $data['qty' . $i], 'price' => $data['price' . $i], 'sub_total' => $data['total' . $i], 'total_befor' => $data['total' . $i], 'remark' => $data['remark' . $i], 'disc_value' => $data['dis-value' . $i], 'is_free' => $is_free);
             //print_r($data_item); echo "<br />";echo "<br />";
             $db->insert("tb_purchase_order_item", $data_item[$i]);
             unset($data_item[$i]);
             $data_history[$i] = array('order' => $id_order_update, 'pro_id' => $data['item_id_' . $i], 'type' => 1, 'customer_id' => $data['v_name'], 'status' => $data["status"], 'order_total' => $data['total' . $i], 'qty' => $data['qty' . $i], 'unit_price' => $data['price' . $i], 'sub_total' => $data['total' . $i], 'last_update_date' => new Zend_Date());
             //print_r($data_history);exit();
             $db->insert("tb_purchase_order_history", $data_history[$i]);
             unset($data_history[$i]);
             $locationid = $data['LocationId'];
             $itemId = $data['item_id_' . $i];
             $qtyrecord = $data['qty' . $i];
             //qty on 1 record
             // Update stock in tb_product
             $rows = $db_global->productLocationInventory($itemId, $locationid);
             //to check product location
             if ($rows) {
                 $update_prolo = array("qty_onorder" => $rows["qty_onorder"] + $qtyrecord, "qty_avaliable" => $rows["qty_avaliable"] + $qtyrecord, "last_mod_date" => new Zend_Date());
                 $this->_name = "tb_prolocation";
                 $where = $this->getAdapter()->quoteInto("ProLocationID=?", $rows["ProLocationID"]);
                 $this->update($update_prolo, $where);
                 unset($update_prolo);
                 $update_product = array("qty_onorder" => $rows["qty_onorder"] + $qtyrecord, "qty_available" => $rows["qty_available"] + $qtyrecord, "last_mod_date" => new Zend_Date());
                 $this->_name = "tb_product";
                 $where = $this->getAdapter()->quoteInto("pro_id=?", $itemId);
                 $this->update($update_product, $where);
             } else {
                 $update_prolo = array("qty_onorder" => $rows["qty_onorder"] + $qtyrecord, "qty_avaliable" => $rows["qty_avaliable"] + $qtyrecord, "last_mod_date" => new Zend_Date());
                 $this->_name = "tb_prolocation";
                 $this->insert($update_prolo);
                 unset($update_prolo);
                 $update_product = array("qty_onorder" => $rows["qty_onorder"] + $qtyrecord, "qty_available" => $rows["qty_available"] + $qtyrecord, "last_mod_date" => new Zend_Date());
                 $this->_name = "tb_product";
                 $this->insert($update_product);
             }
         }
         $db->commit();
     } catch (Exception $e) {
         $db->rollBack();
         $e->getMessage();
     }
 }
Ejemplo n.º 11
0
 public function CustomerAddOrderPayment($data)
 {
     try {
         $db = $this->getAdapter();
         $db->beginTransaction();
         $db_global = new Application_Model_DbTable_DbGlobal();
         $session_user = new Zend_Session_Namespace('auth');
         $userName = $session_user->user_name;
         $GetUserId = $session_user->user_id;
         $ids = explode(',', $data['identity']);
         //print_r($ids);exit();
         //command below not yet use
         // 		$idrecord=$data['customer_id'];
         // 		$datainfo=array(
         // 				"contact_name"=>$data['contact'],
         // 				"phone"       =>$data['txt_phone'],
         // 		);
         // 		//updage customer info
         // 		$itemid=$db_global->updateRecord($datainfo, $idrecord, "customer_id","tb_customer");
         // 		unset($datainfo);
         if ($data['order'] == "") {
             $date = new Zend_Date();
             $order_add = "SO" . $date->get('hh-mm-ss');
         } else {
             $order_add = $data['order'];
         }
         $db->getProfiler()->setEnabled(true);
         $info_order = array("customer_id" => $data['customer_id'], "LocationId" => $data['LocationId'], "order" => $order_add, "sales_ref" => $data['sales_ref'], "date_order" => $data['order_date'], "status" => $data['status'], "remark" => $data['remark'], "user_mod" => $GetUserId, "timestamp" => new Zend_Date(), "net_total" => $data['net_total'], "discount_value" => $data['dis_value'], "discount_real" => $data["global_disc"], "paid" => $data['paid'], "all_total" => $data['all_total'], "balance" => $data['remain']);
         //and info of order
         $id_order = $db_global->addRecord($info_order, "tb_sales_order");
         unset($info_order);
         Zend_Debug::dump($db->getProfiler()->getLastQueryProfile()->getQuery());
         Zend_Debug::dump($db->getProfiler()->getLastQueryProfile()->getQueryParams());
         $db->getProfiler()->setEnabled(false);
         $ids = explode(',', $data['identity']);
         foreach ($ids as $i) {
             if (@$data["pricefree_" . $i]) {
                 $check = 1;
             } else {
                 $check = 0;
             }
             $db->getProfiler()->setEnabled(true);
             //add history order
             $data_history = array('pro_id' => $data['item_id_' . $i], 'type' => 2, 'order' => $id_order, 'customer_id' => $data['customer_id'], 'date' => $data['order_date'], "status" => $data['status'], 'order_total' => $data['remain'], 'qty' => $data['qty' . $i], 'unit_price' => $data['price' . $i], 'sub_total' => $data['total' . $i]);
             $db->insert("tb_order_history", $data_history);
             unset($data_history);
             Zend_Debug::dump($db->getProfiler()->getLastQueryProfile()->getQuery());
             Zend_Debug::dump($db->getProfiler()->getLastQueryProfile()->getQueryParams());
             $db->getProfiler()->setEnabled(false);
             $db->getProfiler()->setEnabled(true);
             $history = array('pro_id' => $data['item_id_' . $i], 'type' => 2, 'order' => $id_order, 'customer_id' => $data['customer_id'], 'date' => $data['order_date'], "status" => $data['status'], 'order_total' => $data['remain'], 'qty' => $data['qty' . $i], 'unit_price' => $data['price' . $i], 'sub_total' => $data['total' . $i], "dis_value" => $data['dis-value' . $i], "dis_amount" => $data["real-value" . $i], 'is_free' => $check);
             $db->insert("tb_sale_order_history", $history);
             unset($history);
             Zend_Debug::dump($db->getProfiler()->getLastQueryProfile()->getQuery());
             Zend_Debug::dump($db->getProfiler()->getLastQueryProfile()->getQueryParams());
             $db->getProfiler()->setEnabled(false);
             $db->getProfiler()->setEnabled(true);
             $sale_history = array('pro_id' => $data['item_id_' . $i], 'type' => 2, 'order' => $id_order, 'customer_id' => $data['customer_id'], 'date' => $data['order_date'], "status" => $data['status'], 'order_total' => $data['remain'], 'qty' => $data['qty' . $i], 'unit_price' => $data['price' . $i], 'sub_total' => $data['total' . $i]);
             $db->insert("tb_purchase_order_history", $sale_history);
             unset($sale_history);
             Zend_Debug::dump($db->getProfiler()->getLastQueryProfile()->getQuery());
             Zend_Debug::dump($db->getProfiler()->getLastQueryProfile()->getQueryParams());
             $db->getProfiler()->setEnabled(false);
             $db->getProfiler()->setEnabled(true);
             //$check = @$data["pricefree_".$i];
             //print_r($check);
             $data_item[$i] = array('order_id' => $id_order, 'pro_id' => $data['item_id_' . $i], 'qty_order' => $data['qty' . $i], 'price' => $data['price' . $i], 'total_befor' => $data['total' . $i], 'is_free' => $check, 'sub_total' => $data['total' . $i], "disc_value" => $data['dis-value' . $i], "disc_amount" => $data["real-value" . $i]);
             $db->insert("tb_sales_order_item", $data_item[$i]);
             unset($data_item[$i]);
             Zend_Debug::dump($db->getProfiler()->getLastQueryProfile()->getQuery());
             Zend_Debug::dump($db->getProfiler()->getLastQueryProfile()->getQueryParams());
             $db->getProfiler()->setEnabled(false);
             //check stock product location
             $locationid = $data['LocationId'];
             $itemId = $data['item_id_' . $i];
             $qtyrecord = $data['qty' . $i];
             //qty on 1 record
             $db->getProfiler()->setEnabled(true);
             $rows = $db_global->productLocationInventory($itemId, $locationid);
             //to check product location
             Zend_Debug::dump($db->getProfiler()->getLastQueryProfile()->getQuery());
             Zend_Debug::dump($db->getProfiler()->getLastQueryProfile()->getQueryParams());
             $db->getProfiler()->setEnabled(false);
             //exit();
             $qtyold = $rows['qty'];
             $qty_avaliable = $rows["qty_avaliable"] - $qtyrecord;
             $qty_available = $rows["qty_available"] - $qtyrecord;
             $getrecord_id = $rows["ProLocationID"];
             if ($rows) {
                 if ($qty_available <= 0) {
                     Application_Form_FrmMessage::message("The Qty onhanh is out of stock!!");
                     Application_Form_FrmMessage::redirectUrl("/sales/sales-order");
                     $db->rollBack();
                     break;
                 } elseif ($qty_avaliable <= 0) {
                     Application_Form_FrmMessage::message("The in your location is out of stock!!");
                     Application_Form_FrmMessage::redirectUrl("/sales/sales-order");
                     $db->rollBack();
                     break;
                 } else {
                     if ($data["status"] == 5) {
                         $db->getProfiler()->setEnabled(true);
                         $itemOnHand = array('qty_onhand' => $rows["qty_onhand"] - $qtyrecord, 'qty_available' => $rows["qty_available"] - $qtyrecord);
                         $db_global->updateRecord($itemOnHand, $itemId, "pro_id", "tb_product");
                         unset($itemOnHand);
                         $updatedata = array('qty' => $rows['qty'] - $qtyrecord, 'qty_avaliable' => $rows["qty_avaliable"] - $qtyrecord);
                         //update stock product location
                         $db_global->updateRecord($updatedata, $getrecord_id, "ProLocationID", "tb_prolocation");
                         unset($updatedata);
                         Zend_Debug::dump($db->getProfiler()->getLastQueryProfile()->getQuery());
                         Zend_Debug::dump($db->getProfiler()->getLastQueryProfile()->getQueryParams());
                         $db->getProfiler()->setEnabled(false);
                     } else {
                         $db->getProfiler()->setEnabled(true);
                         $itemOnHand = array('qty_onsold' => $rows["pqty_onsold"] + $qtyrecord, 'qty_available' => $rows["qty_available"] - $qtyrecord);
                         //update total stock
                         $db_global->updateRecord($itemOnHand, $itemId, "pro_id", "tb_product");
                         unset($itemOnHand);
                         Zend_Debug::dump($db->getProfiler()->getLastQueryProfile()->getQuery());
                         Zend_Debug::dump($db->getProfiler()->getLastQueryProfile()->getQueryParams());
                         $db->getProfiler()->setEnabled(false);
                         $db->getProfiler()->setEnabled(true);
                         $updatedata = array('qty_onsold' => $rows['qty_onsold'] + $qtyrecord, 'qty_avaliable' => $rows["qty_avaliable"] - $qtyrecord);
                         //update stock product location
                         $db_global->updateRecord($updatedata, $getrecord_id, "ProLocationID", "tb_prolocation");
                         unset($updatedata);
                         Zend_Debug::dump($db->getProfiler()->getLastQueryProfile()->getQuery());
                         Zend_Debug::dump($db->getProfiler()->getLastQueryProfile()->getQueryParams());
                         $db->getProfiler()->setEnabled(false);
                     }
                     //exit();
                 }
                 //update stock record
             } else {
                 //insert stock ;
                 $rows_pro_exit = $db_global->productLocation($itemId, $locationid);
                 if ($rows_pro_exit) {
                     $updatedata = array('qty_onsold' => $rows_pro_exit['qty_onsold'] + $qtyrecord, 'qty_avaliable' => $rows["qty_available"] - $qtyrecord);
                     //update stock product location
                     $itemid = $db_global->updateRecord($updatedata, $rows_pro_exit['ProLocationID'], "ProLocationID", "tb_prolocation");
                     unset($updatedata);
                 } else {
                     $insertdata = array('pro_id' => $itemId, 'LocationId' => $locationid, 'last_usermod' => $GetUserId, 'qty_onsold' => $qtyrecord, 'qty_avaliable' => -$qtyrecord, 'qty' => -$qtyrecord, 'last_mod_date' => new Zend_Date());
                     //update stock product location
                     $db->insert("tb_prolocation", $insertdata);
                     unset($insertdata);
                 }
                 $rowitem = $db_global->InventoryExist($itemId);
                 //to check product location
                 if ($rowitem) {
                     $itemOnHand = array('qty_onsold' => $rowitem["qty_onsold"] + $qtyrecord, 'qty_available' => $rows["qty_available"] - $qtyrecord);
                     //update total stock
                     $itemid = $db_global->updateRecord($itemOnHand, $itemId, "pro_id", "tb_product");
                     unset($itemOnHand);
                 } else {
                     $dataInventory = array('pro_id' => $itemId, 'qty_onsold' => $data['qty' . $i], 'Timestamp' => new Zend_date());
                     $db->insert("tb_product", $dataInventory);
                     unset($dataInventory);
                     //update stock product location
                 }
             }
         }
         $db->commit();
     } catch (Exception $e) {
         $db->rollBack();
         $e->getMessage();
     }
 }
 public function updateVendorStock($data)
 {
     try {
         $db = $this->getAdapter();
         $db->beginTransaction();
         $db_global = new Application_Model_DbTable_DbGlobal();
         $session_user = new Zend_Session_Namespace('auth');
         $userName = $session_user->user_name;
         $GetUserId = $session_user->user_id;
         //for update order by id\
         $id_order_update = $data['id'];
         $recieved_id = $data["recieve_id"];
         //update info of order in tb_purchase order
         // Select all qty in tb_product and tb_purchase_order_item for compare product exist or not for update qty to old qty
         $sql_itm = "SELECT\n\t\t\t\t\t\t\t(SELECT p.pro_id FROM tb_product AS p WHERE p.pro_id = po.`pro_id`) AS pro_id\n\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t,(SELECT p.qty_onorder FROM tb_product AS p WHERE p.pro_id = po.`pro_id`) AS qty_onorder\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t,(SELECT p.qty_onhand \tFROM tb_product AS p WHERE p.pro_id = po.`pro_id`) AS qty_onhand\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t,(SELECT p.qty_available \tFROM tb_product AS p WHERE p.pro_id = po.`pro_id`) AS qty_available\n\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t, SUM(po.`qty_order`) AS qty_order FROM\n\t\t\t\t\t\t\n\t\t\t\t\ttb_purchase_order_item AS po WHERE po.order_id = {$id_order_update} GROUP BY po.pro_id";
         $rows_order = $db_global->getGlobalDb($sql_itm);
         //print_r($rows_order);exit();
         // if product in purchase order item
         if ($rows_order) {
             foreach ($rows_order as $row_order) {
                 //print_r($row_order);exit();
                 //update qty and qty_onorder to old qty in tb_prolocation
                 $row_get = $db_global->porductLocationExist($row_order["pro_id"], $data["old_location"]);
                 // Check product Location exit
                 //print_r($row_get);exit();
                 $qty_prolo = $row_get["qty"] - $row_order["qty_order"];
                 $qty_order_prolo = $row_get["qty_onorder"] - $row_order["qty_order"];
                 $qty = $row_order["qty_onhand"] - $row_order["qty_order"];
                 $qty_order = $row_order["qty_onorder"] - $row_order["qty_order"];
                 if ($row_get) {
                     if ($data["oldStatus"] == 5 or $data["oldStatus"] == 4) {
                         if ($qty_prolo < 0) {
                             Application_Form_FrmMessage::message("You can't update!! because qty stock in Location is less than Quality order");
                             Application_Form_FrmMessage::redirectUrl("/purchase/index/index");
                         } else {
                             $qty_on_location = array("qty" => $row_get["qty"] - $row_order["qty_order"], "last_usermod" => $GetUserId, "last_mod_date" => new Zend_Date());
                         }
                         $db_global->updateRecord($qty_on_location, $row_get["ProLocationID"], "ProLocationID", "tb_prolocation");
                     } else {
                         if ($qty_order_prolo < 0) {
                             Application_Form_FrmMessage::message("You can't update!! because qty order in Location is less than Quality order");
                             Application_Form_FrmMessage::redirectUrl("/purchase/index/index");
                         } else {
                             $qty_on_location = array("qty_onorder" => $row_get["qty_onorder"] - $row_order["qty_order"], "last_usermod" => $GetUserId, "last_mod_date" => new Zend_Date());
                         }
                         $db_global->updateRecord($qty_on_location, $row_get["ProLocationID"], "ProLocationID", "tb_prolocation");
                     }
                 }
                 if ($data["oldStatus"] == 5 or $data["oldStatus"] == 4) {
                     if ($qty < 0) {
                         Application_Form_FrmMessage::message("You can't update!! because qty in stock is less than Quality order");
                         Application_Form_FrmMessage::redirectUrl("/purchase/index/index");
                     } else {
                         $qty_on_order = array("qty_onhand" => $row_order["qty_onhand"] - $row_order["qty_order"], "qty_available" => $row_order["qty_available"] - $row_order["qty_order"], "last_mod_date" => new Zend_Date());
                         $db_global->updateRecord($qty_on_order, $row_order["pro_id"], "pro_id", "tb_product");
                     }
                 } else {
                     if ($qty_order < 0) {
                         Application_Form_FrmMessage::message("You can't update!! because QTY onorder in stock is less than Quality order");
                         Application_Form_FrmMessage::redirectUrl("/purchase/index/index");
                     } else {
                         $qty_on_order = array("qty_onorder" => $row_order["qty_onorder"] - $row_order["qty_order"], "last_mod_date" => new Zend_Date());
                     }
                     $db_global->updateRecord($qty_on_order, $row_order["pro_id"], "pro_id", "tb_product");
                 }
                 //update total stock
             }
         }
         unset($rows_order);
         $info_purchase_order = array("vendor_id" => $data['v_name'], "LocationId" => $data["LocationId"], "order" => $data['txt_order'], "date_order" => $data['order_date'], "status" => $data["status"], "remark" => $data['remark'], "user_mod" => $GetUserId, "timestamp" => new Zend_Date(), "paid" => $data['paid'], "all_total" => $data['totalAmoun'], "balance" => $data['remain']);
         $db_global->updateRecord($info_purchase_order, $id_order_update, "order_id", "tb_purchase_order");
         // end update info of order in tb_purchase order
         $ids = explode(',', $data['identity']);
         $sql_recieve = new purchase_Model_DbTable_DbPurchaseOrder();
         $result = $sql_recieve->recieved_info($id_order_update);
         $prifix = "SELECT * FROM tb_setting WHERE `code` =16";
         $ro = $db_global->getGlobalDbRow($prifix);
         $RO = $ro["key_value"];
         $date = new Zend_Date();
         $recieve_no = $RO . $date->get('hh-mm-ss');
         if ($result) {
             if ($data["oldStatus"] == 5 or $data["oldStatus"] == 4) {
                 if ($data["status"] == 5 or $data["status"] == 4) {
                     $data_recieved_order = array("recieve_type" => 1, "order_id" => $id_order_update, "order_no" => $data["txt_order"], "vendor_id" => $data['v_name'], "location_id" => $data["LocationId"], "date_recieve" => new Zend_Date(), "status" => $data['status'], "is_active" => 1, "paid" => $data['paid'], "all_total" => $data['totalAmoun'], "balance" => $data['remain'], "user_recieve" => $GetUserId);
                     $recieved_order = $db_global->updateRecord($data_recieved_order, $recieved_id, "recieve_id", "tb_recieve_order");
                     unset($data_recieved_order);
                 } else {
                     $data_recieved_order = array("recieve_type" => 1, "order_id" => $id_order_update, "order_no" => $data["txt_order"], "vendor_id" => $data['v_name'], "location_id" => $data["LocationId"], "date_recieve" => new Zend_Date(), "status" => $data['status'], "is_active" => 0, "paid" => $data['paid'], "all_total" => $data['totalAmoun'], "balance" => $data['remain'], "user_recieve" => $GetUserId);
                     $recieved_order = $db_global->updateRecord($data_recieved_order, $recieved_id, "recieve_id", "tb_recieve_order");
                     unset($data_recieved_order);
                 }
             }
             $sqls = "DELETE FROM tb_recieve_order_item WHERE recieve_id IN ({$recieved_id})";
             $db_global->deleteRecords($sqls);
             unset($sqls);
             foreach ($ids as $i) {
                 $recieved_item[$i] = array("recieve_id" => $recieved_id, "pro_id" => $data['item_id_' . $i], "order_id" => $id_order_update, "qty_order" => $data['qty' . $i], "qty_recieve" => $data['qty' . $i], "price" => $data['price' . $i], "total_before" => $data['total' . $i], "sub_total" => $data['total' . $i]);
                 $db->insert("tb_recieve_order_item", $recieved_item[$i]);
                 unset($recieved_item[$i]);
             }
         } else {
             $prifix = "SELECT * FROM tb_setting WHERE `code` =16";
             $ro = $db_global->getGlobalDbRow($prifix);
             $RO = $ro["key_value"];
             $date = new Zend_Date();
             $recieve_no = $RO . $date->get('hh-mm-ss');
             if ($data["status"] == 5 or $data["status"] == 4) {
                 $data_recieved_order = array("recieve_type" => 1, "order_id" => $id_order_update, "recieve_no" => $recieve_no, "order_no" => $data["txt_order"], "vendor_id" => $data['v_name'], "location_id" => $data["LocationId"], "order_date" => new Zend_Date(), "date_recieve" => new Zend_Date(), "status" => $data['status'], "is_active" => 1, "paid" => $data['paid'], "all_total" => $data['totalAmoun'], "balance" => $data['remain'], "user_recieve" => $GetUserId);
                 $recieved_order = $db_global->addRecord($data_recieved_order, "tb_recieve_order");
                 unset($data_recieved_order);
                 foreach ($ids as $i) {
                     $recieved_item[$i] = array("recieve_id" => $recieved_order, "pro_id" => $data['item_id_' . $i], "order_id" => $id_order_update, "qty_order" => $data['qty' . $i], "qty_recieve" => $data['qty' . $i], "price" => $data['price' . $i], "total_before" => $data['total' . $i], "sub_total" => $data['total' . $i]);
                     $db->insert("tb_recieve_order_item", $recieved_item[$i]);
                     unset($recieved_item[$i]);
                 }
             }
         }
         // Delete old purchase order item before insert new purchase order item in old order_id
         $sql = "DELETE FROM tb_purchase_order_item WHERE order_id IN ({$id_order_update})";
         $db_global->deleteRecords($sql);
         unset($sql);
         $sql_history = "DELETE FROM tb_purchase_order_history WHERE `order` IN ({$id_order_update})";
         $db_global->deleteRecords($sql_history);
         unset($sql_history);
         /// update
         $ids = explode(',', $data['identity']);
         //add order in tb_inventory must update code again 9/8/13
         foreach ($ids as $i) {
             // Insert New purchase order item in old order_id
             $data_item[$i] = array('order_id' => $id_order_update, 'pro_id' => $data['item_id_' . $i], 'qty_order' => $data['qty' . $i], 'price' => $data['price' . $i], 'sub_total' => $data['total' . $i], 'total_befor' => $data['total' . $i], 'remark' => $data['remark_' . $i]);
             //print_r($data_item); echo "<br />";echo "<br />";
             $db->insert("tb_purchase_order_item", $data_item[$i]);
             unset($data_item[$i]);
             $data_history[$i] = array('order' => $id_order_update, 'pro_id' => $data['item_id_' . $i], 'type' => 1, 'customer_id' => $data['v_name'], 'status' => $data["status"], 'order_total' => $data['total' . $i], 'qty' => $data['qty' . $i], 'unit_price' => $data['price' . $i], 'sub_total' => $data['total' . $i], 'date' => $data["old_history_date"], 'last_update_date' => new Zend_Date());
             //print_r($data_history);exit();
             $db->insert("tb_purchase_order_history", $data_history[$i]);
             unset($data_history[$i]);
             $locationid = $data['LocationId'];
             $itemId = $data['item_id_' . $i];
             $qtyrecord = $data['qty' . $i];
             //qty on 1 record
             // Update stock in tb_product
             $rows = $db_global->productLocationInventory($itemId, $locationid);
             //to check product location
             if ($rows) {
                 $getrecord_id = $rows["ProLocationID"];
                 if ($data["status"] == 5 or $data["status"] == 4) {
                     $itemOnHand = array('qty_onhand' => $rows["qty_onhand"] + $qtyrecord, 'qty_available' => $rows["qty_available"] + $qtyrecord, 'last_mod_date' => new Zend_date());
                     $db_global->updateRecord($itemOnHand, $itemId, "pro_id", "tb_product");
                     unset($itemOnHand);
                 } else {
                     $itemOnHand = array('qty_onorder' => $rows["pqty_onorder"] + $qtyrecord, 'last_mod_date' => new Zend_date());
                     $db_global->updateRecord($itemOnHand, $itemId, "pro_id", "tb_product");
                     unset($itemOnHand);
                 }
                 //End update total stock
                 // Update product Location
                 if ($data["status"] == 5 or $data["status"] == 4) {
                     $updatedata = array('qty' => $rows['qty'] + $qtyrecord, 'last_mod_date' => new Zend_date());
                     $db_global->updateRecord($updatedata, $getrecord_id, "ProLocationID", "tb_prolocation");
                     unset($updatedata);
                 } else {
                     $updatedata = array('qty_onorder' => $rows['qty_onorder'] + $qtyrecord, 'last_mod_date' => new Zend_date());
                     $db_global->updateRecord($updatedata, $getrecord_id, "ProLocationID", "tb_prolocation");
                     unset($updatedata);
                 }
                 //End update stock product location						//update stock record
             } else {
                 //insert stock ;
                 $rows_pro_exit = $db_global->productLocation($itemId, $locationid);
                 // check product location exist
                 $db->getProfiler()->setEnabled(true);
                 // if product exist Update qty in tb_prolocation
                 if ($rows_pro_exit) {
                     if ($data["status"] == 5 or $data["status"] == 4) {
                         $updatedata = array('qty' => $rows['qty'] + $qtyrecord, 'last_mod_date' => new Zend_date());
                         $itemid = $db_global->updateRecord($updatedata, $rows_pro_exit['ProLocationID'], "ProLocationID", "tb_prolocation");
                         unset($updatedata);
                     } else {
                         $updatedata = array('qty_onorder' => $rows['qty_onorder'] + $qtyrecord, 'last_mod_date' => new Zend_date());
                         $itemid = $db_global->updateRecord($updatedata, $rows_pro_exit['ProLocationID'], "ProLocationID", "tb_prolocation");
                         unset($updatedata);
                     }
                     // 					$itemid=$db_global->updateRecord($updatedata,$rows_pro_exit['ProLocationID'], "ProLocationID", "tb_prolocation");
                     // 					unset($updatedata);
                     // End if product exist Update qty in tb_prolocation
                 } else {
                     // If product not exist insert New product in tb_prolocation
                     $insertdata = array('pro_id' => $itemId, 'LocationId' => $locationid, 'last_usermod' => $GetUserId, 'qty' => $qtyrecord, 'last_mod_date' => new Zend_Date());
                     //update stock product location
                     $db->insert("tb_prolocation", $insertdata);
                     unset($insertdata);
                 }
                 // End If product not exist insert New product in tb_prolocation
                 $rowitem = $db_global->InventoryExist($itemId);
                 //to check product exist
                 // If productt exist update product in tb_product
                 if ($rowitem) {
                     if ($data["status"] == 5 or $data["status"] == 4) {
                         $itemOnHand = array('qty_onhand' => $rows["qty_onhand"] + $qtyrecord, 'qty_available' => $rows["qty_available"] + $qtyrecord, 'last_mod_date' => new Zend_date());
                         $itemid = $db_global->updateRecord($itemOnHand, $itemId, "pro_id", "tb_product");
                         unset($itemOnHand);
                     } else {
                         $itemOnHand = array('qty_onorder' => $rows["qty_onrder"] + $qtyrecord, 'last_mod_date' => new Zend_date());
                         $itemid = $db_global->updateRecord($itemOnHand, $itemId, "pro_id", "tb_product");
                         unset($itemOnHand);
                     }
                     //update total stock
                     // 					$itemid=$db_global->updateRecord($itemOnHand,$itemId,"pro_id","tb_product");
                     // 					unset($itemOnHand);
                     // If productt exist update product in tb_product
                 } else {
                     // If product not exist insert new product in tb_product
                     $dataInventory = array('pro_id' => $itemId, 'qty_onhand' => $qtyrecord, 'qty_available' => $qtyrecord, 'last_mod_date' => new Zend_date());
                     $db->insert("tb_product", $dataInventory);
                     unset($dataInventory);
                     //update stock product location
                 }
             }
         }
         $db->commit();
     } catch (Exception $e) {
         $db->rollBack();
         $e->getMessage();
         //echo $theCauseOfErrorOnlyDoNotRedirectToError;
         //exit();
     }
 }
Ejemplo n.º 13
0
 public function editAction()
 {
     $id = $this->getRequest()->getParam("id");
     $db = new phurchase_Model_DbTable_DbVendor();
     $data = $db->getCateById($id);
     if ($this->getRequest()->isPost()) {
         $data = $this->getRequest()->getPost();
         //print_r($data);exit();
         if (isset($data['save'])) {
             $db->updatCat($data, $id);
             Application_Form_FrmMessage::message("ការកែប្រែបានជោគជ័យ");
             Application_Form_FrmMessage::redirectUrl('/phurchase/vendor/edit/id/' . $id);
         } elseif (isset($data['save_add'])) {
             $db->updatCat($data, $id);
             Application_Form_FrmMessage::message("ការកែប្រែបានជោគជ័យ");
             Application_Form_FrmMessage::redirectUrl('/phurchase/vendor/add');
         } elseif (isset($data['save_close'])) {
             $db->updatCat($data, $id);
             Application_Form_FrmMessage::message("ការកែប្រែបានជោគជ័យ");
             Application_Form_FrmMessage::redirectUrl('/phurchase/vendor');
         }
     }
     $form = new phurchase_Form_FrmVendor();
     $this->view->frmcate = $form->FrmProCate($data);
 }
 public function addRecieveAction()
 {
     $db = new Application_Model_DbTable_DbGlobal();
     if ($this->getRequest()->isPost()) {
         $data = $this->getRequest()->getPost();
         $payment_purchase_order = new purchase_Model_DbTable_DbPurchaseVendor();
         $payment_purchase_order->vendorPurchaseOrderPayment($data);
         Application_Form_FrmMessage::message("Purchase has been received!");
         if ($data['payment'] == 'Save New') {
             Application_Form_FrmMessage::redirectUrl("/purchase/index/add-purchase");
             //$this->_redirect("purchase/index/add-purchase");
         } else {
             $this->_redirect("/purchase/index/index");
         }
         //not yet use in this version
         // 				elseif(@$data['Save']=='Save'){
         // 					$payment_purchase_order = new purchase_Model_DbTable_DbPurchaseVendor();
         // 					$payment_purchase_order -> VendorOrder($data);
         // 					$this->_redirect("purchase/index/index");
         // 				}
         // 				elseif(@$data['New']=='New'){
         // 					$this->_redirect("purchase/index/add-purchase");
         // 				}
     }
     $user = $this->GetuserInfoAction();
     if ($user["level"] != 1 and $user["level"] != 2) {
         $this->_redirect("purchase/index/index");
     }
     ///link left not yet get from DbpurchaseOrder
     $frm_purchase = new Application_Form_purchase(null);
     $form_add_purchase = $frm_purchase->productOrder(null);
     Application_Model_Decorator::removeAllDecorator($form_add_purchase);
     $this->view->form_purchase = $form_add_purchase;
     $formpopup = new Application_Form_FrmPopup(null);
     $formproduct = $formpopup->popuProduct(null);
     Application_Model_Decorator::removeAllDecorator($formproduct);
     $this->view->form_product = $formproduct;
     //for customer
     $formpopup = $formpopup->popupCustomer(null);
     Application_Model_Decorator::removeAllDecorator($formpopup);
     $this->view->form_customer = $formpopup;
     //for add location
     $formAdd = $formpopup->popuLocation(null);
     Application_Model_Decorator::removeAllDecorator($formAdd);
     $this->view->form_addstock = $formAdd;
     $form_agent = $formpopup->popupSaleAgent(null);
     Application_Model_Decorator::removeAllDecorator($form_agent);
     $this->view->form_agent = $form_agent;
 }
Ejemplo n.º 15
0
 public function editAction()
 {
     $id = $this->getRequest()->getParam('id') ? $this->getRequest()->getParam('id') : '0';
     $db = new phurchase_Model_DbTable_DbOrder();
     $itemRows = $db->selectProductOption();
     $this->view->items = $itemRows;
     $orderDetail = $db->getSalesOderID($id);
     $this->view->rowsOrder = $orderDetail;
     $itemRowsGet = $db->getProductOption();
     $this->view->itemsOption = $itemRowsGet;
     $data = $db->getPhurchase($id);
     if ($this->getRequest()->isPost()) {
         $data = $this->getRequest()->getPost();
         //print_r($data);exit();
         if (isset($data['save'])) {
             $db->updatCat($data, $id);
             Application_Form_FrmMessage::message("ការកែប្រែបានជោគជ័យ");
             Application_Form_FrmMessage::redirectUrl('/product/index/edit/id/' . $id);
         } elseif (isset($data['save_add'])) {
             $db->updatCat($data, $id);
             Application_Form_FrmMessage::message("ការកែប្រែបានជោគជ័យ");
             Application_Form_FrmMessage::redirectUrl('/product/index/add');
         } elseif (isset($data['save_close'])) {
             $db->updatCat($data, $id);
             Application_Form_FrmMessage::message("ការកែប្រែបានជោគជ័យ");
             Application_Form_FrmMessage::redirectUrl('/product');
         }
     }
     $form = new phurchase_Form_FrmPhurchaseOrder();
     $this->view->frmcate = $form->FrmProCate($data);
 }
Ejemplo n.º 16
0
	public function editAction(){
		$db = new Group_Model_DbTable_DbClient();
		if($this->getRequest()->isPost()){
			try{
				$data = $this->getRequest()->getPost();
				//print_r($data);exit();
				$id= $db->addClient($data);
				if($data['chackcall']==1){
					Application_Form_FrmMessage::message("វានឹងបន្ថែមទ្រព្យបញ្ចាំរបស់អតិថិជនដោយស្វ័យប្រវត្តិ!");
					Application_Form_FrmMessage::redirectUrl("/group/callteral/add/id/".$id);
				}
				Application_Form_FrmMessage::Sucessfull('EDIT_SUCCESS',"/group/index");
			}catch (Exception $e){
				Application_Form_FrmMessage::message("EDIT_FAILE");
				echo $e->getMessage();
				Application_Model_DbTable_DbUserLog::writeMessageError($e->getMessage());
			}
		}
		$id = $this->getRequest()->getParam("id");
		$row = $db->getClientById($id);
	        $this->view->row=$row;
		$this->view->photo = $row['photo_name'];
		if(empty($row)){
			$this->_redirect("/group/client");
		}
		$fm = new Group_Form_FrmClient();
		$frm = $fm->FrmAddClient($row);
		Application_Model_Decorator::removeAllDecorator($frm);
		$this->view->frm_client = $frm;
		
		$dbpop = new Application_Form_FrmPopupGlobal();
		$this->view->frm_popup_village = $dbpop->frmPopupVillage();
		$this->view->frm_popup_comm = $dbpop->frmPopupCommune();
		$this->view->frm_popup_district = $dbpop->frmPopupDistrict();
		$this->view->frm_popup_clienttype = $dbpop->frmPopupclienttype();
		
		$db = new Application_Model_DbTable_DbGlobal();
		$client_type = $db->getclientdtype();
		array_unshift($client_type,array(
				'id' => -1,
				'name' => '---Add New ---',
		) );
		$this->view->clienttype = $client_type;
	}
Ejemplo n.º 17
0
 public function logoutAction()
 {
     // action body
     if ($this->getRequest()->getParam('value') == 1) {
         $db_access = new Application_Model_DbTable_DbAmountPC();
         $pc_name = strtolower(gethostname());
         $db_access->clearUserLogined($pc_name);
         $aut = Zend_Auth::getInstance();
         $aut->clearIdentity();
         $session_user = new Zend_Session_Namespace('auth');
         $log = new Application_Model_DbTable_DbUserLog();
         $log->insertLogout($session_user->user_id);
         $session_user->unsetAll();
         Application_Form_FrmMessage::redirectUrl("/");
         exit;
     }
 }
 public function indexAction()
 {
     try {
         $db = new Application_Model_DbTable_DbGlobal();
         if ($this->getRequest()->isPost()) {
             $data = $this->getRequest()->getPost();
             //print_r($invoice);exit();
             $recieve_order = new purchase_Model_DbTable_DbCheckInProduct();
             if (isset($data['SaveNew'])) {
                 try {
                     $recieve_order->RecievedPurchaseOrder($data);
                     Application_Form_FrmMessage::message("Purchase has been received!");
                     Application_Form_FrmMessage::redirectUrl("/purchase/index/check-in");
                 } catch (Exception $e) {
                     $e->getMessage();
                 }
             } else {
                 $recieve_order->RecievedPurchaseOrder($data);
                 $this->_redirect("/purchase/index/index");
             }
         }
         $user = $this->GetuserInfoAction();
         if ($user["level"] != 1 and $user["level"] != 2) {
             $this->_redirect("purchase/index/index");
         }
         $db = new Application_Model_DbTable_DbGlobal();
         $frm_purchase = new Application_Form_FrmCheckIn();
         $form_add_purchase = $frm_purchase->productOrder();
         Application_Model_Decorator::removeAllDecorator($form_add_purchase);
         $this->view->form_purchase = $form_add_purchase;
         // item option in select
         $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 search
         // 		$search = new purchase_Form_FrmSearch();
         // 		$frmsearch= $search->formSearch();
         // 		Application_Model_Decorator::removeAllDecorator($frmsearch);
         // 		$this->view->get_frmsearch= $frmsearch;
         //for view left purchase order
         $vendor_sql = "SELECT p.order, p.all_total,p.paid,p.balance\n\t\t\tFROM tb_purchase_order AS p INNER JOIN tb_vendor AS v ON v.vendor_id=p.vendor_id ORDER BY p.timestamp DESC ";
         $rows = $db->getGlobalDb($vendor_sql);
         $this->view->list = $rows;
         //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;
     } catch (Exception $e) {
         Application_Form_FrmMessage::messageError("INSERT_ERROR", $err = $e->getMessage());
     }
 }
Ejemplo n.º 19
0
 public function paymentAction()
 {
     $db_mail = new Application_Model_DbTable_DbSendEmail();
     $db = new Application_Model_DbTable_Dbbookingtaxi();
     if ($this->getRequest()->isPost()) {
         $data = $this->getRequest()->getPost();
         $booking_id = $db->addTaxiBooking($data);
         $db_mail->sendInvoiceEmail($booking_id);
         $session = new Zend_Session_Namespace('taxibooking');
         $session->unsetAll();
         Application_Form_FrmMessage::redirectUrl("/index");
     }
 }
 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;
 }
Ejemplo n.º 21
0
 public function updateReturnItemIn($post)
 {
     try {
         $db = $this->getAdapter();
         $db->beginTransaction();
         $db_global = new Application_Model_DbTable_DbGlobal();
         $session_user = new Zend_Session_Namespace('auth');
         $userName = $session_user->user_name;
         $GetUserId = $session_user->user_id;
         $idrecord = $post['v_name'];
         // 			$datainfo=array(
         // 					"contact_name" => $post['contact'],
         // 					"phone"        => $post['txt_phone'],
         // 					"add_name"     => $post["vendor_address"]
         // 			);
         // 			//updage vendor info
         // 			$db_global->updateRecord($datainfo,$idrecord,"vendor_id","tb_vendor");
         // 			unset($datainfo);
         $return_id = $post["id"];
         $old_location = $post["old_location"];
         $sql_item = "SELECT\n\t   \t(SELECT p.pro_id FROM tb_product AS p WHERE p.pro_id = rvi.`pro_id` LIMIT 1) AS pro_id\n\t   \t\t\n\t   \t,(SELECT p.qty_onorder FROM tb_product AS p WHERE p.pro_id = rvi.`pro_id` LIMIT 1) AS qty_onorder\n\t   \n\t   \t,(SELECT p.qty_onhand \tFROM tb_product AS p WHERE p.pro_id = rvi.`pro_id` LIMIT 1) AS qty_onhand\n\t   \n\t   \t,(SELECT p.qty_available \tFROM tb_product AS p WHERE p.pro_id = rvi.`pro_id` LIMIT 1) AS qty_available\n\t   \t\t\n\t   \t, SUM(rvi.`qty_return`) AS qty_return FROM\n   \n   \ttb_return_vendor_item_in AS rvi WHERE rvi.return_id = {$return_id} GROUP BY rvi.pro_id";
         $rows_return = $db_global->getGlobalDb($sql_item);
         //	print_r($rows_return);
         if ($rows_return) {
             foreach ($rows_return as $row_return) {
                 $qty_stock = $row_return["qty_onhand"] - $row_return["qty_return"];
                 $rows = $db_global->inventoryLocation($old_location, $row_return["pro_id"]);
                 $qty_location = $rows["qty"] - $row_return["qty_return"];
                 //print_r($rows);exit();
                 if ($qty_stock < 0) {
                     Application_Form_FrmMessage::message("Your product stock is less than return");
                     Application_Form_FrmMessage::redirectUrl("/purchase/return/return-in");
                     //exit();
                 } elseif ($qty_location < 0) {
                     Application_Form_FrmMessage::message("You Items is less than item return");
                     Application_Form_FrmMessage::redirectUrl("/purchase/return/return-in");
                     //exit();
                 } else {
                     $qty_on_order = array("qty_onhand" => $row_return["qty_onhand"] - $row_return["qty_return"], "qty_available" => $row_return["qty_available"] - $row_return["qty_return"], "last_mod_date" => new Zend_date());
                     //update total stock
                     $db_global->updateRecord($qty_on_order, $row_return["pro_id"], "pro_id", "tb_product");
                     unset($qty_on_order);
                     $rowitem_exist = $db_global->porductLocationExist($row_return["pro_id"], $old_location);
                     if ($rowitem_exist) {
                         $updatedata = array('qty' => $rowitem_exist["qty"] - $row_return["qty_return"], "last_usermod" => $GetUserId, "last_mod_date" => new Zend_Date());
                         //update stock product location
                         $db_global->updateRecord($updatedata, $rowitem_exist["ProLocationID"], "ProLocationID", "tb_prolocation");
                         unset($updatedata);
                     }
                 }
             }
         }
         $data_update = array("vendor_id" => $post["v_name"], "date_return_in" => $post["return_date"], "remark" => $post["return_remark"], "user_mod" => $GetUserId, "timestamp" => new Zend_Date(), "location_id" => $post["LocationId"], "all_total" => $post["all_total"]);
         $db_global->updateRecord($data_update, $return_id, "returnin_id", "tb_return_vendor_in");
         unset($data_update);
         $sql = "DELETE FROM tb_return_vendor_item_in WHERE return_id IN ({$return_id})";
         $db_global->deleteRecords($sql);
         $delete_history = "DELETE FROM tb_return_history WHERE return_id IN({$return_id})";
         $db_global->deleteRecords($delete_history);
         $ids = explode(',', $post['identity']);
         //add order in tb_inventory must update code again 9/8/13
         foreach ($ids as $i) {
             $add_data = array("return_id" => $return_id, "pro_id" => $post["item_id_" . $i], "qty_return" => $post["qty_return_" . $i], "price" => $post["price_" . $i], "sub_total" => $post["sub_total_" . $i], "return_remark" => $post["remark_" . $i]);
             $db->insert("tb_return_vendor_item", $add_data);
             $add_data = array("return_id" => $return_id, "pro_id" => $post["item_id_" . $i], "qty_return" => $post["qty_return_" . $i], "price" => $post["price_" . $i], "sub_total" => $post["sub_total_" . $i], "return_remark" => $post["remark_" . $i]);
             $db->insert("tb_return_vendor_item_in", $add_data);
             $rows = $db_global->inventoryLocation($post["LocationId"], $post["item_id_" . $i]);
             if ($rows) {
                 $qty_on_return = array("qty_onhand" => $rows["qty_onhand"] + $post["qty_return_" . $i], "qty_available" => $rows["qty_available"] + $post["qty_return_" . $i], "last_mod_date" => new Zend_date());
                 //update total stock
                 $db_global->updateRecord($qty_on_return, $post["item_id_" . $i], "pro_id", "tb_product");
                 unset($qty_on_return);
                 $updatedata = array('qty' => $rows["qty"] + $post["qty_return_" . $i], "last_usermod" => $GetUserId, "last_mod_date" => new Zend_Date());
                 //update stock product location
                 $db_global->updateRecord($updatedata, $rows["ProLocationID"], "ProLocationID", "tb_prolocation");
                 unset($updatedata);
                 unset($qty_on_return);
                 //add return history
                 $data_history = array('transaction_type' => 4, 'pro_id' => $post["item_id_" . $i], 'date' => new Zend_Date(), 'location_id' => $post["LocationId_" . $i], 'Remark' => $post['remark_' . $i], 'qty_edit' => $post["qty_return_" . $i], 'qty_before' => $rows["qty"], 'qty_after' => $rows["qty"] - $post["qty_return_" . $i], 'user_mod' => $GetUserId);
                 $db->insert("tb_move_history", $data_history);
                 unset($data_history);
                 $history = array("return_id" => $return_id, "return_no" => $post["retun_order"], "pro_id" => $post["item_id_" . $i], "location_id" => $post["LocationId"], "return_type" => 2, "vendor_id" => 1, "return_date" => $post["return_date"], "qty_return" => $post["qty_return_" . $i], "price" => $post["price_" . $i], "total_amount" => $post["sub_total_" . $i], "user_mod" => $GetUserId, "remark" => $post["return_remark"]);
                 $db->insert("tb_return_history", $history);
                 unset($history);
             } else {
                 //    			Application_Form_FrmMessage::message("Your product in stock is not exist");
                 //    			Application_Form_FrmMessage::redirectUrl("/purchase/return");
                 //    			exit();
                 $row_location = $db_global->productLocation($post["LocationId"], $post["item_id_" . $i]);
                 if ($row_location) {
                     $updatedata = array('qty' => $rows["qty"] + $post["qty_return_" . $i], "last_usermod" => $GetUserId, "last_mod_date" => new Zend_Date());
                     //update stock product location
                     $db_global->updateRecord($updatedata, $row_location["ProLocationID"], "ProLocationID", "tb_prolocation");
                     unset($updatedata);
                 } else {
                     $insertdata = array('pro_id' => $post["item_id_" . $i], 'LocationId' => $post["LocationId_" . $i], 'qty' => -$post["qty_return_" . $i]);
                 }
                 //update stock product location
                 $db->insert("tb_prolocation", $insertdata);
                 unset($insertdata);
                 //add return history
                 $data_history = array('transaction_type' => 4, 'pro_id' => $post["item_id_" . $i], 'date' => new Zend_Date(), 'location_id' => $post["LocationId_" . $i], 'Remark' => $post['remark_' . $i], 'qty_edit' => $post["qty_return_" . $i], 'qty_before' => 0, 'qty_after' => -$post["qty_return_" . $i], 'user_mod' => $GetUserId);
                 $db->insert("tb_move_history", $data_history);
                 unset($data_history);
                 $history = array("return_id" => $return_id, "return_no" => $post["retun_order"], "pro_id" => $post["item_id_" . $i], "location_id" => $post["LocationId"], "return_type" => 2, "vendor_id" => 1, "return_date" => $post["return_date"], "qty_return" => $post["qty_return_" . $i], "price" => $post["price_" . $i], "total_amount" => $post["sub_total_" . $i], "user_mod" => $GetUserId, "remark" => $post["return_remark"]);
                 $db->insert("tb_return_history", $history);
                 unset($history);
                 $rows_stock = $db_global->InventoryExist($post["item_id_" . $i]);
                 if ($rows_stock) {
                     $dataInventory = array('qty_onhand' => $rows_stock["qty_onhand"] - $post["qty_return_" . $i], 'qty_available' => $rows_stock["qty_available"] - $post["qty_return_" . $i], 'last_mod_date' => new Zend_date());
                     $db_global->updateRecord($dataInventory, $rows_stock["pro_id"], "pro_id", "tb_product");
                     unset($dataInventory);
                 } else {
                     $addInventory = array('pro_id' => $post["item_id_" . $i], 'qty_onhand' => -$post["qty_return_" . $i], 'qty_available' => -$post["qty_return_" . $i], 'last_mod_date' => new Zend_date());
                     $db->insert("tb_product", $addInventory);
                     unset($addInventory);
                 }
             }
         }
         $db->commit();
     } catch (Exception $e) {
         $db->rollBack();
         echo $e->getMessage();
     }
 }
Ejemplo n.º 22
0
 public function changePasswordAction()
 {
     $id = $this->getRequest()->getParam('id');
     $form = new users_Form_FrmUser();
     $this->view->frmusers = $form->frmuser();
     if ($this->getRequest()->isPost()) {
         $data = $this->getRequest()->getPost();
         $db = new users_Model_DbTable_DbUser();
         $old_password = $this->getRequest()->getParam('old_password');
         $password = $this->getRequest()->getParam('password');
         if (isset($data['save'])) {
             if ($db->getpassword($id, $old_password)) {
                 $db->changePassword($id, md5($password));
                 Application_Form_FrmMessage::message("កាបញ្ចូលប្រភេទអ្នកប្រើប្រាស់បានជោគជ័យ");
             } else {
                 Application_Form_FrmMessage::message("កាបញ្ចូលមិនបានជោគជ័យ");
             }
         }
         if (isset($data['save_close'])) {
             if ($db->getpassword($id, $old_password)) {
                 $db->changePassword($id, md5($password));
                 Application_Form_FrmMessage::message("កាបញ្ចូលប្រភេទអ្នកប្រើប្រាស់បានជោគជ័យ");
                 Application_Form_FrmMessage::redirectUrl('/users');
             } else {
                 Application_Form_FrmMessage::message("កាបញ្ចូលមិនបានជោគជ័យ");
             }
         } 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();
         }
     }
 }
Ejemplo n.º 23
0
 public function editAction()
 {
     $id = $this->getRequest()->getParam("id");
     $db = new location_Model_DbTable_DbLocation();
     $row = $db->getLocationById($id);
     $this->view->icon = $row["icon"];
     if ($this->getRequest()->isPost()) {
         $data = $this->getRequest()->getPost();
         //print_r($data);exit();
         if (isset($data['save'])) {
             $db->updat($data, $id);
             Application_Form_FrmMessage::message("ការកែប្រែបានជោគជ័យ");
             Application_Form_FrmMessage::redirectUrl('/location/index/edit/id/' . $id);
         }
         if (isset($data['save_add'])) {
             $db->updat($data, $id);
             Application_Form_FrmMessage::message("ការកែប្រែបានជោគជ័យ");
             Application_Form_FrmMessage::redirectUrl('/location/index/add');
         }
         if (isset($data['save_close'])) {
             $db->updat($data, $id);
             Application_Form_FrmMessage::message("ការកែប្រែបានជោគជ័យ");
             Application_Form_FrmMessage::redirectUrl('/location');
         } 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();
         }
     }
     $form = new location_Form_FrmLocation();
     $this->view->frmcate = $form->FrmLocation($row);
 }
 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;
 }
Ejemplo n.º 25
0
 public function logoutAction()
 {
     // action body
     $this->_redirect("/index");
     if ($this->getRequest()->getParam('value') == 1) {
         $aut = Zend_Auth::getInstance();
         $aut->clearIdentity();
         $session_user = new Zend_Session_Namespace('auth');
         $log = new Application_Model_DbTable_DbUserLog();
         $log->insertLogout($session_user->user_id);
         $session_user->unsetAll();
         Application_Form_FrmMessage::redirectUrl("/");
         exit;
     }
 }
Ejemplo n.º 26
0
 public function editAction()
 {
     $user_type_id = $this->getRequest()->getParam('id');
     $db = new users_Model_DbTable_DbUserType();
     $row = $db->getUserType($user_type_id);
     $frmuser = new users_Form_FrmUserType();
     $this->view->frmusers = $frmuser->frmTypeUser($row);
     if ($this->getRequest()->isPost()) {
         $data = $this->getRequest()->getPost();
         if (isset($data['save'])) {
             $db->updateUserType($data, $user_type_id);
             Application_Form_FrmMessage::redirectUrl('/users/user-type/edit/id/' . $user_type_id);
         }
         if (isset($data['save_add'])) {
             $db->updateUserType($data, $user_type_id);
             Application_Form_FrmMessage::message("កាបញ្ចូលប្រភេទអ្នកប្រើប្រាស់បានជោគជ័យ");
             Application_Form_FrmMessage::redirectUrl('/users/user-type/add');
         }
         if (isset($data['save_close'])) {
             $db->updateUserType($data, $user_type_id);
             Application_Form_FrmMessage::message("កាបញ្ចូលប្រភេទអ្នកប្រើប្រាស់បានជោគជ័យ");
             Application_Form_FrmMessage::redirectUrl('/users/user-type');
         }
     }
 }
 public function addBrandAction()
 {
     $category = new Product_Model_DbTable_DbProduct();
     if ($this->getRequest()->isPost()) {
         $data = $this->getRequest()->getPost();
         //print_r($data);exit();
         $addcategory = $category->addBrand($data);
         Application_Form_FrmMessage::message("Brand Name Has Been Saved !");
         Application_Form_FrmMessage::redirectUrl('/product/index/brand');
     }
     $id = $this->getRequest()->getParam('id') ? $this->getRequest()->getParam('id') : '0';
     if ($id) {
         //view update if get id
         $rows = $category->getBrandName($id);
         $frmcategory = new Application_Form_FrmInclude($rows);
         $frmcate = $frmcategory->addBrand($rows);
         $action = BASE_URL . "/product/index/update-brand";
     } else {
         $frmcategory = new Application_Form_FrmInclude(null);
         $frmcate = $frmcategory->addBrand(null);
         $action = BASE_URL . "/product/index/add-brand";
     }
     Application_Model_Decorator::removeAllDecorator($frmcate);
     $method = "post";
     $url_cancel = BASE_URL . "/product/index/brand";
     $frm = new Application_Form_FrmGlobal();
     $this->view->formVendor = $frm->getForm1($action, $method, $url_cancel, $frmcate, 'MENU_PRODUCT_INDEX_ADD_BRAND');
 }
 public function updateSalesAction()
 {
     $id = $this->getRequest()->getParam('id') ? $this->getRequest()->getParam('id') : '0';
     if ($this->getRequest()->isPost()) {
         //just block only but can use other version
         $data = $this->getRequest()->getPost();
         // 			if($data["status"]!=="Paid"){
         // 				if(@$data['payment']!==''){
         // 					$update_payment_order = new sales_Model_DbTable_DbSalesOrder();
         // 					$update_payment_order->updateCustomerOrderPayment($data);
         // 				}
         // 				elseif(@$data['Update']=='Update'){
         // 					$update_order = new sales_Model_DbTable_DbSalesOrder();
         // 					//not yet dork stock in table inventory
         // 					$update_order->updateCustomerOrder($data);
         // 				}
         // 			}
         // 			else{
         // 				Application_Form_FrmMessage::message("Cann't Edit!Sales Order Has Been Payment Already");
         // 				Application_Form_FrmMessage::redirectUrl("/sales/sales-order/index");
         // 			}
         //for new version
         $sale_order = new sales_Model_DbTable_DbCustomerOrder();
         if (isset($data["payment"])) {
             if ($data["oldStatus"] == 6) {
                 $addOrder = new sales_Model_DbTable_DbSalesOrder();
                 $addOrder->CustomerAddOrderPayment($data);
                 Application_Form_FrmMessage::message("You has been Re-Order successe!");
                 Application_Form_FrmMessage::redirectUrl("/sales/sales-order/index");
             } else {
                 $sale_order->updateCustomerOrder($data);
                 Application_Form_FrmMessage::message("You have been Update customer order success! ");
                 Application_Form_FrmMessage::redirectUrl("/sales/sales-order/index");
             }
         } elseif (isset($data["cancel_order"])) {
             //for cancel customer order
             if ($data["oldStatus"] != 6) {
                 $sale_order->cancelCustomerOrder($data);
                 Application_Form_FrmMessage::message("You have been cancel customer order success! ");
                 Application_Form_FrmMessage::redirectUrl("/sales/sales-order/index");
             } else {
                 Application_Form_FrmMessage::message("Can not cancel again!Becuase You have been cancel customer order already!");
                 Application_Form_FrmMessage::redirectUrl("/sales/sales-order/index");
             }
             // 				$sale_order->cancelCustomerOrder($data);
             // 				Application_Form_FrmMessage::message("You have been cancel customer order success! ");
             // 				Application_Form_FrmMessage::redirectUrl("/sales/sales-order/index");
         }
     }
     $user = $this->GetuserInfoAction();
     if ($user["level"] != 1 and $user["level"] != 2) {
         $gb = new Application_Model_DbTable_DbGlobal();
         $exist = $gb->userSaleOrderExist($id, $user["location_id"]);
         if ($exist == "") {
             $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\t\to.remark,o.net_total,o.discount_type,o.discount_value,o.paid,o.all_total,o.balance,\n\t\t\tc.contact_name,c.phone,c.add_name,c.add_remark\n\t\t\tFROM tb_sales_order AS o\n\t\t\tINNER JOIN tb_customer AS c ON c.customer_id= o.customer_id\n\t\t\tINNER JOIN tb_sales_order_item AS so ON so.order_id=o.order_id\n\t\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);
     Application_Model_Decorator::removeAllDecorator($formStockEdit);
     // omit default zend html tag
     $this->view->form = $formStockEdit;
     $this->view->status_so = $row['status'];
     if ($row['status'] == 1) {
         $this->_redirect("sales/sales-order/update-customer-quote/id/{$id}");
     }
     //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();
     $this->view->itemsOption = $itemRows;
     $items = new Application_Model_GlobalClass();
     $itemRows = $items->getProductOption();
     $this->view->items = $itemRows;
     // 		$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_product = $formproduct;
     //for customer
     $formpopup = $formpopup->popupCustomer(null);
     Application_Model_Decorator::removeAllDecorator($formpopup);
     $this->view->form_customer = $formpopup;
     //for add location
     $formAdd = $formpopup->popuLocation(null);
     Application_Model_Decorator::removeAllDecorator($formAdd);
     $this->view->form_addstock = $formAdd;
     $form_agent = $formpopup->popupSaleAgent(null);
     Application_Model_Decorator::removeAllDecorator($form_agent);
     $this->view->form_agent = $form_agent;
 }
Ejemplo n.º 29
0
 function getvehiclecitytourAction()
 {
     //action step3
     $vehicle_id = $this->getRequest()->getParam("id");
     if ($vehicle_id) {
         $dbbooking = new Application_Model_DbTable_Dbbookingcitytour();
         $dbbooking->createSessionBookingCityTour($vehicle_id, 3);
         $this->_redirect("index/citytourbooking");
     }
     Application_Form_FrmMessage::redirectUrl("/index/testing");
 }
 public function updateReturnItemAction()
 {
     try {
         $session_stock = new Zend_Session_Namespace('stock');
         $id = $this->getRequest()->getParam('id') ? $this->getRequest()->getParam('id') : '0';
         $db_global = new Application_Model_DbTable_DbGlobal();
         $sql = "SELECT * FROM tb_return WHERE return_id =" . $id;
         $rs = $db_global->getGlobalDbRow($sql);
         if ($rs["is_active"] == 0) {
             Application_Form_FrmMessage::message("Can not update return becuase recieved already");
             Application_Form_FrmMessage::redirectUrl("/purchase/return");
         } else {
             if ($this->getRequest()->isPost()) {
                 $data = $this->getRequest()->getPost();
                 if ($data['Save']) {
                     $update_return = new purchase_Model_DbTable_DbReturnItem();
                     $rs = $update_return->updateReturnItem($data);
                     if ($rs == -1) {
                         Application_Form_FrmMessage::Sucessfull("Your product location is not exist", "/purchase/return");
                     }
                     //  					else
                     //  						Application_Form_FrmMessage::Sucessfull("Update Sucessfull", "/purchase/return");
                 }
             }
             // 		$purchase = new purchase_Model_DbTable_DbPurchaseOrder();
             // 		$rows = $purchase->purchaseInfo($id);
             // 		$db = new Application_Model_DbTable_DbGlobal();
             $returnModel = new purchase_Model_DbTable_DbSQLReturnItem();
             $row_info = $returnModel->returnInfo($id);
             $get_form = new Application_Form_FrmReturnItem();
             $session_stock = new Zend_Session_Namespace('stock');
             $frm_return = $get_form->returnItemForm($row_info);
             Application_Model_Decorator::removeAllDecorator($frm_return);
             $this->view->form_return = $frm_return;
             //get qty of return item
             $getReturnItem = $returnModel->getReturnItem($id);
             $this->view->returnItemDetail = $getReturnItem;
             //print_r($getReturnItem);exit();
             //get return item
             $getOption = new Application_Model_GlobalClass();
             $locationRows = $getOption->getLocationOption();
             $this->view->locationOption = $locationRows;
             //print_r($locationRows);exit();
             $itemRows = $getOption->getProductOption();
             $this->view->productOption = $itemRows;
             //print_r($itemRows);exit();
             $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_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;
         }
     } catch (Exception $e) {
         echo $e->getMessage();
     }
 }