本文整理汇总了PHP中getBaseConversionRateForProduct函数的典型用法代码示例。如果您正苦于以下问题:PHP getBaseConversionRateForProduct函数的具体用法?PHP getBaseConversionRateForProduct怎么用?PHP getBaseConversionRateForProduct使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了getBaseConversionRateForProduct函数的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: getPricesForProducts
/** Function used to get the prices for the given list of products based in the specified currency
* @param int $currencyid - currency id based on which the prices have to be provided
* @param array $product_ids - List of product id's for which we want to get the price based on given currency
* @return array $prices_list - List of prices for the given list of products based on the given currency in the form of 'product id' mapped to 'price value'
*/
function getPricesForProducts($currencyid, $product_ids, $module = 'Products')
{
global $adb, $log, $current_user;
$price_list = array();
if (count($product_ids) > 0) {
if ($module == 'Services') {
$query = "SELECT vtiger_currency_info.id, vtiger_currency_info.conversion_rate, " . "vtiger_service.serviceid AS productid, vtiger_service.unit_price, " . "vtiger_productcurrencyrel.actual_price " . "FROM (vtiger_currency_info, vtiger_service) " . "left join vtiger_productcurrencyrel on vtiger_service.serviceid = vtiger_productcurrencyrel.productid " . "and vtiger_currency_info.id = vtiger_productcurrencyrel.currencyid " . "where vtiger_service.serviceid in (" . generateQuestionMarks($product_ids) . ") and vtiger_currency_info.id = ?";
} else {
$query = "SELECT vtiger_currency_info.id, vtiger_currency_info.conversion_rate, " . "vtiger_products.productid, vtiger_products.unit_price, " . "vtiger_productcurrencyrel.actual_price " . "FROM (vtiger_currency_info, vtiger_products) " . "left join vtiger_productcurrencyrel on vtiger_products.productid = vtiger_productcurrencyrel.productid " . "and vtiger_currency_info.id = vtiger_productcurrencyrel.currencyid " . "where vtiger_products.productid in (" . generateQuestionMarks($product_ids) . ") and vtiger_currency_info.id = ?";
}
$params = array($product_ids, $currencyid);
$result = $adb->pquery($query, $params);
for ($i = 0; $i < $adb->num_rows($result); $i++) {
$product_id = $adb->query_result($result, $i, 'productid');
if (getFieldVisibilityPermission($module, $current_user->id, 'unit_price') == '0') {
$actual_price = (double) $adb->query_result($result, $i, 'actual_price');
if ($actual_price == null || $actual_price == '') {
$unit_price = $adb->query_result($result, $i, 'unit_price');
$product_conv_rate = $adb->query_result($result, $i, 'conversion_rate');
$product_base_conv_rate = getBaseConversionRateForProduct($product_id, 'edit', $module);
$conversion_rate = $product_conv_rate * $product_base_conv_rate;
$actual_price = $unit_price * $conversion_rate;
}
$price_list[$product_id] = $actual_price;
} else {
$price_list[$product_id] = '';
}
}
}
return $price_list;
}
开发者ID:jaimeaga84,项目名称:corebos,代码行数:36,代码来源:InventoryUtils.php
示例2: insertPriceInformation
/** function to save the service price information in vtiger_servicecurrencyrel table
* @param string $tablename - vtiger_tablename to save the service currency relationship (servicecurrencyrel)
* @param string $module - current module name
* $return void
*/
function insertPriceInformation($tablename, $module)
{
global $adb, $log, $current_user;
$log->debug("Entering into insertPriceInformation({$tablename}, {$module}) method ...");
//removed the update of currency_id based on the logged in user's preference : fix 6490
$currency_details = getAllCurrencies('all');
//Delete the existing currency relationship if any
if ($this->mode == 'edit' && $_REQUEST['action'] != 'MassEditSave' && $_REQUEST['action'] != 'ProcessDuplicates') {
for ($i = 0; $i < count($currency_details); $i++) {
$curid = $currency_details[$i]['curid'];
$sql = "delete from vtiger_productcurrencyrel where productid=? and currencyid=?";
$adb->pquery($sql, array($this->id, $curid));
}
}
$service_base_conv_rate = getBaseConversionRateForProduct($this->id, $this->mode, $module);
//Save the Product - Currency relationship if corresponding currency check box is enabled
for ($i = 0; $i < count($currency_details); $i++) {
$curid = $currency_details[$i]['curid'];
$curname = $currency_details[$i]['currencylabel'];
$cur_checkname = 'cur_' . $curid . '_check';
$cur_valuename = 'curname' . $curid;
$base_currency_check = 'base_currency' . $curid;
$requestPrice = CurrencyField::convertToDBFormat($_REQUEST['unit_price'], null, true);
$actualPrice = CurrencyField::convertToDBFormat($_REQUEST[$cur_valuename], null, true);
if ($_REQUEST[$cur_checkname] == 'on' || $_REQUEST[$cur_checkname] == 1) {
$conversion_rate = $currency_details[$i]['conversionrate'];
$actual_conversion_rate = $service_base_conv_rate * $conversion_rate;
$converted_price = $actual_conversion_rate * $requestPrice;
$log->debug("Going to save the Product - {$curname} currency relationship");
$query = "insert into vtiger_productcurrencyrel values(?,?,?,?)";
$adb->pquery($query, array($this->id, $curid, $converted_price, $actualPrice));
// Update the Product information with Base Currency choosen by the User.
if ($_REQUEST['base_currency'] == $cur_valuename) {
$adb->pquery("update vtiger_service set currency_id=?, unit_price=? where serviceid=?", array($curid, $actualPrice, $this->id));
}
}
}
$log->debug("Exiting from insertPriceInformation({$tablename}, {$module}) method ...");
}
开发者ID:mslokhat,项目名称:corebos,代码行数:44,代码来源:Services.php
注:本文中的getBaseConversionRateForProduct函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论