本文整理汇总了PHP中updateStk函数的典型用法代码示例。如果您正苦于以下问题:PHP updateStk函数的具体用法?PHP updateStk怎么用?PHP updateStk使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了updateStk函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _create
public function _create($elementType, $element)
{
$createdElement = parent::create($elementType, $element);
$productId = vtws_getIdComponents($element['productid']);
$productId = $productId[1];
$parentTypeHandler = vtws_getModuleHandlerFromId($element['parent_id'], $this->user);
$parentTypeMeta = $parentTypeHandler->getMeta();
$parentType = $parentTypeMeta->getEntityName();
$parent = $this->getParentById($element['parent_id']);
if ($parentType != 'PurchaseOrder') {
//update the stock with existing details
updateStk($productId, $element['quantity'], '', array(), $parentType);
}
$this->initTax($element, $parent);
$this->updateTaxes($createdElement);
$createdElement['incrementondel'] = '1';
if (strcasecmp($parent['hdnTaxType'], $this->Individual) === 0) {
$createdElement = $this->appendTaxInfo($createdElement);
}
return $createdElement;
}
示例2: createRecurringInvoiceFromSO
function createRecurringInvoiceFromSO()
{
$adb = PearDatabase::getInstance();
$salesorder_id = $this->_salesorderid;
$query1 = "SELECT * FROM vtiger_inventoryproductrel WHERE id=?";
$res = $adb->pquery($query1, array($salesorder_id));
$no_of_products = $adb->num_rows($res);
$fieldsList = $adb->getFieldsArray($res);
$update_stock = array();
for ($j = 0; $j < $no_of_products; $j++) {
$row = $adb->query_result_rowdata($res, $j);
$col_value = array();
for ($k = 0; $k < count($fieldsList); $k++) {
if ($fieldsList[$k] != 'lineitem_id') {
$col_value[$fieldsList[$k]] = $row[$fieldsList[$k]];
}
}
if (count($col_value) > 0) {
$col_value['id'] = $this->id;
$columns = array_keys($col_value);
$values = array_values($col_value);
$query2 = "INSERT INTO vtiger_inventoryproductrel(" . implode(",", $columns) . ") VALUES (" . generateQuestionMarks($values) . ")";
$adb->pquery($query2, array($values));
$prod_id = $col_value['productid'];
$qty = $col_value['quantity'];
$update_stock[$col_value['sequence_no']] = $qty;
updateStk($prod_id, $qty, '', array(), 'Invoice');
}
}
$query1 = "SELECT * FROM vtiger_inventorysubproductrel WHERE id=?";
$res = $adb->pquery($query1, array($salesorder_id));
$no_of_products = $adb->num_rows($res);
$fieldsList = $adb->getFieldsArray($res);
for ($j = 0; $j < $no_of_products; $j++) {
$row = $adb->query_result_rowdata($res, $j);
$col_value = array();
for ($k = 0; $k < count($fieldsList); $k++) {
$col_value[$fieldsList[$k]] = $row[$fieldsList[$k]];
}
if (count($col_value) > 0) {
$col_value['id'] = $this->id;
$columns = array_keys($col_value);
$values = array_values($col_value);
$query2 = "INSERT INTO vtiger_inventorysubproductrel(" . implode(",", $columns) . ") VALUES (" . generateQuestionMarks($values) . ")";
$adb->pquery($query2, array($values));
$prod_id = $col_value['productid'];
$qty = $update_stock[$col_value['sequence_no']];
updateStk($prod_id, $qty, '', array(), 'Invoice');
}
}
//Update the netprice (subtotal), taxtype, discount, S&H charge and total for the Invoice
$updatequery = " UPDATE vtiger_invoice SET ";
$updateparams = array();
// Remaining column values to be updated -> column name to field name mapping
$invoice_column_field = array('subtotal' => 'hdnSubTotal', 'total' => 'hdnGrandTotal', 'taxtype' => 'hdnTaxType', 'discount_percent' => 'hdnDiscountPercent', 'discount_amount' => 'hdnDiscountAmount');
$updatecols = array();
foreach ($invoice_column_field as $col => $field) {
$updatecols[] = "{$col}=?";
$updateparams[] = $this->column_fields[$field];
}
if (count($updatecols) > 0) {
$updatequery .= implode(",", $updatecols);
$updatequery .= " WHERE invoiceid=?";
array_push($updateparams, $this->id);
$adb->pquery($updatequery, $updateparams);
}
}
示例3: saveInventoryProductDetails
/** Function used to save the Inventory product details for the passed entity
* @param object reference $focus - object reference to which we want to save the product details from REQUEST values where as the entity will be Purchase Order, Sales Order, Quotes or Invoice
* @param string $module - module name
* @param $update_prod_stock - true or false (default), if true we have to update the stock for PO only
* @return void
*/
function saveInventoryProductDetails(&$focus, $module, $update_prod_stock = 'false', $updateDemand = '')
{
$adb = PearDatabase::getInstance();
$log = vglobal('log');
$id = $focus->id;
$log->debug("Entering into function saveInventoryProductDetails({$module}).");
//Added to get the convertid
if (isset($_REQUEST['convert_from']) && $_REQUEST['convert_from'] != '') {
$id = vtlib_purify($_REQUEST['return_id']);
} else {
if (isset($_REQUEST['duplicate_from']) && $_REQUEST['duplicate_from'] != '') {
$id = vtlib_purify($_REQUEST['duplicate_from']);
}
}
$ext_prod_arr = array();
if ($focus->mode == 'edit') {
if ($_REQUEST['taxtype'] == 'group') {
$all_available_taxes = getAllTaxes('available', '', 'edit', $id);
}
$return_old_values = '';
if ($module != 'PurchaseOrder') {
$return_old_values = 'return_old_values';
}
//we will retrieve the existing product details and store it in a array and then delete all the existing product details and save new values, retrieve the old value and update stock only for SO, Quotes and Invoice not for PO
//$ext_prod_arr = deleteInventoryProductDetails($focus->id,$return_old_values);
deleteInventoryProductDetails($focus);
} else {
if ($_REQUEST['taxtype'] == 'group') {
$all_available_taxes = getAllTaxes('available', '', 'edit', $id);
}
}
$tot_no_prod = $_REQUEST['totalProductCount'];
//If the taxtype is group then retrieve all available taxes, else retrive associated taxes for each product inside loop
$prod_seq = 1;
$total_purchase = 0;
$total_margin = 0;
for ($i = 1; $i <= $tot_no_prod; $i++) {
//if the product is deleted then we should avoid saving the deleted products
if ($_REQUEST["deleted" . $i] == 1) {
continue;
}
$prod_id = vtlib_purify($_REQUEST['hdnProductId' . $i]);
if (isset($_REQUEST['productDescription' . $i])) {
$description = vtlib_purify($_REQUEST['productDescription' . $i]);
}
/* else{
$desc_duery = "select vtiger_crmentity.description AS product_description from vtiger_crmentity where vtiger_crmentity.crmid=?";
$desc_res = $adb->pquery($desc_duery,array($prod_id));
$description = $adb->query_result($desc_res,0,"product_description");
} */
$qty = vtlib_purify($_REQUEST['qty' . $i]);
$listprice = vtlib_purify($_REQUEST['listPrice' . $i]);
$comment = vtlib_purify($_REQUEST['comment' . $i]);
$purchaseCost = vtlib_purify($_REQUEST['purchaseCost' . $i]);
$calculationsid = vtlib_purify($_REQUEST['calculationId' . $i]);
$purchase = vtlib_purify($_REQUEST['purchase' . $i]);
$margin = vtlib_purify($_REQUEST['margin' . $i]);
$marginp = vtlib_purify($_REQUEST['marginp' . $i]);
$total_purchase += $purchase * $qty;
$total_margin += $margin;
//we have to update the Product stock for PurchaseOrder if $update_prod_stock is true
if ($module == 'PurchaseOrder' && $update_prod_stock == 'true') {
addToProductStock($prod_id, $qty);
}
if ($module == 'SalesOrder') {
if ($updateDemand == '-') {
deductFromProductDemand($prod_id, $qty);
} elseif ($updateDemand == '+') {
addToProductDemand($prod_id, $qty);
}
}
$query = "insert into vtiger_inventoryproductrel(id, productid, sequence_no, quantity, listprice, comment, description, calculationsid, purchase, margin, marginp) values(?,?,?,?,?,?,?,?,?,?,?)";
$qparams = array($focus->id, $prod_id, $prod_seq, $qty, $listprice, $comment, $description, $calculationsid, $purchase, $margin, $marginp);
$adb->pquery($query, $qparams);
$lineitem_id = $adb->getLastInsertID();
$sub_prod_str = $_REQUEST['subproduct_ids' . $i];
if (!empty($sub_prod_str)) {
$sub_prod = explode(":", $sub_prod_str);
for ($j = 0; $j < count($sub_prod); $j++) {
$query = "insert into vtiger_inventorysubproductrel(id, sequence_no, productid) values(?,?,?)";
$qparams = array($focus->id, $prod_seq, $sub_prod[$j]);
$adb->pquery($query, $qparams);
}
}
$prod_seq++;
if ($module != 'PurchaseOrder') {
//update the stock with existing details
updateStk($prod_id, $qty, $focus->mode, $ext_prod_arr, $module);
}
//we should update discount and tax details
$updatequery = "update vtiger_inventoryproductrel set ";
$updateparams = array();
//set the discount percentage or discount amount in update query, then set the tax values
if ($_REQUEST['discount_type' . $i] == 'percentage') {
//.........这里部分代码省略.........
示例4: saveInventoryProductDetails
/** Function used to save the Inventory product details for the passed entity
* @param object reference $focus - object reference to which we want to save the product details from REQUEST values where as the entity will be Purchase Order, Sales Order, Quotes or Invoice
* @param string $module - module name
* @param $update_prod_stock - true or false (default), if true we have to update the stock for PO only
* @return void
*/
function saveInventoryProductDetails(&$focus, $module, $update_prod_stock = 'false', $updateDemand = '')
{
global $log, $adb;
$id = $focus->id;
$log->debug("Entering into function saveInventoryProductDetails({$module}).");
//Added to get the convertid
if (isset($_REQUEST['convert_from']) && $_REQUEST['convert_from'] != '') {
$id = vtlib_purify($_REQUEST['return_id']);
} else {
if (isset($_REQUEST['duplicate_from']) && $_REQUEST['duplicate_from'] != '') {
$id = vtlib_purify($_REQUEST['duplicate_from']);
}
}
$ipr_cols = $adb->getColumnNames('vtiger_inventoryproductrel');
$ext_prod_arr = array();
if ($focus->mode == 'edit') {
if ($_REQUEST['taxtype'] == 'group') {
$all_available_taxes = getAllTaxes('available', '', 'edit', $id);
}
$return_old_values = '';
if ($module != 'PurchaseOrder') {
$return_old_values = 'return_old_values';
}
//we will retrieve the existing product details and store it in a array and then delete all the existing product details and save new values, retrieve the old value and update stock only for SO, Quotes and Invoice not for PO
//$ext_prod_arr = deleteInventoryProductDetails($focus->id,$return_old_values);
deleteInventoryProductDetails($focus);
} else {
if ($_REQUEST['taxtype'] == 'group') {
$all_available_taxes = getAllTaxes('available', '', 'edit', $id);
}
}
$tot_no_prod = $_REQUEST['totalProductCount'];
if ($module != 'PurchaseOrder') {
if (GlobalVariable::getVariable('B2B', '1') == '1') {
$acvid = $focus->column_fields['account_id'];
} else {
$acvid = $focus->column_fields['contact_id'];
}
} else {
$acvid = $focus->column_fields['vendor_id'];
}
//If the taxtype is group then retrieve all available taxes, else retrive associated taxes for each product inside loop
$prod_seq = 1;
for ($i = 1; $i <= $tot_no_prod; $i++) {
//if the product is deleted then we should avoid saving the deleted products
if ($_REQUEST["deleted" . $i] == 1) {
continue;
}
$prod_id = vtlib_purify($_REQUEST['hdnProductId' . $i]);
if (isset($_REQUEST['productDescription' . $i])) {
$description = vtlib_purify($_REQUEST['productDescription' . $i]);
}
/*else{
$desc_duery = "select vtiger_crmentity.description AS product_description from vtiger_crmentity where vtiger_crmentity.crmid=?";
$desc_res = $adb->pquery($desc_duery,array($prod_id));
$description = $adb->query_result($desc_res,0,"product_description");
} */
$qty = vtlib_purify($_REQUEST['qty' . $i]);
$listprice = vtlib_purify($_REQUEST['listPrice' . $i]);
$comment = vtlib_purify($_REQUEST['comment' . $i]);
//we have to update the Product stock for PurchaseOrder if $update_prod_stock is true
if ($module == 'PurchaseOrder' && $update_prod_stock == 'true') {
addToProductStock($prod_id, $qty);
}
if ($module == 'SalesOrder') {
if ($updateDemand == '-') {
deductFromProductDemand($prod_id, $qty);
} elseif ($updateDemand == '+') {
addToProductDemand($prod_id, $qty);
}
}
$query = "insert into vtiger_inventoryproductrel(id, productid, sequence_no, quantity, listprice, comment, description) values(?,?,?,?,?,?,?)";
$qparams = array($focus->id, $prod_id, $prod_seq, $qty, $listprice, $comment, $description);
$adb->pquery($query, $qparams);
$lineitem_id = $adb->getLastInsertID();
$sub_prod_str = $_REQUEST['subproduct_ids' . $i];
if (!empty($sub_prod_str)) {
$sub_prod = explode(":", $sub_prod_str);
for ($j = 0; $j < count($sub_prod); $j++) {
$query = "insert into vtiger_inventorysubproductrel(id, sequence_no, productid) values(?,?,?)";
$qparams = array($focus->id, $prod_seq, $sub_prod[$j]);
$adb->pquery($query, $qparams);
}
}
$prod_seq++;
if ($module != 'PurchaseOrder') {
//update the stock with existing details
updateStk($prod_id, $qty, $focus->mode, $ext_prod_arr, $module);
}
//we should update discount and tax details
$updatequery = "update vtiger_inventoryproductrel set ";
$updateparams = array();
//set the discount percentage or discount amount in update query, then set the tax values
if ($_REQUEST['discount_type' . $i] == 'percentage') {
//.........这里部分代码省略.........
示例5: createRecurringInvoiceFromSO
function createRecurringInvoiceFromSO()
{
global $adb;
$salesorder_id = $this->_salesorderid;
$query1 = "SELECT * FROM vtiger_inventoryproductrel WHERE id=?";
$res = $adb->pquery($query1, array($salesorder_id));
$no_of_products = $adb->num_rows($res);
$fieldsList = $adb->getFieldsArray($res);
$update_stock = array();
for ($j = 0; $j < $no_of_products; $j++) {
$row = $adb->query_result_rowdata($res, $j);
$col_value = array();
for ($k = 0; $k < count($fieldsList); $k++) {
//Here we check if field is different form lineitem_id (original) and
//field is different from discount_amount or is equal and not empty (null) and
//field is different from discount_percent or is equal and not empty (null)
//to prevent fails when discount percent is null (resulting invoice have discount_percent as 0 and
//don't do any discount)
if ($fieldsList[$k] != 'lineitem_id' && ($fieldsList[$k] != 'discount_amount' || $fieldsList[$k] == 'discount_amount' && !empty($row[$fieldsList[$k]])) && ($fieldsList[$k] != 'discount_percent' || $fieldsList[$k] == 'discount_percent' && !empty($row[$fieldsList[$k]]))) {
$col_value[$fieldsList[$k]] = $row[$fieldsList[$k]];
}
}
if (count($col_value) > 0) {
$col_value['id'] = $this->id;
$col_value['comment'] = decode_html($col_value['comment']);
$columns = array_keys($col_value);
$values = array_values($col_value);
$query2 = "INSERT INTO vtiger_inventoryproductrel(" . implode(",", $columns) . ") VALUES (" . generateQuestionMarks($values) . ")";
$adb->pquery($query2, array($values));
$prod_id = $col_value['productid'];
$qty = $col_value['quantity'];
$update_stock[$col_value['sequence_no']] = $qty;
updateStk($prod_id, $qty, '', array(), 'Invoice');
}
}
$query1 = "SELECT * FROM vtiger_inventorysubproductrel WHERE id=?";
$res = $adb->pquery($query1, array($salesorder_id));
$no_of_products = $adb->num_rows($res);
$fieldsList = $adb->getFieldsArray($res);
for ($j = 0; $j < $no_of_products; $j++) {
$row = $adb->query_result_rowdata($res, $j);
$col_value = array();
for ($k = 0; $k < count($fieldsList); $k++) {
$col_value[$fieldsList[$k]] = $row[$fieldsList[$k]];
}
if (count($col_value) > 0) {
$col_value['id'] = $this->id;
$columns = array_keys($col_value);
$values = array_values($col_value);
$query2 = "INSERT INTO vtiger_inventorysubproductrel(" . implode(",", $columns) . ") VALUES (" . generateQuestionMarks($values) . ")";
$adb->pquery($query2, array($values));
$prod_id = $col_value['productid'];
$qty = $update_stock[$col_value['sequence_no']];
updateStk($prod_id, $qty, '', array(), 'Invoice');
}
}
// Add the Shipping taxes for the Invoice
$query3 = "SELECT * FROM vtiger_inventoryshippingrel WHERE id=?";
$res = $adb->pquery($query3, array($salesorder_id));
$no_of_shippingtax = $adb->num_rows($res);
$fieldsList = $adb->getFieldsArray($res);
for ($j = 0; $j < $no_of_shippingtax; $j++) {
$row = $adb->query_result_rowdata($res, $j);
$col_value = array();
for ($k = 0; $k < count($fieldsList); $k++) {
$col_value[$fieldsList[$k]] = $row[$fieldsList[$k]];
}
if (count($col_value) > 0) {
$col_value['id'] = $this->id;
$columns = array_keys($col_value);
$values = array_values($col_value);
$query4 = "INSERT INTO vtiger_inventoryshippingrel(" . implode(",", $columns) . ") VALUES (" . generateQuestionMarks($values) . ")";
$adb->pquery($query4, array($values));
}
}
//Update the netprice (subtotal), taxtype, discount, S&H charge, adjustment and total for the Invoice
$updatequery = " UPDATE vtiger_invoice SET ";
$updateparams = array();
// Remaining column values to be updated -> column name to field name mapping
$invoice_column_field = array('adjustment' => 'txtAdjustment', 'subtotal' => 'hdnSubTotal', 'total' => 'hdnGrandTotal', 'taxtype' => 'hdnTaxType', 'discount_percent' => 'hdnDiscountPercent', 'discount_amount' => 'hdnDiscountAmount', 's_h_amount' => 'hdnS_H_Amount');
$updatecols = array();
foreach ($invoice_column_field as $col => $field) {
$updatecols[] = "{$col}=?";
$updateparams[] = $this->column_fields[$field];
}
if (count($updatecols) > 0) {
$updatequery .= implode(",", $updatecols);
$updatequery .= " WHERE invoiceid=?";
array_push($updateparams, $this->id);
$adb->pquery($updatequery, $updateparams);
}
}