40require
'../main.inc.php';
41require_once DOL_DOCUMENT_ROOT.
'/core/lib/product.lib.php';
42require_once DOL_DOCUMENT_ROOT.
'/core/lib/price.lib.php';
43require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
44require_once DOL_DOCUMENT_ROOT.
'/product/dynamic_price/class/price_expression.class.php';
45require_once DOL_DOCUMENT_ROOT.
'/product/dynamic_price/class/price_parser.class.php';
46require_once DOL_DOCUMENT_ROOT.
'/core/class/extrafields.class.php';
59 require_once DOL_DOCUMENT_ROOT.
'/product/class/productcustomerprice.class.php';
65$langs->loadLangs(array(
'products',
'bills',
'companies',
'other'));
73$action =
GETPOST(
'action',
'aZ09');
74$cancel =
GETPOST(
'cancel',
'alpha');
77$search_soc =
GETPOST(
'search_soc');
80$fieldvalue = (!empty($id) ?
$id : (!empty($ref) ? $ref :
''));
81$fieldtype = (!empty($ref) ?
'ref' :
'rowid');
83 $socid = $user->socid;
87if ($id > 0 || !empty($ref)) {
95 $conf->global->PRODUIT_MULTIPRICES_LIMIT = 5;
99$hookmanager->initHooks(array(
'productpricecard',
'globalcard'));
102 if (
$object->type == $object::TYPE_PRODUCT) {
105 if (
$object->type == $object::TYPE_SERVICE) {
109 restrictedArea($user,
'produit|service', $fieldvalue,
'product&product',
'',
'', $fieldtype);
112$maxpricesupplier = 0;
116 if (
$object->type == $object::TYPE_PRODUCT) {
117 $permissiontoadd = $user->hasRight(
'produit',
'creer');
119 if (
$object->type == $object::TYPE_SERVICE) {
120 $permissiontoadd = $user->hasRight(
'service',
'creer');
123 $permissiontoadd = ($user->hasRight(
'produit',
'creer') || $user->hasRight(
'service',
'creer'));
135$parameters = array(
'id' => $id,
'ref' => $ref);
136$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
138 setEventMessages($hookmanager->error, $hookmanager->errors,
'errors');
141if (empty($reshook)) {
142 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
146 if ($action ==
'setlabelsellingprice' && $user->admin) {
147 require_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
148 $keyforlabel =
'PRODUIT_MULTIPRICES_LABEL'.GETPOST(
'pricelevel');
153 if (($action ==
'update_vat') && !$cancel && $permissiontoadd) {
154 $tva_tx_txt =
GETPOST(
'tva_tx',
'alpha');
156 $price_label =
GETPOST(
'price_label',
'alpha');
159 $tva_tx = $tva_tx_txt;
162 if (preg_match(
'/\((.*)\)/', $tva_tx_txt, $reg)) {
163 $vatratecode = $reg[1];
164 $tva_tx = preg_replace(
'/\s*\(.*\)/',
'', $tva_tx_txt);
167 $tva_tx =
price2num(preg_replace(
'/\*/',
'', $tva_tx));
168 $npr = preg_match(
'/\*/', $tva_tx_txt) ? 1 : 0;
171 $localtax1_type =
'0';
172 $localtax2_type =
'0';
175 if (preg_match(
'/\((.*)\)/', $tva_tx_txt, $reg)) {
177 $vatratecode = $reg[1];
179 $sql =
"SELECT t.rowid, t.type_vat, t.code, t.recuperableonly, t.localtax1, t.localtax2, t.localtax1_type, t.localtax2_type";
180 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_tva as t, ".MAIN_DB_PREFIX.
"c_country as c";
181 $sql .=
" WHERE t.fk_pays = c.rowid AND c.code = '".$db->escape(
$mysoc->country_code).
"'";
182 $sql .=
" AND t.taux = ".((float) $tva_tx).
" AND t.active = 1";
183 $sql .=
" AND t.code = '".$db->escape($vatratecode).
"'";
184 $sql .=
" AND t.type_vat IN (0, 1)";
185 $sql .=
" AND t.entity IN (".getEntity(
'c_tva').
")";
186 $resql = $db->query($sql);
188 $obj = $db->fetch_object($resql);
190 $npr = $obj->recuperableonly;
191 $localtax1 = $obj->localtax1;
192 $localtax2 = $obj->localtax2;
193 $localtax1_type = $obj->localtax1_type;
194 $localtax2_type = $obj->localtax2_type;
199 $sql =
"SELECT t.rowid, t.code, t.recuperableonly, t.localtax1, t.localtax2, t.localtax1_type, t.localtax2_type";
200 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_tva as t, ".MAIN_DB_PREFIX.
"c_country as c";
201 $sql .=
" WHERE t.fk_pays = c.rowid AND c.code = '".$db->escape(
$mysoc->country_code).
"'";
202 $sql .=
" AND t.taux = ".((float) $tva_tx).
" AND t.active = 1";
203 $sql .=
" AND t.code = ''";
204 $sql .=
" AND t.entity IN (".getEntity(
'c_tva').
")";
205 $resql = $db->query($sql);
207 $obj = $db->fetch_object($resql);
209 $npr = $obj->recuperableonly;
210 $localtax1 = $obj->localtax1;
211 $localtax2 = $obj->localtax2;
212 $localtax1_type = $obj->localtax1_type;
213 $localtax2_type = $obj->localtax2_type;
218 $object->default_vat_code = $vatratecode;
221 $object->localtax1_tx = $localtax1;
222 $object->localtax2_tx = $localtax2;
223 $object->localtax1_type = $localtax1_type;
224 $object->localtax2_type = $localtax2_type;
225 $object->price_label = $price_label;
237 $produit_multiprices_limit =
getDolGlobalInt(
'PRODUIT_MULTIPRICES_LIMIT');
238 for ($i = 1; $i <= $produit_multiprices_limit; $i++) {
240 if (
$object->multiprices_base_type[$i] ==
'HT') {
241 $oldprice =
$object->multiprices[$i];
242 $oldminprice =
$object->multiprices_min[$i];
244 $oldprice =
$object->multiprices_ttc[$i];
245 $oldminprice =
$object->multiprices_min_ttc[$i];
247 $oldpricebasetype =
$object->multiprices_base_type[$i];
248 $oldnpr =
$object->multiprices_recuperableonly[$i];
251 $localtaxarray = array();
253 $ret =
$object->updatePrice($oldprice, $oldpricebasetype, $user, (
float) $tva_tx, $oldminprice, $level, $oldnpr, 0, 0, $localtaxarray, $vatratecode, $price_label);
262 if (
$object->price_base_type ==
'HT') {
264 $oldminprice =
$object->price_min;
266 $oldprice =
$object->price_ttc;
267 $oldminprice =
$object->price_min_ttc;
269 $oldpricebasetype =
$object->price_base_type;
273 $localtaxarray = array();
275 $ret =
$object->updatePrice($oldprice, $oldpricebasetype, $user, (
float) $tva_tx, $oldminprice, $level, $oldnpr, 0, 0, $localtaxarray, $vatratecode, $price_label);
293 $maxpricesupplier = 0;
295 if (($action ==
'update_price' || $action ==
'update_level_price') && !$cancel && $permissiontoadd) {
297 $pricestoupdate = array();
302 $maxpricesupplier =
$object->min_recommended_price();
308 $object->fk_price_expression = empty($eid) ? 0 : $eid;
310 if (
$object->fk_price_expression != 0) {
312 require_once DOL_DOCUMENT_ROOT.
'/product/dynamic_price/class/price_parser.class.php';
315 if ($priceparser->parseProduct($object) < 0) {
317 setEventMessages($priceparser->translatedError(),
null,
'errors');
324 || ($action ==
'update_level_price' &&
getDolGlobalString(
'PRODUIT_CUSTOMER_PRICES_AND_MULTIPRICES')))) {
325 $newprice =
GETPOST(
'price',
'array');
326 $newprice_min =
GETPOST(
'price_min',
'array');
327 $newpricebase =
GETPOST(
'multiprices_base_type',
'array');
328 $newvattx =
GETPOST(
'tva_tx',
'array');
329 $newvatnpr =
GETPOST(
'tva_npr',
'array');
330 $newlocaltax1_tx =
GETPOST(
'localtax1_tx',
'array');
331 $newlocaltax1_type =
GETPOST(
'localtax1_type',
'array');
332 $newlocaltax2_tx =
GETPOST(
'localtax2_tx',
'array');
333 $newlocaltax2_type =
GETPOST(
'localtax2_type',
'array');
336 $object->price_autogen = (int) (
GETPOST(
'usePriceRules') ==
'on');
338 $produit_multiprices_limit =
getDolGlobalInt(
'PRODUIT_MULTIPRICES_LIMIT');
339 for ($i = 1; $i <= $produit_multiprices_limit; $i++) {
340 if (!isset($newprice[$i])) {
344 $tva_tx_txt = $newvattx[$i];
346 $tva_tx = $tva_tx_txt;
349 if (preg_match(
'/\((.*)\)/', $tva_tx_txt, $reg)) {
350 $vat_src_code = $reg[1];
351 $tva_tx = preg_replace(
'/\s*\(.*\)/',
'', $tva_tx_txt);
353 $tva_tx =
price2num(preg_replace(
'/\*/',
'', $tva_tx));
355 $npr = preg_match(
'/\*/', $tva_tx_txt) ? 1 : 0;
356 $localtax1 = $newlocaltax1_tx[$i];
357 $localtax1_type = $newlocaltax1_type[$i];
358 $localtax2 = $newlocaltax2_tx[$i];
359 $localtax2_type = $newlocaltax2_type[$i];
360 if (preg_match(
'/\((.*)\)/', $tva_tx_txt, $reg)) {
362 $vatratecode = $reg[1];
364 $sql =
"SELECT t.rowid, t.code, t.recuperableonly, t.localtax1, t.localtax2, t.localtax1_type, t.localtax2_type";
365 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_tva as t, ".MAIN_DB_PREFIX.
"c_country as c";
366 $sql .=
" WHERE t.fk_pays = c.rowid AND c.code = '".$db->escape(
$mysoc->country_code).
"'";
367 $sql .=
" AND t.taux = ".((float) $tva_tx).
" AND t.active = 1";
368 $sql .=
" AND t.code ='".$db->escape($vatratecode).
"'";
369 $sql .=
" AND t.entity IN (".getEntity(
'c_tva').
")";
370 $resql = $db->query($sql);
372 $obj = $db->fetch_object($resql);
374 $npr = $obj->recuperableonly;
375 $localtax1 = $obj->localtax1;
376 $localtax2 = $obj->localtax2;
377 $localtax1_type = $obj->localtax1_type;
378 $localtax2_type = $obj->localtax2_type;
382 if (in_array(
$mysoc->country_code, array(
'ES'))) {
389 $sql =
"SELECT t.rowid, t.code, t.recuperableonly, t.localtax1, t.localtax2, t.localtax1_type, t.localtax2_type";
390 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_tva as t, ".MAIN_DB_PREFIX.
"c_country as c";
391 $sql .=
" WHERE t.fk_pays = c.rowid AND c.code = '".$db->escape(
$mysoc->country_code).
"'";
392 $sql .=
" AND t.taux = ".((float) $tva_tx).
" AND t.active = 1";
393 $sql .=
" AND t.code = ''";
394 $resql = $db->query($sql);
396 $obj = $db->fetch_object($resql);
398 $npr = $obj->recuperableonly;
399 $localtax1 = $obj->localtax1;
400 $localtax2 = $obj->localtax2;
401 $localtax1_type = $obj->localtax1_type;
402 $localtax2_type = $obj->localtax2_type;
407 $pricestoupdate[$i] = array(
409 'price' =>
price2num($newprice[$i],
'', 2),
410 'price_min' =>
price2num($newprice_min[$i],
'', 2),
411 'price_base_type' => $newpricebase[$i],
412 'default_vat_code' => $vatratecode,
415 'localtaxes_array' => array(
'0' => $localtax1_type,
'1' => $localtax1,
'2' => $localtax2_type,
'3' => $localtax2)
426 $newpricebase =
GETPOST(
'price_base_type',
'alpha');
427 $tva_tx_txt =
GETPOST(
'tva_tx',
'alpha');
428 $price_label =
GETPOST(
'price_label',
'alpha');
430 $tva_tx = $tva_tx_txt;
433 if (preg_match(
'/\((.*)\)/', $tva_tx_txt, $reg)) {
434 $vat_src_code = $reg[1];
435 $tva_tx = preg_replace(
'/\s*\(.*\)/',
'', $tva_tx_txt);
437 $tva_tx =
price2num(preg_replace(
'/\*/',
'', $tva_tx));
439 $npr = preg_match(
'/\*/', $tva_tx_txt) ? 1 : 0;
442 $localtax1_type =
'0';
443 $localtax2_type =
'0';
445 if (preg_match(
'/\((.*)\)/', $tva_tx_txt, $reg)) {
447 $vatratecode = $reg[1];
449 $sql =
"SELECT t.rowid, t.code, t.recuperableonly, t.localtax1, t.localtax2, t.localtax1_type, t.localtax2_type";
450 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_tva as t, ".MAIN_DB_PREFIX.
"c_country as c";
451 $sql .=
" WHERE t.fk_pays = c.rowid AND c.code = '".$db->escape(
$mysoc->country_code).
"'";
452 $sql .=
" AND t.taux = ".((float) $tva_tx).
" AND t.active = 1";
453 $sql .=
" AND t.code ='".$db->escape($vatratecode).
"'";
454 $sql .=
" AND t.entity IN (".getEntity(
'c_tva').
")";
455 $resql = $db->query($sql);
457 $obj = $db->fetch_object($resql);
459 $npr = $obj->recuperableonly;
460 $localtax1 = $obj->localtax1;
461 $localtax2 = $obj->localtax2;
462 $localtax1_type = $obj->localtax1_type;
463 $localtax2_type = $obj->localtax2_type;
467 if (in_array(
$mysoc->country_code, array(
'ES'))) {
474 $sql =
"SELECT t.rowid, t.code, t.recuperableonly, t.localtax1, t.localtax2, t.localtax1_type, t.localtax2_type";
475 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_tva as t, ".MAIN_DB_PREFIX.
"c_country as c";
476 $sql .=
" WHERE t.fk_pays = c.rowid AND c.code = '".$db->escape(
$mysoc->country_code).
"'";
477 $sql .=
" AND t.taux = ".((float) $tva_tx).
" AND t.active = 1";
478 $sql .=
" AND t.code = ''";
479 $resql = $db->query($sql);
481 $obj = $db->fetch_object($resql);
483 $npr = $obj->recuperableonly;
484 $localtax1 = $obj->localtax1;
485 $localtax2 = $obj->localtax2;
486 $localtax1_type = $obj->localtax1_type;
487 $localtax2_type = $obj->localtax2_type;
492 $pricestoupdate[0] = array(
493 'price' => $newprice,
494 'price_label' => $price_label,
495 'price_min' => $newprice_min,
496 'price_base_type' => $newpricebase,
497 'default_vat_code' => $vatratecode,
500 'localtaxes_array' => array(
'0' => $localtax1_type,
'1' => $localtax1,
'2' => $localtax2_type,
'3' => $localtax2)
509 $object->packaging = (float) $packaging;
512 foreach ($pricestoupdate as $key => $val) {
513 $newprice = $val[
'price'];
515 if ($val[
'price'] < $val[
'price_min'] && !empty(
$object->fk_price_expression)) {
516 $newprice = $val[
'price_min'];
520 $newprice_min =
price2num($val[
'price_min'],
'MU');
523 if (
getDolGlobalString(
'PRODUCT_MINIMUM_RECOMMENDED_PRICE') && $newprice_min < $maxpricesupplier) {
524 setEventMessages($langs->trans(
"MinimumPriceLimit",
price($maxpricesupplier, 0,
'', 1, - 1, - 1,
'auto')),
null,
'errors');
529 if (!array_key_exists($key,
$object->multiprices) ||
$object->multiprices[$key] != $newprice ||
$object->multiprices_min[$key] != $newprice_min ||
$object->multiprices_base_type[$key] != $val[
'price_base_type'] ||
$object->multiprices_tva_tx[$key] != $newvattx) {
530 $res =
$object->updatePrice((
float) $newprice, $val[
'price_base_type'], $user, (
float) $val[
'vat_tx'], (
float) $newprice_min, $key, $val[
'npr'], $psq, 0, $val[
'localtaxes_array'], $val[
'default_vat_code'], $val[
'price_label']);
542 $price_extralabels = $extrafields->fetch_name_optionals_label(
"product_price");
544 $sql =
"SELECT rowid";
545 $sql .=
" FROM ".$object->db->prefix().
"product_price";
546 $sql .=
" WHERE entity IN (".getEntity(
'productprice').
")";
547 $sql .=
" AND price_level=".((int) $key);
548 $sql .=
" AND fk_product = ".((int)
$object->id);
549 $sql .=
" ORDER BY date_price DESC, rowid DESC";
551 $resql =
$object->db->query($sql);
553 $lineid =
$object->db->fetch_object($resql);
556 if (!empty($lineid->rowid)) {
557 require_once DOL_DOCUMENT_ROOT .
'/core/class/genericobject.class.php';
560 $genericObject->id = $lineid->rowid;
561 $genericObject->table_element =
'product_price';
562 foreach ($price_extralabels as $code => $label) {
563 $extrafield_values = $extrafields->getOptionalsFromPost(
'product_price', (
string) $key);
564 $genericObject->array_options[
'options_'.$code] = $extrafield_values[
'options_'.$code];
566 $result = $genericObject->insertExtraFields();
569 setEventMessages($genericObject->error, $genericObject->errors,
'errors');
584 setEventMessages($langs->trans(
"RecordSaved"),
null,
'mesgs');
587 $action =
'edit_price';
593 if ($action ==
'delete' && $user->hasRight(
'produit',
'supprimer')) {
601 if ($action ==
'activate_price_by_qty' && $permissiontoadd) {
604 $basePriceType =
$object->price_base_type;
605 $basePrice = ($basePriceType ==
'HT') ?
$object->price :
$object->price_ttc;
606 $basePriceMin = ($basePriceType ==
'HT') ?
$object->price_min :
$object->price_min_ttc;
607 if (
getDolGlobalString(
'PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES') && $level > 0 && isset(
$object->multiprices[$level])) {
609 $basePriceType = (empty(
$object->multiprices_base_type[$level]) ?
'HT' :
$object->multiprices_base_type[$level]);
610 $basePrice = ($basePriceType ==
'HT') ?
$object->multiprices[$level] :
$object->multiprices_ttc[$level];
611 $basePriceMin = ($basePriceType ==
'HT') ?
$object->multiprices_min[$level] :
$object->multiprices_min_ttc[$level];
613 $ret =
$object->updatePrice($basePrice, $basePriceType, $user,
$object->tva_tx, $basePriceMin, $level,
$object->tva_npr, 1, 0, array(),
$object->default_vat_code);
620 if ($action ==
'disable_price_by_qty' && $permissiontoadd) {
623 $basePriceType =
$object->price_base_type;
624 $basePrice = ($basePriceType ==
'HT') ?
$object->price :
$object->price_ttc;
625 $basePriceMin = ($basePriceType ==
'HT') ?
$object->price_min :
$object->price_min_ttc;
626 if (
getDolGlobalString(
'PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES') && $level > 0 && isset(
$object->multiprices[$level])) {
628 $basePriceType = (empty(
$object->multiprices_base_type[$level]) ?
'HT' :
$object->multiprices_base_type[$level]);
629 $basePrice = ($basePriceType ==
'HT') ?
$object->multiprices[$level] :
$object->multiprices_ttc[$level];
630 $basePriceMin = ($basePriceType ==
'HT') ?
$object->multiprices_min[$level] :
$object->multiprices_min_ttc[$level];
632 $ret =
$object->updatePrice($basePrice, $basePriceType, $user,
$object->tva_tx, $basePriceMin, $level,
$object->tva_npr, -1, 0, array(),
$object->default_vat_code);
639 if ($action ==
'edit_price_by_qty') {
644 if ($action ==
'update_price_by_qty' && $permissiontoadd) {
654 if (empty($quantity)) {
656 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Qty")),
null,
'errors');
658 if (empty($newprice)) {
660 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Price")),
null,
'errors');
662 if (!$error && !($rowid > 0)) {
664 $sql =
"SELECT pp.rowid FROM ".MAIN_DB_PREFIX.
"product_price as pp";
665 $sql .=
" WHERE pp.rowid = ".((int) $priceid).
" AND pp.fk_product = ".((int)
$object->id);
666 $resql = $db->query($sql);
667 if (!$resql || !$db->num_rows($resql)) {
669 setEventMessages($langs->trans(
"ErrorRecordNotFound"),
null,
'errors');
674 if (
$object->price_base_type ==
'TTC') {
679 $unitPrice =
price2num((
float) $price / (
float) $quantity,
'MU');
683 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"product_price_by_qty SET";
684 $sql .=
" price=".((float) $price).
",";
685 $sql .=
" unitprice=".((float) $unitPrice).
",";
686 $sql .=
" quantity=".((float) $quantity).
",";
687 $sql .=
" remise_percent=".((float) $remise_percent).
",";
688 $sql .=
" remise=".((float) $remise);
689 $sql .=
" WHERE rowid = ".((int) $rowid);
690 $sql .=
" AND fk_product_price IN (SELECT pp.rowid FROM ".MAIN_DB_PREFIX.
"product_price as pp WHERE pp.fk_product = ".((int)
$object->id).
")";
692 $result = $db->query($sql);
694 dol_print_error($db);
697 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"product_price_by_qty (fk_product_price,price,unitprice,quantity,remise_percent,remise) values (";
698 $sql .= ((int) $priceid).
','.((float) $price).
','.((float) $unitPrice).
','.((float) $quantity).
','.((float) $remise_percent).
','.((float) $remise).
')';
700 $result = $db->query($sql);
702 if ($db->lasterrno() ==
'DB_ERROR_RECORD_ALREADY_EXISTS') {
703 setEventMessages($langs->trans(
"DuplicateRecord"),
null,
'errors');
705 dol_print_error($db);
712 if ($action ==
'delete_price_by_qty' && $permissiontoadd) {
714 if (!empty($rowid)) {
715 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"product_price_by_qty";
716 $sql .=
" WHERE rowid = ".((int) $rowid);
717 $sql .=
" AND fk_product_price IN (SELECT pp.rowid FROM ".MAIN_DB_PREFIX.
"product_price as pp WHERE pp.fk_product = ".((int)
$object->id).
")";
719 $result = $db->query($sql);
721 setEventMessages((
'delete_price_by_qty'.$langs->transnoentities(
'MissingIds')),
null,
'errors');
725 if ($action ==
'delete_all_price_by_qty' && $permissiontoadd) {
727 if (!empty($priceid)) {
728 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"product_price_by_qty";
729 $sql .=
" WHERE fk_product_price = ".((int) $priceid);
730 $sql .=
" AND fk_product_price IN (SELECT pp.rowid FROM ".MAIN_DB_PREFIX.
"product_price as pp WHERE pp.fk_product = ".((int)
$object->id).
")";
732 $result = $db->query($sql);
734 setEventMessages((
'delete_price_by_qty'.$langs->transnoentities(
'MissingIds')),
null,
'errors');
743 if ($action ==
'add_customer_price_confirm' && !$cancel && $prodcustprice !==
null && ($user->hasRight(
'produit',
'creer') || $user->hasRight(
'service',
'creer'))) {
744 $maxpricesupplier =
$object->min_recommended_price();
746 $update_child_soc =
GETPOSTINT(
'updatechildprice');
750 $prodcustprice->ref_customer =
GETPOST(
'ref_customer',
'alpha');
751 $prodcustprice->fk_product =
$object->id;
754 $prodcustprice->price_base_type =
GETPOST(
"price_base_type",
'alpha');
755 $prodcustprice->price_label =
GETPOST(
"price_label",
'alpha');
760 $extralabels = $extrafields->fetch_name_optionals_label(
"product_customer_price");
761 $extrafield_values = $extrafields->getOptionalsFromPost(
"product_customer_price");
763 $tva_tx_txt =
GETPOST(
"tva_tx",
'alpha');
765 $tva_tx = $tva_tx_txt;
767 if (preg_match(
'/\((.*)\)/', $tva_tx_txt, $reg)) {
768 $vat_src_code = $reg[1];
769 $tva_tx = preg_replace(
'/\s*\(.*\)/',
'', $tva_tx_txt);
771 $tva_tx =
price2num(preg_replace(
'/\*/',
'', $tva_tx));
773 $npr = preg_match(
'/\*/', $tva_tx_txt) ? 1 : 0;
776 $localtax1_type =
'0';
777 $localtax2_type =
'0';
779 if (preg_match(
'/\((.*)\)/', $tva_tx_txt, $reg)) {
781 $vatratecode = $reg[1];
783 $sql =
"SELECT t.rowid, t.code, t.recuperableonly, t.localtax1, t.localtax2, t.localtax1_type, t.localtax2_type";
784 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_tva as t, ".MAIN_DB_PREFIX.
"c_country as c";
785 $sql .=
" WHERE t.fk_pays = c.rowid AND c.code = '".$db->escape(
$mysoc->country_code).
"'";
786 $sql .=
" AND t.taux = ".((float) $tva_tx).
" AND t.active = 1";
787 $sql .=
" AND t.code ='".$db->escape($vatratecode).
"'";
788 $sql .=
" AND t.entity IN (".getEntity(
'c_tva').
")";
789 $resql = $db->query($sql);
791 $obj = $db->fetch_object($resql);
793 $npr = $obj->recuperableonly;
794 $localtax1 = $obj->localtax1;
795 $localtax2 = $obj->localtax2;
796 $localtax1_type = $obj->localtax1_type;
797 $localtax2_type = $obj->localtax2_type;
801 if (in_array(
$mysoc->country_code, array(
'ES'))) {
808 $sql =
"SELECT t.rowid, t.code, t.recuperableonly, t.localtax1, t.localtax2, t.localtax1_type, t.localtax2_type";
809 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_tva as t, ".MAIN_DB_PREFIX.
"c_country as c";
810 $sql .=
" WHERE t.fk_pays = c.rowid AND c.code = '".$db->escape(
$mysoc->country_code).
"'";
811 $sql .=
" AND t.taux = ".((float) $tva_tx).
" AND t.active = 1";
812 $sql .=
" AND t.code = ''";
813 $resql = $db->query($sql);
815 $obj = $db->fetch_object($resql);
817 $npr = $obj->recuperableonly;
818 $localtax1 = $obj->localtax1;
819 $localtax2 = $obj->localtax2;
820 $localtax1_type = $obj->localtax1_type;
821 $localtax2_type = $obj->localtax2_type;
826 $prodcustprice->default_vat_code = $vatratecode;
827 $prodcustprice->tva_tx = $tva_tx;
828 $prodcustprice->recuperableonly = $npr;
829 $prodcustprice->localtax1_tx = $localtax1;
830 $prodcustprice->localtax2_tx = $localtax2;
831 $prodcustprice->localtax1_type = $localtax1_type;
832 $prodcustprice->localtax2_type = $localtax2_type;
834 if (!($prodcustprice->fk_soc > 0)) {
835 $langs->load(
"errors");
836 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"ThirdParty")),
null,
'errors');
838 $action =
'add_customer_price';
840 if (
getDolGlobalString(
'PRODUCT_MINIMUM_RECOMMENDED_PRICE') && $prodcustprice->price_min < (
float) $maxpricesupplier) {
841 $langs->load(
"errors");
842 setEventMessages($langs->trans(
"MinimumPriceLimit",
price((
float) $maxpricesupplier, 0,
'', 1, -1, -1,
'auto')),
null,
'errors');
844 $action =
'add_customer_price';
849 $result = $prodcustprice->create($user, 0, $update_child_soc);
851 if (!empty($extrafield_values) && is_array($extrafield_values)) {
853 $res = $productcustomerprice->fetch($prodcustprice->id);
855 foreach ($extrafield_values as $key => $value) {
856 $productcustomerprice->array_options[$key] = $value;
858 $result2 = $productcustomerprice->insertExtraFields();
860 $prodcustprice->error = $productcustomerprice->error;
861 $prodcustprice->errors = $productcustomerprice->errors;
869 setEventMessages($prodcustprice->error, $prodcustprice->errors,
'errors');
870 $action =
'add_customer_price';
872 setEventMessages($langs->trans(
'RecordSaved'),
null,
'mesgs');
879 if (in_array($action, [
'confirm_remove_customer_price',
'update_customer_price_confirm']) && $prodcustprice !==
null) {
881 if ((
int) $prodcustprice->fk_product !== (
int)
$object->id) {
882 setEventMessages($langs->trans(
"ErrorRecordNotFound"),
null,
'errors');
887 if ($action ==
'confirm_remove_customer_price' && $prodcustprice !==
null && ($user->hasRight(
'produit',
'supprimer') || $user->hasRight(
'service',
'supprimer'))) {
889 $update_child_soc =
GETPOSTINT(
'updatechildprice');
892 $result = $prodcustprice->delete($user, 0, $update_child_soc);
895 $db->query(
"DELETE FROM ".MAIN_DB_PREFIX.
"product_customer_price_extrafields WHERE fk_object = ".((
int) $prodcustprice->id));
896 setEventMessages($langs->trans(
"PriceRemoved"),
null,
'mesgs');
903 setEventMessages($prodcustprice->error, $prodcustprice->errors,
'errors');
905 setEventMessages($langs->trans(
'RecordDeleted'),
null,
'mesgs');
910 if ($action ==
'update_customer_price_confirm' && !$cancel && $prodcustprice !==
null && ($user->hasRight(
'produit',
'creer') || $user->hasRight(
'service',
'creer'))) {
911 $maxpricesupplier =
$object->min_recommended_price();
913 $update_child_soc =
GETPOSTINT(
'updatechildprice');
918 $prodcustprice->ref_customer =
GETPOST(
'ref_customer',
'alpha');
921 $prodcustprice->price_base_type =
GETPOST(
"price_base_type",
'alpha');
922 $prodcustprice->price_label =
GETPOST(
"price_label",
'alpha');
927 $extralabels = $extrafields->fetch_name_optionals_label(
"product_customer_price");
928 $extrafield_values = $extrafields->getOptionalsFromPost(
"product_customer_price");
930 $tva_tx_txt =
GETPOST(
"tva_tx");
932 $tva_tx = $tva_tx_txt;
934 if (preg_match(
'/\((.*)\)/', $tva_tx_txt, $reg)) {
935 $vat_src_code = $reg[1];
936 $tva_tx = preg_replace(
'/\s*\(.*\)/',
'', $tva_tx_txt);
938 $tva_tx =
price2num(preg_replace(
'/\*/',
'', $tva_tx));
940 $npr = preg_match(
'/\*/', $tva_tx_txt) ? 1 : 0;
943 $localtax1_type =
'0';
944 $localtax2_type =
'0';
946 if (preg_match(
'/\((.*)\)/', $tva_tx_txt, $reg)) {
948 $vatratecode = $reg[1];
950 $sql =
"SELECT t.rowid, t.code, t.recuperableonly, t.localtax1, t.localtax2, t.localtax1_type, t.localtax2_type";
951 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_tva as t, ".MAIN_DB_PREFIX.
"c_country as c";
952 $sql .=
" WHERE t.fk_pays = c.rowid AND c.code = '".$db->escape(
$mysoc->country_code).
"'";
953 $sql .=
" AND t.taux = ".((float) $tva_tx).
" AND t.active = 1";
954 $sql .=
" AND t.code ='".$db->escape($vatratecode).
"'";
955 $sql .=
" AND t.entity IN (".getEntity(
'c_tva').
")";
956 $resql = $db->query($sql);
958 $obj = $db->fetch_object($resql);
960 $npr = $obj->recuperableonly;
961 $localtax1 = $obj->localtax1;
962 $localtax2 = $obj->localtax2;
963 $localtax1_type = $obj->localtax1_type;
964 $localtax2_type = $obj->localtax2_type;
968 if (in_array(
$mysoc->country_code, array(
'ES'))) {
975 $sql =
"SELECT t.rowid, t.code, t.recuperableonly, t.localtax1, t.localtax2, t.localtax1_type, t.localtax2_type";
976 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_tva as t, ".MAIN_DB_PREFIX.
"c_country as c";
977 $sql .=
" WHERE t.fk_pays = c.rowid AND c.code = '".$db->escape(
$mysoc->country_code).
"'";
978 $sql .=
" AND t.taux = ".((float) $tva_tx).
" AND t.active = 1";
979 $sql .=
" AND t.code = ''";
980 $resql = $db->query($sql);
982 $obj = $db->fetch_object($resql);
984 $npr = $obj->recuperableonly;
985 $localtax1 = $obj->localtax1;
986 $localtax2 = $obj->localtax2;
987 $localtax1_type = $obj->localtax1_type;
988 $localtax2_type = $obj->localtax2_type;
993 $prodcustprice->default_vat_code = $vatratecode;
994 $prodcustprice->tva_tx = $tva_tx;
995 $prodcustprice->recuperableonly = $npr;
996 $prodcustprice->localtax1_tx = $localtax1;
997 $prodcustprice->localtax2_tx = $localtax2;
998 $prodcustprice->localtax1_type = $localtax1_type;
999 $prodcustprice->localtax2_type = $localtax2_type;
1001 if ($prodcustprice->price_min < $maxpricesupplier &&
getDolGlobalString(
'PRODUCT_MINIMUM_RECOMMENDED_PRICE')) {
1002 setEventMessages($langs->trans(
"MinimumPriceLimit",
price($maxpricesupplier, 0,
'', 1, -1, -1,
'auto')),
null,
'errors');
1004 $action =
'update_customer_price';
1008 $result = $prodcustprice->update($user, 0, $update_child_soc);
1010 if (!empty($extrafield_values) && is_array($extrafield_values)) {
1012 $res = $productcustomerprice->fetch($prodcustprice->id);
1014 foreach ($extrafield_values as $key => $value) {
1015 $productcustomerprice->array_options[$key] = $value;
1017 $result2 = $productcustomerprice->insertExtraFields();
1019 $prodcustprice->error = $productcustomerprice->error;
1020 $prodcustprice->errors = $productcustomerprice->errors;
1028 setEventMessages($prodcustprice->error, $prodcustprice->errors,
'errors');
1029 $action =
'update_customer_price';
1031 setEventMessages($langs->trans(
"Save"),
null,
'mesgs');
1043$form =
new Form($db);
1045if (!empty($id) || !empty($ref)) {
1050$title = $langs->trans(
'ProductServiceCard');
1054 $title = $langs->trans(
'Product').
" ".$shortlabel.
" - ".$langs->trans(
'SellingPrices');
1055 $helpurl =
'EN:Module_Products|FR:Module_Produits|ES:Módulo_Productos';
1058 $title = $langs->trans(
'Service').
" ".$shortlabel.
" - ".$langs->trans(
'SellingPrices');
1059 $helpurl =
'EN:Module_Services_En|FR:Module_Services|ES:Módulo_Servicios';
1062llxHeader(
'', $title, $helpurl,
'', 0, 0,
'',
'',
'',
'classforhorizontalscrolloftabs mod-product page-price');
1064if ($action ==
'ask_remove_customer_price' && ($user->hasRight(
'produit',
'supprimer') || $user->hasRight(
'service',
'supprimer'))) {
1065 $formquestion = array(
1066 array(
'type' =>
'checkbox',
'name' =>
'updatechildprice',
'label' => $langs->trans(
'ForceDeleteChildPriceSoc'),
'value' => 0),
1068 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&lineid='.
GETPOSTINT(
'lineid'), $langs->trans(
'DeleteCustomerPrice'), $langs->trans(
'ConfirmDeleteCustomerPrice'),
'confirm_remove_customer_price', $formquestion, 0, 1);
1073$titre = $langs->trans(
"CardProduct".
$object->type);
1078$linkback =
'<a href="'.DOL_URL_ROOT.
'/product/list.php?restore_lastsearch_values=1&type='.
$object->type.
'">'.$langs->trans(
"BackToList").
'</a>';
1079$object->next_prev_filter =
"(te.fk_product_type:=:".((int)
$object->type).
")";
1082if ($user->socid && !in_array(
'product', explode(
',',
getDolGlobalString(
'MAIN_MODULES_FOR_EXTERNAL')))) {
1086dol_banner_tab($object,
'ref', $linkback, $shownav,
'ref');
1089print
'<div class="fichecenter">';
1091print
'<div class="underbanner clearboth"></div>';
1092print
'<table class="border tableforfield centpercent">';
1099 if (!empty($socid)) {
1102 $soc->fetch($socid);
1106 $typeformat =
'select;0:'.$langs->trans(
"Product").
',1:'.$langs->trans(
"Service");
1107 print
'<tr><td class="">';
1108 print (!
getDolGlobalString(
'PRODUCT_DENY_CHANGE_PRODUCT_TYPE')) ? $form->editfieldkey(
"Type",
'fk_product_type', (
string)
$object->type, $object, 0, $typeformat) : $langs->trans(
'Type');
1110 print $form->editfieldval(
"Type",
'fk_product_type',
$object->type, $object, 0, $typeformat);
1115 print
'<tr><td class="titlefieldcreate">';
1116 print $langs->trans(
"SellingPrice");
1118 print
'<td colspan="2">';
1119 if (
$object->multiprices_base_type[$soc->price_level] ==
'TTC') {
1120 print
'<span class="amount">'.price(
$object->multiprices_ttc[$soc->price_level]).
'</span>';
1122 print
'<span class="amount">'.price(
$object->multiprices[$soc->price_level]).
'</span>';
1124 if (
$object->multiprices_base_type[$soc->price_level]) {
1125 print
' '.$langs->trans(
$object->multiprices_base_type[$soc->price_level]);
1127 print
' '.$langs->trans(
$object->price_base_type);
1132 print
'<tr><td>'.$langs->trans(
"MinPrice").
'</td><td colspan="2">';
1133 if (
$object->multiprices_base_type[$soc->price_level] ==
'TTC') {
1134 print
price(
$object->multiprices_min_ttc[$soc->price_level]).
' '.$langs->trans(
$object->multiprices_base_type[$soc->price_level]);
1136 print
price(
$object->multiprices_min[$soc->price_level]).
' '.$langs->trans(empty(
$object->multiprices_base_type[$soc->price_level]) ?
'HT' :
$object->multiprices_base_type[$soc->price_level]);
1142 print
'<tr><td>'.$langs->trans(
"DefaultTaxRate").
'</td><td colspan="2">';
1144 $positiverates =
'';
1146 $positiverates .= ($positiverates ?
'/' :
'').
price2num(
$object->multiprices_tva_tx[$soc->price_level]);
1148 if (empty($positiverates)) {
1149 $positiverates =
'0';
1151 echo
vatrate($positiverates.($object->default_vat_code ?
' ('.$object->default_vat_code.
')' :
''), true,
$object->tva_npr);
1156 print
'<tr><td>'.$langs->trans(
"DefaultTaxRate").
'</td><td>';
1158 $positiverates =
'';
1163 $positiverates .= ($positiverates ?
'/' :
'').
price2num(
$object->localtax1_tx);
1166 $positiverates .= ($positiverates ?
'/' :
'').
price2num(
$object->localtax2_tx);
1168 if (empty($positiverates)) {
1169 $positiverates =
'0';
1171 echo
vatrate($positiverates.($object->default_vat_code ?
' ('.$object->default_vat_code.
')' :
''), true,
$object->tva_npr);
1179 $typeformat =
'select;0:'.$langs->trans(
"Product").
',1:'.$langs->trans(
"Service");
1180 print
'<tr><td class="">';
1181 print (!
getDolGlobalString(
'PRODUCT_DENY_CHANGE_PRODUCT_TYPE')) ? $form->editfieldkey(
"Type",
'fk_product_type', (
string)
$object->type, $object, 0, $typeformat) : $langs->trans(
'Type');
1183 print $form->editfieldval(
"Type",
'fk_product_type',
$object->type, $object, 0, $typeformat);
1188 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"DefaultTaxRate").
'</td>';
1189 print
'<td colspan="2">'.vatrate(
$object->multiprices_tva_tx[1],
true).
'</td>';
1194 $typeformat =
'select;0:'.$langs->trans(
"Product").
',1:'.$langs->trans(
"Service");
1195 print
'<tr><td class="">';
1196 print (!
getDolGlobalString(
'PRODUCT_DENY_CHANGE_PRODUCT_TYPE')) ? $form->editfieldkey(
"Type",
'fk_product_type', (
string)
$object->type, $object, 0, $typeformat) : $langs->trans(
'Type');
1198 print $form->editfieldval(
"Type",
'fk_product_type',
$object->type, $object, 0, $typeformat);
1203 print
'<!-- Default VAT Rate -->';
1204 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"DefaultTaxRate").
'</td><td>';
1207 $positiverates =
'';
1209 $positiverates .= ($positiverates ?
'<span class="opacitymedium">/</span>' :
'').
price2num(
$object->tva_tx);
1212 $positiverates .= ($positiverates ?
'<span class="opacitymedium">/</span>' :
'').
price2num(
$object->localtax1_tx);
1215 $positiverates .= ($positiverates ?
'<span class="opacitymedium">/</span>' :
'').
price2num(
$object->localtax2_tx);
1217 if (empty($positiverates)) {
1218 $positiverates =
'0';
1221 print
vatrate($positiverates.($object->default_vat_code ?
' ('.$object->default_vat_code.
')' :
''), true,
$object->tva_npr, 1);
1234 print
'<table class="liste centpercent">';
1235 print
'<tr class="liste_titre"><td>';
1236 print $langs->trans(
"PriceLevel");
1238 print
' <a class="editfielda" href="'.dolBuildUrl($_SERVER[
"PHP_SELF"], [
'action' =>
'editlabelsellingprice',
'id' =>
$object->id],
true).
'">'.img_edit($langs->trans(
'EditSellingPriceLabel'), 0).
'</a>';
1241 print
'<td style="text-align: right">'.$langs->trans(
"SellingPrice").
'</td>';
1242 print
'<td style="text-align: right">'.$langs->trans(
"MinPrice").
'</td>';
1244 $extrafields->fetch_name_optionals_label(
"product_price");
1245 if ($extrafields->attributes[
"product_price"] && array_key_exists(
'label', $extrafields->attributes[
"product_price"])) {
1246 $extralabels = $extrafields->attributes[
"product_price"][
'label'];
1247 if (!empty($extralabels)) {
1248 foreach ($extralabels as $key => $value) {
1250 if (!empty($extrafields->attributes[
"product_price"][
'list'][$key]) && $extrafields->attributes[
"product_price"][
'list'][$key] != 3) {
1251 if (!empty($extrafields->attributes[
"product_price"][
'langfile'][$key])) {
1252 $langs->load($extrafields->attributes[
"product_price"][
'langfile'][$key]);
1254 if (!empty($extrafields->attributes[
"product_price"][
'help'][$key])) {
1255 $extratitle = $form->textwithpicto($langs->trans($value), $langs->trans($extrafields->attributes[
"product_price"][
'help'][$key]));
1257 $extratitle = $langs->trans($value);
1259 $field =
'ef.' . $key;
1260 print
'<td style="text-align: right">'.$extratitle.
'</td>';
1267 $produit_multiprices_limit =
getDolGlobalInt(
'PRODUIT_MULTIPRICES_LIMIT');
1268 for ($i = 1; $i <= $produit_multiprices_limit; $i++) {
1269 print
'<tr class="oddeven">';
1273 $keyforlabel =
'PRODUIT_MULTIPRICES_LABEL'.$i;
1274 if (preg_match(
'/editlabelsellingprice/', $action)) {
1275 print
'<form method="post" action="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'">';
1276 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1277 print
'<input type="hidden" name="action" value="setlabelsellingprice">';
1278 print
'<input type="hidden" name="pricelevel" value="'.$i.
'">';
1279 print $langs->trans(
"SellingPrice").
' '.$i.
' - ';
1280 print
'<input class="maxwidthonsmartphone" type="text" name="labelsellingprice" value="' .
getDolGlobalString($keyforlabel).
'">';
1281 print
' <input type="submit" class="button smallpaddingimp" value="'.$langs->trans(
"Modify").
'">';
1284 print $langs->trans(
"SellingPrice").
' '.$i;
1291 if (
$object->multiprices_base_type [$i] ==
'TTC') {
1292 print
'<td class="right"><span class="amount">'.price(
$object->multiprices_ttc[$i]);
1294 print
'<td class="right"><span class="amount">'.price(
$object->multiprices[$i]);
1297 if (
$object->multiprices_base_type[$i]) {
1298 print
' '.$langs->trans(
$object->multiprices_base_type [$i]).
'</span></td>';
1300 print
' '.$langs->trans(
$object->price_base_type).
'</span></td>';
1304 print
'<td style="text-align: right">';
1305 if (empty(
$object->multiprices_base_type[$i])) {
1306 $object->multiprices_base_type[$i] =
"HT";
1308 if (
$object->multiprices_base_type[$i] ==
'TTC') {
1309 print
price(
$object->multiprices_min_ttc[$i]).
' '.$langs->trans(
$object->multiprices_base_type[$i]);
1311 print
price(
$object->multiprices_min[$i]).
' '.$langs->trans(
$object->multiprices_base_type[$i]);
1314 if (!empty($extralabels)) {
1315 require_once DOL_DOCUMENT_ROOT .
'/core/class/genericobject.class.php';
1318 $genericObject->table_element =
'product_price';
1319 $sql1 =
"SELECT rowid";
1320 $sql1 .=
" FROM ".$object->db->prefix().
"product_price";
1321 $sql1 .=
" WHERE entity IN (".getEntity(
'productprice').
")";
1322 $sql1 .=
" AND price_level=".((int) $i);
1323 $sql1 .=
" AND fk_product = ".((int)
$object->id);
1324 $sql1 .=
" ORDER BY date_price DESC, rowid DESC";
1325 $sql1 .=
" LIMIT 1";
1326 $resql1 =
$object->db->query($sql1);
1327 if ($resql1 && $lineid =
$object->db->fetch_object($resql1)) {
1328 $genericObject->id = $lineid->rowid;
1329 $genericObject->fetch_optionals();
1331 foreach ($extralabels as $key => $value) {
1332 if (!empty($extrafields->attributes[
"product_price"][
'list'][$key]) && $extrafields->attributes[
"product_price"][
'list'][$key] != 3) {
1333 $extravalue = $genericObject->array_options[
'options_' . $key];
1335 if (!empty($extrafields->attributes[
"product_price"][
'computed'][$key])) {
1336 $genericObject->price =
$object->multiprices[$i];
1337 $genericObject->price_ttc =
$object->multiprices_ttc[$i];
1338 $genericObject->price_base_type =
$object->multiprices_base_type[$i];
1339 $genericObject->price_min =
$object->multiprices_min[$i];
1340 $genericObject->price_min_ttc =
$object->multiprices_min_ttc[$i];
1341 $genericObject->tva_tx =
$object->multiprices_tva_tx[$i];
1343 $objectoffield = $genericObject;
1344 $extravalue =
dol_eval((
string) $extrafields->attributes[
"product_price"][
'computed'][$key], 1, 1,
'2');
1346 print
'<td align="right">'.$extrafields->showOutputField($key, $extravalue,
'',
'product_price').
"</td>";
1355 print
'<tr><td>'.$langs->trans(
"PriceByQuantity").
' '.$i;
1359 print
'</td><td colspan="2">';
1361 if (
$object->prices_by_qty[$i] == 1) {
1362 print
'<table width="50%" class="border" summary="List of quantities">';
1364 print
'<tr class="liste_titre">';
1365 print
'<td>'.$langs->trans(
"PriceByQuantityRange").
' '.$i.
'</td>';
1366 print
'<td class="right">'.$langs->trans(
"HT").
'</td>';
1367 print
'<td class="right">'.$langs->trans(
"UnitPrice").
'</td>';
1368 print
'<td class="right">'.$langs->trans(
"Discount").
'</td>';
1369 print
'<td> </td>';
1372 foreach (
$object->prices_by_qty_list[$i] as $ii => $prices) {
1373 if ($action ==
'edit_price_by_qty' && $rowid == $prices[
'rowid'] && ($user->hasRight(
'produit',
'creer') || $user->hasRight(
'service',
'creer'))) {
1374 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'" method="POST">';
1375 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1376 print
'<input type="hidden" name="action" value="update_price_by_qty">';
1377 print
'<input type="hidden" name="priceid" value="'.$object->prices_by_qty_id[$i].
'">';
1378 print
'<input type="hidden" value="'.$prices[
'rowid'].
'" name="rowid">';
1379 print
'<tr class="'.($ii % 2 == 0 ?
'pair' :
'impair').
'">';
1380 print
'<td><input size="5" type="text" value="'.$prices[
'quantity'].
'" name="quantity"></td>';
1381 print
'<td class="right" colspan="2"><input size="10" type="text" value="'.price2num($prices[
'price'],
'MU').
'" name="price"> '.
$object->price_base_type.
'</td>';
1382 print
'<td class="right nowraponall"><input size="5" type="text" value="'.$prices[
'remise_percent'].
'" name="remise_percent"> %</td>';
1383 print
'<td class="center"><input type="submit" value="'.$langs->trans(
"Modify").
'" class="button"></td>';
1387 print
'<tr class="'.($ii % 2 == 0 ?
'pair' :
'impair').
'">';
1388 print
'<td>'.$prices[
'quantity'].
'</td>';
1389 print
'<td class="right">'.price($prices[
'price']).
'</td>';
1390 print
'<td class="right">'.price($prices[
'unitprice']).
'</td>';
1391 print
'<td class="right">'.price($prices[
'remise_percent']).
' %</td>';
1392 print
'<td class="center">';
1393 if (($user->hasRight(
'produit',
'creer') || $user->hasRight(
'service',
'creer'))) {
1394 print
'<a class="editfielda marginleftonly marginrightonly" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=edit_price_by_qty&token='.
newToken().
'&rowid='.$prices[
"rowid"].
'">';
1395 print img_edit().
'</a>';
1396 print
'<a class="marginleftonly marginrightonly" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=delete_price_by_qty&token='.
newToken().
'&rowid='.$prices[
"rowid"].
'">';
1397 print img_delete().
'</a>';
1405 if ($action !=
'edit_price_by_qty' && ($user->hasRight(
'produit',
'creer') || $user->hasRight(
'service',
'creer'))) {
1406 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'" method="POST">';
1407 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1408 print
'<input type="hidden" name="action" value="update_price_by_qty">';
1409 print
'<input type="hidden" name="priceid" value="'.$object->prices_by_qty_id[$i].
'">';
1410 print
'<input type="hidden" value="0" name="rowid">';
1411 print
'<tr class="'.($ii % 2 == 0 ?
'pair' :
'impair').
'">';
1412 print
'<td><input size="5" type="text" value="1" name="quantity"></td>';
1413 print
'<td class="right" class="nowrap"><input size="10" type="text" value="0" name="price"> '.$object->price_base_type.
'</td>';
1414 print
'<td class="right"> </td>';
1415 print
'<td class="right" class="nowraponall"><input size="5" type="text" value="0" name="remise_percent"> %</td>';
1416 print
'<td class="center"><input type="submit" value="'.$langs->trans(
"Add").
'" class="button"></td>';
1422 print
'<a class="editfielda marginleftonly marginrightonly" href="'.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&action=disable_price_by_qty&level='.$i.
'&token='.
newToken().
'">('.$langs->trans(
"DisablePriceByQty").
')</a>';
1424 print $langs->trans(
"No");
1425 print
' <a class="marginleftonly marginrightonly" href="'.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&action=activate_price_by_qty&level='.$i.
'&token='.
newToken().
'">('.$langs->trans(
"Activate").
')</a>';
1434 $typeformat =
'select;0:'.$langs->trans(
"Product").
',1:'.$langs->trans(
"Service");
1435 print
'<tr><td class="">';
1436 print (!
getDolGlobalString(
'PRODUCT_DENY_CHANGE_PRODUCT_TYPE')) ? $form->editfieldkey(
"Type",
'fk_product_type', (
string)
$object->type, $object, 0, $typeformat) : $langs->trans(
'Type');
1438 print $form->editfieldval(
"Type",
'fk_product_type',
$object->type, $object, 0, $typeformat);
1443 print
'<tr><td class="titlefield">'.$langs->trans(
"DefaultTaxRate").
'</td><td>';
1445 $positiverates =
'';
1450 $positiverates .= ($positiverates ?
'/' :
'').
price2num(
$object->localtax1_tx);
1453 $positiverates .= ($positiverates ?
'/' :
'').
price2num(
$object->localtax2_tx);
1455 if (empty($positiverates)) {
1456 $positiverates =
'0';
1458 echo
vatrate($positiverates.($object->default_vat_code ?
' ('.$object->default_vat_code.
')' :
''), true,
$object->tva_npr, 0, 1);
1468 print
'<tr class="field_selling_price"><td>'.$langs->trans(
"SellingPrice").
'</td><td>';
1469 if (
$object->price_base_type ==
'TTC') {
1474 print
'<i class="opacitymedium"> - ' .
price(
$object->price_ttc).
' '.$langs->trans(
'TTC') .
'</i>';
1481 print
'<tr class="field_min_price"><td>'.$langs->trans(
"MinPrice").
'</td><td>';
1482 if (
$object->price_base_type ==
'TTC') {
1487 print
'<i class="opacitymedium"> - ' .
price(
$object->price_min_ttc).
' '.$langs->trans(
'TTC') .
'</i>';
1494 print
'<tr class="field_price_label"><td>'.$form->textwithpicto($langs->trans(
"PackagingForThisProduct"), $langs->trans(
"PackagingForThisProductDesc")).
'</td><td>';
1500 print
'<tr class="field_price_label"><td>'.$langs->trans(
"PriceLabel").
'</td><td>';
1507 print
'<tr><td>'.$langs->trans(
"PriceByQuantity");
1508 if (
$object->prices_by_qty[0] == 0) {
1509 print
' <a href="'.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&action=activate_price_by_qty&level=1&token='.
newToken().
'">('.$langs->trans(
"Activate").
')';
1511 print
' <a href="'.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&action=disable_price_by_qty&level=1&token='.
newToken().
'">('.$langs->trans(
"DisablePriceByQty").
')';
1515 if (
$object->prices_by_qty[0] == 1) {
1516 print
'<table width="50%" class="border" summary="List of quantities">';
1517 print
'<tr class="liste_titre">';
1519 print
'<td>'.$langs->trans(
"Quantity").
'</td>';
1520 print
'<td class="right">'.$langs->trans(
"Price").
'</td>';
1521 print
'<td class="right"></td>';
1522 print
'<td class="right">'.$langs->trans(
"UnitPrice").
'</td>';
1523 print
'<td class="right">'.$langs->trans(
"Discount").
'</td>';
1524 print
'<td> </td>';
1526 if ($action !=
'edit_price_by_qty') {
1527 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'" method="POST">';
1528 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1529 print
'<input type="hidden" name="action" value="update_price_by_qty">';
1530 print
'<input type="hidden" name="priceid" value="'.$object->prices_by_qty_id[0].
'">';
1531 print
'<input type="hidden" value="0" name="rowid">';
1533 print
'<tr class="'.(($ii % 2) == 0 ?
'pair' :
'impair').
'">';
1534 print
'<td><input size="5" type="text" value="1" name="quantity"></td>';
1535 print
'<td class="right"><input class="width50 right" type="text" value="0" name="price"></td>';
1539 print
'<td class="right"> </td>';
1540 print
'<td class="right nowraponall"><input type="text" class="width50 right" value="0" name="remise_percent"> %</td>';
1541 print
'<td class="center"><input type="submit" value="'.$langs->trans(
"Add").
'" class="button"></td>';
1546 foreach (
$object->prices_by_qty_list[0] as $ii => $prices) {
1547 if ($action ==
'edit_price_by_qty' && $rowid == $prices[
'rowid'] && ($user->hasRight(
'produit',
'creer') || $user->hasRight(
'service',
'creer'))) {
1548 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'" method="POST">';
1549 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1550 print
'<input type="hidden" name="action" value="update_price_by_qty">';
1551 print
'<input type="hidden" name="priceid" value="'.$object->prices_by_qty_id[0].
'">';
1552 print
'<input type="hidden" value="'.$prices[
'rowid'].
'" name="rowid">';
1553 print
'<tr class="'.($ii % 2 == 0 ?
'pair' :
'impair').
'">';
1554 print
'<td><input size="5" type="text" value="'.$prices[
'quantity'].
'" name="quantity"></td>';
1555 print
'<td class="right"><input class="width50 right" type="text" value="'.price2num($prices[
'price'],
'MU').
'" name="price"></td>';
1556 print
'<td class="right">';
1558 print $prices[
'price_base_type'];
1560 print
'<td class="right"> </td>';
1561 print
'<td class="right nowraponall"><input class="width50 right" type="text" value="'.$prices[
'remise_percent'].
'" name="remise_percent"> %</td>';
1562 print
'<td class="center"><input type="submit" value="'.$langs->trans(
"Modify").
'" class="button"></td>';
1566 print
'<tr class="'.($ii % 2 == 0 ?
'pair' :
'impair').
'">';
1567 print
'<td>'.$prices[
'quantity'].
'</td>';
1568 print
'<td class="right">'.price($prices[
'price']).
'</td>';
1569 print
'<td class="right">';
1571 print $prices[
'price_base_type'];
1573 print
'<td class="right">'.price($prices[
'unitprice']).
'</td>';
1574 print
'<td class="right">'.price($prices[
'remise_percent']).
' %</td>';
1575 print
'<td class="center">';
1576 if (($user->hasRight(
'produit',
'creer') || $user->hasRight(
'service',
'creer'))) {
1577 print
'<a class="editfielda marginleftonly marginrightonly" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=edit_price_by_qty&token='.
newToken().
'&rowid='.$prices[
"rowid"].
'">';
1578 print img_edit().
'</a>';
1579 print
'<a class="marginleftonly marginrightonly" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=delete_price_by_qty&token='.
newToken().
'&rowid='.$prices[
"rowid"].
'">';
1580 print img_delete().
'</a>';
1590 print $langs->trans(
"No");
1599print
'<div class="clearboth"></div>';
1608if (!$action || $action ==
'delete' || $action ==
'showlog_customer_price' || $action ==
'showlog_default_price' || $action ==
'add_customer_price'
1609 || $action ==
'activate_price_by_qty' || $action ==
'disable_price_by_qty') {
1610 print
"\n".
'<div class="tabsAction">'.
"\n";
1612 $parameters = array();
1613 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters, $object, $action);
1614 if (empty($reshook)) {
1617 print
'<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="' .
dol_escape_htmltag($langs->trans(
"NoEditVariants")) .
'">' . $langs->trans(
"UpdateDefaultPrice") .
'</a></div>';
1621 if ($user->hasRight(
'produit',
'creer') || $user->hasRight(
'service',
'creer')) {
1622 print
'<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER[
'PHP_SELF'] .
'?action=edit_price&token='.newToken().
'&id=' .
$object->id .
'">' . $langs->trans(
"UpdateDefaultPrice") .
'</a></div>';
1624 print
'<div class="inline-block divButAction"><span class="butActionRefused" title="'.dol_escape_htmltag($langs->trans(
"NotEnoughPermissions")).
'">' . $langs->trans(
"UpdateDefaultPrice") .
'</span></div>';
1629 if ($user->hasRight(
'produit',
'creer') || $user->hasRight(
'service',
'creer')) {
1630 print
'<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER[
"PHP_SELF"] .
'?action=add_customer_price&token='.newToken().
'&id=' .
$object->id .
'">' . $langs->trans(
"AddCustomerPrice") .
'</a></div>';
1632 print
'<div class="inline-block divButAction"><span class="butActionRefused" title="'.dol_escape_htmltag($langs->trans(
"NotEnoughPermissions")).
'">' . $langs->trans(
"AddCustomerPrice") .
'</span></div>';
1637 if ($user->hasRight(
'produit',
'creer') || $user->hasRight(
'service',
'creer')) {
1638 print
'<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER[
'PHP_SELF'] .
'?action=edit_vat&token='.newToken().
'&id=' .
$object->id .
'">' . $langs->trans(
"UpdateVAT") .
'</a></div>';
1640 print
'<div class="inline-block divButAction"><span class="butActionRefused" title="'.dol_escape_htmltag($langs->trans(
"NotEnoughPermissions")).
'">' . $langs->trans(
"UpdateVAT") .
'</span></div>';
1643 if ($user->hasRight(
'produit',
'creer') || $user->hasRight(
'service',
'creer')) {
1644 print
'<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER[
'PHP_SELF'] .
'?action=edit_level_price&token='.newToken().
'&id=' .
$object->id .
'">' . $langs->trans(
"UpdateLevelPrices") .
'</a></div>';
1646 print
'<div class="inline-block divButAction"><span class="butActionRefused" title="'.dol_escape_htmltag($langs->trans(
"NotEnoughPermissions")).
'">' . $langs->trans(
"UpdateLevelPrices") .
'</span></div>';
1661if ($action ==
'edit_vat' && ($user->hasRight(
'produit',
'creer') || $user->hasRight(
'service',
'creer'))) {
1664 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'" method="POST">';
1665 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1666 print
'<input type="hidden" name="action" value="update_vat">';
1667 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
1671 print
'<table class="border centpercent">';
1674 print
'<tr><td>'.$langs->trans(
"DefaultTaxRate").
'</td><td>';
1684 print $form->buttonsSaveCancel();
1686 print
'<br></form><br>';
1689if (($action ==
'edit_price' || $action ==
'edit_level_price') && $permissiontoadd) {
1694 print
'<!-- Edit price -->'.
"\n";
1695 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'" method="POST">';
1696 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1697 print
'<input type="hidden" name="action" value="update_price">';
1698 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
1702 print
'<div class="div-table-responsive-no-min">';
1703 print
'<table class="border centpercent">';
1706 print
'<tr><td class="titlefield">'.$langs->trans(
"DefaultTaxRate").
'</td><td>';
1712 print $langs->trans(
'PriceBase');
1715 print $form->selectPriceBaseType(
$object->price_base_type,
"price_base_type");
1722 print
'<!-- Show price mode of dynamicprices editor -->'.
"\n";
1723 print
'<tr><td>'.$langs->trans(
"PriceMode").
'</td><td>';
1724 print img_picto(
'',
'dynamicprice',
'class="pictofixedwidth"');
1726 $price_expression_list = array(0 => $langs->trans(
"Numeric").
' <span class="opacitymedium">('.$langs->trans(
"NoDynamicPrice").
')</span>');
1727 foreach ($price_expression->list_price_expression() as $entry) {
1728 $price_expression_list[$entry->id] = $entry->title;
1730 $price_expression_preselection =
GETPOST(
'eid') ?
GETPOST(
'eid') : (
$object->fk_price_expression ?
$object->fk_price_expression :
'0');
1731 print $form->selectarray(
'eid', $price_expression_list, $price_expression_preselection);
1732 print
' <a id="expression_editor" class="classlink">'.$langs->trans(
"PriceExpressionEditor").
'</a>';
1738 <script
type=
"text/javascript">
1739 jQuery(document).ready(
function() {
1740 jQuery(
"#expression_editor").click(
function() {
1741 window.location =
"<?php echo DOL_URL_ROOT ?>/product/dynamic_price/editor.php?id=<?php echo $id ?>&tab=price&eid=" + $(
"#eid").val();
1743 jQuery(
"#eid").change(on_change);
1746 function on_change() {
1747 if ($(
"#eid").val() == 0) {
1748 jQuery(
"#price_numeric").show();
1750 jQuery(
"#price_numeric").hide();
1759 $product->fetch($id, $ref,
'',
'1');
1760 print
'<tr id="price_numeric"><td>';
1761 $text = $langs->trans(
'SellingPrice');
1762 print $form->textwithpicto($text, $langs->trans(
"PrecisionUnitIsLimitedToXDecimals",
getDolGlobalString(
'MAIN_MAX_DECIMALS_UNIT')), 1,
'help');
1764 if (
$object->price_base_type ==
'TTC') {
1765 print
'<input name="price" size="10" value="'.price($product->price_ttc).
'">';
1767 print
'<input name="price" size="10" value="'.price($product->price).
'">';
1773 $text = $langs->trans(
'MinPrice');
1774 print $form->textwithpicto($text, $langs->trans(
"PrecisionUnitIsLimitedToXDecimals",
getDolGlobalString(
'MAIN_MAX_DECIMALS_UNIT')), 1,
'help');
1776 if (
$object->price_base_type ==
'TTC') {
1777 print
'<input name="price_min" size="10" value="'.($object->price_min_ttc ?
price(
$object->price_min_ttc) :
'').
'">';
1779 print
'<input name="price_min" size="10" value="'.($object->price_min ?
price(
$object->price_min) :
'').
'">';
1782 print
' '.$langs->trans(
"MinimumRecommendedPrice",
price((
float) $maxpricesupplier, 0,
'', 1, -1, -1,
'auto')).
' '.img_warning().
'</td>';
1790 print $form->textwithpicto($langs->trans(
"PackagingForThisProduct"), $langs->trans(
"PackagingForThisProductDesc"));
1792 $packaging =
$object->packaging;
1793 print
'<input class="flat" name="packaging" size="5" value="' . ($packaging ?
price($packaging, 0,
'', 1, -1, 2) :
'').
'">';
1800 print $langs->trans(
'PriceLabel');
1802 print
'<input name="price_label" maxlength="255" class="minwidth300 maxwidth400onsmartphone" value="'.$object->price_label.
'">';
1806 $parameters = array();
1807 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters, $object, $action);
1814 print $form->buttonsSaveCancel();
1817 } elseif ($action ==
'edit_level_price' && $permissiontoadd) {
1818 print
'<!-- Edit price per level -->'.
"\n"; ?>
1821 var showHidePriceRules =
function () {
1822 var otherPrices = $(
'div.fiche form table tbody tr:not(:first)');
1823 var minPrice1 = $(
'div.fiche form input[name="price_min[1]"]');
1825 if (jQuery(
'input#usePriceRules').prop(
'checked')) {
1834 jQuery(document).ready(
function () {
1835 showHidePriceRules();
1837 jQuery(
'input#usePriceRules').click(showHidePriceRules);
1842 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'" method="POST">';
1843 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1844 print
'<input type="hidden" name="action" value="update_level_price">';
1845 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
1850 print $langs->trans(
'UseMultipriceRules').
' <input type="checkbox" id="usePriceRules" name="usePriceRules" '.(
$object->price_autogen ?
'checked' :
'').
'><br><br>';
1853 print
'<div class="div-table-responsive-no-min">';
1854 print
'<table class="noborder">';
1855 print
'<thead><tr class="liste_titre">';
1857 print
'<td>'.$langs->trans(
"PriceLevel").
'</td>';
1860 print
'<td style="text-align: center">'.$langs->trans(
"DefaultTaxRate").
'</td>';
1865 print
'<td class="center">'.$langs->trans(
"SellingPrice").
'</td>';
1867 print
'<td class="center">'.$langs->trans(
"MinPrice").
'</td>';
1874 $extrafields->fetch_name_optionals_label(
"product_price");
1875 if ($extrafields->attributes[
"product_price"] && array_key_exists(
'label', $extrafields->attributes[
"product_price"])) {
1876 $extralabels = $extrafields->attributes[
"product_price"][
'label'];
1877 if (!empty($extralabels)) {
1878 foreach ($extralabels as $key => $value) {
1880 if (!empty($extrafields->attributes[
"product_price"][
'list'][$key]) && $extrafields->attributes[
"product_price"][
'list'][$key] != 3) {
1881 if (!empty($extrafields->attributes[
"product_price"][
'langfile'][$key])) {
1882 $langs->load($extrafields->attributes[
"product_price"][
'langfile'][$key]);
1884 if (!empty($extrafields->attributes[
"product_price"][
'help'][$key])) {
1885 $extratitle = $form->textwithpicto($langs->trans($value), $langs->trans($extrafields->attributes[
"product_price"][
'help'][$key]));
1887 $extratitle = $langs->trans($value);
1889 print
'<td style="text-align: right">'.$extratitle.
'</td>';
1894 print
'</tr></thead>';
1898 $produit_multiprices_limit =
getDolGlobalInt(
'PRODUIT_MULTIPRICES_LIMIT');
1899 for ($i = 1; $i <= $produit_multiprices_limit; $i++) {
1900 print
'<tr class="oddeven">';
1902 $keyforlabel =
'PRODUIT_MULTIPRICES_LABEL'.$i;
1904 print $form->textwithpicto($text, $langs->trans(
"PrecisionUnitIsLimitedToXDecimals",
getDolGlobalString(
'MAIN_MAX_DECIMALS_UNIT')), 1,
'help');
1910 print
'<input type="hidden" name="tva_tx['.$i.
']" value="'.(
$object->default_vat_code ?
$object->tva_tx.
' ('.
$object->default_vat_code.
')' :
$object->tva_tx).
'">';
1911 print
'<input type="hidden" name="tva_npr['.$i.
']" value="'.
$object->tva_npr.
'">';
1912 print
'<input type="hidden" name="localtax1_tx['.$i.
']" value="'.
$object->localtax1_tx.
'">';
1913 print
'<input type="hidden" name="localtax1_type['.$i.
']" value="'.
$object->localtax1_type.
'">';
1914 print
'<input type="hidden" name="localtax2_tx['.$i.
']" value="'.
$object->localtax2_tx.
'">';
1915 print
'<input type="hidden" name="localtax2_type['.$i.
']" value="'.
$object->localtax2_type.
'">';
1919 print
'<td style="text-align: center">';
1920 print $form->load_tva(
"tva_tx[".$i.
']',
$object->multiprices_tva_tx[$i],
$mysoc,
null,
$object->id, 0,
$object->type,
false, 1, 1);
1925 print
'<td style="text-align: center">';
1926 if (
$object->multiprices_base_type [$i] ==
'TTC') {
1927 print
'<input name="price['.$i.
']" size="10" value="'.
price(
$object->multiprices_ttc [$i]).
'">';
1929 print
'<input name="price['.$i.
']" size="10" value="'.
price(
$object->multiprices [$i]).
'">';
1931 print
' '.$form->selectPriceBaseType(
$object->multiprices_base_type [$i],
"multiprices_base_type[".$i.
"]");
1935 print
'<td style="text-align: center">';
1936 if (
$object->multiprices_base_type [$i] ==
'TTC') {
1937 print
'<input name="price_min['.$i.
']" size="10" value="'.
price(
$object->multiprices_min_ttc [$i]).
'">';
1939 print
'<input name="price_min['.$i.
']" size="10" value="'.
price(
$object->multiprices_min [$i]).
'">';
1942 print
'<td class="left">'.$langs->trans(
"MinimumRecommendedPrice",
price((
float) $maxpricesupplier, 0,
'', 1, -1, -1,
'auto')).
' '.img_warning().
'</td>';
1946 if (!empty($extralabels)) {
1947 require_once DOL_DOCUMENT_ROOT .
'/core/class/genericobject.class.php';
1950 $genericObject->table_element =
'product_price';
1951 $sql1 =
"SELECT rowid";
1952 $sql1 .=
" FROM ".$object->db->prefix().
"product_price";
1953 $sql1 .=
" WHERE entity IN (".getEntity(
'productprice').
")";
1954 $sql1 .=
" AND price_level=".((int) $i);
1955 $sql1 .=
" AND fk_product = ".((int)
$object->id);
1956 $sql1 .=
" ORDER BY date_price DESC, rowid DESC";
1957 $sql1 .=
" LIMIT 1";
1958 $resql1 =
$object->db->query($sql1);
1959 if ($resql1 && $lineid =
$object->db->fetch_object($resql1)) {
1960 $genericObject->id = $lineid->rowid;
1961 $genericObject->fetch_optionals();
1963 foreach ($extralabels as $key => $value) {
1964 if (!empty($extrafields->attributes[
"product_price"][
'list'][$key]) && ($extrafields->attributes[
"product_price"][
'list'][$key] == 1 || $extrafields->attributes[
"product_price"][
'list'][$key] == 3 || ($action ==
"edit_level_price" && $extrafields->attributes[
"product_price"][
'list'][$key] == 4))) {
1965 if (!empty($extrafields->attributes[
"product_price"][
'langfile'][$key])) {
1966 $langs->load($extrafields->attributes[
"product_price"][
'langfile'][$key]);
1970 print
'<td align="center">';
1971 print $extrafields->showInputField($key, $genericObject->array_options[
'options_' . $key],
'', (
string) $i,
'',
'', $genericObject,
'product_price');
1987 print $form->buttonsSaveCancel();
1998 $sortfield =
GETPOST(
'sortfield',
'aZ09comma');
1999 $sortorder =
GETPOST(
'sortorder',
'aZ09comma');
2001 if (empty($page) || $page == -1) {
2004 $offset = $limit * $page;
2005 $pageprev = $page - 1;
2006 $pagenext = $page + 1;
2008 $sortorder =
"ASC,ASC";
2011 $sortfield =
"soc.nom,t.date_begin";
2015 $filter = array(
't.fk_product' => (
string)
$object->id);
2017 if (!empty($search_soc)) {
2018 $filter[
'soc.nom'] = (string) $search_soc;
2021 if ($action ==
'add_customer_price') {
2023 $maxpricesupplier =
$object->min_recommended_price();
2025 print
'<!-- add_customer_price -->';
2028 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'" method="POST">';
2029 print
'<input type="hidden" name="token" value="'.newToken().
'">';
2030 print
'<input type="hidden" name="action" value="add_customer_price_confirm">';
2031 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
2033 print
'<div class="tabBar tabBarWithBottom">';
2035 print
'<table class="border centpercent">';
2037 print
'<td class="fieldrequired">'.$langs->trans(
'ThirdParty').
'</td>';
2039 $filter =
'(s.client:IN:1,2,3)';
2040 print img_picto(
'',
'company').$form->select_company(
GETPOSTINT(
'socid'),
'socid', $filter,
'SelectThirdParty', 0, 0, array(), 0,
'minwidth300');
2045 print
'<tr><td>' . $langs->trans(
'RefCustomer') .
'</td>';
2046 print
'<td><input name="ref_customer" size="12"></td></tr>';
2050 print
'<tr><td>'.$langs->trans(
"AppliedPricesFrom").
'</td><td>';
2051 print $form->selectDate(!empty($date_begin) ? $date_begin :
dol_now(),
"date_begin", 0, 0, 1,
"date_begin");
2056 print
'<tr><td>'.$langs->trans(
"AppliedPricesTo").
'</td><td>';
2057 print $form->selectDate($date_end,
"date_end", 0, 0, 1,
"date_end");
2061 print
'<tr><td class="fieldrequired">'.$langs->trans(
"DefaultTaxRate").
'</td><td>';
2066 print
'<tr><td class="fieldrequired">';
2067 print $langs->trans(
'PriceBase');
2070 print $form->selectPriceBaseType(
$object->price_base_type,
"price_base_type");
2075 print
'<tr><td class="fieldrequired">';
2076 $text = $langs->trans(
'SellingPrice');
2077 print $form->textwithpicto($text, $langs->trans(
"PrecisionUnitIsLimitedToXDecimals",
getDolGlobalString(
'MAIN_MAX_DECIMALS_UNIT')), 1,
'help');
2079 if (
$object->price_base_type ==
'TTC') {
2080 print
'<input name="price" size="10" value="'.price(
$object->price_ttc).
'">';
2082 print
'<input name="price" size="10" value="'.price(
$object->price).
'">';
2088 $text = $langs->trans(
'MinPrice');
2089 print $form->textwithpicto($text, $langs->trans(
"PrecisionUnitIsLimitedToXDecimals",
getDolGlobalString(
'MAIN_MAX_DECIMALS_UNIT')), 1,
'help');
2090 if (
$object->price_base_type ==
'TTC') {
2091 print
'<td><input name="price_min" size="10" value="'.price(
$object->price_min_ttc).
'">';
2093 print
'<td><input name="price_min" size="10" value="'.price(
$object->price_min).
'">';
2096 print
'<td class="left">'.$langs->trans(
"MinimumRecommendedPrice",
price($maxpricesupplier, 0,
'', 1, -1, -1,
'auto')).
' '.img_warning().
'</td>';
2102 print $langs->trans(
'PriceLabel');
2104 print
'<input name="price_label" maxlength="255" class="minwidth300 maxwidth400onsmartphone" value="'.$object->price_label.
'">';
2110 print
'<tr><td>'.$langs->trans(
"Discount").
'</td><td>';
2111 print
'<input name="discount_percent" size="10" value="'.price($discount_percent).
'">';
2115 $extrafields->fetch_name_optionals_label(
"product_customer_price");
2116 $extralabels = !empty($extrafields->attributes[
"product_customer_price"][
'label']) ? $extrafields->attributes[
"product_customer_price"][
'label'] :
'';
2117 $extrafield_values = $extrafields->getOptionalsFromPost(
"product_customer_price");
2118 if (!empty($extralabels)) {
2119 if (empty($prodcustprice->id)) {
2120 foreach ($extralabels as $key => $value) {
2121 if (!empty($extrafields->attributes[
"product_customer_price"][
'list'][$key]) && ($extrafields->attributes[
"product_customer_price"][
'list'][$key] == 1 || $extrafields->attributes[
"product_customer_price"][
'list'][$key] == 3 || ($action ==
"add_customer_price" && $extrafields->attributes[
"product_customer_price"][
'list'][$key] == 4))) {
2122 if (!empty($extrafields->attributes[
"product_customer_price"][
'langfile'][$key])) {
2123 $langs->load($extrafields->attributes[
"product_customer_price"][
'langfile'][$key]);
2126 print
'<tr><td'.($extrafields->attributes[
"product_customer_price"][
'required'][$key] ?
' class="fieldrequired"' :
'').
'>';
2127 if (!empty($extrafields->attributes[
"product_customer_price"][
'help'][$key])) {
2128 print $form->textwithpicto($langs->trans($value), $langs->trans($extrafields->attributes[
"product_customer_price"][
'help'][$key]));
2130 print $langs->trans($value);
2132 print
'</td><td>'.$extrafields->showInputField($key,
GETPOSTISSET(
'options_'.$key) ? $extrafield_values[
'options_'.$key] :
'',
'',
'',
'',
'', 0,
'product_customer_price').
'</td></tr>';
2143 print
'<div class="center">';
2146 print
'<div class="marginbottomonly">';
2147 print
'<input type="checkbox" name="updatechildprice" id="updatechildprice" value="1"> ';
2148 print
'<label for="updatechildprice">'.$langs->trans(
'ForceUpdateChildPriceSoc').
'</label>';
2151 print $form->buttonsSaveCancel();
2154 } elseif ($action ==
'edit_customer_price') {
2156 $maxpricesupplier =
$object->min_recommended_price();
2158 print
'<!-- edit_customer_price -->';
2161 $result = $prodcustprice->fetch(
GETPOSTINT(
'lineid'));
2163 setEventMessages($prodcustprice->error, $prodcustprice->errors,
'errors');
2166 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'" method="POST">';
2167 print
'<input type="hidden" name="token" value="'.newToken().
'">';
2168 print
'<input type="hidden" name="action" value="update_customer_price_confirm">';
2169 print
'<input type="hidden" name="lineid" value="'.$prodcustprice->id.
'">';
2171 print
'<table class="liste centpercent">';
2173 print
'<td class="titlefield fieldrequired">'.$langs->trans(
'ThirdParty').
'</td>';
2174 $staticsoc =
new Societe($db);
2175 $staticsoc->fetch($prodcustprice->fk_soc);
2176 print
"<td>".$staticsoc->getNomUrl(1).
"</td>";
2180 print
'<tr><td>' . $langs->trans(
'RefCustomer') .
'</td>';
2181 print
'<td><input name="ref_customer" size="12" value="' .
dol_escape_htmltag($prodcustprice->ref_customer) .
'"></td></tr>';
2184 print
'<tr><td>'.$langs->trans(
"AppliedPricesFrom").
'</td><td>';
2185 print $form->selectDate($prodcustprice->date_begin,
"date_begin", 0, 0, 1,
"date_begin");
2189 print
'<tr><td>'.$langs->trans(
"AppliedPricesTo").
'</td><td>';
2190 print $form->selectDate($prodcustprice->date_end,
"date_end", 0, 0, 1,
"date_end");
2194 print
'<tr><td class="fieldrequired">'.$langs->trans(
"DefaultTaxRate").
'</td><td>';
2195 print $form->load_tva(
"tva_tx", $prodcustprice->default_vat_code ? $prodcustprice->tva_tx.
' ('.$prodcustprice->default_vat_code.
')' : $prodcustprice->tva_tx,
$mysoc, null,
$object->id, $prodcustprice->recuperableonly,
$object->
type, false, 1, 1);
2199 print
'<tr><td class="fieldrequired">';
2200 print $langs->trans(
'PriceBase');
2203 print $form->selectPriceBaseType($prodcustprice->price_base_type,
"price_base_type");
2208 print
'<tr><td class="fieldrequired">';
2209 $text = $langs->trans(
'SellingPrice');
2210 print $form->textwithpicto($text, $langs->trans(
"PrecisionUnitIsLimitedToXDecimals",
getDolGlobalString(
'MAIN_MAX_DECIMALS_UNIT')), 1,
'help');
2212 if ($prodcustprice->price_base_type ==
'TTC') {
2213 print
'<input name="price" size="10" value="'.price($prodcustprice->price_ttc).
'">';
2215 print
'<input name="price" size="10" value="'.price($prodcustprice->price).
'">';
2221 $text = $langs->trans(
'MinPrice');
2222 print $form->textwithpicto($text, $langs->trans(
"PrecisionUnitIsLimitedToXDecimals",
getDolGlobalString(
'MAIN_MAX_DECIMALS_UNIT')), 1,
'help');
2224 if ($prodcustprice->price_base_type ==
'TTC') {
2225 print
'<input name="price_min" size="10" value="'.price($prodcustprice->price_min_ttc).
'">';
2227 print
'<input name="price_min" size="10" value="'.price($prodcustprice->price_min).
'">';
2231 print
'<td class="left">'.$langs->trans(
"MinimumRecommendedPrice",
price($maxpricesupplier, 0,
'', 1, -1, -1,
'auto')).
' '.img_warning().
'</td>';
2237 print $langs->trans(
'PriceLabel');
2239 print
'<input name="price_label" maxlength="255" class="minwidth300 maxwidth400onsmartphone" value="'.$prodcustprice->price_label.
'">';
2244 print
'<tr><td>'.$langs->trans(
"Discount").
'</td><td>';
2245 print
'<input name="discount_percent" size="10" value="'.price($prodcustprice->discount_percent).
'">';
2249 $extrafields->fetch_name_optionals_label(
"product_customer_price");
2250 $extralabels = !empty($extrafields->attributes[
"product_customer_price"][
'label']) ? $extrafields->attributes[
"product_customer_price"][
'label'] :
'';
2251 $extrafield_values = $extrafields->getOptionalsFromPost(
"product_customer_price");
2252 if (!empty($extralabels)) {
2254 foreach ($extralabels as $key => $value) {
2255 if (!empty($extrafields->attributes[
"product_customer_price"][
'list'][$key]) && ($extrafields->attributes[
"product_customer_price"][
'list'][$key] == 1 || $extrafields->attributes[
"product_customer_price"][
'list'][$key] == 3 || ($action ==
"edit_customer_price" && $extrafields->attributes[
"product_customer_price"][
'list'][$key] == 4))) {
2256 if (!empty($extrafields->attributes[
"product_customer_price"][
'langfile'][$key])) {
2257 $langs->load($extrafields->attributes[
"product_customer_price"][
'langfile'][$key]);
2260 print
'<tr><td'.($extrafields->attributes[
"product_customer_price"][
'required'][$key] ?
' class="fieldrequired"' :
'').
'>';
2261 if (!empty($extrafields->attributes[
"product_customer_price"][
'help'][$key])) {
2262 print $form->textwithpicto($langs->trans($value), $langs->trans($extrafields->attributes[
"product_customer_price"][
'help'][$key]));
2264 print $langs->trans($value);
2266 print
'</td><td>'.$extrafields->showInputField($key,
GETPOSTISSET(
'options_'.$key) ? $extrafield_values[
'options_'.$key] :
'',
'',
'',
'',
'', 0,
'product_customer_price').
'</td></tr>';
2271 $sql .=
" fk_object";
2272 foreach ($extralabels as $key => $value) {
2273 $sql .=
", ".$db->sanitize($key);
2275 $sql .=
" FROM ".MAIN_DB_PREFIX.
"product_customer_price_extrafields";
2276 $sql .=
" WHERE fk_object = ".((int) $prodcustprice->id);
2277 $resql = $db->query($sql);
2279 $obj = $db->fetch_object($resql);
2280 foreach ($extralabels as $key => $value) {
2281 if (!empty($extrafields->attributes[
"product_customer_price"][
'list'][$key]) && ($extrafields->attributes[
"product_customer_price"][
'list'][$key] == 1 || $extrafields->attributes[
"product_customer_price"][
'list'][$key] == 3 || ($action ==
"edit_customer_price" && $extrafields->attributes[
"product_customer_price"][
'list'][$key] == 4))) {
2282 if (!empty($extrafields->attributes[
"product_customer_price"][
'langfile'][$key])) {
2283 $langs->load($extrafields->attributes[
"product_customer_price"][
'langfile'][$key]);
2286 print
'<tr><td'.($extrafields->attributes[
"product_customer_price"][
'required'][$key] ?
' class="fieldrequired"' :
'').
'>';
2287 if (!empty($extrafields->attributes[
"product_customer_price"][
'help'][$key])) {
2288 print $form->textwithpicto($langs->trans($value), $langs->trans($extrafields->attributes[
"product_customer_price"][
'help'][$key]));
2290 print $langs->trans($value);
2292 print
'</td><td>'.$extrafields->showInputField($key,
GETPOSTISSET(
'options_'.$key) ? $extrafield_values[
'options_'.$key] : $obj->{$key},
'',
'',
'',
'', 0,
'product_customer_price');
2304 print
'<div class="center">';
2305 print
'<div class="marginbottomonly">';
2306 print
'<input type="checkbox" name="updatechildprice" id="updatechildprice" value="1"> ';
2307 print
'<label for="updatechildprice">'.$langs->trans(
'ForceUpdateChildPriceSoc').
'</label>';
2310 print $form->buttonsSaveCancel();
2312 print
'<br></form>';
2313 } elseif ($action ==
'showlog_customer_price') {
2315 print
'<!-- list of all log of prices per customer -->'.
"\n";
2317 $sortfield =
't.datec';
2318 $filter = array(
't.fk_product' => (
string)
$object->id,
't.fk_soc' => (
string)
GETPOSTINT(
'socid'));
2321 $nbtotalofrecords =
'';
2323 $nbtotalofrecords = $prodcustprice->fetchAllLog($sortorder, $sortfield,
$conf->liste_limit, $offset, $filter);
2326 $result = $prodcustprice->fetchAllLog($sortorder, $sortfield,
$conf->liste_limit, $offset, $filter);
2328 setEventMessages($prodcustprice->error, $prodcustprice->errors,
'errors');
2331 $option =
'&socid='.GETPOSTINT(
'socid').
'&id='.
$object->id;
2333 $staticsoc =
new Societe($db);
2336 $title = $langs->trans(
'PriceByCustomerLog');
2337 $title .=
' - '.$staticsoc->getNomUrl(1);
2339 $backbutton =
'<a class="justalink" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'">'.$langs->trans(
"GoBack").
'</a>';
2342 print_barre_liste($title, $page, $_SERVER[
'PHP_SELF'], $option, $sortfield, $sortorder, $backbutton, count($prodcustprice->lines), $nbtotalofrecords,
'title_accountancy.png');
2344 if (count($prodcustprice->lines) > 0) {
2345 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'" method="POST">';
2346 print
'<input type="hidden" name="token" value="'.newToken().
'">';
2347 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
2349 print
'<div class="div-table-responsive-no-min">';
2350 print
'<table class="liste centpercent">';
2352 print
'<tr class="liste_titre">';
2353 print
'<td>'.$langs->trans(
"ThirdParty").
'</td>';
2354 print
'<td>'.$langs->trans(
'RefCustomer').
'</td>';
2355 print
'<td>'.$langs->trans(
"AppliedPricesFrom").
'</td>';
2356 print
'<td>'.$langs->trans(
"AppliedPricesTo").
'</td>';
2357 print
'<td class="center">'.$langs->trans(
"PriceBase").
'</td>';
2358 print
'<td class="right">'.$langs->trans(
"DefaultTaxRate").
'</td>';
2359 print
'<td class="right">'.$langs->trans(
"HT").
'</td>';
2360 print
'<td class="right">'.$langs->trans(
"TTC").
'</td>';
2361 if (
$mysoc->localtax1_assuj ==
"1" ||
$mysoc->localtax2_assuj ==
"1") {
2362 print
'<td class="right">'.$langs->trans(
"INCT").
'</td>';
2364 print
'<td class="right">'.$langs->trans(
"MinPrice").
' '.$langs->trans(
"HT").
'</td>';
2365 print
'<td class="right">'.$langs->trans(
"MinPrice").
' '.$langs->trans(
"TTC").
'</td>';
2366 print
'<td class="right">'.$langs->trans(
"PriceLabel").
'</td>';
2367 print
'<td class="right">'.$langs->trans(
"Discount").
'</td>';
2368 print
'<td class="right">'.$langs->trans(
"ChangedBy").
'</td>';
2369 print
'<td>'.$langs->trans(
"DateCreation").
'</td>';
2372 foreach ($prodcustprice->lines as $line) {
2374 $staticsoc =
new Societe($db);
2375 $staticsoc->fetch($line->fk_soc);
2377 $tva_tx = $line->default_vat_code ? $line->tva_tx.
' ('.$line->default_vat_code.
')' : $line->tva_tx;
2380 if ($line->price_base_type ==
'HT') {
2383 $pu = $line->price_ttc;
2387 $localtaxarray =
getLocalTaxesFromRate($line->tva_tx.($line->default_vat_code ?
' ('.$line->default_vat_code.
')' :
''), 0, $staticsoc,
$mysoc);
2389 $resultarray =
calcul_price_total(1, $pu, 0, (
float) $line->tva_tx, 1, 1, 0, $line->price_base_type, $line->recuperableonly,
$object->type,
$mysoc, $localtaxarray);
2391 $total_ht = $resultarray[0];
2392 $total_vat = $resultarray[1];
2393 $total_localtax1 = $resultarray[9];
2394 $total_localtax2 = $resultarray[10];
2395 $total_ttc = $resultarray[2];
2397 print
'<tr class="oddeven">';
2399 print
'<td class="tdoverflowmax125">'.$staticsoc->getNomUrl(1).
"</td>";
2400 print
'<td>'.$line->ref_customer.
'</td>';
2401 print
"<td>".dol_print_date($line->date_begin,
"day",
'tzuserrel').
"</td>";
2402 print
"<td>".dol_print_date($line->date_end,
"day",
'tzuserrel').
"</td>";
2403 print
'<td class="center">'.$langs->trans($line->price_base_type).
"</td>";
2404 print
'<td class="right nowraponall">';
2406 $positiverates =
'';
2408 $positiverates .= ($positiverates ?
'/' :
'').
price2num($line->tva_tx);
2411 $positiverates .= ($positiverates ?
'/' :
'').
price2num($line->localtax1_tx);
2414 $positiverates .= ($positiverates ?
'/' :
'').
price2num($line->localtax2_tx);
2416 if (empty($positiverates)) {
2417 $positiverates =
'0';
2420 echo
vatrate($positiverates.($line->default_vat_code ?
' ('.$line->default_vat_code.
')' :
''), true, $line->recuperableonly);
2424 print
'<td class="right"><span class="amount">'.price($line->price).
"</span></td>";
2426 print
'<td class="right"><span class="amount">'.price($line->price_ttc).
"</span></td>";
2427 if (
$mysoc->localtax1_assuj ==
"1" ||
$mysoc->localtax2_assuj ==
"1") {
2428 print
'<td class="right">'.price($resultarray[2]).
'</td>';
2431 print
'<td class="right">'.price($line->price_min).
'</td>';
2432 print
'<td class="right">'.price($line->price_min_ttc).
'</td>';
2433 print
'<td class="right">'.dolPrintHTML($line->price_label).
'</td>';
2434 print
'<td class="right">'.price($line->discount_percent).
'</td>';
2437 print
'<td class="tdoverflowmax125">';
2439 if ($line->fk_user > 0) {
2440 $userstatic =
new User($db);
2441 $userstatic->fetch($line->fk_user);
2442 print $userstatic->getNomUrl(1,
'', 0, 0, 24, 0,
'login');
2446 print
"<td>".dol_print_date($line->datec,
"dayhour",
'tzuserrel').
"</td>";
2452 print $langs->trans(
'None');
2454 } elseif ($action !=
'showlog_default_price' && $action !=
'edit_price' && $action !=
'edit_level_price') {
2456 print
'<!-- list of all prices per customer -->'.
"\n";
2459 $nbtotalofrecords =
'';
2461 $nbtotalofrecords = $prodcustprice->fetchAll($sortorder, $sortfield, 0, 0, $filter);
2464 $result = $prodcustprice->fetchAll($sortorder, $sortfield,
$conf->liste_limit, $offset, $filter);
2466 setEventMessages($prodcustprice->error, $prodcustprice->errors,
'errors');
2469 $option =
'&search_soc='.$search_soc.
'&id='.
$object->id;
2472 print_barre_liste($langs->trans(
'PriceByCustomer'), $page, $_SERVER [
'PHP_SELF'], $option, $sortfield, $sortorder,
'', count($prodcustprice->lines), $nbtotalofrecords,
'title_accountancy.png');
2474 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'" method="POST">';
2475 print
'<input type="hidden" name="token" value="'.newToken().
'">';
2476 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
2478 print
'<!-- List of prices per customer -->'.
"\n";
2479 print
'<div class="div-table-responsive-no-min">'.
"\n";
2480 print
'<table class="liste centpercent">'.
"\n";
2482 if (count($prodcustprice->lines) > 0 || $search_soc) {
2483 $extrafields->fetch_name_optionals_label(
"product_customer_price");
2484 $custom_price_extralabels = !empty($extrafields->attributes[
"product_customer_price"][
'label']) ? $extrafields->attributes[
"product_customer_price"][
'label'] :
'';
2490 if (
$mysoc->localtax1_assuj ==
"1" ||
$mysoc->localtax2_assuj ==
"1") {
2493 if (!empty($custom_price_extralabels) && is_array($custom_price_extralabels)) {
2494 $colspan += count($custom_price_extralabels);
2497 print
'<tr class="liste_titre">';
2498 print
'<td class="liste_titre"><input type="text" class="flat maxwidth125" name="search_soc" value="'.$search_soc.
'"></td>';
2499 print
'<td class="liste_titre" colspan="'.$colspan.
'"> </td>';
2501 print
'<td class="liste_titre maxwidthsearch">';
2502 $searchpicto = $form->showFilterAndCheckAddButtons(0);
2508 print
'<tr class="liste_titre">';
2509 print
'<td>'.$langs->trans(
"ThirdParty").
'</td>';
2510 print
'<td>'.$langs->trans(
'RefCustomer').
'</td>';
2511 print
'<td>'.$langs->trans(
"AppliedPricesFrom").
'</td>';
2512 print
'<td>'.$langs->trans(
"AppliedPricesTo").
'</td>';
2513 print
'<td class="center">'.$langs->trans(
"PriceBase").
'</td>';
2514 print
'<td class="right">'.$langs->trans(
"DefaultTaxRate").
'</td>';
2515 print
'<td class="right">'.$langs->trans(
"HT").
'</td>';
2516 print
'<td class="right">'.$langs->trans(
"TTC").
'</td>';
2517 if (
$mysoc->localtax1_assuj ==
"1" ||
$mysoc->localtax2_assuj ==
"1") {
2518 print
'<td class="right">'.$langs->trans(
"INCT").
'</td>';
2520 print
'<td class="right">'.$langs->trans(
"MinPrice").
' '.$langs->trans(
"HT").
'</td>';
2521 print
'<td class="right">'.$langs->trans(
"MinPrice").
' '.$langs->trans(
"TTC").
'</td>';
2522 print
'<td class="right">'.$langs->trans(
"PriceLabel").
'</td>';
2523 print
'<td class="right">'.$langs->trans(
"Discount").
'</td>';
2525 $extrafields->fetch_name_optionals_label(
"product_customer_price");
2526 if ($extrafields->attributes[
"product_customer_price"] && array_key_exists(
'label', $extrafields->attributes[
"product_customer_price"])) {
2527 $extralabels = $extrafields->attributes[
"product_customer_price"][
'label'];
2528 if (!empty($extralabels)) {
2529 foreach ($extralabels as $key => $value) {
2531 if (!empty($extrafields->attributes[
"product_customer_price"][
'list'][$key]) && $extrafields->attributes[
"product_customer_price"][
'list'][$key] != 3) {
2532 if (!empty($extrafields->attributes[
"product_customer_price"][
'langfile'][$key])) {
2533 $langs->load($extrafields->attributes[
"product_customer_price"][
'langfile'][$key]);
2535 if (!empty($extrafields->attributes[
"product_customer_price"][
'help'][$key])) {
2536 $extratitle = $form->textwithpicto($langs->trans($value), $langs->trans($extrafields->attributes[
"product_customer_price"][
'help'][$key]));
2538 $extratitle = $langs->trans($value);
2540 print
'<td style="text-align: right">'.$extratitle.
'</td>';
2545 print
'<td>'.$langs->trans(
"ChangedBy").
'</td>';
2550 if (
$object->price_base_type ==
'HT') {
2559 $resultarray =
calcul_price_total(1, $pu, 0,
$object->tva_tx, 1, 1, 0,
$object->price_base_type, 0,
$object->type,
$mysoc, $localtaxarray);
2561 $total_ht = $resultarray[0];
2562 $total_vat = $resultarray[1];
2563 $total_localtax1 = $resultarray[9];
2564 $total_localtax2 = $resultarray[10];
2565 $total_ttc = $resultarray[2];
2568 print
'<!-- PRODUIT_CUSTOMER_PRICES_AND_MULTIPRICES -->'.
"\n";
2569 print
'<tr class="oddeven">';
2570 print
'<td colspan="4">' . $langs->trans(
'Default') .
'</td>';
2572 print
'<td class="center">'.$langs->trans(
$object->price_base_type).
"</td>";
2575 print
'<td class="right nowraponall">';
2577 $positiverates =
'';
2582 $positiverates .= ($positiverates ?
'/' :
'').
price2num(
$object->localtax1_tx);
2585 $positiverates .= ($positiverates ?
'/' :
'').
price2num(
$object->localtax2_tx);
2587 if (empty($positiverates)) {
2588 $positiverates =
'0';
2590 echo
vatrate($positiverates.($object->default_vat_code ?
' ('.$object->default_vat_code.
')' :
''), true,
$object->tva_npr);
2594 print
'<td class="right"><span class="amount">'.price(
$object->price).
"</span></td>";
2596 print
'<td class="right"><span class="amount">'.price(
$object->price_ttc).
"</span></td>";
2597 if (
$mysoc->localtax1_assuj ==
"1" ||
$mysoc->localtax2_assuj ==
"1") {
2599 print
'<td class="right"><span class="amount">'.price($resultarray[2]).
'</span></td>';
2602 print
'<td class="right">'.price(
$object->price_min).
'</td>';
2603 print
'<td class="right">'.price(
$object->price_min_ttc).
'</td>';
2604 print
'<td class="right">'.dolPrintHTML(
$object->price_label).
'</td>';
2605 print
'<td class="right"></td>';
2606 print
'<td class="right"></td>';
2607 if (!empty($extralabels)) {
2608 foreach ($extralabels as $key) {
2610 if (!empty($extrafields->attributes[
"product_customer_price"][
'list'][$key]) && $extrafields->attributes[
"product_customer_price"][
'list'][$key] != 3) {
2611 print
'<td class="right"></td>';
2615 if ($user->hasRight(
'produit',
'supprimer') || $user->hasRight(
'service',
'supprimer')) {
2616 print
'<td class="nowraponall">';
2617 print
'<a class="marginleftonly marginrightonly" href="'.$_SERVER[
"PHP_SELF"].
'?action=showlog_default_price&token='.
newToken().
'&id='.
$object->id.
'">';
2618 print img_info($langs->trans(
'PriceByCustomerLog'));
2621 print
'<a class="marginleftonly marginrightonly editfielda" href="'.$_SERVER[
"PHP_SELF"].
'?action=edit_price&token='.
newToken().
'&id='.
$object->id.
'">';
2622 print img_edit(
'default', 0,
'style="vertical-align: middle;"');
2629 if (count($prodcustprice->lines) > 0) {
2630 foreach ($prodcustprice->lines as $line) {
2632 $staticsoc =
new Societe($db);
2633 $staticsoc->fetch($line->fk_soc);
2635 $tva_tx = $line->default_vat_code ? $line->tva_tx.
' ('.$line->default_vat_code.
')' : $line->tva_tx;
2638 if ($line->price_base_type ==
'HT') {
2641 $pu = $line->price_ttc;
2645 $localtaxarray =
getLocalTaxesFromRate($line->tva_tx.($line->default_vat_code ?
' ('.$line->default_vat_code.
')' :
''), 0, $staticsoc,
$mysoc);
2647 $resultarray =
calcul_price_total(1, $pu, 0, (
float) $line->tva_tx, 1, 1, 0, $line->price_base_type, $line->recuperableonly,
$object->type,
$mysoc, $localtaxarray);
2649 $total_ht = $resultarray[0];
2650 $total_vat = $resultarray[1];
2651 $total_localtax1 = $resultarray[9];
2652 $total_localtax2 = $resultarray[10];
2653 $total_ttc = $resultarray[2];
2655 print
'<tr class="oddeven">';
2657 print
'<td class="tdoverflowmax125">'.$staticsoc->getNomUrl(1).
"</td>";
2658 print
'<td>'.dolPrintHTML($line->ref_customer).
'</td>';
2659 print
"<td>".dol_print_date($line->date_begin,
"day",
'tzuserrel').
"</td>";
2660 print
"<td>".dol_print_date($line->date_end,
"day",
'tzuserrel').
"</td>";
2661 print
'<td class="center">'.$langs->trans($line->price_base_type).
"</td>";
2663 print
'<td class="right nowraponall">';
2665 $positiverates =
'';
2667 $positiverates .= ($positiverates ?
'/' :
'').
price2num($line->tva_tx);
2670 $positiverates .= ($positiverates ?
'/' :
'').
price2num($line->localtax1_tx);
2673 $positiverates .= ($positiverates ?
'/' :
'').
price2num($line->localtax2_tx);
2675 if (empty($positiverates)) {
2676 $positiverates =
'0';
2679 echo
vatrate($positiverates.($line->default_vat_code ?
' ('.$line->default_vat_code.
')' :
''), true, $line->recuperableonly);
2683 print
'<td class="right"><span class="amount">'.price($line->price).
"</span></td>";
2685 print
'<td class="right"><span class="amount">'.price($line->price_ttc).
"</span></td>";
2686 if (
$mysoc->localtax1_assuj ==
"1" ||
$mysoc->localtax2_assuj ==
"1") {
2688 print
'<td class="right"><span class="amount">'.price($resultarray[2]).
'</span></td>';
2691 print
'<td class="right">'.price($line->price_min).
'</td>';
2692 print
'<td class="right">'.price($line->price_min_ttc).
'</td>';
2693 print
'<td class="right">'.dolPrintHTMLForAttribute($line->price_label).
'</td>';
2694 print
'<td class="right">'.price($line->discount_percent).
'</td>';
2697 $extrafields->fetch_name_optionals_label(
"product_customer_price");
2698 $extralabels = $extrafields->attributes[
"product_customer_price"][
'label'] ?? array();
2699 if (!empty($extralabels)) {
2701 $sql .=
" fk_object";
2702 foreach ($extralabels as $key => $value) {
2703 $sql .=
", ".$db->sanitize($key);
2705 $sql .=
" FROM ".MAIN_DB_PREFIX.
"product_customer_price_extrafields";
2706 $sql .=
" WHERE fk_object = ".((int) $line->id);
2707 $resql = $db->query($sql);
2710 $obj = ($db->num_rows($resql) == 1) ? $db->fetch_object($resql) :
null;
2711 foreach ($extralabels as $key => $value) {
2712 if (!empty($extrafields->attributes[
"product_customer_price"][
'list'][$key]) && $extrafields->attributes[
"product_customer_price"][
'list'][$key] != 3) {
2714 if (!empty($extrafields->attributes[
"product_customer_price"][
'computed'][$key])) {
2715 $objectoffield = $line;
2716 $extravalue =
dol_eval((
string) $extrafields->attributes[
"product_customer_price"][
'computed'][$key], 1, 1,
'2');
2717 print
'<td align="right">'.$extrafields->showOutputField($key, $extravalue,
'',
'product_customer_price').
"</td>";
2719 print
'<td align="right">'.$extrafields->showOutputField($key, $obj->{$key},
'',
'product_customer_price').
"</td>";
2730 print
'<td class="tdoverflowmax125">';
2731 if ($line->fk_user > 0) {
2732 $userstatic =
new User($db);
2733 $userstatic->fetch($line->fk_user);
2735 print $userstatic->getNomUrl(-1,
'', 0, 0, 24, 0,
'login');
2741 print
'<td class="right nowraponall">';
2742 if ($user->hasRight(
'produit',
'creer') || $user->hasRight(
'service',
'creer')) {
2743 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=showlog_customer_price&token='.
newToken().
'&id='.
$object->id.
'&socid='.$line->fk_soc.
'">';
2744 print img_info($langs->trans(
'PriceByCustomerLog'));
2747 print
'<a class="marginleftonly editfielda" href="'.$_SERVER[
"PHP_SELF"].
'?action=edit_customer_price&token='.
newToken().
'&id='.
$object->id.
'&lineid='.$line->id.
'">';
2748 print img_edit(
'default', 0,
'style="vertical-align: middle;"');
2752 if ($user->hasRight(
'produit',
'supprimer') || $user->hasRight(
'service',
'supprimer')) {
2753 print
'<a class="marginleftonly" href="'.$_SERVER[
"PHP_SELF"].
'?action=ask_remove_customer_price&token='.
newToken().
'&id='.
$object->id.
'&lineid='.$line->id.
'">';
2754 print img_delete(
'default',
'style="vertical-align: middle;"');
2772if ((!
getDolGlobalString(
'PRODUIT_CUSTOMER_PRICES') || $action ==
'showlog_default_price') && !in_array($action, array(
'edit_price',
'edit_level_price',
'edit_vat'))) {
2773 $sql =
"SELECT p.rowid, p.price, p.price_ttc, p.price_base_type, p.tva_tx, p.default_vat_code, p.recuperableonly, p.localtax1_tx, p.localtax1_type, p.localtax2_tx, p.localtax2_type,";
2774 $sql .=
" p.price_level, p.price_min, p.price_min_ttc,p.price_by_qty,";
2775 $sql .=
" p.date_price as dp, p.fk_price_expression, u.rowid as user_id, u.login";
2776 $sql .=
" ,p.price_label";
2777 $sql .=
" FROM ".MAIN_DB_PREFIX.
"product_price as p,";
2778 $sql .=
" ".MAIN_DB_PREFIX.
"user as u";
2779 $sql .=
" WHERE fk_product = ".((int)
$object->id);
2780 $sql .=
" AND p.entity IN (".getEntity(
'productprice').
")";
2781 $sql .=
" AND p.fk_user_author = u.rowid";
2783 $sql .=
" AND p.price_level = ".((int) $soc->price_level);
2785 $sql .=
" ORDER BY p.date_price DESC, p.rowid DESC, p.price_level ASC";
2789 $result = $db->query($sql);
2791 print
'<div class="divlogofpreviouscustomerprice">';
2793 $num = $db->num_rows($result);
2802 $ret =
$object->updatePrice((
$object->multiprices_base_type[1] ==
'TTC' ?
$object->multiprices_ttc[1] :
$object->multiprices[1]),
$object->multiprices_base_type[1], $user, (empty(
$object->multiprices_tva_tx[1]) ? 0 :
$object->multiprices_tva_tx[1]), (
$object->multiprices_base_type[1] ==
'TTC' ?
$object->multiprices_min_ttc[1] :
$object->multiprices_min[1]), 1, 0, 0, 0, array(),
$object->default_vat_code);
2804 $ret =
$object->updatePrice((
$object->price_base_type ==
'TTC' ?
$object->price_ttc :
$object->
price),
$object->price_base_type, $user,
$object->tva_tx, (
$object->price_base_type ==
'TTC' ?
$object->price_min_ttc :
$object->price_min), 0,
$object->tva_npr, 0, 0, array(),
$object->default_vat_code);
2810 $result = $db->query($sql);
2811 $num = $db->num_rows($result);
2818 $backbutton =
'<a class="justalink" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'">'.$langs->trans(
"GoBack").
'</a>';
2822 print_barre_liste($langs->trans(
"DefaultPriceLog"), 0, $_SERVER[
"PHP_SELF"],
'',
'',
'', $backbutton, 0, $num,
'title_accountancy.png');
2825 print_barre_liste($langs->trans(
"PriceByCustomerLog"), 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', 0, $num,
'title_accountancy.png');
2828 print
'<!-- List of log prices -->'.
"\n";
2829 print
'<div class="div-table-responsive">'.
"\n";
2830 print
'<table class="liste centpercent noborder">'.
"\n";
2832 print
'<tr class="liste_titre">';
2833 print
'<th>'.$langs->trans(
"AppliedPricesFrom").
'</tg>';
2836 print
'<th class="center">'.$langs->trans(
"PriceLevel").
'</th>';
2839 print
'<th class="center">'.$langs->trans(
"Type").
'</th>';
2842 print
'<th class="center">'.$langs->trans(
"PriceBase").
'</th>';
2844 print
'<th class="right">'.$langs->trans(
"DefaultTaxRate").
'</th>';
2846 print
'<th class="right">'.$langs->trans(
"HT").
'</th>';
2847 print
'<th class="right">'.$langs->trans(
"TTC").
'</th>';
2848 if (
$mysoc->localtax1_assuj ==
"1" ||
$mysoc->localtax2_assuj ==
"1") {
2849 print
'<th class="right">'.$langs->trans(
"INCT").
'</th>';
2852 print
'<th class="right">'.$langs->trans(
"PriceExpressionSelected").
'</th>';
2854 print
'<th class="right">'.$langs->trans(
"MinPrice").
' '.$langs->trans(
"HT").
'</th>';
2855 print
'<th class="right">'.$langs->trans(
"MinPrice").
' '.$langs->trans(
"TTC").
'</th>';
2856 print
'<th class="right">'.$langs->trans(
"Label").
'</th>';
2857 print
'<th>'.$langs->trans(
"ChangedBy").
'</th>';
2858 if ($user->hasRight(
'produit',
'supprimer')) {
2859 print
'<th class="right"> </th>';
2863 $notfirstlineforlevel = array();
2867 $objp = $db->fetch_object($result);
2869 print
'<tr class="oddeven">';
2871 print
"<td>".dol_print_date($db->jdate($objp->dp),
"dayhour",
'tzuserrel').
"</td>";
2875 print
'<td class="center">'.$objp->price_level.
"</td>";
2879 $type = ($objp->price_by_qty == 1) ?
'PriceByQuantity' :
'Standard';
2880 print
'<td class="center">'.$langs->trans($type).
"</td>";
2883 print
'<td class="center">';
2884 if (empty($objp->price_by_qty)) {
2885 print $langs->trans($objp->price_base_type);
2890 print
'<td class="right">';
2892 if (empty($objp->price_by_qty)) {
2893 $positiverates =
'';
2895 $positiverates .= ($positiverates ?
'/' :
'').
price2num($objp->tva_tx);
2898 $positiverates .= ($positiverates ?
'/' :
'').
price2num($objp->localtax1_tx);
2901 $positiverates .= ($positiverates ?
'/' :
'').
price2num($objp->localtax2_tx);
2903 if (empty($positiverates)) {
2904 $positiverates =
'0';
2906 echo
vatrate($positiverates.($objp->default_vat_code ?
' ('.$objp->default_vat_code.
')' :
''), true, !empty($objp->tva_npr) ? $objp->tva_npr : 0);
2919 if ($objp->price_base_type ==
'HT') {
2922 $pu = $objp->price_ttc;
2928 $resultarray =
calcul_price_total(1, $pu, 0, $objp->tva_tx, 1, 1, 0, $objp->price_base_type, $objp->recuperableonly,
$object->type,
$mysoc, $localtaxarray);
2930 $total_ht = $resultarray[0];
2931 $total_vat = $resultarray[1];
2932 $total_localtax1 = $resultarray[9];
2933 $total_localtax2 = $resultarray[10];
2934 $total_ttc = $resultarray[2];
2937 if (!empty($objp->fk_price_expression) && !empty(
$conf->dynamicprices->enabled)) {
2939 $res = $price_expression->fetch($objp->fk_price_expression);
2940 $title = $price_expression->title;
2941 print
'<td class="right"></td>';
2942 print
'<td class="right"></td>';
2943 if (
$mysoc->localtax1_assuj ==
"1" ||
$mysoc->localtax2_assuj ==
"1") {
2944 print
'<td class="right"></td>';
2946 print
'<td class="right">'.$title.
"</td>";
2949 print
'<td class="right">';
2950 if (empty($objp->price_by_qty)) {
2951 print
'<span class="amount">'.price($objp->price).
'</span>';
2955 print
'<td class="right">';
2956 if (empty($objp->price_by_qty)) {
2957 $price_ttc = $objp->price_ttc;
2958 print
'<span class="amount">'.price($price_ttc).
'<span>';
2961 if (
$mysoc->localtax1_assuj ==
"1" ||
$mysoc->localtax2_assuj ==
"1") {
2962 print
'<td class="right">';
2963 print $resultarray[2];
2967 print
'<td class="right"></td>';
2972 print
'<td class="right">';
2973 if (empty($objp->price_by_qty)) {
2974 print
price($objp->price_min);
2979 print
'<td class="right">';
2980 if (empty($objp->price_by_qty)) {
2981 $price_min_ttc = $objp->price_min_ttc;
2982 print
price($price_min_ttc);
2988 print dolPrintHTML($objp->price_label);
2992 print
'<td class="tdoverflowmax125">';
2993 if ($objp->user_id > 0) {
2995 $userstatic =
new User($db);
2996 $userstatic->fetch($objp->user_id);
2997 print $userstatic->getNomUrl(-1,
'', 0, 0, 24, 0,
'login');
3002 if ($user->hasRight(
'produit',
'supprimer')) {
3005 if (empty($notfirstlineforlevel[$objp->price_level])) {
3006 $notfirstlineforlevel[$objp->price_level] = 1;
3014 print
'<td class="right">';
3015 if ($candelete || ($db->jdate($objp->dp) >=
dol_now())) {
3016 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=delete&token='.
newToken().
'&id='.
$object->id.
'&lineid='.$objp->rowid.
'">';
3037 dol_print_error($db);
$id
Support class for third parties, contacts, members, users or resources.
if(! $sortfield) if(! $sortorder) $object
$propal type
'integer', 'integer:ObjectClass:PathToClass[:AddCreateButtonOrNot[:Filter[:Sortfield]]]',...
dolibarr_set_const($db, $name, $value, $type='chaine', $visible=0, $note='', $entity=1)
Insert a parameter (key,value) into database (delete old key then insert it again).
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
Class of a generic business object.
Class for accessing price expression table.
Class to parse product price expressions.
File of class to manage predefined price products or services by customer.
Class to manage products or services.
const TYPE_PRODUCT
Regular product.
const TYPE_SERVICE
Service.
Class to manage third parties objects (customers, suppliers, prospects...)
Class to manage Dolibarr users.
dol_now($mode='gmt')
Return date for now.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed information (by default a local PHP server timestamp) Rep...
vatrate($rate, $addpercent=false, $info_bits=0, $usestarfornpr=0, $html=0)
Return a string with VAT rate label formatted for view output Used into pdf and HTML pages.
price2num($amount, $rounding='', $option=0, $currencycode='')
Function that return a number with universal decimal format (decimal separator is '.
dol_eval($s, $returnvalue=1, $hideerrors=1, $onlysimplestring='1')
Replace eval function to add more security.
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.
getLocalTaxesFromRate($vatrate, $local, $buyer, $seller, $firstparamisid=0)
Get type and rate of localtaxes for a particular vat rate/country of a thirdparty.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0, $nodefault=0)
Return value of a param into GET or POST supervariable.
GETPOSTINT($paramname, $method=0, $nodefault=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_clone($srcobject, $native=2)
Create a clone of instance of object (new instance with same value for each properties) With native =...
dol_trunc($string, $size=40, $trunc='right', $stringencoding='UTF-8', $nodot=0, $display=0)
Truncate a string to a particular length adding '...' if string larger than length.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
get_localtax($vatrate, $local, $thirdparty_buyer=null, $thirdparty_seller=null, $vatnpr=0)
Return localtax rate for a particular VAT rate, when selling a product with vat $vatrate,...
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0, $morecssdiv='')
Show tabs of a record.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
calcul_price_total($qty, $pu, $remise_percent_ligne, $txtva, $uselocaltax1_rate, $uselocaltax2_rate, $notused, $price_base_type, $info_bits, $type, $seller=null, $localtaxes_array=[], $progress=100, $multicurrency_tx=1, $pu_devise=0, $multicurrency_code='')
Calculate totals (net, vat, ...) of a line.
product_prepare_head($object)
Prepare array with list of tabs.
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $nodie=0, $mode='')
Check permissions of a user to show a page and an object.