• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP updateStk函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了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;
 }
开发者ID:cannking,项目名称:vtigercrm-debug,代码行数:21,代码来源:VtigerLineItemOperation.php


示例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);
     }
 }
开发者ID:rcrrich,项目名称:UpdatePackages,代码行数:67,代码来源:Invoice.php


示例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') {
//.........这里部分代码省略.........
开发者ID:rcrrich,项目名称:UpdatePackages,代码行数:101,代码来源:InventoryUtils.php


示例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') {
//.........这里部分代码省略.........
开发者ID:jaimeaga84,项目名称:corebos,代码行数:101,代码来源:InventoryUtils.php


示例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);
     }
 }
开发者ID:casati-dolibarr,项目名称:corebos,代码行数:92,代码来源:Invoice.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP updateTable函数代码示例发布时间:2022-05-23
下一篇:
PHP updateStatus函数代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap