25if (!defined(
'NOTOKENRENEWAL')) {
 
   26  define(
'NOTOKENRENEWAL', 
'1'); 
 
   28if (!defined(
'NOREQUIREMENU')) {
 
   29  define(
'NOREQUIREMENU', 
'1');
 
   31if (!defined(
'NOREQUIREAJAX')) {
 
   32  define(
'NOREQUIREAJAX', 
'1');
 
   34if (!defined(
'NOREQUIRESOC')) {
 
   35  define(
'NOREQUIRESOC', 
'1');
 
   39require 
'../../main.inc.php';
 
   40require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.product.class.php';
 
   42$idprod = 
GETPOST(
'idprod', 
'int');
 
   47$langs->loadLangs(array(
"stocks", 
"margins", 
"products"));
 
   60  $producttmp->fetch($idprod);
 
   62  $sorttouse = 
's.nom, pfp.quantity, pfp.price';
 
   63  if (
GETPOST(
'bestpricefirst')) {
 
   64    $sorttouse = 
'pfp.unitprice, s.nom, pfp.quantity, pfp.price';
 
   67  $productSupplierArray = $producttmp->list_product_fournisseur_price($idprod, $sorttouse); 
 
   68  if (is_array($productSupplierArray)) {
 
   69    foreach ($productSupplierArray as $productSupplier) {
 
   70      if (
getDolGlobalInt(
"DISABLE_BAD_REPUTATION_PRODUCT_PRICE") && $productSupplier->supplier_reputation == 
"DONOTORDER") {
 
   74      $price = $productSupplier->fourn_price * (1 - $productSupplier->fourn_remise_percent / 100);
 
   75      $unitprice = $productSupplier->fourn_unitprice * (1 - $productSupplier->fourn_remise_percent / 100);
 
   77      $title = $productSupplier->fourn_name.
' - '.$productSupplier->fourn_ref.
' - ';
 
   79      if ($productSupplier->fourn_qty == 1) {
 
   80        $title .= 
price($price, 0, $langs, 0, 0, -1, $conf->currency).
"/";
 
   82      $title .= $productSupplier->fourn_qty.
' '.($productSupplier->fourn_qty == 1 ? $langs->trans(
"Unit") : $langs->trans(
"Units"));
 
   84      if ($productSupplier->fourn_qty > 1) {
 
   86        $title .= 
price($unitprice, 0, $langs, 0, 0, -1, $conf->currency).
"/".$langs->trans(
"Unit");
 
   90      $label = 
price($price, 0, $langs, 0, 0, -1, $conf->currency).
"/".$langs->trans(
"Unit");
 
   91      if ($productSupplier->fourn_ref) {
 
   92        $label .= 
' ('.$productSupplier->fourn_ref.
')';
 
   95      $prices[] = array(
"id" => $productSupplier->product_fourn_price_id, 
"price" => 
price2num($price, 
'', 0), 
"label" => $label, 
"title" => $title); 
 
  100  if (isModEnabled(
'stock')) {
 
  102    $price = $producttmp->pmp;
 
  103    if (empty($price) && 
getDolGlobalString(
'PRODUCT_USE_SUB_COST_PRICES_IF_COST_PRICE_EMPTY')) {
 
  105      $producttmp->get_sousproduits_arbo();
 
  106      $prods_arbo=$producttmp->get_arbo_each_prod();
 
  107      if (!empty($prods_arbo)) {
 
  109        foreach ($prods_arbo as $child) {
 
  111          $sousprod->fetch($child[
'id']);
 
  112          $price += $sousprod->pmp;
 
  117    $prices[] = array(
"id" => 
'pmpprice', 
"price" => 
price2num($price), 
"label" => $langs->trans(
"PMPValueShort").
': '.
price($price, 0, $langs, 0, 0, -1, $conf->currency), 
"title" => $langs->trans(
"PMPValueShort").
': '.
price($price, 0, $langs, 0, 0, -1, $conf->currency));  
 
  121  $price = $producttmp->cost_price;
 
  122  if (empty($price) && 
getDolGlobalString(
'PRODUCT_USE_SUB_COST_PRICES_IF_COST_PRICE_EMPTY')) {
 
  124    $producttmp->get_sousproduits_arbo();
 
  125    $prods_arbo=$producttmp->get_arbo_each_prod();
 
  126    if (!empty($prods_arbo)) {
 
  128      foreach ($prods_arbo as $child) {
 
  130        $sousprod->fetch($child[
'id']);
 
  131        $price += $sousprod->cost_price;
 
  136  $prices[] = array(
"id" => 
'costprice', 
"price" => 
price2num($price), 
"label" => $langs->trans(
"CostPrice").
': '.
price($price, 0, $langs, 0, 0, -1, $conf->currency), 
"title" => $langs->trans(
"PMPValueShort").
': '.
price($price, 0, $langs, 0, 0, -1, $conf->currency)); 
 
  139echo json_encode($prices);
 
Class to manage predefined suppliers products.
Class to manage products or services.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
if(!defined( 'NOREQUIREMENU')) if(!empty(GETPOST('seteventmessages', 'alpha'))) if(!function_exists("llxHeader")) top_httphead($contenttype='text/html', $forcenocache=0)
Show HTTP header.