25 if (!defined(
'NOTOKENRENEWAL')) define(
'NOTOKENRENEWAL',
'1');
26 if (!defined(
'NOREQUIREMENU')) define(
'NOREQUIREMENU',
'1');
27 if (!defined(
'NOREQUIREAJAX')) define(
'NOREQUIREAJAX',
'1');
28 if (!defined(
'NOREQUIRESOC')) define(
'NOREQUIRESOC',
'1');
30 require
'../../main.inc.php';
31 require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.product.class.php';
33 $idprod =
GETPOST(
'idprod',
'int');
38 $langs->loadLangs(array(
"stocks",
"margins"));
52 $producttmp->fetch($idprod);
54 $sorttouse =
's.nom, pfp.quantity, pfp.price';
55 if (
GETPOST(
'bestpricefirst')) $sorttouse =
'pfp.unitprice, s.nom, pfp.quantity, pfp.price';
57 $productSupplierArray = $producttmp->list_product_fournisseur_price($idprod, $sorttouse);
58 if (is_array($productSupplierArray))
60 foreach ($productSupplierArray as $productSupplier)
62 $price = $productSupplier->fourn_price * (1 - $productSupplier->fourn_remise_percent / 100);
63 $unitprice = $productSupplier->fourn_unitprice * (1 - $productSupplier->fourn_remise_percent / 100);
65 $title = $productSupplier->fourn_name.
' - '.$productSupplier->fourn_ref.
' - ';
67 if ($productSupplier->fourn_qty == 1)
69 $title .=
price($price, 0, $langs, 0, 0, -1, $conf->currency).
"/";
71 $title .= $productSupplier->fourn_qty.
' '.($productSupplier->fourn_qty == 1 ? $langs->trans(
"Unit") : $langs->trans(
"Units"));
73 if ($productSupplier->fourn_qty > 1)
76 $title .=
price($unitprice, 0, $langs, 0, 0, -1, $conf->currency).
"/".$langs->trans(
"Unit");
80 $label =
price($price, 0, $langs, 0, 0, -1, $conf->currency).
"/".$langs->trans(
"Unit");
81 if ($productSupplier->fourn_ref) $label .=
' ('.$productSupplier->fourn_ref.
')';
83 $prices[] = array(
"id" => $productSupplier->product_fourn_price_id,
"price" =>
price2num($price, 0,
'', 0),
"label" => $label,
"title" => $title);
88 if (!empty($conf->stock->enabled))
91 $price = $producttmp->pmp;
92 $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));
96 $price = $producttmp->cost_price;
97 $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));
100 echo json_encode($prices);
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
if(!defined('NOREQUIREMENU')) if(!function_exists("llxHeader")) top_httphead($contenttype= 'text/html', $forcenocache=0)
Show HTTP header.
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...
price2num($amount, $rounding= '', $option=0)
Function that return a number with universal decimal format (decimal separator is '...
Class to manage predefined suppliers products.