* SPDX-License-Identifier: AGPL-3.0-only
************************************/
global $app_strings,$mod_strings,$current_language,$theme,$log,$currentModule,$table_prefix;
$current_module_strings = return_module_language($current_language, $currentModule);
$productid = vtlib_purify($_REQUEST['return_id']);
$parenttab = getParentTab();
$theme_path="themes/".$theme."/";
$image_path=$theme_path."images/";
require_once('modules/VteCore/layout_utils.php'); //crmv@30447
$productNameArr = getEntityName($currentModule, array($productid));
$productname = $productNameArr[$productid];
if(getFieldVisibilityPermission($currentModule,$current_user->id,'unit_price') != '0'){
echo "";
echo "
";
exit();
}
$smarty=new VteSmarty();
$smarty->assign("MOD", $mod_strings);
$smarty->assign("APP", $app_strings);
$smarty->assign("IMAGE_PATH",$image_path);
$InventoryUtils = InventoryUtils::getInstance(); // crmv@42024
$LVU = ListViewUtils::getInstance();
$focus = CRMEntity::getInstance('PriceBooks');
//Retreive the list of PriceBooks
$list_query = $LVU->getListQuery("PriceBooks");
$list_query .= " and {$table_prefix}_pricebook.active<>0 ORDER BY {$table_prefix}_pricebook.pricebookid DESC"; // crmv@115340
$list_result = $adb->query($list_query);
$num_rows = $adb->num_rows($list_result);
$record_string= "Total No of PriceBooks : ".$num_rows;
//Retreiving the array of already releated products
$sql1="select {$table_prefix}_crmentity.crmid, {$table_prefix}_pricebookproductrel.pricebookid,{$table_prefix}_service.unit_price
from {$table_prefix}_pricebookproductrel inner join {$table_prefix}_crmentity on {$table_prefix}_crmentity.crmid={$table_prefix}_pricebookproductrel.productid
inner join {$table_prefix}_service on {$table_prefix}_service.serviceid={$table_prefix}_pricebookproductrel.productid
where {$table_prefix}_crmentity.deleted=0 and {$table_prefix}_pricebookproductrel.productid=?";
$res1 = $adb->pquery($sql1, array($productid));
$num_prod_rows = $adb->num_rows($res1);
$pbk_array = Array();
for($i=0; $i<$num_prod_rows; $i++)
{
$pbkid=$adb->query_result($res1,$i,"pricebookid");
$pbk_array[$pbkid] = $pbkid;
}
$pro_unit_price = getUnitPrice($productid, $currentModule);
$prod_price_details = $InventoryUtils->getPriceDetailsForProduct($productid, $pro_unit_price, 'available', $currentModule);
$prod_cur_price = array();
for($i=0; $i