本文整理汇总了PHP中Application_Model_DbTable_DbGlobal::addRecord方法的典型用法代码示例。如果您正苦于以下问题:PHP Application_Model_DbTable_DbGlobal::addRecord方法的具体用法?PHP Application_Model_DbTable_DbGlobal::addRecord怎么用?PHP Application_Model_DbTable_DbGlobal::addRecord使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Application_Model_DbTable_DbGlobal
的用法示例。
在下文中一共展示了Application_Model_DbTable_DbGlobal::addRecord方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addNewAgent
public function addNewAgent($data)
{
$db = new Application_Model_DbTable_DbGlobal();
$datainfo = array("name" => $data['agent_name'], "phone" => $data['phone'], "job_title" => $data['position'], "stock_id" => $data['location'], "description" => $data['desc']);
$agent_id = $db->addRecord($datainfo, "tb_sale_agent");
return $agent_id;
}
示例2: addMeasure
public function addMeasure($data)
{
$db = new Application_Model_DbTable_DbGlobal();
$_arr = array("measure_name" => $data["measure_name"]);
$result = $db->addRecord($_arr, "tb_measure");
return $result;
}
示例3: addNewCustomer
final function addNewCustomer($post)
{
$session_user = new Zend_Session_Namespace('auth');
$db = new Application_Model_DbTable_DbGlobal();
$userName = $session_user->user_name;
$GetUserId = $session_user->user_id;
$data = array('type_price' => $post['price_type'], 'cust_name' => $post['customer_name'], 'contact_name' => $post['contact'], 'phone' => $post['phone'], 'add_name' => $post['address'], 'email' => $post['txt_mail'], 'last_usermod' => $GetUserId, 'last_mod_date' => new Zend_Date(), 'CurrencyId' => 1);
$result = $db->addRecord($data, "tb_customer");
return $result;
}
示例4: addNewVenor
public final function addNewVenor($post)
{
$db_global = new Application_Model_DbTable_DbGlobal();
$session_user = new Zend_Session_Namespace('auth');
$userName = $session_user->user_name;
$GetUserId = $session_user->user_id;
$db = $this->getAdapter();
$datavendor = array("v_name" => $post["v_name"], "contact_name" => $post["contact"], "phone" => $post["phone"], "add_name" => $post["address"], "email" => $post["txt_mail"], "last_usermod" => $GetUserId, "last_mod_date" => new Zend_Date(), "CurrencyId" => 1);
$result = $db_global->addRecord($datavendor, "tb_vendor");
return $result;
}
示例5: 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);
}
}
}
}
示例6: quoteUpdate
public function quoteUpdate($data)
{
$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 = $data['customer_id'];
$datainfo = array("contact_name" => $data['contact'], "phone" => $data['txt_phone'], "add_name" => $data['remark_add']);
$itemid = $db_global->updateRecord($datainfo, $idrecord, "customer_id", "tb_customer");
$id = $data["id"];
$sql_del = "DELETE FROM tb_sales_order_item WHERE order_id IN ({$id})";
$db_global->deleteRecords($sql_del);
$sql_sale = "DELETE FROM tb_sales_order WHERE order_id IN ({$id})";
$sql_del_history = "DELETE FROM tb_order_history WHERE type = 2 AND order_id IN ({$id})";
$info_order = array("customer_id" => $data['customer_id'], "LocationId" => $data['LocationId'], "sales_ref" => $data['sales_ref'], "date_order" => $data['order_date'], "payment_method" => $data['payment_name'], "currency_id" => $data['currency'], "remark" => $data['remark'], "user_mod" => $GetUserId, "timestamp" => new Zend_Date(), "net_total" => $data['net_total'], "discount_type" => $data['discount_type'], "discount_value" => $data['discount_value'], "discount_real" => $data["discount_real"], "paid" => $data['paid'], "all_total" => $data['all_total'], "balance" => $data['all_total'] - $data['paid']);
//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) {
$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], '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]);
//add history order
$data_history[$i] = array('pro_id' => $data['item_id_' . $i], 'type' => 2, 'order' => $id_order, 'customer_id' => $data['customer_id'], 'date' => new Zend_Date(), 'status' => 1, 'order_total' => $data['all_total'], 'qty' => $data['qty' . $i], 'unit_price' => $data['price' . $i], 'sub_total' => $data['after_discount' . $i]);
$order_history = $db->insert("tb_order_history", $data_history[$i]);
unset($data_history[$i]);
//update stock total inventory (QTY Reserved)
}
}
示例7: getReturnItemIn
public function getReturnItemIn($post)
{
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;
if ($post['retun_order'] == "") {
$date = new Zend_Date();
$order_no = "RVI" . $date->get('hh-mm-ss');
} else {
$order_no = $post['retun_order'];
}
$data_update = array("returnout_id" => $post["return_reference"], "location_id" => $post["LocationId"], "returnin_no" => $order_no, "remark" => $post["return_remark"], "user_mod" => $GetUserId, "timestamp" => new Zend_Date(), "date_return_out" => $post["return_date"], "date_return_in" => $post["return_date"], "vendor_id" => $post["v_name"], "all_total" => $post["all_total"]);
$return_id = $db_global->addRecord($data_update, "tb_return_vendor_in");
unset($data_update);
$update_return = array("is_active" => 0);
$update_returns = $db_global->updateRecord($update_return, $post["return_reference"], "return_id", "tb_return");
unset($update_return);
$ids = explode(',', $post['identity']);
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_in", $add_data);
$rows = $db_global->inventoryLocation($post["LocationId"], $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("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);
//add return history
$data_history = array('transaction_type' => 5, 'pro_id' => $post["item_id_" . $i], 'date' => new Zend_Date(), 'location_id' => $post["LocationId"], 'Remark' => $order_no, '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" => $order_no, "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 {
$row_location = $db_global->productLocation($post["LocationId"], $post["item_id_" . $i]);
$insertdata = array('pro_id' => $post["item_id_" . $i], 'LocationId' => $post["LocationId"], 'qty' => $post["qty_return_" . $i]);
//update stock product location
$db->insert("tb_prolocation", $insertdata);
unset($insertdata);
//add return history
$data_history = array('transaction_type' => 5, 'pro_id' => $post["item_id_" . $i], 'date' => new Zend_Date(), 'location_id' => $post["LocationId"], 'Remark' => $order_no, '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('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_prodcut");
unset($dataInventory);
} else {
$addInventory = array('pro_id' => $post["item_id_" . $i], 'qty_onhand' => $post["qty_return_" . $i], 'qty_available' => $post["qty_return_" . $i], 'Timestamp' => new Zend_date());
$db->insert("tb_prodcut", $addInventory);
unset($addInventory);
}
}
}
$db->commit();
} catch (Exception $e) {
$db->rollBack();
echo $e->getMessage();
exit;
}
}
示例8: 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);
//.........这里部分代码省略.........
示例9: addStockLocation
final function addStockLocation($post)
{
$db_global = new Application_Model_DbTable_DbGlobal();
$session_user = new Zend_Session_Namespace('auth');
$GetUserId = $session_user->user_id;
$datalocation = array("Name" => $post["location_name"], "user_id" => $GetUserId, "last_mod_date" => new Zend_Date(), "contact" => $post["ContactName"], "phone" => $post["ContactNumber"], "stock_add" => $post["location_add"], "remark" => $post["remark_add"]);
$GetLocationId = $db_global->addRecord($datalocation, "tb_sublocation");
return $GetLocationId;
}
示例10: VendorOrder
public function VendorOrder($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']);
//updage vendor info
$itemid = $db_global->updateRecord($datainfo, $idrecord, "vendor_id", "tb_vendor");
if ($data['txt_order'] == "") {
$date = new Zend_Date();
$order_add = "PO" . $date->get('hh-mm-ss');
} else {
$order_add = $data['txt_order'];
}
$info_purchase_order = array("vendor_id" => $data['v_name'], "LocationId" => $data["LocationId"], "order" => $order_add, "date_order" => $data['order_date'], "status" => 2, "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['paid'], "all_total" => $data['all_total'], "balance" => $data['all_total'] - $data['paid']);
//and info of purchase order
$purchase_id = $db_global->addRecord($info_purchase_order, "tb_purchase_order");
unset($info_purchase_order);
$ids = explode(',', $data['identity']);
// $qtyonhand=0;
foreach ($ids as $i) {
//add history purchase order
$data_history = array('pro_id' => $data['item_id_' . $i], 'type' => 1, 'order' => $purchase_id, 'customer_id' => $data['v_name'], 'date' => new Zend_Date(), 'status' => 2, 'order_total' => $data['all_total'], 'qty' => $data['qty' . $i], 'unit_price' => $data['price' . $i], 'sub_total' => $data['after_discount' . $i]);
$db_global->addRecord($data_history, "tb_purchase_order_history");
unset($data_history);
//add purchase order item
$data_item[$i] = array('order_id' => $purchase_id, '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]);
$id_order_item = $db_global->addRecord($data_item[$i], "tb_purchase_order_item");
unset($data_item[$i]);
//update stock total inventory
$locationid = $data['LocationId'];
$itemId = $data['item_id_' . $i];
$qtyrecord = $data['qty' . $i];
//qty on 1 record
$sql = "SELECT tv.ProdId, tv.QuantityOnOrder,tv.QuantityAvailable\n\t\t\tFROM tb_inventorytotal AS tv\n\t\t\tINNER JOIN tb_product AS p ON tv.ProdId = p.pro_id\n\t\t\tWHERE p.pro_id = " . $data['item_id_' . $i];
$rows = $db_global->getGlobalDbRow($sql);
if ($rows) {
$qty_onhand = $rows["QuantityOnOrder"] + $qtyrecord;
$qty_on_order = array("QuantityOnOrder" => $rows["QuantityOnOrder"] + $qtyrecord);
//update total stock
$db_global->updateRecord($qty_on_order, $itemId, "ProdId", "tb_inventorytotal");
unset($qty_on_order);
} else {
$row = $db_global->InventoryExist($itemId);
if ($row) {
$qty_onhand = $rows["QuantityOnOrder"] + $qtyrecord;
$qty_on_order = array("QuantityOnOrder" => $rows["QuantityOnOrder"] + $qtyrecord);
//update total stock
$db_global->updateRecord($qty_on_order, $itemId, "ProdId", "tb_inventorytotal");
unset($qty_on_order);
} else {
$addInventory = array('ProdId' => $itemId, 'QuantityOnOrder' => $data['qty' . $i], 'Timestamp' => new Zend_date());
$db_global->addRecord($addInventory, "tb_inventorytotal");
unset($addInventory);
}
}
}
}
示例11: updatCat
public function updatCat($data, $id)
{
try {
$db_global = new Application_Model_DbTable_DbGlobal();
$db = $this->getAdapter();
$db->beginTransaction();
$older = $data['id_code'];
$sql = "SELECT p.`order` FROM tb_purchase_order AS p WHERE p.`order`= '{$older}'";
$session_user = new Zend_Session_Namespace('auth');
$userName = $session_user->user_name;
$GetUserId = $session_user->user_id;
$info_purchase_order = array("vendor_id" => $data['vendor'], "date_in" => $data['date'], "status" => $data['status'], "user_mod" => $GetUserId, "timestamp" => new Zend_Date(), "paid" => $data['paid'], "discount" => $data['discount'], "all_total" => $data['totalAmoun'], "balance" => $data['remain']);
$this->_name = "tb_purchase_order";
$where = $db->quoteInto("order_id", $id);
$this->update($info_purchase_order, $where);
$row_old_order = $this->getSalesOderID($id);
if ($row_old_order) {
foreach ($row_old_order as $rs) {
$pro_exist = $db_global->InventoryExist($rs["pro_id"]);
//foreach ($pro_exist as $rs_pro){
//print_r($pro_exist["qty_onorder"]);exit();
$itemOnOrder = array('qty_onorder' => $pro_exist["qty_onorder"] - ($rs['qty_unit'] * $pro_exist["qty_perunit"] + $rs['qty']), 'qty_onhand' => $pro_exist["qty_onhand"] - ($rs['qty_unit'] * $pro_exist["qty_perunit"] + $rs['qty']), 'qty_available' => $pro_exist["qty_available"] - ($rs['qty_unit'] * $pro_exist["qty_perunit"] + $rs['qty']));
//update total stock
$db_global->updateRecord($itemOnOrder, $rs["pro_id"], "pro_id", "tb_product");
//}
}
}
$sql = "DELETE FROM tb_purchase_order_item WHERE order_id={$id}";
$db->query($sql);
$ids = explode(',', $data['identity']);
foreach ($ids as $i) {
$itemId = $data['item_id' . $i];
$qtyrecord = $data['unit_qty' . $i];
//qty on 1 record
$data_history[$i] = array('pro_id' => $data['item_id' . $i], 'type' => 1, 'order' => $id, 'customer_id' => $data['vendor'], 'date' => new Zend_Date(), 'status' => $data['status'], 'qty_unit' => $data['unit_qty' . $i], 'qty_per_unit' => $data['unit_price' . $i], 'qty' => $data['qty' . $i], 'price' => $data['price_per_qty' . $i], "discount" => $data['discount'], 'total' => $data['total_price' . $i]);
$order_history = $db_global->addRecord($data_history[$i], "tb_purchase_order_history");
unset($data_history[$i]);
$data_item[$i] = array('order_id' => $id, 'pro_id' => $data['item_id' . $i], 'qty_unit' => $data['unit_qty' . $i], 'qty_per_unit' => $data['unit_price' . $i], 'qty' => $data['qty' . $i], 'price' => $data['price_per_qty' . $i], 'total_befor' => $data['total_price' . $i], "discount" => $data['discount'], 'sub_total' => $data['total_price' . $i]);
$recieved_order = $db->insert("tb_purchase_order_item", $data_item[$i]);
$data_item_history[$i] = array('order_id' => $id, 'pro_id' => $data['item_id' . $i], 'qty_unit' => $data['unit_qty' . $i], 'qty_per_unit' => $data['unit_price' . $i], 'qty' => $data['qty' . $i], 'price' => $data['price_per_qty' . $i], 'total_befor' => $data['total_price' . $i], 'sub_total' => $data['total_price' . $i]);
$recieved_order_history = $db->insert("tb_purchase_order_item_history", $data_item[$i]);
$rows = $db_global->InventoryExist($itemId);
//print_r($rows);exit();
if ($rows) {
//$qty_onhand = $rowitem["QuantityOnHand"]+$data['qty'.$i];
echo $rows["qty_perunit"];
$itemOnOrder = array('qty_onorder' => $rows["qty_onorder"] + $data['unit_qty' . $i] * $rows["qty_perunit"] + $data['qty' . $i], 'qty_onhand' => $rows["qty_onhand"] + $data['unit_qty' . $i] * $rows["qty_perunit"] + $data['qty' . $i], 'qty_available' => $rows["qty_available"] + $data['unit_qty' . $i] * $rows["qty_perunit"] + $data['qty' . $i], 'pro_id' => $itemId);
//update total stock
$db_global->updateRecord($itemOnOrder, $itemId, "pro_id", "tb_product");
} else {
$dataInventory = array('pro_id' => $itemId, 'qty_onorder' => $rows["qty_onorder"] + $data['unit_qty' . $i] * $rows["qty_perunit"] + $data['qty' . $i], 'qty_onhand' => $rows["qty_onhand"] + $data['unit_qty' . $i] * $rows["qty_perunit"] + $data['qty' . $i], 'qty_available' => $rows["qty_available"] + $data['unit_qty' . $i] * $rows["qty_perunit"] + $data['qty' . $i], 'last_mod_date' => new Zend_date());
$db->insert("tb_product", $dataInventory);
//add move hostory
}
}
// exit();
$db->commit();
} catch (Exception $e) {
$db->rollBack();
$e->getMessage();
exit;
}
}
示例12: TransferStockTransaction
public function TransferStockTransaction($post)
{
$db = $this->getAdapter();
$session_user = new Zend_Session_Namespace('auth');
$userName = $session_user->user_name;
$GetUserId = $session_user->user_id;
$db_global = new Application_Model_DbTable_DbGlobal();
if ($post['from_location'] !== $post['to_location']) {
//try{
if ($post['invoce_num'] != "") {
$tr_no = $post['invoce_num'];
} else {
$date = new Zend_Date();
$tr_no = "TR" . $date->get('hh-mm-ss');
}
$data_transfer = array('invoice_num' => $tr_no, 'transfer_date' => $post['transfer_date'], 'from_location' => $post['from_location'], 'to_location' => $post['to_location'], 'user_id' => $GetUserId, 'mod_date' => new Zend_Date(), 'remark' => $post['remark_transfer']);
$transfer_id = $db_global->addRecord($data_transfer, "tb_stocktransfer");
unset($data_transfer);
$identity = explode(',', $post['identity']);
foreach ($identity as $i) {
$data_item = array('transfer_id' => $transfer_id, 'pro_id' => $post['item_id_' . $i], 'qty' => $post['qty_id_' . $i], 'remark_transfer' => $post['remark_' . $i]);
$db->insert("tb_transfer_item", $data_item);
unset($data_item);
$rows = $db_global->porductLocationExist($post['item_id_' . $i], $post['from_location']);
if ($rows) {
//update poduct location from
$data_qty_location = array('qty' => $rows['qty'] - $post['qty_id_' . $i]);
$db_global->updateRecord($data_qty_location, $rows['ProLocationID'], "ProLocationID", "tb_prolocation");
//add move history
$data_history = array('transaction_type' => 2, 'pro_id' => $post['item_id_' . $i], 'date' => new Zend_Date(), 'location_id' => $post['from_location'], 'Remark' => $post['remark_' . $i], 'qty_edit' => $post['qty_id_' . $i], 'qty_before' => $rows['qty'], 'qty_after' => $rows['qty'] - $post['qty_id_' . $i], 'user_mod' => $GetUserId);
$db->insert("tb_move_history", $data_history);
unset($data_qty_location);
unset($rows);
unset($data_history);
//update product location to
$rows_gets_qty = $db_global->porductLocationExist($post['item_id_' . $i], $post['to_location']);
if ($rows_gets_qty) {
$data_qty_location = array('qty' => $rows_gets_qty['qty'] + $post['qty_id_' . $i]);
$itemid = $db_global->updateRecord($data_qty_location, $rows_gets_qty['ProLocationID'], "ProLocationID", "tb_prolocation");
//add move history
$data_history = array('transaction_type' => 2, 'pro_id' => $post['item_id_' . $i], 'date' => new Zend_Date(), 'location_id' => $post['to_location'], 'Remark' => $post['remark_' . $i], 'qty_edit' => $post['qty_id_' . $i], 'qty_before' => $rows_gets_qty['qty'], 'qty_after' => $rows_gets_qty['qty'] + $post['qty_id_' . $i], 'user_mod' => $GetUserId);
$db->insert("tb_move_history", $data_history);
unset($rows_gets_qty);
unset($data_history);
} else {
$add_pro_location = array('pro_id' => $post['item_id_' . $i], 'LocationId' => $post['to_location'], 'qty' => $post['qty_id_' . $i], 'last_usermod' => $GetUserId, 'last_mod_date' => new Zend_Date());
$db->insert("tb_prolocation", $add_pro_location);
//if receive not have
$data_history = array('transaction_type' => 2, 'pro_id' => $post['item_id_' . $i], 'date' => new Zend_Date(), 'location_id' => $post['to_location'], 'Remark' => $post['remark_' . $i], 'qty_edit' => $post['qty_id_' . $i], 'qty_before' => 0, 'qty_after' => $post['qty_id_' . $i], 'user_mod' => $GetUserId);
$db->insert("tb_move_history", $data_history);
unset($add_pro_location);
unset($data_history);
}
} else {
//if from doesn't exist
//add qty in location if from doesn't exist
$add_pro_location = array('pro_id' => $post['item_id_' . $i], 'LocationId' => $post['from_location'], 'qty' => -$post['qty_id_' . $i], 'last_usermod' => $GetUserId, 'last_mod_date' => new Zend_Date());
$db->insert("tb_prolocation", $add_pro_location);
unset($add_pro_location);
//echeck for get product location
$data_history = array('transaction_type' => 1, 'pro_id' => $post['item_id_' . $i], 'date' => new Zend_Date(), 'location_id' => $post['from_location'], 'Remark' => $post['remark_' . $i], 'qty_edit' => $post['qty_id_' . $i], 'qty_after' => -$post['qty_id_' . $i], 'user_mod' => $GetUserId);
$db->insert("tb_move_history", $data_history);
unset($data_history);
//for get stock
$rows_gets_qty = $db_global->porductLocationExist($post['item_id_' . $i], $post['to_location']);
if ($rows_gets_qty) {
$data_qty_location = array('qty' => $rows_gets_qty['qty'] + $post['qty_id_' . $i]);
$db_global->updateRecord($data_qty_location, $rows_gets_qty['ProLocationID'], "ProLocationID", "tb_prolocation");
//add move history
$data_history = array('transaction_type' => 2, 'pro_id' => $post['item_id_' . $i], 'date' => new Zend_Date(), 'location_id' => $post['to_location'], 'Remark' => $post['remark_' . $i], 'qty_edit' => $post['qty_id_' . $i], 'qty_before' => $rows_gets_qty['qty'], 'qty_after' => $rows_gets_qty['qty'] + $post['qty_id_' . $i], 'user_mod' => $GetUserId);
$db->insert("tb_move_history", $data_history);
unset($rows_gets_qty);
unset($data_qty_location);
} else {
//if doesn't exist from and to
$add_pro_location = array('pro_id' => $post['item_id_' . $i], 'LocationId' => $post['to_location'], 'qty' => $post['qty_id_' . $i], 'last_usermod' => $GetUserId, 'last_mod_date' => new Zend_Date());
$db->insert("tb_prolocation", $add_pro_location);
unset($add_pro_location);
//if doesn't exist from and to
$data_history = array('transaction_type' => 1, 'pro_id' => $post['item_id_' . $i], 'date' => new Zend_Date(), 'location_id' => $post['to_location'], 'Remark' => $post['remark_' . $i], 'qty_edit' => $post['qty_id_' . $i], 'qty_after' => $post['qty_id_' . $i], 'user_mod' => $GetUserId);
$db->insert("tb_move_history", $data_history);
unset($data_history);
}
}
}
//forforeach
//$db->commit();
/*}//try
catch (Exception $e) {
$db->rollBack();
$this->view->msg = $e->getMessage();
}*/
}
//for if
}