26if (!defined(
'NOTOKENRENEWAL')) {
27 define(
'NOTOKENRENEWAL',
'1');
29if (!defined(
'NOREQUIREMENU')) {
30 define(
'NOREQUIREMENU',
'1');
32if (!defined(
'NOREQUIREAJAX')) {
33 define(
'NOREQUIREAJAX',
'1');
35if (!defined(
'NOREQUIRESOC')) {
36 define(
'NOREQUIRESOC',
'1');
40require
'../../main.inc.php';
41require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.product.class.php';
55$langs->loadLangs(array(
"stocks",
"margins",
"products"));
68 $producttmp->fetch($idprod);
70 $sorttouse =
's.nom, pfp.quantity, pfp.price';
71 if (
GETPOST(
'bestpricefirst')) {
72 $sorttouse =
'pfp.unitprice, s.nom, pfp.quantity, pfp.price';
75 $productSupplierArray = $producttmp->list_product_fournisseur_price($idprod, $sorttouse);
76 if (is_array($productSupplierArray)) {
77 foreach ($productSupplierArray as $productSupplier) {
78 if (
getDolGlobalInt(
"DISABLE_BAD_REPUTATION_PRODUCT_PRICE") && $productSupplier->supplier_reputation ==
"DONOTORDER") {
82 $price = $productSupplier->fourn_price * (1 - $productSupplier->fourn_remise_percent / 100);
83 $unitprice = $productSupplier->fourn_unitprice * (1 - $productSupplier->fourn_remise_percent / 100);
85 $title = $productSupplier->fourn_name.
' - '.$productSupplier->fourn_ref.
' - ';
87 if ($productSupplier->fourn_qty == 1) {
88 $title .=
price($price, 0, $langs, 0, 0, -1,
$conf->currency).
"/";
90 $title .= $productSupplier->fourn_qty.
' '.($productSupplier->fourn_qty == 1 ? $langs->trans(
"Unit") : $langs->trans(
"Units"));
92 if ($productSupplier->fourn_qty > 1) {
94 $title .=
price($unitprice, 0, $langs, 0, 0, -1,
$conf->currency).
"/".$langs->trans(
"Unit");
98 $label =
price($price, 0, $langs, 0, 0, -1,
$conf->currency).
"/".$langs->trans(
"Unit");
99 if ($productSupplier->fourn_ref) {
100 $label .=
' ('.$productSupplier->fourn_ref.
')';
103 $prices[] = array(
"id" => $productSupplier->product_fourn_price_id,
"price" =>
price2num($price,
'', 0),
"label" => $label,
"title" => $title);
108 if (isModEnabled(
'stock')) {
110 $price = $producttmp->pmp;
111 if (empty($price) &&
getDolGlobalString(
'PRODUCT_USE_SUB_COST_PRICES_IF_COST_PRICE_EMPTY')) {
113 $producttmp->get_sousproduits_arbo();
114 $prods_arbo=$producttmp->get_arbo_each_prod();
115 if (!empty($prods_arbo)) {
117 foreach ($prods_arbo as $child) {
119 $sousprod->fetch($child[
'id']);
120 $price += $sousprod->pmp;
125 $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));
129 $price = $producttmp->cost_price;
130 if (empty($price) &&
getDolGlobalString(
'PRODUCT_USE_SUB_COST_PRICES_IF_COST_PRICE_EMPTY')) {
132 $producttmp->get_sousproduits_arbo();
133 $prods_arbo=$producttmp->get_arbo_each_prod();
134 if (!empty($prods_arbo)) {
136 foreach ($prods_arbo as $child) {
138 $sousprod->fetch($child[
'id']);
139 $price += $sousprod->cost_price;
144 $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));
147echo json_encode($prices);
Class to manage predefined suppliers products.
Class to manage products or services.
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
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 a 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.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...