当前位置: 首页>>代码示例>>PHP>>正文


PHP Application_Model_DbTable_DbGlobal::inventoryLocation方法代码示例

本文整理汇总了PHP中Application_Model_DbTable_DbGlobal::inventoryLocation方法的典型用法代码示例。如果您正苦于以下问题:PHP Application_Model_DbTable_DbGlobal::inventoryLocation方法的具体用法?PHP Application_Model_DbTable_DbGlobal::inventoryLocation怎么用?PHP Application_Model_DbTable_DbGlobal::inventoryLocation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Application_Model_DbTable_DbGlobal的用法示例。


在下文中一共展示了Application_Model_DbTable_DbGlobal::inventoryLocation方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: updateReturnItem

 public function updateReturnItem($post)
 {
     $db = $this->getAdapter();
     $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"];
     $data_update = array("vendor_id" => $post["v_name"], "return_no" => $post['retun_order'], "date_return" => $post["return_date"], "payment_method" => $post["payment_name"], "currency_id" => $post["currency"], "remark" => $post["return_remark"], "user_mod" => $GetUserId, "timestamp" => new Zend_Date(), "paid" => $post["paid"], "all_total" => $post["all_total"], "balance" => $post["all_total"] - $post["paid"]);
     $db_global->addRecord($data_update, "tb_return");
     $db_global->updateRecord($data_update, $return_id, "return_id", "tb_return");
     unset($data_update);
     /////
     $sql_item = "SELECT iv.ProdId, iv.QuantityOnHand,iv.QuantityAvailable,rv.location_id,rv.qty_return FROM tb_return_vendor_item AS rv\n  \tINNER JOIN tb_inventorytotal AS iv ON iv.ProdId = rv.pro_id WHERE rv.return_id = {$return_id}";
     $rows_return = $db_global->getGlobalDb($sql_item);
     if ($rows_return) {
         foreach ($rows_return as $row_return) {
             $qty_on_order = array("QuantityOnHand" => $row_return["QuantityOnHand"] + $row_return["qty_return"], "QuantityAvailable" => $row_return["QuantityAvailable"] + $row_return["qty_return"], "Timestamp" => new zend_date());
             //update total stock
             $db_global->updateRecord($qty_on_order, $row_return["ProdId"], "ProdId", "tb_inventorytotal");
             unset($qty_on_order);
             $rowitem_exist = $db_global->porductLocationExist($row_return["ProdId"], $row_return["location_id"]);
             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);
             }
         }
     }
     $sql = "DELETE FROM tb_return_vendor_item WHERE return_id IN ({$return_id})";
     $db_global->deleteRecords($sql);
     $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], "location_id" => $post["LocationId_" . $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);
         $rows = $db_global->inventoryLocation($post["LocationId_" . $i], $post["item_id_" . $i]);
         if ($rows) {
             $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);
             $qty_on_return = array("QuantityOnHand" => $rows["QuantityOnHand"] - $post["qty_return_" . $i], "QuantityAvailable" => $rows["QuantityAvailable"] - $post["qty_return_" . $i], "Timestamp" => new zend_date());
             //update total stock
             $db_global->updateRecord($qty_on_return, $post["item_id_" . $i], "ProdId", "tb_inventorytotal");
             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);
         } 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);
             $rows_stock = $db_global->InventoryExist($post["item_id_" . $i]);
             if ($rows_stock) {
                 $dataInventory = array('QuantityOnHand' => $rows_stock["QuantityOnHand"] - $post["qty_return_" . $i], 'QuantityAvailable' => $rows_stock["QuantityAvailable"] - $post["qty_return_" . $i], 'Timestamp' => new Zend_date());
                 $db_global->updateRecord($dataInventory, $rows_stock["ProdId"], "ProdId", "tb_inventorytotal");
                 unset($dataInventory);
             } else {
                 $addInventory = array('ProdId' => $post["item_id_" . $i], 'QuantityOnHand' => -$post["qty_return_" . $i], 'QuantityAvailable' => -$post["qty_return_" . $i], 'Timestamp' => new Zend_date());
                 $db->insert("tb_inventorytotal", $addInventory);
                 unset($addInventory);
             }
         }
     }
 }
开发者ID:pingitgroup,项目名称:stockpingitgroup,代码行数:78,代码来源:DbReturnItem.php

示例2: updateCustomerOrderPayment

 public function updateCustomerOrderPayment($data)
 {
     $db_global = new Application_Model_DbTable_DbGlobal();
     $db = $this->getAdapter();
     $session_user = new Zend_Session_Namespace('auth');
     $userName = $session_user->user_name;
     $GetUserId = $session_user->user_id;
     $idrecord = $data['customer_id'];
     $datainfo = array("contact_name" => $data['contact'], "phone" => $data['txt_phone']);
     //updage customer info
     $db_global->updateRecord($datainfo, $idrecord, "customer_id", "tb_customer");
     $id_order_update = $data['id'];
     $info_order = array("customer_id" => $data['customer_id'], "LocationId" => $data['LocationId'], "order" => $data['order'], "sales_ref" => $data['sales_ref'], "date_order" => $data['order_date'], "status" => 4, "payment_method" => $data['payment_name'], "currency_id" => $data['currency'], "remark" => $data['remark'], "user_mod" => $GetUserId, "timestamp" => new Zend_Date(), "version" => 1, "net_total" => $data['net_total'], "discount_type" => $data['discount_type'], "discount_value" => $data['discount_value'], "discount_real" => $data["discount_real"], "paid" => $data['all_total'], "all_total" => $data['all_total'], "balance" => 0);
     //update info of order
     $db_global->updateRecord($info_order, $id_order_update, "order_id", "tb_sales_order");
     unset($info_order);
     $rows_exist = $db_global->salesOrderHistoryExitAll($id_order_update);
     if ($rows_exist) {
         foreach ($rows_exist as $id_history) {
             $data_status = array('status' => 4);
             $db_global->updateRecord($data_status, $id_history['history_id'], "history_id", "tb_order_history");
             unset($data_status);
         }
     }
     //and info of order
     $sql_item = "SELECT iv.ProdId, iv.QuantitySold, iv.QuantityAvailable, sum(so.qty_order) AS qtysold FROM tb_sales_order_item AS so\n\t\tINNER JOIN tb_inventorytotal AS iv ON iv.ProdId = so.pro_id WHERE so.order_id ={$id_order_update} GROUP BY so.pro_id";
     $rows_sold = $db_global->getGlobalDb($sql_item);
     if ($rows_sold) {
         foreach ($rows_sold as $row_sold) {
             $qty_on_sold = array("QuantitySold" => $row_sold["QuantitySold"] - $row_sold["qtysold"], "QuantityAvailable" => $row_sold["QuantityAvailable"] + $row_sold["qtysold"]);
             //update total stock
             $db_global->updateRecord($qty_on_sold, $row_sold["ProdId"], "ProdId", "tb_inventorytotal");
         }
     }
     unset($qty_on_sold);
     unset($rows_order);
     $sql = "DELETE FROM tb_sales_order_item WHERE order_id IN ({$id_order_update})";
     $db_global->deleteRecords($sql);
     $ids = explode(',', $data['identity']);
     $qtyonhand = 0;
     foreach ($ids as $i) {
         $data_item[$i] = array('order_id' => $id_order_update, 'pro_id' => $data['item_id_' . $i], 'qty_order' => $data['qty' . $i], 'price' => $data['price' . $i], 'total_befor' => $data['total' . $i], 'disc_type' => $data['dis-type-' . $i], 'disc_value' => $data['dis-value' . $i], 'sub_total' => $data['after_discount' . $i]);
         $db->insert("tb_sales_order_item", $data_item[$i]);
         unset($data_item[$i]);
         $locationid = $data['LocationId'];
         $itemId = $data['item_id_' . $i];
         $qtyrecord = $data['qty' . $i];
         //qty on 1 record
         // 			$sql="SELECT pl.ProLocationID, pl.qty, iv.QuantityOnHand, iv.QuantityAvailable
         // 			FROM tb_prolocation AS pl
         // 			INNER JOIN tb_inventorytotal AS iv ON iv.ProdId = pl.pro_id
         // 			WHERE pl.LocationId =".$locationid." AND pl.pro_id=".$itemId;
         $rows = $db_global->inventoryLocation($locationid, $itemId);
         if ($rows) {
             $qty_on_order = array("QuantityAvailable" => $rows["QuantityAvailable"] - $data['qty' . $i], "QuantityOnHand" => $rows["QuantityOnHand"] - $data['qty' . $i]);
             //update total stock
             $db_global->updateRecord($qty_on_order, $itemId, "ProdId", "tb_inventorytotal");
             unset($qty_on_order);
             //update stock dork
             $updatedata = array('qty' => $rows["qty"] - $qtyrecord);
             //update stock product location
             $db_global->updateRecord($updatedata, $rows["ProLocationID"], "ProLocationID", "tb_prolocation");
             unset($updatedata);
             //update stock record
         } else {
             //insert stock
             $insertdata = array('pro_id' => $itemId, 'LocationId' => $locationid, 'qty' => -$qtyrecord);
             //update stock product location
             $db->insert("tb_prolocation", $insertdata);
             unset($insertdata);
             $rows_stock = $db_global->InventoryExist($itemId);
             if ($rows_stock) {
                 $dataInventory = array('ProdId' => $itemId, 'QuantityOnHand' => $rows_stock["QuantityOnHand"] - $data['qty' . $i], 'Timestamp' => new Zend_date());
                 $db_global->updateRecord($dataInventory, $rows_stock["ProdId"], "ProdId", "tb_inventorytotal");
                 unset($dataInventory);
             } else {
                 $addInventory = array('ProdId' => $itemId, 'QuantityOnHand' => -$qtyrecord, 'QuantityAvailable' => -$qtyrecord, 'Timestamp' => new Zend_date());
                 $db->insert("tb_inventorytotal", $addInventory);
                 unset($addInventory);
             }
         }
     }
 }
