本文整理汇总了PHP中Application_Model_DbTable_DbGlobal::productLocationInventory方法的典型用法代码示例。如果您正苦于以下问题:PHP Application_Model_DbTable_DbGlobal::productLocationInventory方法的具体用法?PHP Application_Model_DbTable_DbGlobal::productLocationInventory怎么用?PHP Application_Model_DbTable_DbGlobal::productLocationInventory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Application_Model_DbTable_DbGlobal
的用法示例。
在下文中一共展示了Application_Model_DbTable_DbGlobal::productLocationInventory方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: CustomerAddOrderPayment
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 {
//.........这里部分代码省略.........
示例2: updateCustomerOrder
public function updateCustomerOrder($data)
{
try {
$db_global = new Application_Model_DbTable_DbGlobal();
$db = $this->getAdapter();
$db->beginTransaction();
$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'];
$info_order = array("customer_id" => $data['customer_id'], "LocationId" => $data['LocationId'], "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']);
//update info of order
$db_global->updateRecord($info_order, $id_order_update, "order_id", "tb_sales_order");
unset($info_order);
// $sql_item="SELECT iv.ProdId, iv.QuantityOnHand, iv.QuantityAvailable, sum(so.qty_order) AS qtysold ,s.LocationId
// FROM tb_sales_order AS s,tb_sales_order_item AS so
// , tb_inventorytotal AS iv WHERE iv.ProdId = so.pro_id AND so.order_id=s.order_id AND so.order_id =$id_order_update GROUP BY so.pro_id";
$sql = "SELECT \n\t\t\t\t\t\tp.`pro_id`,\n\t\t\t\t\t\tp.`qty_available`,\n\t\t\t\t\t\tp.`qty_onhand`,\n\t\t\t\t\t\tp.`qty_onsold`,\n\t\t\t\t\t\tSUM(soi.`qty_order`) AS qty_sold_order,\n\t\t\t\t\t\tso.`LocationId`\n\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\tFROM\n\t\t\t\t\t tb_product AS p,\n\t\t\t\t\t tb_sales_order AS so,\n\t\t\t\t\t tb_sales_order_item AS soi \n\t\t\t\t\tWHERE \n\t\t\t\t\t\tp.`pro_id`=soi.`pro_id`\n\t\t\t\t\t\tAND soi.`order_id`=so.`order_id`\n\t\t\t\t\t\tAND soi.`order_id`= {$id_order_update}\n\t\t\t\t\tGROUP BY soi.`pro_id`";
$rows_sold = $db_global->getGlobalDb($sql);
if ($rows_sold) {
foreach ($rows_sold as $row_sold) {
//just add to stock inventory tmp then withdrawal
if ($data["oldStatus"] == 5) {
$update_product = array("qty_onhand" => $row_sold["qty_onhand"] + $row_sold[" qty_sold_order"], "qty_available" => $row_sold["qty_available"] + $row_sold["qty_sold_order"], "last_mod_date" => new Zend_Date());
$db_global->updateRecord($update_product, $row_sold["pro_id"], "pro_id", "tb_product");
} else {
$update_pro = array("qty_onsold" => $row_sold["qty_onsold"] - $row_sold["qty_sold_order"], "qty_available" => $row_sold["qty_available"] + $row_sold["qty_sold_order"], "last_mod_date" => new Zend_Date());
$db_global->updateRecord($update_pro, $row_sold["pro_id"], "pro_id", "tb_inventorytotal");
}
//update total stock
//$row_get = $db_global->porductLocationExist($row_sold["ProdId"],$row_sold["LocationId"]);//old
$row_get = $db_global->porductLocationExist($row_sold["ProdId"], $data["old_location"]);
if ($row_get) {
if ($data["oldStatus"] == 5) {
$update_prolo = array("qty" => $row_get["qty"] + $row_sold["qty_sold_order"], "last_usermod" => $GetUserId, "last_mod_date" => new Zend_Date());
} else {
$qty_on_location = array("qty" => $row_get["qty"] + $row_sold["qty_sold_order"], "qty_onsold" => $row_get["qty"], "last_usermod" => $GetUserId, "last_mod_date" => new Zend_Date());
}
$qty_on_location = array("qty" => $row_get["qty"] + $row_sold["qty_sold_order"], "last_usermod" => $GetUserId, "last_mod_date" => new Zend_Date());
//update total stock
$db_global->updateRecord($qty_on_location, $row_get["ProLocationID"], "ProLocationID", "tb_prolocation");
}
}
}
unset($qty_on_order);
//delete old sale order
unset($rows_sold);
$sql = "DELETE FROM tb_sales_order_item WHERE order_id IN ({$id_order_update})";
$db_global->deleteRecords($sql);
$ids = explode(',', $data['identity']);
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], 'sub_total' => $data['total' . $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
$rows = $db_global->productLocationInventory($itemId, $locationid);
//to check product location
if ($rows) {
$qtyold = $rows['qty'];
$getrecord_id = $rows["ProLocationID"];
$itemOnHand = array('QuantityOnHand' => $rows["QuantityOnHand"] - $qtyrecord, 'QuantityAvailable' => $rows["QuantityAvailable"] - $qtyrecord);
//update total stock
$db_global->updateRecord($itemOnHand, $itemId, "ProdId", "tb_inventorytotal");
unset($itemOnHand);
//update stock dork
//$newqty = $rows['qty']-$qtyrecord;
$updatedata = array('qty' => $rows['qty'] - $qtyrecord);
//update stock product location
$db_global->updateRecord($updatedata, $getrecord_id, "ProLocationID", "tb_prolocation");
unset($updatedata);
//update stock record
} else {
//insert stock ;
$rows_pro_exit = $db_global->productLocation($itemId, $locationid);
if ($rows_pro_exit) {
$updatedata = array('qty' => $rows_pro_exit['qty'] + $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' => -$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('QuantityOnHand' => $rowitem["QuantityOnHand"] - $qtyrecord, 'QuantityAvailable' => $rowitem["QuantityAvailable"] - $qtyrecord);
//update total stock
$itemid = $db_global->updateRecord($itemOnHand, $itemId, "ProdId", "tb_inventorytotal");
unset($itemOnHand);
} else {
$dataInventory = array('ProdId' => $itemId, 'QuantityOnHand' => -$data['qty' . $i], 'QuantityAvailable' => -$data['qty' . $i], 'Timestamp' => new Zend_date());
$db->insert("tb_inventorytotal", $dataInventory);
unset($dataInventory);
//.........这里部分代码省略.........
示例3: receivePaidOrder
//.........这里部分代码省略.........
$this->update($info_purchase_order, $where);
unset($info_purchase_order);
//$db_global->updateRecord($info_purchase_order,$id_order_update,"order_id","tb_purchase_order");
// $sql_itm ="SELECT
// (SELECT p.pro_id FROM tb_product AS p WHERE p.pro_id = po.`pro_id`) AS pro_id
// ,(SELECT p.qty_onorder FROM tb_product AS p WHERE p.pro_id = po.`pro_id`) AS qty_onorder
// ,(SELECT p.qty_onhand FROM tb_product AS p WHERE p.pro_id = po.`pro_id`) AS qty_onhand
// ,(SELECT p.qty_available FROM tb_product AS p WHERE p.pro_id = po.`pro_id`) AS qty_available
// , SUM(po.`qty_order`) AS qty_order FROM
// tb_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_onhand = $row["qty_onhand"]-$row["qty_order"];
// $qty_available = $row["qty_available"]-$row["qty_order"];
// $qty = $row_get["qty"]-$row["qty_order"];
// $qty_available_prolo = $row_get["qty_avaliable"]-$row["qty_order"];
// if($qty_onhand<=0 OR $qty<=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_onhand" => $qty_onhand,
// "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" => $qty,
// "qty_avaliable" => $qty_available_prolo
// );
// $this->_name="tb_prolocation";
// $where = $this->getAdapter()->quoteInto("ProLocationID=?", $row_get["ProLocationID"]);
// $this->update($update_prolocation, $where);
// }
// }
// }
$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']);
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);
$db->insert("tb_purchase_order_item", $data_item[$i]);
unset($data_item[$i]);
$recieve_item = array("recieve_id" => $recieve_id, "pro_id" => $data['item_id_' . $i], "order_id" => $id_order_update, "qty_order" => $data['qty' . $i], "qty_recieve" => $data['qty' . $i], "qty_remian" => 0, "price" => $data['price' . $i], "disc_value" => $data["dis-value" . $i], "is_free" => $is_free, "total_before" => 0, "sub_total" => $data['total' . $i]);
$this->_name = "tb_recieve_order_item";
$this->insert($recieve_item);
unset($recieve_item);
$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], 'status' => 4, 'unit_price' => $data['price' . $i], 'sub_total' => $data['total' . $i], 'last_update_date' => new Zend_Date());
$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" => $rows["qty"] + $qtyrecord, "qty_avaliable" => $rows["qty_avaliable"] + $qtyrecord, "qty_onorder" => $rows["qty_onorder"] - $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_onhand" => $rows["qty_onhand"] + $qtyrecord, "qty_available" => $rows["qty_available"] + $qtyrecord, "qty_onorder" => $rows["pqty_onorder"] - $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" => $rows["qty"] + $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_onhand" => $rows["qty_onhand"] + $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);
}
}
$db->commit();
} catch (Exception $e) {
$db->rollBack();
$e->getMessage();
}
}
示例4: updateVendorCancellOrder
public function updateVendorCancellOrder($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'];
//update info of order in tb_purchase order
// if($data["status"]==6){
// }
$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");
unset($info_purchase_order);
// Insert recieved order
$recieved_id = $data["recieve_id"];
$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 {
$sql = "SELECT * FROM tb_setting WHERE `code`=16";
$ro = $db_global->getGlobalDbRow($sql);
$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]);
}
}
}
// end update info of order in tb_purchase order
// 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
//print_r($ids);exit();
foreach ($ids as $i) {
// Insert recieved order item
$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
//print_r($rows); exit();
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);
//.........这里部分代码省略.........
示例5: CustomerAddOrderPayment
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;
//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'];
}
$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(), "paid" => $data['remain'], "all_total" => $data['remain'], "balance" => 0);
//and info of order
$id_order = $db_global->addRecord($info_order, "tb_sales_order");
unset($info_order);
$ids = explode(',', $data['identity']);
foreach ($ids as $i) {
//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' => 4, '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);
$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], 'sub_total' => $data['total' . $i]);
$db->insert("tb_sales_order_item", $data_item[$i]);
unset($data_item[$i]);
//check stock product location
$locationid = $data['LocationId'];
$itemId = $data['item_id_' . $i];
$qtyrecord = $data['qty' . $i];
//qty on 1 record
$rows = $db_global->productLocationInventory($itemId, $locationid);
//to check product location
if ($rows) {
$qtyold = $rows['qty'];
$getrecord_id = $rows["ProLocationID"];
$itemOnHand = array('qty_onsold' => $rows["qty_onsold"] + $qtyrecord, 'qty_onsold' => $rows["qty_onsold"] + $qtyrecord);
//update total stock
$db_global->updateRecord($itemOnHand, $itemId, "pro_id", "tb_product");
unset($itemOnHand);
//update stock dork
//$newqty = $rows['qty']-$qtyrecord;
$updatedata = array('qty_onsold' => $rows['qty_onsold'] + $qtyrecord);
//update stock product location
$db_global->updateRecord($updatedata, $getrecord_id, "ProLocationID", "tb_prolocation");
unset($updatedata);
//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);
//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' => -$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('QuantityOnHand' => $rowitem["QuantityOnHand"] - $qtyrecord, 'QuantityAvailable' => $rowitem["QuantityAvailable"] - $qtyrecord);
//update total stock
$itemid = $db_global->updateRecord($itemOnHand, $itemId, "ProdId", "tb_inventorytotal");
unset($itemOnHand);
} else {
$dataInventory = array('ProdId' => $itemId, 'QuantityOnHand' => -$data['qty' . $i], 'QuantityAvailable' => -$data['qty' . $i], 'Timestamp' => new Zend_date());
$db->insert("tb_inventorytotal", $dataInventory);
unset($dataInventory);
//update stock product location
}
}
}
$db->commit();
} catch (Exception $e) {
$db->rollBack();
}
}
示例6: updateVendorOrder
public function updateVendorOrder($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'];
$info_purchase_order = array("vendor_id" => $data['v_name'], "LocationId" => $data["LocationId"], "order" => $data['txt_order'], "date_order" => $data['order_date'], "status" => 4, "remark" => $data['remark'], "user_mod" => $GetUserId, "timestamp" => new Zend_Date(), "paid" => $data['paid'], "balance" => $data['remain']);
//update info of order
$db_global->updateRecord($info_purchase_order, $id_order_update, "order_id", "tb_purchase_order");
$sql_itm = "SELECT iv.ProdId, iv.QuantityOnHand,iv.QuantityAvailable,sum(po.qty_order) AS qty_order FROM tb_purchase_order_item AS po\n\t\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_itm);
if ($rows_order) {
foreach ($rows_order as $row_order) {
$qty_on_order = array("QuantityOnHand" => $row_order["QuantityOnHand"] - $row_order["qty_order"], "QuantityAvailable" => $row_order["QuantityAvailable"] - $row_order["qty_order"], "Timestamp" => new Zend_Date());
//update total stock
$db_global->updateRecord($qty_on_order, $row_order["ProdId"], "ProdId", "tb_inventorytotal");
$row_get = $db_global->porductLocationExist($row_order["ProdId"], $data["old_location"]);
if ($row_get) {
$qty_on_location = array("qty" => $row_get["qty"] - $row_order["qty_order"], "last_usermod" => $GetUserId, "last_mod_date" => new Zend_Date());
//update total stock
$db_global->updateRecord($qty_on_location, $row_get["ProLocationID"], "ProLocationID", "tb_prolocation");
}
}
}
unset($rows_order);
$sql = "DELETE FROM tb_purchase_order_item WHERE order_id IN ({$id_order_update})";
$db_global->deleteRecords($sql);
$ids = explode(',', $data['identity']);
//add order in tb_inventory must update code again 9/8/13
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], 'sub_total' => $data['total' . $i], 'remark' => $data['remark_' . $i]);
$db->insert("tb_purchase_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
$rows = $db_global->productLocationInventory($itemId, $locationid);
//to check product location
if ($rows) {
$getrecord_id = $rows["ProLocationID"];
$itemOnHand = array('QuantityOnHand' => $rows["QuantityOnHand"] + $qtyrecord, 'QuantityAvailable' => $rows["QuantityAvailable"] + $qtyrecord);
//update total stock
$db_global->updateRecord($itemOnHand, $itemId, "ProdId", "tb_inventorytotal");
unset($itemOnHand);
//update stock dork
//$newqty = $rows['qty']-$qtyrecord;
$updatedata = array('qty' => $rows['qty'] + $qtyrecord);
//update stock product location
$db_global->updateRecord($updatedata, $getrecord_id, "ProLocationID", "tb_prolocation");
unset($updatedata);
//update stock record
} else {
//insert stock ;
$rows_pro_exit = $db_global->productLocation($itemId, $locationid);
if ($rows_pro_exit) {
$updatedata = array('qty' => $rows_pro_exit['qty'] + $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' => $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('QuantityOnHand' => $rowitem["QuantityOnHand"] + $qtyrecord, 'QuantityAvailable' => $rowitem["QuantityAvailable"] + $qtyrecord);
//update total stock
$itemid = $db_global->updateRecord($itemOnHand, $itemId, "ProdId", "tb_inventorytotal");
unset($itemOnHand);
} else {
$dataInventory = array('ProdId' => $itemId, 'QuantityOnHand' => $qtyrecord, 'QuantityAvailable' => $qtyrecord, 'Timestamp' => new Zend_date());
$db->insert("tb_inventorytotal", $dataInventory);
unset($dataInventory);
//update stock product location
}
}
}
$db->commit();
} catch (Exception $e) {
$db->rollBack();
}
}
示例7: RecievedPurchaseOrder
public function RecievedPurchaseOrder($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;
$_order_no = $data["order_no"];
$_order_id = $data["order_id"];
$ids = explode(',', $data['identity']);
//print_r($row);//exit();
if ($data['invoice_no'] == "") {
$date = new Zend_Date();
$recieved_num = "RO" . $date->get('hh-mm-ss');
} else {
$recieved_num = $data['invoice_no'];
}
$sql_itm = "SELECT\n\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\n\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\n\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\n\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\n\t\t\t\t, SUM(po.`qty_order`) AS qty_order FROM\n\t\t\t\t\n\t\t\t\ttb_purchase_order_item AS po WHERE po.order_id = {$_order_no} GROUP BY po.pro_id";
$result = $db_global->getGlobalDb($sql_itm);
if ($result) {
foreach ($result as $row_pro) {
$row_get = $db_global->porductLocationExist($row_pro["pro_id"], $data["LocationId"]);
//print_r($row_get);
if ($row_get) {
$update_prolo_stock = array("qty_onorder" => $row_get["qty_onorder"] - $row_pro["qty_order"], "last_usermod" => $GetUserId, "last_mod_date" => new Zend_Date());
$update_data = $db_global->updateRecord($update_prolo_stock, $row_get["ProLocationID"], "ProLocationID", "tb_prolocation");
unset($update_prolo_stock);
}
$update_product_stock = array("qty_onorder" => $row_pro["qty_onorder"] - $row_pro["qty_order"], "last_mod_date" => new Zend_Date());
$sqls = $db_global->updateRecord($update_product_stock, $row_pro["pro_id"], "pro_id", "tb_product");
unset($update_product_stock);
}
}
unset($result);
try {
$info_purchase_order = array("vendor_id" => $data['v_name'], "LocationId" => $data["LocationId"], "status" => 5, "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, $_order_no, "order_id", "tb_purchase_order");
unset($info_purchase_order);
} catch (Exception $e) {
echo $e->getMessage();
}
$sql_recieve = new purchase_Model_DbTable_DbPurchaseOrder();
$result_recieve = $sql_recieve->recieved_info($_order_no);
$recieved_id = $result_recieve["recieve_id"];
if ($result_recieve) {
$data_recieved_order = array("recieve_type" => 1, "vendor_id" => $data['v_name'], "location_id" => $data["LocationId"], "date_recieve" => new Zend_Date(), "status" => 5, "is_active" => 1, "paid" => $data['paid'], "all_total" => $data['totalAmoun'], "balance" => $data['remain'], "user_recieve" => $GetUserId);
$recieved_order = $db_global->updateRecord($data_recieved_order, $result_recieve["recieve_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" => $_order_no, "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 {
$recieve_order = array("recieve_no" => $recieved_num, "order_id" => $_order_no, "order_no" => $data['order_num'], "vendor_id" => $data["v_name"], "recieve_type" => 1, "location_id" => $data["LocationId"], "order_date" => $data["order_date"], "date_recieve" => new Zend_Date(), "status" => 5, "is_active" => 1, "paid" => $data["paid"], "all_total" => $data["remain"], "user_recieve" => $GetUserId);
$this->_name = "tb_recieve_order";
$recieved_order = $this->insert($recieve_order);
unset($recieve_order);
foreach ($ids as $i) {
$recieved_item[$i] = array("recieve_id" => $recieved_order, "pro_id" => $data['item_id_' . $i], "order_id" => $_order_no, "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]);
}
}
$sql = "DELETE FROM tb_purchase_order_item WHERE order_id IN ({$_order_no})";
$db_global->deleteRecords($sql);
unset($sql);
$sql_history = "DELETE FROM tb_purchase_order_history WHERE `order` IN ({$_order_no})";
$db_global->deleteRecords($sql_history);
unset($sql_history);
foreach ($ids as $i) {
// Insert New purchase order item in old order_id
$data_item[$i] = array('order_id' => $_order_no, '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' => $_order_no, 'pro_id' => $data['item_id_' . $i], 'type' => 1, 'customer_id' => $data['v_name'], 'status' => 5, 'order_total' => $data['total' . $i], 'qty' => $data['qty' . $i], 'unit_price' => $data['price' . $i], 'sub_total' => $data['total' . $i], 'date' => $data["order_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"];
$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);
$updatedata = array('qty' => $rows['qty'] + $qtyrecord, 'last_mod_date' => new Zend_date());
$db_global->updateRecord($updatedata, $getrecord_id, "ProLocationID", "tb_prolocation");
} else {
//.........这里部分代码省略.........