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


PHP addToProductStock函数代码示例

本文整理汇总了PHP中addToProductStock函数的典型用法代码示例。如果您正苦于以下问题:PHP addToProductStock函数的具体用法?PHP addToProductStock怎么用?PHP addToProductStock使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: 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

示例2: 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

示例3: save_module

 function save_module($module)
 {
     global $adb;
     //in ajax save we should not call this function, because this will delete all the existing product values
     if ($_REQUEST['action'] != 'PurchaseOrderAjax' && $_REQUEST['ajxaction'] != 'DETAILVIEW' && $_REQUEST['action'] != 'MassEditSave' && $_REQUEST['action'] != 'ProcessDuplicates') {
         //Based on the total Number of rows we will save the product relationship with this entity
         saveInventoryProductDetails($this, 'PurchaseOrder', $this->update_prod_stock);
     }
     //In Ajax edit, if the status changed to Received Shipment then we have to update the product stock
     if ($_REQUEST['action'] == 'PurchaseOrderAjax' && $this->update_prod_stock == 'true') {
         $inventory_res = $this->db->pquery("select productid, quantity from vtiger_inventoryproductrel where id=?", array($this->id));
         $noofproducts = $this->db->num_rows($inventory_res);
         //We have to update the stock for all the products in this PO
         for ($prod_count = 0; $prod_count < $noofproducts; $prod_count++) {
             $productid = $this->db->query_result($inventory_res, $prod_count, 'productid');
             $quantity = $this->db->query_result($inventory_res, $prod_count, 'quantity');
             $this->db->println("Stock is going to be updated for the productid - {$productid} with quantity - {$quantity}");
             addToProductStock($productid, $quantity);
         }
     }
     // Update the currency id and the conversion rate for the purchase order
     $update_query = "update vtiger_purchaseorder set currency_id=?, conversion_rate=? where purchaseorderid=?";
     $update_params = array($this->column_fields['currency_id'], $this->column_fields['conversion_rate'], $this->id);
     $adb->pquery($update_query, $update_params);
 }
开发者ID:sacredwebsite,项目名称:vtigercrm,代码行数:25,代码来源:PurchaseOrder.php

示例4: save_module

 function save_module($module)
 {
     global $adb, $updateInventoryProductRel_deduct_stock;
     $updateInventoryProductRel_deduct_stock = false;
     //in ajax save we should not call this function, because this will delete all the existing product values
     if ($_REQUEST['action'] != 'PurchaseOrderAjax' && $_REQUEST['ajxaction'] != 'DETAILVIEW' && $_REQUEST['action'] != 'MassEditSave' && $_REQUEST['action'] != 'ProcessDuplicates' && $_REQUEST['action'] != 'SaveAjax' && $this->isLineItemUpdate != false && $_REQUEST['action'] != 'FROM_WS') {
         $requestProductIdsList = $requestQuantitiesList = array();
         $totalNoOfProducts = $_REQUEST['totalProductCount'];
         for ($i = 1; $i <= $totalNoOfProducts; $i++) {
             $productId = $_REQUEST['hdnProductId' . $i];
             $requestProductIdsList[$productId] = $productId;
             if (array_key_exists($productId, $requestQuantitiesList)) {
                 $requestQuantitiesList[$productId] = $requestQuantitiesList[$productId] + $_REQUEST['qty' . $i];
                 continue;
             }
             $requestQuantitiesList[$productId] = $_REQUEST['qty' . $i];
         }
         if ($this->mode == '' && $this->column_fields['postatus'] === 'Received Shipment') {
             //Updating Product stock quantity during create mode
             foreach ($requestProductIdsList as $productId) {
                 addToProductStock($productId, $requestQuantitiesList[$productId]);
             }
         } else {
             if ($this->column_fields['postatus'] === 'Received Shipment' && $this->mode != '') {
                 //Updating Product stock quantity during edit mode
                 $recordId = $this->id;
                 $result = $adb->pquery("SELECT productid, quantity FROM vtiger_inventoryproductrel WHERE id = ?", array($recordId));
                 $numOfRows = $adb->num_rows($result);
                 for ($i = 0; $i < $numOfRows; $i++) {
                     $productId = $adb->query_result($result, $i, 'productid');
                     $productIdsList[$productId] = $productId;
                     $quantitiesList[$productId] = $adb->query_result($result, $i, 'quantity');
                 }
                 $newProductIds = array_diff($requestProductIdsList, $productIdsList);
                 if ($newProductIds) {
                     foreach ($newProductIds as $productId) {
                         addToProductStock($productId, $requestQuantitiesList[$productId]);
                     }
                 }
                 $deletedProductIds = array_diff($productIdsList, $requestProductIdsList);
                 if ($deletedProductIds) {
                     foreach ($deletedProductIds as $productId) {
                         $productStock = getPrdQtyInStck($productId);
                         $quantity = $productStock - $quantitiesList[$productId];
                         updateProductQty($productId, $quantity);
                     }
                 }
                 $updatedProductIds = array_intersect($productIdsList, $requestProductIdsList);
                 if ($updatedProductIds) {
                     foreach ($updatedProductIds as $productId) {
                         $quantityDiff = $quantitiesList[$productId] - $requestQuantitiesList[$productId];
                         if ($quantityDiff < 0) {
                             $quantityDiff = -$quantityDiff;
                             addToProductStock($productId, $quantityDiff);
                         } elseif ($quantityDiff > 0) {
                             $productStock = getPrdQtyInStck($productId);
                             $quantity = $productStock - $quantityDiff;
                             updateProductQty($productId, $quantity);
                         }
                     }
                 }
             }
         }
         //Based on the total Number of rows we will save the product relationship with this entity
         saveInventoryProductDetails($this, 'PurchaseOrder', $this->update_prod_stock);
         if ($this->mode != '') {
             $updateInventoryProductRel_deduct_stock = true;
         }
     }
     // Update the currency id and the conversion rate for the purchase order
     $update_query = "update vtiger_purchaseorder set currency_id=?, conversion_rate=? where purchaseorderid=?";
     $update_params = array($this->column_fields['currency_id'], $this->column_fields['conversion_rate'], $this->id);
     $adb->pquery($update_query, $update_params);
 }
开发者ID:krzychab,项目名称:YetiForceCRM,代码行数:74,代码来源:PurchaseOrder.php


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