开发者ID:pingitgroup,项目名称:stockpingitgroup,代码行数:83,代码来源:DbSalesOrder.php

示例3: updateReturnItemIn

 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);
//.........这里部分代码省略.........
开发者ID:pingitgroup,项目名称:stockpingitgroup,代码行数:101,代码来源:DbReturnItem.php

示例4: receivedCompleted

 public function receivedCompleted($data)
 {
     $db_global = new Application_Model_DbTable_DbGlobal();
     $advance = new purchase_Model_DbTable_DbPurchaseAdvance();
     $session_user = new Zend_Session_Namespace('auth');
     $userName = $session_user->user_name;
     $GetUserId = $session_user->user_id;
     $db = $this->getAdapter();
     $rows_tmp = $advance->purchaseOrderTMPExist($data['purchase_order']);
     if ($rows_tmp) {
         foreach ($rows_tmp as $post) {
             //add info received item
             $data_receive = array("purchase_order_id" => $data['purchase_order'], "location_id" => $post["qty_order"], "pro_id" => $post["pro_id"], "qty_order" => $post["qty_order"], "qty_receive" => $post["qty_order"], "qty_remain" => 0, "receive_date" => new Zend_Date(), "user_id" => $GetUserId, "mod_date" => new Zend_Date());
             $db->insert("tb_purchase_order_receive", $data_receive);
             $rows = $db_global->inventoryLocation($data["location_id"], $post["pro_id"]);
             if ($rows) {
                 $qty_on_order = array('QuantityOnHand' => $rows["QuantityOnHand"] + $post["qty_order"], 'QuantityOnOrder' => $rows["QuantityOnOrder"] - $post["qty_order"], 'QuantityAvailable' => $rows["QuantityAvailable"] + $post["qty_order"], 'Timestamp' => new Zend_date());
                 // 						//update total stock
                 $db_global->updateRecord($qty_on_order, $post["pro_id"], "ProdId", "tb_inventorytotal");
                 // 						unset($qty_on_order);
                 $updatedata = array('qty' => $rows["qty"] + $post["qty_order"], "last_usermod" => $GetUserId, "last_mod_date" => new Zend_Date());
                 //update stock product location
                 $db_global->updateRecord($updatedata, $rows["ProLocationID"], "ProLocationID", "tb_prolocation");
                 unset($updatedata);
                 $row_get = $advance->getItemPurchaseExist($data['purchase_order'], $post["pro_id"]);
                 if ($row_get) {
                     $data_update = array("qty_order" => $row_get["qty_order"] - $post["qty_order"]);
                     $db_global->updateRecord($data_update, $row_get["id"], "id", "tb_purchase_order_item_tmp");
                     unset($data_update);
                 }
             } else {
                 // 						$insertdata=array(
                 // 								'pro_id'     => $post["pro_id"],
                 // 								'LocationId' => $data["location_id"],
                 // 								'qty'        => $post["qty_order"]
                 // 						);
                 // 						//update stock product location
                 // 						$db->insert("tb_prolocation", $insertdata);
                 // // 						unset($insertdata);
                 // // 						//update tmp purchase order
                 // 						$row_get = $advance-> getItemPurchaseExist($data["purchase_id"], $post["pro_id"]);
                 // 						if($row_get){
                 // 							$data_update = array(
                 // 									"qty_order" => $row_get["qty_order"]-$post["qty_order"],
                 // 							);
                 // 							$db_global->updateRecord($data_update,$row_get["id"],"id","tb_purchase_order_item_tmp");
                 // 							unset($data_update);
                 // 						}
                 // 						$rows_stock=$db_global->InventoryExist($post["pro_id"]);
                 // 						if($rows_stock){
                 // 							$dataInventory= array(
                 // 									'QuantityOnHand'    => $rows_stock["QuantityOnHand"]+ $post["qty_order"],
                 // 									'QuantityOnOrder'   => $rows_stock["QuantityOnOrder"]- $post["qty_order"],
                 // 									'QuantityAvailable' => $rows_stock["QuantityAvailable"]+$post["qty_order"],
                 // 									'Timestamp'         => new Zend_date()
                 // 							);
                 // 							$db_global->updateRecord($dataInventory,$rows_stock["ProdId"],"ProdId","tb_inventorytotal");
                 // 							unset($dataInventory);
                 //     					}
                 // 						else{
                 // 							$addInventory= array(
                 // 									'ProdId'            => $post["pro_id"],
                 // 									'QuantityOnHand'    => $post["qty_order"],
                 // 									'QuantityAvailable' => $post["qty_order"],
                 // 									'Timestamp'         => new Zend_date()
                 // 							);
                 // 							$db->insert("tb_inventorytotal", $addInventory);
                 // 							unset($addInventory);
                 // 						}
             }
         }
     }
 }
开发者ID:pingitgroup,项目名称:stockpingitgroup,代码行数:73,代码来源:DbAdvance.php

示例5: updateVendorOrderPayment

 public function updateVendorOrderPayment($data)
 {
     $db_global = new Application_Model_DbTable_DbGlobal();
     $db = $this->getAdapter();
     $session_user = new Zend_Session_Namespace('auth');
     $userName = $session_user->user_name;
     $GetUserId = $session_user->user_id;
     // 		$idrecord=$data['v_name'];
     // 		$datainfo=array(
     // 				"contact_name"=>$data['contact'],
     // 				"phone"       =>$data['txt_phone'],
     // 				//	"add_remark"  =>$data['remark_add']
     // 		);
     // 		//updage customer info
     // 		$itemid=$db_global->updateRecord($datainfo,$idrecord,"vendor_id","tb_vendor");
     $id_order_update = $data['id'];
     $info_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(), "version" => 1, "net_total" => $data['net_total'], "discount_type" => $data['discount_type'], "discount_value" => $data['discount_value'], "discount_real" => $data['discount_real'], "paid" => $data['all_total'], "all_total" => $data['all_total'], "balance" => 0);
     //update info of order not done
     $db_global->updateRecord($info_order, $id_order_update, "order_id", "tb_purchase_order");
     $rows_exist = $db_global->purchaseOrderHistoryExitAll($id_order_update);
     //print_r($rows_exist);exit();
     if ($rows_exist) {
         foreach ($rows_exist as $id_history) {
             $data_status = array('status' => 4);
             $db_global->updateRecord($data_status, $id_history['history_id'], "history_id", "tb_purchase_order_history");
             unset($data_status);
         }
     }
     unset($info_order);
     //if error check this here
     //and info of order
     $sql_item = "SELECT iv.ProdId, iv.QuantityOnOrder,sum(po.qty_order) AS qtyorder\n\t\tFROM tb_purchase_order_item AS po\n\t\tINNER JOIN tb_inventorytotal AS iv ON iv.ProdId = po.pro_id WHERE po.order_id = {$id_order_update} GROUP BY po.pro_id";
     $rows_order = $db_global->getGlobalDb($sql_item);
     if ($rows_order) {
         foreach ($rows_order as $row_order) {
             $qty_on_order = array("QuantityOnOrder" => $row_order["QuantityOnOrder"] - $row_order["qtyorder"]);
             //update total stock
             $db_global->updateRecord($qty_on_order, $row_order["ProdId"], "ProdId", "tb_inventorytotal");
         }
     }
     unset($rows_order);
     unset($rows_order);
     $sql = "DELETE FROM tb_purchase_order_item WHERE order_id IN ({$id_order_update})";
     $db_global->deleteRecords($sql);
     //$db->DeleteData("tb_purchase_order_item"," WHERE order_id = ".$id_order_update);
     $ids = explode(',', $data['identity']);
     $qtyonhand = 0;
     foreach ($ids as $i) {
         $data_item[$i] = array('order_id' => $id_order_update, 'pro_id' => $data['item_id_' . $i], 'qty_order' => $data['qty' . $i], 'price' => $data['price' . $i], 'total_befor' => $data['total' . $i], 'disc_type' => $data['dis-type-' . $i], 'disc_value' => $data['dis-value' . $i], 'sub_total' => $data['after_discount' . $i]);
         $db->insert("tb_purchase_order_item", $data_item[$i]);
         unset($data_item[$i]);
         //UPDATE STOCK
         //check stock product location
         $locationid = $data['LocationId'];
         $itemId = $data['item_id_' . $i];
         $qtyrecord = $data['qty' . $i];
         //qty on 1 record
         $rows = $db_global->inventoryLocation($locationid, $itemId);
         if ($rows) {
             $qty_on_order = array("QuantityAvailable" => $rows["QuantityAvailable"] + $data['qty' . $i], "QuantityOnHand" => $rows["QuantityOnHand"] + $data['qty' . $i]);
             //update total stock
             $db_global->updateRecord($qty_on_order, $itemId, "ProdId", "tb_inventorytotal");
             unset($qty_on_order);
             //update stock dork
             $newqty = $rows["qty"] + $qtyrecord;
             $updatedata = array('qty' => $newqty);
             //update stock product location
             $db_global->updateRecord($updatedata, $rows["ProLocationID"], "ProLocationID", "tb_prolocation");
             unset($updatedata);
             //update stock record
         } else {
             $insertdata = array('pro_id' => $itemId, 'LocationId' => $locationid, 'qty' => $qtyrecord);
             //update stock product location
             $db->insert("tb_prolocation", $insertdata);
             $rows_stock = $db_global->InventoryExist($itemId);
             if ($rows_stock) {
                 $dataInventory = array('ProdId' => $itemId, 'QuantityOnHand' => $rows_stock["QuantityOnHand"] + $data['qty' . $i], 'QuantityAvailable' => $rows_stock["QuantityAvailable"] + $data['qty' . $i], 'Timestamp' => new Zend_date());
                 $db_global->updateRecord($dataInventory, $rows_stock["ProdId"], "ProdId", "tb_inventorytotal");
                 unset($dataInventory);
             } else {
                 $addInventory = array('ProdId' => $itemId, 'QuantityOnHand' => $data['qty' . $i], 'QuantityAvailable' => $data['qty' . $i], 'Timestamp' => new Zend_date());
                 $db->insert("tb_inventorytotal", $addInventory);
                 unset($addInventory);
             }
         }
     }
 }
开发者ID:pingitgroup,项目名称:stockpingitgroup,代码行数:87,代码来源:DbPurchaseVendor.php


注:本文中的Application_Model_DbTable_DbGlobal::inventoryLocation方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。