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;
115 $permissiontoadd =
$object->getRights()->creer;
117 $permissiontoadd = ($user->hasRight(
'produit',
'creer') || $user->hasRight(
'service',
'creer'));
129$parameters = array(
'id' => $id,
'ref' => $ref);
130$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
135if (empty($reshook)) {
136 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
140 if ($action ==
'setlabelsellingprice' && $user->admin) {
141 require_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
142 $keyforlabel =
'PRODUIT_MULTIPRICES_LABEL'.GETPOST(
'pricelevel');
147 if (($action ==
'update_vat') && !$cancel && $permissiontoadd) {
148 $tva_tx_txt =
GETPOST(
'tva_tx',
'alpha');
150 $price_label =
GETPOST(
'price_label',
'alpha');
153 $tva_tx = $tva_tx_txt;
156 if (preg_match(
'/\((.*)\)/', $tva_tx_txt, $reg)) {
157 $vatratecode = $reg[1];
158 $tva_tx = preg_replace(
'/\s*\(.*\)/',
'', $tva_tx_txt);
161 $tva_tx =
price2num(preg_replace(
'/\*/',
'', $tva_tx));
162 $npr = preg_match(
'/\*/', $tva_tx_txt) ? 1 : 0;
165 $localtax1_type =
'0';
166 $localtax2_type =
'0';
169 if (preg_match(
'/\((.*)\)/', $tva_tx_txt, $reg)) {
171 $vatratecode = $reg[1];
173 $sql =
"SELECT t.rowid, t.type_vat, t.code, t.recuperableonly, t.localtax1, t.localtax2, t.localtax1_type, t.localtax2_type";
174 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_tva as t, ".MAIN_DB_PREFIX.
"c_country as c";
175 $sql .=
" WHERE t.fk_pays = c.rowid AND c.code = '".$db->escape(
$mysoc->country_code).
"'";
176 $sql .=
" AND t.taux = ".((float) $tva_tx).
" AND t.active = 1";
177 $sql .=
" AND t.code = '".$db->escape($vatratecode).
"'";
178 $sql .=
" AND t.type_vat IN (0, 1)";
179 $sql .=
" AND t.entity IN (".getEntity(
'c_tva').
")";
180 $resql =
$db->query($sql);
182 $obj =
$db->fetch_object($resql);
184 $npr = $obj->recuperableonly;
185 $localtax1 = $obj->localtax1;
186 $localtax2 = $obj->localtax2;
187 $localtax1_type = $obj->localtax1_type;
188 $localtax2_type = $obj->localtax2_type;
193 $sql =
"SELECT t.rowid, t.code, t.recuperableonly, t.localtax1, t.localtax2, t.localtax1_type, t.localtax2_type";
194 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_tva as t, ".MAIN_DB_PREFIX.
"c_country as c";
195 $sql .=
" WHERE t.fk_pays = c.rowid AND c.code = '".$db->escape(
$mysoc->country_code).
"'";
196 $sql .=
" AND t.taux = ".((float) $tva_tx).
" AND t.active = 1";
197 $sql .=
" AND t.code = ''";
198 $sql .=
" AND t.entity IN (".getEntity(
'c_tva').
")";
199 $resql =
$db->query($sql);
201 $obj =
$db->fetch_object($resql);
203 $npr = $obj->recuperableonly;
204 $localtax1 = $obj->localtax1;
205 $localtax2 = $obj->localtax2;
206 $localtax1_type = $obj->localtax1_type;
207 $localtax2_type = $obj->localtax2_type;
212 $object->default_vat_code = $vatratecode;
215 $object->localtax1_tx = $localtax1;
216 $object->localtax2_tx = $localtax2;
217 $object->localtax1_type = $localtax1_type;
218 $object->localtax2_type = $localtax2_type;
219 $object->price_label = $price_label;
231 $produit_multiprices_limit =
getDolGlobalInt(
'PRODUIT_MULTIPRICES_LIMIT');
232 for ($i = 1; $i <= $produit_multiprices_limit; $i++) {
234 if (
$object->multiprices_base_type[$i] ==
'HT') {
235 $oldprice =
$object->multiprices[$i];
236 $oldminprice =
$object->multiprices_min[$i];
238 $oldprice =
$object->multiprices_ttc[$i];
239 $oldminprice =
$object->multiprices_min_ttc[$i];
241 $oldpricebasetype =
$object->multiprices_base_type[$i];
242 $oldnpr =
$object->multiprices_recuperableonly[$i];
245 $localtaxarray = array();
247 $ret =
$object->updatePrice($oldprice, $oldpricebasetype, $user, (
float) $tva_tx, $oldminprice, $level, $oldnpr, 0, 0, $localtaxarray, $vatratecode, $price_label);
256 if (
$object->price_base_type ==
'HT') {
258 $oldminprice =
$object->price_min;
260 $oldprice =
$object->price_ttc;
261 $oldminprice =
$object->price_min_ttc;
263 $oldpricebasetype =
$object->price_base_type;
267 $localtaxarray = array();
269 $ret =
$object->updatePrice($oldprice, $oldpricebasetype, $user, (
float) $tva_tx, $oldminprice, $level, $oldnpr, 0, 0, $localtaxarray, $vatratecode, $price_label);
287 $maxpricesupplier = 0;
289 if (($action ==
'update_price' || $action ==
'update_level_price') && !$cancel && $permissiontoadd) {
291 $pricestoupdate = array();
296 $maxpricesupplier =
$object->min_recommended_price();
302 $object->fk_price_expression = empty($eid) ? 0 : $eid;
304 if (
$object->fk_price_expression != 0) {
306 require_once DOL_DOCUMENT_ROOT.
'/product/dynamic_price/class/price_parser.class.php';
309 if ($priceparser->parseProduct($object) < 0) {
318 || ($action ==
'update_level_price' &&
getDolGlobalString(
'PRODUIT_CUSTOMER_PRICES_AND_MULTIPRICES')))) {
319 $newprice =
GETPOST(
'price',
'array');
320 $newprice_min =
GETPOST(
'price_min',
'array');
321 $newpricebase =
GETPOST(
'multiprices_base_type',
'array');
322 $newvattx =
GETPOST(
'tva_tx',
'array');
323 $newvatnpr =
GETPOST(
'tva_npr',
'array');
324 $newlocaltax1_tx =
GETPOST(
'localtax1_tx',
'array');
325 $newlocaltax1_type =
GETPOST(
'localtax1_type',
'array');
326 $newlocaltax2_tx =
GETPOST(
'localtax2_tx',
'array');
327 $newlocaltax2_type =
GETPOST(
'localtax2_type',
'array');
330 $object->price_autogen = (int) (
GETPOST(
'usePriceRules') ==
'on');
332 $produit_multiprices_limit =
getDolGlobalInt(
'PRODUIT_MULTIPRICES_LIMIT');
333 for ($i = 1; $i <= $produit_multiprices_limit; $i++) {
334 if (!isset($newprice[$i])) {
338 $tva_tx_txt = $newvattx[$i];
340 $tva_tx = $tva_tx_txt;
343 if (preg_match(
'/\((.*)\)/', $tva_tx_txt, $reg)) {
344 $vat_src_code = $reg[1];
345 $tva_tx = preg_replace(
'/\s*\(.*\)/',
'', $tva_tx_txt);
347 $tva_tx =
price2num(preg_replace(
'/\*/',
'', $tva_tx));
349 $npr = preg_match(
'/\*/', $tva_tx_txt) ? 1 : 0;
350 $localtax1 = $newlocaltax1_tx[$i];
351 $localtax1_type = $newlocaltax1_type[$i];
352 $localtax2 = $newlocaltax2_tx[$i];
353 $localtax2_type = $newlocaltax2_type[$i];
354 if (preg_match(
'/\((.*)\)/', $tva_tx_txt, $reg)) {
356 $vatratecode = $reg[1];
358 $sql =
"SELECT t.rowid, t.code, t.recuperableonly, t.localtax1, t.localtax2, t.localtax1_type, t.localtax2_type";
359 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_tva as t, ".MAIN_DB_PREFIX.
"c_country as c";
360 $sql .=
" WHERE t.fk_pays = c.rowid AND c.code = '".$db->escape(
$mysoc->country_code).
"'";
361 $sql .=
" AND t.taux = ".((float) $tva_tx).
" AND t.active = 1";
362 $sql .=
" AND t.code ='".$db->escape($vatratecode).
"'";
363 $sql .=
" AND t.entity IN (".getEntity(
'c_tva').
")";
364 $resql =
$db->query($sql);
366 $obj =
$db->fetch_object($resql);
368 $npr = $obj->recuperableonly;
369 $localtax1 = $obj->localtax1;
370 $localtax2 = $obj->localtax2;
371 $localtax1_type = $obj->localtax1_type;
372 $localtax2_type = $obj->localtax2_type;
376 if (in_array(
$mysoc->country_code, array(
'ES'))) {
383 $sql =
"SELECT t.rowid, t.code, t.recuperableonly, t.localtax1, t.localtax2, t.localtax1_type, t.localtax2_type";
384 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_tva as t, ".MAIN_DB_PREFIX.
"c_country as c";
385 $sql .=
" WHERE t.fk_pays = c.rowid AND c.code = '".$db->escape(
$mysoc->country_code).
"'";
386 $sql .=
" AND t.taux = ".((float) $tva_tx).
" AND t.active = 1";
387 $sql .=
" AND t.code = ''";
388 $resql =
$db->query($sql);
390 $obj =
$db->fetch_object($resql);
392 $npr = $obj->recuperableonly;
393 $localtax1 = $obj->localtax1;
394 $localtax2 = $obj->localtax2;
395 $localtax1_type = $obj->localtax1_type;
396 $localtax2_type = $obj->localtax2_type;
401 $pricestoupdate[$i] = array(
403 'price' =>
price2num($newprice[$i],
'', 2),
404 'price_min' =>
price2num($newprice_min[$i],
'', 2),
405 'price_base_type' => $newpricebase[$i],
406 'default_vat_code' => $vatratecode,
409 'localtaxes_array' => array(
'0' => $localtax1_type,
'1' => $localtax1,
'2' => $localtax2_type,
'3' => $localtax2)
420 $newpricebase =
GETPOST(
'price_base_type',
'alpha');
421 $tva_tx_txt =
GETPOST(
'tva_tx',
'alpha');
422 $price_label =
GETPOST(
'price_label',
'alpha');
424 $tva_tx = $tva_tx_txt;
427 if (preg_match(
'/\((.*)\)/', $tva_tx_txt, $reg)) {
428 $vat_src_code = $reg[1];
429 $tva_tx = preg_replace(
'/\s*\(.*\)/',
'', $tva_tx_txt);
431 $tva_tx =
price2num(preg_replace(
'/\*/',
'', $tva_tx));
433 $npr = preg_match(
'/\*/', $tva_tx_txt) ? 1 : 0;
436 $localtax1_type =
'0';
437 $localtax2_type =
'0';
439 if (preg_match(
'/\((.*)\)/', $tva_tx_txt, $reg)) {
441 $vatratecode = $reg[1];
443 $sql =
"SELECT t.rowid, t.code, t.recuperableonly, t.localtax1, t.localtax2, t.localtax1_type, t.localtax2_type";
444 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_tva as t, ".MAIN_DB_PREFIX.
"c_country as c";
445 $sql .=
" WHERE t.fk_pays = c.rowid AND c.code = '".$db->escape(
$mysoc->country_code).
"'";
446 $sql .=
" AND t.taux = ".((float) $tva_tx).
" AND t.active = 1";
447 $sql .=
" AND t.code ='".$db->escape($vatratecode).
"'";
448 $sql .=
" AND t.entity IN (".getEntity(
'c_tva').
")";
449 $resql =
$db->query($sql);
451 $obj =
$db->fetch_object($resql);
453 $npr = $obj->recuperableonly;
454 $localtax1 = $obj->localtax1;
455 $localtax2 = $obj->localtax2;
456 $localtax1_type = $obj->localtax1_type;
457 $localtax2_type = $obj->localtax2_type;
461 if (in_array(
$mysoc->country_code, array(
'ES'))) {
468 $sql =
"SELECT t.rowid, t.code, t.recuperableonly, t.localtax1, t.localtax2, t.localtax1_type, t.localtax2_type";
469 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_tva as t, ".MAIN_DB_PREFIX.
"c_country as c";
470 $sql .=
" WHERE t.fk_pays = c.rowid AND c.code = '".$db->escape(
$mysoc->country_code).
"'";
471 $sql .=
" AND t.taux = ".((float) $tva_tx).
" AND t.active = 1";
472 $sql .=
" AND t.code = ''";
473 $resql =
$db->query($sql);
475 $obj =
$db->fetch_object($resql);
477 $npr = $obj->recuperableonly;
478 $localtax1 = $obj->localtax1;
479 $localtax2 = $obj->localtax2;
480 $localtax1_type = $obj->localtax1_type;
481 $localtax2_type = $obj->localtax2_type;
486 $pricestoupdate[0] = array(
487 'price' => $newprice,
488 'price_label' => $price_label,
489 'price_min' => $newprice_min,
490 'price_base_type' => $newpricebase,
491 'default_vat_code' => $vatratecode,
494 'localtaxes_array' => array(
'0' => $localtax1_type,
'1' => $localtax1,
'2' => $localtax2_type,
'3' => $localtax2)
503 $object->packaging = (float) $packaging;
506 foreach ($pricestoupdate as $key => $val) {
507 $newprice = $val[
'price'];
509 if ($val[
'price'] < $val[
'price_min'] && !empty(
$object->fk_price_expression)) {
510 $newprice = $val[
'price_min'];
514 $newprice_min =
price2num($val[
'price_min'],
'MU');
517 if (
getDolGlobalString(
'PRODUCT_MINIMUM_RECOMMENDED_PRICE') && $newprice_min < $maxpricesupplier) {
518 setEventMessages($langs->trans(
"MinimumPriceLimit",
price($maxpricesupplier, 0,
'', 1, - 1, - 1,
'auto')),
null,
'errors');
523 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) {
524 $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']);
536 $price_extralabels = $extrafields->fetch_name_optionals_label(
"product_price");
538 $sql =
"SELECT rowid";
539 $sql .=
" FROM ".$object->db->prefix().
"product_price";
540 $sql .=
" WHERE entity IN (".getEntity(
'productprice').
")";
541 $sql .=
" AND price_level=".((int) $key);
542 $sql .=
" AND fk_product = ".((int)
$object->id);
543 $sql .=
" ORDER BY date_price DESC, rowid DESC";
545 $resql =
$object->db->query($sql);
547 $lineid =
$object->db->fetch_object($resql);
550 if (!empty($lineid->rowid)) {
551 require_once DOL_DOCUMENT_ROOT .
'/core/class/genericobject.class.php';
554 $genericObject->id = $lineid->rowid;
555 $genericObject->table_element =
'product_price';
556 foreach ($price_extralabels as $code => $label) {
557 $extrafield_values = $extrafields->getOptionalsFromPost(
'product_price', (
string) $key);
558 $genericObject->array_options[
'options_'.$code] = $extrafield_values[
'options_'.$code];
560 $result = $genericObject->insertExtraFields();
581 $action =
'edit_price';
587 if ($action ==
'delete' && $user->hasRight(
'produit',
'supprimer')) {
595 if ($action ==
'activate_price_by_qty' && $permissiontoadd) {
600 $ret =
$object->updatePrice($basePrice,
$object->price_base_type, $user,
$object->tva_tx, $basePriceMin, $level,
$object->tva_npr, 1, 0, array(),
$object->default_vat_code);
607 if ($action ==
'disable_price_by_qty' && $permissiontoadd) {
612 $ret =
$object->updatePrice($basePrice,
$object->price_base_type, $user,
$object->tva_tx, $basePriceMin, $level,
$object->tva_npr, 0, 0, array(),
$object->default_vat_code);
619 if ($action ==
'edit_price_by_qty') {
624 if ($action ==
'update_price_by_qty' && $permissiontoadd) {
634 if (empty($quantity)) {
636 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Qty")),
null,
'errors');
638 if (empty($newprice)) {
640 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Price")),
null,
'errors');
644 if (
$object->price_base_type ==
'TTC') {
649 $unitPrice =
price2num((
float) $price / (
float) $quantity,
'MU');
653 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"product_price_by_qty SET";
654 $sql .=
" price=".((float) $price).
",";
655 $sql .=
" unitprice=".((float) $unitPrice).
",";
656 $sql .=
" quantity=".((float) $quantity).
",";
657 $sql .=
" remise_percent=".((float) $remise_percent).
",";
658 $sql .=
" remise=".((float) $remise);
659 $sql .=
" WHERE rowid = ".((int) $rowid);
661 $result =
$db->query($sql);
666 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"product_price_by_qty (fk_product_price,price,unitprice,quantity,remise_percent,remise) values (";
667 $sql .= ((int) $priceid).
','.((float) $price).
','.((float) $unitPrice).
','.((float) $quantity).
','.((float) $remise_percent).
','.((float) $remise).
')';
669 $result =
$db->query($sql);
671 if (
$db->lasterrno() ==
'DB_ERROR_RECORD_ALREADY_EXISTS') {
681 if ($action ==
'delete_price_by_qty' && $permissiontoadd) {
683 if (!empty($rowid)) {
684 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"product_price_by_qty";
685 $sql .=
" WHERE rowid = ".((int) $rowid);
687 $result =
$db->query($sql);
689 setEventMessages((
'delete_price_by_qty'.$langs->transnoentities(
'MissingIds')),
null,
'errors');
693 if ($action ==
'delete_all_price_by_qty' && $permissiontoadd) {
695 if (!empty($priceid)) {
696 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"product_price_by_qty";
697 $sql .=
" WHERE fk_product_price = ".((int) $priceid);
699 $result =
$db->query($sql);
701 setEventMessages((
'delete_price_by_qty'.$langs->transnoentities(
'MissingIds')),
null,
'errors');
710 if ($action ==
'add_customer_price_confirm' && !$cancel && $prodcustprice !==
null && ($user->hasRight(
'produit',
'creer') || $user->hasRight(
'service',
'creer'))) {
711 $maxpricesupplier =
$object->min_recommended_price();
713 $update_child_soc =
GETPOSTINT(
'updatechildprice');
717 $prodcustprice->ref_customer =
GETPOST(
'ref_customer',
'alpha');
718 $prodcustprice->fk_product =
$object->id;
721 $prodcustprice->price_base_type =
GETPOST(
"price_base_type",
'alpha');
722 $prodcustprice->price_label =
GETPOST(
"price_label",
'alpha');
727 $extralabels = $extrafields->fetch_name_optionals_label(
"product_customer_price");
728 $extrafield_values = $extrafields->getOptionalsFromPost(
"product_customer_price");
730 $tva_tx_txt =
GETPOST(
"tva_tx",
'alpha');
732 $tva_tx = $tva_tx_txt;
734 if (preg_match(
'/\((.*)\)/', $tva_tx_txt, $reg)) {
735 $vat_src_code = $reg[1];
736 $tva_tx = preg_replace(
'/\s*\(.*\)/',
'', $tva_tx_txt);
738 $tva_tx =
price2num(preg_replace(
'/\*/',
'', $tva_tx));
740 $npr = preg_match(
'/\*/', $tva_tx_txt) ? 1 : 0;
743 $localtax1_type =
'0';
744 $localtax2_type =
'0';
746 if (preg_match(
'/\((.*)\)/', $tva_tx_txt, $reg)) {
748 $vatratecode = $reg[1];
750 $sql =
"SELECT t.rowid, t.code, t.recuperableonly, t.localtax1, t.localtax2, t.localtax1_type, t.localtax2_type";
751 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_tva as t, ".MAIN_DB_PREFIX.
"c_country as c";
752 $sql .=
" WHERE t.fk_pays = c.rowid AND c.code = '".$db->escape(
$mysoc->country_code).
"'";
753 $sql .=
" AND t.taux = ".((float) $tva_tx).
" AND t.active = 1";
754 $sql .=
" AND t.code ='".$db->escape($vatratecode).
"'";
755 $sql .=
" AND t.entity IN (".getEntity(
'c_tva').
")";
756 $resql =
$db->query($sql);
758 $obj =
$db->fetch_object($resql);
760 $npr = $obj->recuperableonly;
761 $localtax1 = $obj->localtax1;
762 $localtax2 = $obj->localtax2;
763 $localtax1_type = $obj->localtax1_type;
764 $localtax2_type = $obj->localtax2_type;
768 if (in_array(
$mysoc->country_code, array(
'ES'))) {
775 $sql =
"SELECT t.rowid, t.code, t.recuperableonly, t.localtax1, t.localtax2, t.localtax1_type, t.localtax2_type";
776 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_tva as t, ".MAIN_DB_PREFIX.
"c_country as c";
777 $sql .=
" WHERE t.fk_pays = c.rowid AND c.code = '".$db->escape(
$mysoc->country_code).
"'";
778 $sql .=
" AND t.taux = ".((float) $tva_tx).
" AND t.active = 1";
779 $sql .=
" AND t.code = ''";
780 $resql =
$db->query($sql);
782 $obj =
$db->fetch_object($resql);
784 $npr = $obj->recuperableonly;
785 $localtax1 = $obj->localtax1;
786 $localtax2 = $obj->localtax2;
787 $localtax1_type = $obj->localtax1_type;
788 $localtax2_type = $obj->localtax2_type;
793 $prodcustprice->default_vat_code = $vatratecode;
794 $prodcustprice->tva_tx = $tva_tx;
795 $prodcustprice->recuperableonly = $npr;
796 $prodcustprice->localtax1_tx = $localtax1;
797 $prodcustprice->localtax2_tx = $localtax2;
798 $prodcustprice->localtax1_type = $localtax1_type;
799 $prodcustprice->localtax2_type = $localtax2_type;
801 if (!($prodcustprice->fk_soc > 0)) {
802 $langs->load(
"errors");
803 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"ThirdParty")),
null,
'errors');
805 $action =
'add_customer_price';
807 if (
getDolGlobalString(
'PRODUCT_MINIMUM_RECOMMENDED_PRICE') && $prodcustprice->price_min < (
float) $maxpricesupplier) {
808 $langs->load(
"errors");
809 setEventMessages($langs->trans(
"MinimumPriceLimit",
price((
float) $maxpricesupplier, 0,
'', 1, -1, -1,
'auto')),
null,
'errors');
811 $action =
'add_customer_price';
816 $result = $prodcustprice->create($user, 0, $update_child_soc);
818 if (!empty($extrafield_values) && is_array($extrafield_values)) {
820 $res = $productcustomerprice->fetch($prodcustprice->id);
822 foreach ($extrafield_values as $key => $value) {
823 $productcustomerprice->array_options[$key] = $value;
825 $result2 = $productcustomerprice->insertExtraFields();
827 $prodcustprice->error = $productcustomerprice->error;
828 $prodcustprice->errors = $productcustomerprice->errors;
837 $action =
'add_customer_price';
845 if ($action ==
'confirm_remove_customer_price' && $prodcustprice !==
null && ($user->hasRight(
'produit',
'supprimer') || $user->hasRight(
'service',
'supprimer'))) {
847 $update_child_soc =
GETPOSTINT(
'updatechildprice');
850 $result = $prodcustprice->delete($user, 0, $update_child_soc);
853 $db->query(
"DELETE FROM ".MAIN_DB_PREFIX.
"product_customer_price_extrafields WHERE fk_object = ".((
int) $prodcustprice->id));
868 if ($action ==
'update_customer_price_confirm' && !$cancel && $prodcustprice !==
null && ($user->hasRight(
'produit',
'creer') || $user->hasRight(
'service',
'creer'))) {
869 $maxpricesupplier =
$object->min_recommended_price();
871 $update_child_soc =
GETPOSTINT(
'updatechildprice');
876 $prodcustprice->ref_customer =
GETPOST(
'ref_customer',
'alpha');
879 $prodcustprice->price_base_type =
GETPOST(
"price_base_type",
'alpha');
880 $prodcustprice->price_label =
GETPOST(
"price_label",
'alpha');
885 $extralabels = $extrafields->fetch_name_optionals_label(
"product_customer_price");
886 $extrafield_values = $extrafields->getOptionalsFromPost(
"product_customer_price");
888 $tva_tx_txt =
GETPOST(
"tva_tx");
890 $tva_tx = $tva_tx_txt;
892 if (preg_match(
'/\((.*)\)/', $tva_tx_txt, $reg)) {
893 $vat_src_code = $reg[1];
894 $tva_tx = preg_replace(
'/\s*\(.*\)/',
'', $tva_tx_txt);
896 $tva_tx =
price2num(preg_replace(
'/\*/',
'', $tva_tx));
898 $npr = preg_match(
'/\*/', $tva_tx_txt) ? 1 : 0;
901 $localtax1_type =
'0';
902 $localtax2_type =
'0';
904 if (preg_match(
'/\((.*)\)/', $tva_tx_txt, $reg)) {
906 $vatratecode = $reg[1];
908 $sql =
"SELECT t.rowid, t.code, t.recuperableonly, t.localtax1, t.localtax2, t.localtax1_type, t.localtax2_type";
909 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_tva as t, ".MAIN_DB_PREFIX.
"c_country as c";
910 $sql .=
" WHERE t.fk_pays = c.rowid AND c.code = '".$db->escape(
$mysoc->country_code).
"'";
911 $sql .=
" AND t.taux = ".((float) $tva_tx).
" AND t.active = 1";
912 $sql .=
" AND t.code ='".$db->escape($vatratecode).
"'";
913 $sql .=
" AND t.entity IN (".getEntity(
'c_tva').
")";
914 $resql =
$db->query($sql);
916 $obj =
$db->fetch_object($resql);
918 $npr = $obj->recuperableonly;
919 $localtax1 = $obj->localtax1;
920 $localtax2 = $obj->localtax2;
921 $localtax1_type = $obj->localtax1_type;
922 $localtax2_type = $obj->localtax2_type;
926 if (in_array(
$mysoc->country_code, array(
'ES'))) {
933 $sql =
"SELECT t.rowid, t.code, t.recuperableonly, t.localtax1, t.localtax2, t.localtax1_type, t.localtax2_type";
934 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_tva as t, ".MAIN_DB_PREFIX.
"c_country as c";
935 $sql .=
" WHERE t.fk_pays = c.rowid AND c.code = '".$db->escape(
$mysoc->country_code).
"'";
936 $sql .=
" AND t.taux = ".((float) $tva_tx).
" AND t.active = 1";
937 $sql .=
" AND t.code = ''";
938 $resql =
$db->query($sql);
940 $obj =
$db->fetch_object($resql);
942 $npr = $obj->recuperableonly;
943 $localtax1 = $obj->localtax1;
944 $localtax2 = $obj->localtax2;
945 $localtax1_type = $obj->localtax1_type;
946 $localtax2_type = $obj->localtax2_type;
951 $prodcustprice->default_vat_code = $vatratecode;
952 $prodcustprice->tva_tx = $tva_tx;
953 $prodcustprice->recuperableonly = $npr;
954 $prodcustprice->localtax1_tx = $localtax1;
955 $prodcustprice->localtax2_tx = $localtax2;
956 $prodcustprice->localtax1_type = $localtax1_type;
957 $prodcustprice->localtax2_type = $localtax2_type;
959 if ($prodcustprice->price_min < $maxpricesupplier &&
getDolGlobalString(
'PRODUCT_MINIMUM_RECOMMENDED_PRICE')) {
960 setEventMessages($langs->trans(
"MinimumPriceLimit",
price($maxpricesupplier, 0,
'', 1, -1, -1,
'auto')),
null,
'errors');
962 $action =
'update_customer_price';
966 $result = $prodcustprice->update($user, 0, $update_child_soc);
968 if (!empty($extrafield_values) && is_array($extrafield_values)) {
970 $res = $productcustomerprice->fetch($prodcustprice->id);
972 foreach ($extrafield_values as $key => $value) {
973 $productcustomerprice->array_options[$key] = $value;
975 $result2 = $productcustomerprice->insertExtraFields();
977 $prodcustprice->error = $productcustomerprice->error;
978 $prodcustprice->errors = $productcustomerprice->errors;
987 $action =
'update_customer_price';
1003if (!empty($id) || !empty($ref)) {
1008$title = $langs->trans(
'ProductServiceCard');
1012 $title = $langs->trans(
'Product').
" ".$shortlabel.
" - ".$langs->trans(
'SellingPrices');
1013 $helpurl =
'EN:Module_Products|FR:Module_Produits|ES:Módulo_Productos';
1016 $title = $langs->trans(
'Service').
" ".$shortlabel.
" - ".$langs->trans(
'SellingPrices');
1017 $helpurl =
'EN:Module_Services_En|FR:Module_Services|ES:Módulo_Servicios';
1020llxHeader(
'', $title, $helpurl,
'', 0, 0,
'',
'',
'',
'classforhorizontalscrolloftabs mod-product page-price');
1022if ($action ==
'ask_remove_customer_price' && ($user->hasRight(
'produit',
'supprimer') || $user->hasRight(
'service',
'supprimer'))) {
1023 $formquestion = array(
1024 array(
'type' =>
'checkbox',
'name' =>
'updatechildprice',
'label' => $langs->trans(
'ForceDeleteChildPriceSoc'),
'value' => 0),
1026 $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);
1031$titre = $langs->trans(
"CardProduct".
$object->type);
1036$linkback =
'<a href="'.DOL_URL_ROOT.
'/product/list.php?restore_lastsearch_values=1&type='.
$object->type.
'">'.$langs->trans(
"BackToList").
'</a>';
1037$object->next_prev_filter =
"(te.fk_product_type:=:".((int)
$object->type).
")";
1040if ($user->socid && !in_array(
'product', explode(
',',
getDolGlobalString(
'MAIN_MODULES_FOR_EXTERNAL')))) {
1044dol_banner_tab($object,
'ref', $linkback, $shownav,
'ref');
1047print
'<div class="fichecenter">';
1049print
'<div class="underbanner clearboth"></div>';
1050print
'<table class="border tableforfield centpercent">';
1057 if (!empty($socid)) {
1060 $soc->fetch($socid);
1064 $typeformat =
'select;0:'.$langs->trans(
"Product").
',1:'.$langs->trans(
"Service");
1065 print
'<tr><td class="">';
1066 print (!
getDolGlobalString(
'PRODUCT_DENY_CHANGE_PRODUCT_TYPE')) ? $form->editfieldkey(
"Type",
'fk_product_type', (
string)
$object->type, $object, 0, $typeformat) : $langs->trans(
'Type');
1068 print $form->editfieldval(
"Type",
'fk_product_type',
$object->type, $object, 0, $typeformat);
1073 print
'<tr><td class="titlefieldcreate">';
1074 print $langs->trans(
"SellingPrice");
1076 print
'<td colspan="2">';
1077 if (
$object->multiprices_base_type[$soc->price_level] ==
'TTC') {
1078 print
'<span class="amount">'.price(
$object->multiprices_ttc[$soc->price_level]).
'</span>';
1080 print
'<span class="amount">'.price(
$object->multiprices[$soc->price_level]).
'</span>';
1082 if (
$object->multiprices_base_type[$soc->price_level]) {
1083 print
' '.$langs->trans(
$object->multiprices_base_type[$soc->price_level]);
1085 print
' '.$langs->trans(
$object->price_base_type);
1090 print
'<tr><td>'.$langs->trans(
"MinPrice").
'</td><td colspan="2">';
1091 if (
$object->multiprices_base_type[$soc->price_level] ==
'TTC') {
1092 print
price(
$object->multiprices_min_ttc[$soc->price_level]).
' '.$langs->trans(
$object->multiprices_base_type[$soc->price_level]);
1094 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]);
1100 print
'<tr><td>'.$langs->trans(
"DefaultTaxRate").
'</td><td colspan="2">';
1102 $positiverates =
'';
1104 $positiverates .= ($positiverates ?
'/' :
'').
price2num(
$object->multiprices_tva_tx[$soc->price_level]);
1107 $positiverates .= ($positiverates ?
'/' :
'').
price2num(
$object->multiprices_localtax1_tx[$soc->price_level]);
1110 $positiverates .= ($positiverates ?
'/' :
'').
price2num(
$object->multiprices_localtax2_tx[$soc->price_level]);
1112 if (empty($positiverates)) {
1113 $positiverates =
'0';
1115 echo
vatrate($positiverates.($object->default_vat_code ?
' ('.$object->default_vat_code.
')' :
''), true,
$object->tva_npr);
1120 print
'<tr><td>'.$langs->trans(
"DefaultTaxRate").
'</td><td>';
1122 $positiverates =
'';
1127 $positiverates .= ($positiverates ?
'/' :
'').
price2num(
$object->localtax1_tx);
1130 $positiverates .= ($positiverates ?
'/' :
'').
price2num(
$object->localtax2_tx);
1132 if (empty($positiverates)) {
1133 $positiverates =
'0';
1135 echo
vatrate($positiverates.($object->default_vat_code ?
' ('.$object->default_vat_code.
')' :
''), true,
$object->tva_npr);
1143 $typeformat =
'select;0:'.$langs->trans(
"Product").
',1:'.$langs->trans(
"Service");
1144 print
'<tr><td class="">';
1145 print (!
getDolGlobalString(
'PRODUCT_DENY_CHANGE_PRODUCT_TYPE')) ? $form->editfieldkey(
"Type",
'fk_product_type', (
string)
$object->type, $object, 0, $typeformat) : $langs->trans(
'Type');
1147 print $form->editfieldval(
"Type",
'fk_product_type',
$object->type, $object, 0, $typeformat);
1152 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"DefaultTaxRate").
'</td>';
1153 print
'<td colspan="2">'.vatrate(
$object->multiprices_tva_tx[1],
true).
'</td>';
1158 $typeformat =
'select;0:'.$langs->trans(
"Product").
',1:'.$langs->trans(
"Service");
1159 print
'<tr><td class="">';
1160 print (!
getDolGlobalString(
'PRODUCT_DENY_CHANGE_PRODUCT_TYPE')) ? $form->editfieldkey(
"Type",
'fk_product_type', (
string)
$object->type, $object, 0, $typeformat) : $langs->trans(
'Type');
1162 print $form->editfieldval(
"Type",
'fk_product_type',
$object->type, $object, 0, $typeformat);
1167 print
'<!-- Default VAT Rate -->';
1168 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"DefaultTaxRate").
'</td><td>';
1171 $positiverates =
'';
1173 $positiverates .= ($positiverates ?
'<span class="opacitymedium">/</span>' :
'').
price2num(
$object->tva_tx);
1176 $positiverates .= ($positiverates ?
'<span class="opacitymedium">/</span>' :
'').
price2num(
$object->localtax1_tx);
1179 $positiverates .= ($positiverates ?
'<span class="opacitymedium">/</span>' :
'').
price2num(
$object->localtax2_tx);
1181 if (empty($positiverates)) {
1182 $positiverates =
'0';
1185 print
vatrate($positiverates.($object->default_vat_code ?
' ('.$object->default_vat_code.
')' :
''), true,
$object->tva_npr, 1);
1198 print
'<table class="liste centpercent">';
1199 print
'<tr class="liste_titre"><td>';
1200 print $langs->trans(
"PriceLevel");
1202 print
' <a class="editfielda" href="'.dolBuildUrl($_SERVER[
"PHP_SELF"], [
'action' =>
'editlabelsellingprice',
'id' =>
$object->id],
true).
'">'.
img_edit($langs->trans(
'EditSellingPriceLabel'), 0).
'</a>';
1205 print
'<td style="text-align: right">'.$langs->trans(
"SellingPrice").
'</td>';
1206 print
'<td style="text-align: right">'.$langs->trans(
"MinPrice").
'</td>';
1208 $extrafields->fetch_name_optionals_label(
"product_price");
1209 if ($extrafields->attributes[
"product_price"] && array_key_exists(
'label', $extrafields->attributes[
"product_price"])) {
1210 $extralabels = $extrafields->attributes[
"product_price"][
'label'];
1211 if (!empty($extralabels)) {
1212 foreach ($extralabels as $key => $value) {
1214 if (!empty($extrafields->attributes[
"product_price"][
'list'][$key]) && $extrafields->attributes[
"product_price"][
'list'][$key] != 3) {
1215 if (!empty($extrafields->attributes[
"product_price"][
'langfile'][$key])) {
1216 $langs->load($extrafields->attributes[
"product_price"][
'langfile'][$key]);
1218 if (!empty($extrafields->attributes[
"product_price"][
'help'][$key])) {
1219 $extratitle = $form->textwithpicto($langs->trans($value), $langs->trans($extrafields->attributes[
"product_price"][
'help'][$key]));
1221 $extratitle = $langs->trans($value);
1223 $field =
'ef.' . $key;
1224 print
'<td style="text-align: right">'.$extratitle.
'</td>';
1231 $produit_multiprices_limit =
getDolGlobalInt(
'PRODUIT_MULTIPRICES_LIMIT');
1232 for ($i = 1; $i <= $produit_multiprices_limit; $i++) {
1233 print
'<tr class="oddeven">';
1237 $keyforlabel =
'PRODUIT_MULTIPRICES_LABEL'.$i;
1238 if (preg_match(
'/editlabelsellingprice/', $action)) {
1239 print
'<form method="post" action="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'">';
1240 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1241 print
'<input type="hidden" name="action" value="setlabelsellingprice">';
1242 print
'<input type="hidden" name="pricelevel" value="'.$i.
'">';
1243 print $langs->trans(
"SellingPrice").
' '.$i.
' - ';
1244 print
'<input class="maxwidthonsmartphone" type="text" name="labelsellingprice" value="' .
getDolGlobalString($keyforlabel).
'">';
1245 print
' <input type="submit" class="button smallpaddingimp" value="'.$langs->trans(
"Modify").
'">';
1248 print $langs->trans(
"SellingPrice").
' '.$i;
1255 if (
$object->multiprices_base_type [$i] ==
'TTC') {
1256 print
'<td class="right"><span class="amount">'.price(
$object->multiprices_ttc[$i]);
1258 print
'<td class="right"><span class="amount">'.price(
$object->multiprices[$i]);
1261 if (
$object->multiprices_base_type[$i]) {
1262 print
' '.$langs->trans(
$object->multiprices_base_type [$i]).
'</span></td>';
1264 print
' '.$langs->trans(
$object->price_base_type).
'</span></td>';
1268 print
'<td style="text-align: right">';
1269 if (empty(
$object->multiprices_base_type[$i])) {
1270 $object->multiprices_base_type[$i] =
"HT";
1272 if (
$object->multiprices_base_type[$i] ==
'TTC') {
1273 print
price(
$object->multiprices_min_ttc[$i]).
' '.$langs->trans(
$object->multiprices_base_type[$i]);
1275 print
price(
$object->multiprices_min[$i]).
' '.$langs->trans(
$object->multiprices_base_type[$i]);
1278 if (!empty($extralabels)) {
1279 require_once DOL_DOCUMENT_ROOT .
'/core/class/genericobject.class.php';
1282 $genericObject->table_element =
'product_price';
1283 $sql1 =
"SELECT rowid";
1284 $sql1 .=
" FROM ".$object->db->prefix().
"product_price";
1285 $sql1 .=
" WHERE entity IN (".getEntity(
'productprice').
")";
1286 $sql1 .=
" AND price_level=".((int) $i);
1287 $sql1 .=
" AND fk_product = ".((int)
$object->id);
1288 $sql1 .=
" ORDER BY date_price DESC, rowid DESC";
1289 $sql1 .=
" LIMIT 1";
1290 $resql1 =
$object->db->query($sql1);
1291 if ($resql1 && $lineid =
$object->db->fetch_object($resql1)) {
1292 $genericObject->id = $lineid->rowid;
1293 $genericObject->fetch_optionals();
1295 foreach ($extralabels as $key => $value) {
1296 if (!empty($extrafields->attributes[
"product_price"][
'list'][$key]) && $extrafields->attributes[
"product_price"][
'list'][$key] != 3) {
1297 print
'<td align="right">'.$extrafields->showOutputField($key, $genericObject->array_options[
'options_' . $key],
'',
'product_price').
"</td>";
1306 print
'<tr><td>'.$langs->trans(
"PriceByQuantity").
' '.$i;
1310 print
'</td><td colspan="2">';
1312 if (
$object->prices_by_qty[$i] == 1) {
1313 print
'<table width="50%" class="border" summary="List of quantities">';
1315 print
'<tr class="liste_titre">';
1316 print
'<td>'.$langs->trans(
"PriceByQuantityRange").
' '.$i.
'</td>';
1317 print
'<td class="right">'.$langs->trans(
"HT").
'</td>';
1318 print
'<td class="right">'.$langs->trans(
"UnitPrice").
'</td>';
1319 print
'<td class="right">'.$langs->trans(
"Discount").
'</td>';
1320 print
'<td> </td>';
1323 foreach (
$object->prices_by_qty_list[$i] as $ii => $prices) {
1324 if ($action ==
'edit_price_by_qty' && $rowid == $prices[
'rowid'] && ($user->hasRight(
'produit',
'creer') || $user->hasRight(
'service',
'creer'))) {
1325 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'" method="POST">';
1326 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1327 print
'<input type="hidden" name="action" value="update_price_by_qty">';
1328 print
'<input type="hidden" name="priceid" value="'.$object->prices_by_qty_id[$i].
'">';
1329 print
'<input type="hidden" value="'.$prices[
'rowid'].
'" name="rowid">';
1330 print
'<tr class="'.($ii % 2 == 0 ?
'pair' :
'impair').
'">';
1331 print
'<td><input size="5" type="text" value="'.$prices[
'quantity'].
'" name="quantity"></td>';
1332 print
'<td class="right" colspan="2"><input size="10" type="text" value="'.price2num($prices[
'price'],
'MU').
'" name="price"> '.
$object->price_base_type.
'</td>';
1333 print
'<td class="right nowraponall"><input size="5" type="text" value="'.$prices[
'remise_percent'].
'" name="remise_percent"> %</td>';
1334 print
'<td class="center"><input type="submit" value="'.$langs->trans(
"Modify").
'" class="button"></td>';
1338 print
'<tr class="'.($ii % 2 == 0 ?
'pair' :
'impair').
'">';
1339 print
'<td>'.$prices[
'quantity'].
'</td>';
1340 print
'<td class="right">'.price($prices[
'price']).
'</td>';
1341 print
'<td class="right">'.price($prices[
'unitprice']).
'</td>';
1342 print
'<td class="right">'.price($prices[
'remise_percent']).
' %</td>';
1343 print
'<td class="center">';
1344 if (($user->hasRight(
'produit',
'creer') || $user->hasRight(
'service',
'creer'))) {
1345 print
'<a class="editfielda marginleftonly marginrightonly" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=edit_price_by_qty&token='.
newToken().
'&rowid='.$prices[
"rowid"].
'">';
1347 print
'<a class="marginleftonly marginrightonly" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=delete_price_by_qty&token='.
newToken().
'&rowid='.$prices[
"rowid"].
'">';
1356 if ($action !=
'edit_price_by_qty' && ($user->hasRight(
'produit',
'creer') || $user->hasRight(
'service',
'creer'))) {
1357 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'" method="POST">';
1358 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1359 print
'<input type="hidden" name="action" value="update_price_by_qty">';
1360 print
'<input type="hidden" name="priceid" value="'.$object->prices_by_qty_id[$i].
'">';
1361 print
'<input type="hidden" value="0" name="rowid">';
1362 print
'<tr class="'.($ii % 2 == 0 ?
'pair' :
'impair').
'">';
1363 print
'<td><input size="5" type="text" value="1" name="quantity"></td>';
1364 print
'<td class="right" class="nowrap"><input size="10" type="text" value="0" name="price"> '.$object->price_base_type.
'</td>';
1365 print
'<td class="right"> </td>';
1366 print
'<td class="right" class="nowraponall"><input size="5" type="text" value="0" name="remise_percent"> %</td>';
1367 print
'<td class="center"><input type="submit" value="'.$langs->trans(
"Add").
'" class="button"></td>';
1373 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>';
1375 print $langs->trans(
"No");
1376 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>';
1385 $typeformat =
'select;0:'.$langs->trans(
"Product").
',1:'.$langs->trans(
"Service");
1386 print
'<tr><td class="">';
1387 print (!
getDolGlobalString(
'PRODUCT_DENY_CHANGE_PRODUCT_TYPE')) ? $form->editfieldkey(
"Type",
'fk_product_type', (
string)
$object->type, $object, 0, $typeformat) : $langs->trans(
'Type');
1389 print $form->editfieldval(
"Type",
'fk_product_type',
$object->type, $object, 0, $typeformat);
1394 print
'<tr><td class="titlefield">'.$langs->trans(
"DefaultTaxRate").
'</td><td>';
1396 $positiverates =
'';
1401 $positiverates .= ($positiverates ?
'/' :
'').
price2num(
$object->localtax1_tx);
1404 $positiverates .= ($positiverates ?
'/' :
'').
price2num(
$object->localtax2_tx);
1406 if (empty($positiverates)) {
1407 $positiverates =
'0';
1409 echo
vatrate($positiverates.($object->default_vat_code ?
' ('.$object->default_vat_code.
')' :
''), true,
$object->tva_npr, 0, 1);
1419 print
'<tr class="field_selling_price"><td>'.$langs->trans(
"SellingPrice").
'</td><td>';
1420 if (
$object->price_base_type ==
'TTC') {
1425 print
'<i class="opacitymedium"> - ' .
price(
$object->price_ttc).
' '.$langs->trans(
'TTC') .
'</i>';
1432 print
'<tr class="field_min_price"><td>'.$langs->trans(
"MinPrice").
'</td><td>';
1433 if (
$object->price_base_type ==
'TTC') {
1438 print
'<i class="opacitymedium"> - ' .
price(
$object->price_min_ttc).
' '.$langs->trans(
'TTC') .
'</i>';
1445 print
'<tr class="field_price_label"><td>'.$form->textwithpicto($langs->trans(
"PackagingForThisProduct"), $langs->trans(
"PackagingForThisProductDesc")).
'</td><td>';
1451 print
'<tr class="field_price_label"><td>'.$langs->trans(
"PriceLabel").
'</td><td>';
1458 print
'<tr><td>'.$langs->trans(
"PriceByQuantity");
1459 if (
$object->prices_by_qty[0] == 0) {
1460 print
' <a href="'.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&action=activate_price_by_qty&level=1&token='.
newToken().
'">('.$langs->trans(
"Activate").
')';
1462 print
' <a href="'.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&action=disable_price_by_qty&level=1&token='.
newToken().
'">('.$langs->trans(
"DisablePriceByQty").
')';
1466 if (
$object->prices_by_qty[0] == 1) {
1467 print
'<table width="50%" class="border" summary="List of quantities">';
1468 print
'<tr class="liste_titre">';
1470 print
'<td>'.$langs->trans(
"Quantity").
'</td>';
1471 print
'<td class="right">'.$langs->trans(
"Price").
'</td>';
1472 print
'<td class="right"></td>';
1473 print
'<td class="right">'.$langs->trans(
"UnitPrice").
'</td>';
1474 print
'<td class="right">'.$langs->trans(
"Discount").
'</td>';
1475 print
'<td> </td>';
1477 if ($action !=
'edit_price_by_qty') {
1478 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'" method="POST">';
1479 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1480 print
'<input type="hidden" name="action" value="update_price_by_qty">';
1481 print
'<input type="hidden" name="priceid" value="'.$object->prices_by_qty_id[0].
'">';
1482 print
'<input type="hidden" value="0" name="rowid">';
1484 print
'<tr class="'.(($ii % 2) == 0 ?
'pair' :
'impair').
'">';
1485 print
'<td><input size="5" type="text" value="1" name="quantity"></td>';
1486 print
'<td class="right"><input class="width50 right" type="text" value="0" name="price"></td>';
1490 print
'<td class="right"> </td>';
1491 print
'<td class="right nowraponall"><input type="text" class="width50 right" value="0" name="remise_percent"> %</td>';
1492 print
'<td class="center"><input type="submit" value="'.$langs->trans(
"Add").
'" class="button"></td>';
1497 foreach (
$object->prices_by_qty_list[0] as $ii => $prices) {
1498 if ($action ==
'edit_price_by_qty' && $rowid == $prices[
'rowid'] && ($user->hasRight(
'produit',
'creer') || $user->hasRight(
'service',
'creer'))) {
1499 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'" method="POST">';
1500 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1501 print
'<input type="hidden" name="action" value="update_price_by_qty">';
1502 print
'<input type="hidden" name="priceid" value="'.$object->prices_by_qty_id[0].
'">';
1503 print
'<input type="hidden" value="'.$prices[
'rowid'].
'" name="rowid">';
1504 print
'<tr class="'.($ii % 2 == 0 ?
'pair' :
'impair').
'">';
1505 print
'<td><input size="5" type="text" value="'.$prices[
'quantity'].
'" name="quantity"></td>';
1506 print
'<td class="right"><input class="width50 right" type="text" value="'.price2num($prices[
'price'],
'MU').
'" name="price"></td>';
1507 print
'<td class="right">';
1509 print $prices[
'price_base_type'];
1511 print
'<td class="right"> </td>';
1512 print
'<td class="right nowraponall"><input class="width50 right" type="text" value="'.$prices[
'remise_percent'].
'" name="remise_percent"> %</td>';
1513 print
'<td class="center"><input type="submit" value="'.$langs->trans(
"Modify").
'" class="button"></td>';
1517 print
'<tr class="'.($ii % 2 == 0 ?
'pair' :
'impair').
'">';
1518 print
'<td>'.$prices[
'quantity'].
'</td>';
1519 print
'<td class="right">'.price($prices[
'price']).
'</td>';
1520 print
'<td class="right">';
1522 print $prices[
'price_base_type'];
1524 print
'<td class="right">'.price($prices[
'unitprice']).
'</td>';
1525 print
'<td class="right">'.price($prices[
'remise_percent']).
' %</td>';
1526 print
'<td class="center">';
1527 if (($user->hasRight(
'produit',
'creer') || $user->hasRight(
'service',
'creer'))) {
1528 print
'<a class="editfielda marginleftonly marginrightonly" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=edit_price_by_qty&token='.
newToken().
'&rowid='.$prices[
"rowid"].
'">';
1530 print
'<a class="marginleftonly marginrightonly" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=delete_price_by_qty&token='.
newToken().
'&rowid='.$prices[
"rowid"].
'">';
1541 print $langs->trans(
"No");
1550print
'<div class="clearboth"></div>';
1559if (!$action || $action ==
'delete' || $action ==
'showlog_customer_price' || $action ==
'showlog_default_price' || $action ==
'add_customer_price'
1560 || $action ==
'activate_price_by_qty' || $action ==
'disable_price_by_qty') {
1561 print
"\n".
'<div class="tabsAction">'.
"\n";
1563 $parameters = array();
1564 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters, $object, $action);
1565 if (empty($reshook)) {
1568 print
'<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="' .
dol_escape_htmltag($langs->trans(
"NoEditVariants")) .
'">' . $langs->trans(
"UpdateDefaultPrice") .
'</a></div>';
1572 if ($user->hasRight(
'produit',
'creer') || $user->hasRight(
'service',
'creer')) {
1573 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>';
1575 print
'<div class="inline-block divButAction"><span class="butActionRefused" title="'.dol_escape_htmltag($langs->trans(
"NotEnoughPermissions")).
'">' . $langs->trans(
"UpdateDefaultPrice") .
'</span></div>';
1580 if ($user->hasRight(
'produit',
'creer') || $user->hasRight(
'service',
'creer')) {
1581 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>';
1583 print
'<div class="inline-block divButAction"><span class="butActionRefused" title="'.dol_escape_htmltag($langs->trans(
"NotEnoughPermissions")).
'">' . $langs->trans(
"AddCustomerPrice") .
'</span></div>';
1588 if ($user->hasRight(
'produit',
'creer') || $user->hasRight(
'service',
'creer')) {
1589 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>';
1591 print
'<div class="inline-block divButAction"><span class="butActionRefused" title="'.dol_escape_htmltag($langs->trans(
"NotEnoughPermissions")).
'">' . $langs->trans(
"UpdateVAT") .
'</span></div>';
1594 if ($user->hasRight(
'produit',
'creer') || $user->hasRight(
'service',
'creer')) {
1595 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>';
1597 print
'<div class="inline-block divButAction"><span class="butActionRefused" title="'.dol_escape_htmltag($langs->trans(
"NotEnoughPermissions")).
'">' . $langs->trans(
"UpdateLevelPrices") .
'</span></div>';
1612if ($action ==
'edit_vat' && ($user->hasRight(
'produit',
'creer') || $user->hasRight(
'service',
'creer'))) {
1615 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'" method="POST">';
1616 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1617 print
'<input type="hidden" name="action" value="update_vat">';
1618 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
1622 print
'<table class="border centpercent">';
1625 print
'<tr><td>'.$langs->trans(
"DefaultTaxRate").
'</td><td>';
1633 print $form->buttonsSaveCancel();
1635 print
'<br></form><br>';
1638if (($action ==
'edit_price' || $action ==
'edit_level_price') &&
$object->getRights()->creer) {
1643 print
'<!-- Edit price -->'.
"\n";
1644 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'" method="POST">';
1645 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1646 print
'<input type="hidden" name="action" value="update_price">';
1647 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
1651 print
'<div class="div-table-responsive-no-min">';
1652 print
'<table class="border centpercent">';
1655 print
'<tr><td class="titlefield">'.$langs->trans(
"DefaultTaxRate").
'</td><td>';
1661 print $langs->trans(
'PriceBase');
1664 print $form->selectPriceBaseType(
$object->price_base_type,
"price_base_type");
1671 print
'<!-- Show price mode of dynamicprices editor -->'.
"\n";
1672 print
'<tr><td>'.$langs->trans(
"PriceMode").
'</td><td>';
1673 print
img_picto(
'',
'dynamicprice',
'class="pictofixedwidth"');
1675 $price_expression_list = array(0 => $langs->trans(
"Numeric").
' <span class="opacitymedium">('.$langs->trans(
"NoDynamicPrice").
')</span>');
1676 foreach ($price_expression->list_price_expression() as $entry) {
1677 $price_expression_list[$entry->id] = $entry->title;
1679 $price_expression_preselection =
GETPOST(
'eid') ?
GETPOST(
'eid') : (
$object->fk_price_expression ?
$object->fk_price_expression :
'0');
1680 print $form->selectarray(
'eid', $price_expression_list, $price_expression_preselection);
1681 print
' <a id="expression_editor" class="classlink">'.$langs->trans(
"PriceExpressionEditor").
'</a>';
1687 <script
type=
"text/javascript">
1688 jQuery(document).ready(
function() {
1689 jQuery(
"#expression_editor").click(
function() {
1690 window.location =
"<?php echo DOL_URL_ROOT ?>/product/dynamic_price/editor.php?id=<?php echo $id ?>&tab=price&eid=" + $(
"#eid").val();
1692 jQuery(
"#eid").change(on_change);
1695 function on_change() {
1696 if ($(
"#eid").val() == 0) {
1697 jQuery(
"#price_numeric").show();
1699 jQuery(
"#price_numeric").hide();
1708 $product->fetch($id, $ref,
'',
'1');
1709 print
'<tr id="price_numeric"><td>';
1710 $text = $langs->trans(
'SellingPrice');
1711 print $form->textwithpicto($text, $langs->trans(
"PrecisionUnitIsLimitedToXDecimals",
getDolGlobalString(
'MAIN_MAX_DECIMALS_UNIT')), 1,
'help');
1713 if (
$object->price_base_type ==
'TTC') {
1714 print
'<input name="price" size="10" value="'.price($product->price_ttc).
'">';
1716 print
'<input name="price" size="10" value="'.price($product->price).
'">';
1722 $text = $langs->trans(
'MinPrice');
1723 print $form->textwithpicto($text, $langs->trans(
"PrecisionUnitIsLimitedToXDecimals",
getDolGlobalString(
'MAIN_MAX_DECIMALS_UNIT')), 1,
'help');
1725 if (
$object->price_base_type ==
'TTC') {
1726 print
'<input name="price_min" size="10" value="'.($object->price_min_ttc ?
price(
$object->price_min_ttc) :
'').
'">';
1728 print
'<input name="price_min" size="10" value="'.($object->price_min ?
price(
$object->price_min) :
'').
'">';
1731 print
' '.$langs->trans(
"MinimumRecommendedPrice",
price((
float) $maxpricesupplier, 0,
'', 1, -1, -1,
'auto')).
' '.
img_warning().
'</td>';
1739 print $form->textwithpicto($langs->trans(
"PackagingForThisProduct"), $langs->trans(
"PackagingForThisProductDesc"));
1741 $packaging =
$object->packaging;
1742 print
'<input class="flat" name="packaging" size="5" value="' . ($packaging ?
price($packaging, 0,
'', 1, -1, 2) :
'').
'">';
1749 print $langs->trans(
'PriceLabel');
1751 print
'<input name="price_label" maxlength="255" class="minwidth300 maxwidth400onsmartphone" value="'.$object->price_label.
'">';
1755 $parameters = array();
1756 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters, $object, $action);
1763 print $form->buttonsSaveCancel();
1766 } elseif ($action ==
'edit_level_price' &&
$object->getRights()->creer) {
1767 print
'<!-- Edit price per level -->'.
"\n"; ?>
1770 var showHidePriceRules =
function () {
1771 var otherPrices = $(
'div.fiche form table tbody tr:not(:first)');
1772 var minPrice1 = $(
'div.fiche form input[name="price_min[1]"]');
1774 if (jQuery(
'input#usePriceRules').prop(
'checked')) {
1783 jQuery(document).ready(
function () {
1784 showHidePriceRules();
1786 jQuery(
'input#usePriceRules').click(showHidePriceRules);
1791 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'" method="POST">';
1792 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1793 print
'<input type="hidden" name="action" value="update_level_price">';
1794 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
1799 print $langs->trans(
'UseMultipriceRules').
' <input type="checkbox" id="usePriceRules" name="usePriceRules" '.(
$object->price_autogen ?
'checked' :
'').
'><br><br>';
1802 print
'<div class="div-table-responsive-no-min">';
1803 print
'<table class="noborder">';
1804 print
'<thead><tr class="liste_titre">';
1806 print
'<td>'.$langs->trans(
"PriceLevel").
'</td>';
1809 print
'<td style="text-align: center">'.$langs->trans(
"DefaultTaxRate").
'</td>';
1814 print
'<td class="center">'.$langs->trans(
"SellingPrice").
'</td>';
1816 print
'<td class="center">'.$langs->trans(
"MinPrice").
'</td>';
1823 $extrafields->fetch_name_optionals_label(
"product_price");
1824 if ($extrafields->attributes[
"product_price"] && array_key_exists(
'label', $extrafields->attributes[
"product_price"])) {
1825 $extralabels = $extrafields->attributes[
"product_price"][
'label'];
1826 if (!empty($extralabels)) {
1827 foreach ($extralabels as $key => $value) {
1829 if (!empty($extrafields->attributes[
"product_price"][
'list'][$key]) && $extrafields->attributes[
"product_price"][
'list'][$key] != 3) {
1830 if (!empty($extrafields->attributes[
"product_price"][
'langfile'][$key])) {
1831 $langs->load($extrafields->attributes[
"product_price"][
'langfile'][$key]);
1833 if (!empty($extrafields->attributes[
"product_price"][
'help'][$key])) {
1834 $extratitle = $form->textwithpicto($langs->trans($value), $langs->trans($extrafields->attributes[
"product_price"][
'help'][$key]));
1836 $extratitle = $langs->trans($value);
1838 print
'<td style="text-align: right">'.$extratitle.
'</td>';
1843 print
'</tr></thead>';
1847 $produit_multiprices_limit =
getDolGlobalInt(
'PRODUIT_MULTIPRICES_LIMIT');
1848 for ($i = 1; $i <= $produit_multiprices_limit; $i++) {
1849 print
'<tr class="oddeven">';
1851 $keyforlabel =
'PRODUIT_MULTIPRICES_LABEL'.$i;
1853 print $form->textwithpicto($text, $langs->trans(
"PrecisionUnitIsLimitedToXDecimals",
getDolGlobalString(
'MAIN_MAX_DECIMALS_UNIT')), 1,
'help');
1859 print
'<input type="hidden" name="tva_tx['.$i.
']" value="'.(
$object->default_vat_code ?
$object->tva_tx.
' ('.
$object->default_vat_code.
')' :
$object->tva_tx).
'">';
1860 print
'<input type="hidden" name="tva_npr['.$i.
']" value="'.
$object->tva_npr.
'">';
1861 print
'<input type="hidden" name="localtax1_tx['.$i.
']" value="'.
$object->localtax1_tx.
'">';
1862 print
'<input type="hidden" name="localtax1_type['.$i.
']" value="'.
$object->localtax1_type.
'">';
1863 print
'<input type="hidden" name="localtax2_tx['.$i.
']" value="'.
$object->localtax2_tx.
'">';
1864 print
'<input type="hidden" name="localtax2_type['.$i.
']" value="'.
$object->localtax2_type.
'">';
1868 print
'<td style="text-align: center">';
1874 print
'<td style="text-align: center">';
1875 if (
$object->multiprices_base_type [$i] ==
'TTC') {
1876 print
'<input name="price['.$i.
']" size="10" value="'.
price(
$object->multiprices_ttc [$i]).
'">';
1878 print
'<input name="price['.$i.
']" size="10" value="'.
price(
$object->multiprices [$i]).
'">';
1880 print
' '.$form->selectPriceBaseType(
$object->multiprices_base_type [$i],
"multiprices_base_type[".$i.
"]");
1884 print
'<td style="text-align: center">';
1885 if (
$object->multiprices_base_type [$i] ==
'TTC') {
1886 print
'<input name="price_min['.$i.
']" size="10" value="'.
price(
$object->multiprices_min_ttc [$i]).
'">';
1888 print
'<input name="price_min['.$i.
']" size="10" value="'.
price(
$object->multiprices_min [$i]).
'">';
1891 print
'<td class="left">'.$langs->trans(
"MinimumRecommendedPrice",
price((
float) $maxpricesupplier, 0,
'', 1, -1, -1,
'auto')).
' '.
img_warning().
'</td>';
1895 if (!empty($extralabels)) {
1896 require_once DOL_DOCUMENT_ROOT .
'/core/class/genericobject.class.php';
1899 $genericObject->table_element =
'product_price';
1900 $sql1 =
"SELECT rowid";
1901 $sql1 .=
" FROM ".$object->db->prefix().
"product_price";
1902 $sql1 .=
" WHERE entity IN (".getEntity(
'productprice').
")";
1903 $sql1 .=
" AND price_level=".((int) $i);
1904 $sql1 .=
" AND fk_product = ".((int)
$object->id);
1905 $sql1 .=
" ORDER BY date_price DESC, rowid DESC";
1906 $sql1 .=
" LIMIT 1";
1907 $resql1 =
$object->db->query($sql1);
1908 if ($resql1 && $lineid =
$object->db->fetch_object($resql1)) {
1909 $genericObject->id = $lineid->rowid;
1910 $genericObject->fetch_optionals();
1912 foreach ($extralabels as $key => $value) {
1913 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))) {
1914 if (!empty($extrafields->attributes[
"product_price"][
'langfile'][$key])) {
1915 $langs->load($extrafields->attributes[
"product_price"][
'langfile'][$key]);
1919 print
'<td align="center">';
1920 print $extrafields->showInputField($key, $genericObject->array_options[
'options_' . $key],
'', (
string) $i,
'',
'', $genericObject,
'product_price');
1936 print $form->buttonsSaveCancel();
1947 $sortfield =
GETPOST(
'sortfield',
'aZ09comma');
1948 $sortorder =
GETPOST(
'sortorder',
'aZ09comma');
1950 if (empty($page) || $page == -1) {
1953 $offset = $limit * $page;
1954 $pageprev = $page - 1;
1955 $pagenext = $page + 1;
1957 $sortorder =
"ASC,ASC";
1960 $sortfield =
"soc.nom,t.date_begin";
1964 $filter = array(
't.fk_product' => (
string)
$object->id);
1966 if (!empty($search_soc)) {
1967 $filter[
'soc.nom'] = (
string) $search_soc;
1970 if ($action ==
'add_customer_price') {
1972 $maxpricesupplier =
$object->min_recommended_price();
1974 print
'<!-- add_customer_price -->';
1977 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'" method="POST">';
1978 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1979 print
'<input type="hidden" name="action" value="add_customer_price_confirm">';
1980 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
1982 print
'<div class="tabBar tabBarWithBottom">';
1984 print
'<table class="border centpercent">';
1986 print
'<td class="fieldrequired">'.$langs->trans(
'ThirdParty').
'</td>';
1988 $filter =
'(s.client:IN:1,2,3)';
1989 print
img_picto(
'',
'company').$form->select_company(
GETPOSTINT(
'socid'),
'socid', $filter,
'SelectThirdParty', 0, 0, array(), 0,
'minwidth300');
1994 print
'<tr><td>' . $langs->trans(
'RefCustomer') .
'</td>';
1995 print
'<td><input name="ref_customer" size="12"></td></tr>';
1999 print
'<tr><td>'.$langs->trans(
"AppliedPricesFrom").
'</td><td>';
2000 print $form->selectDate(!empty($date_begin) ? $date_begin :
dol_now(),
"date_begin", 0, 0, 1,
"date_begin");
2005 print
'<tr><td>'.$langs->trans(
"AppliedPricesTo").
'</td><td>';
2006 print $form->selectDate($date_end,
"date_end", 0, 0, 1,
"date_end");
2010 print
'<tr><td class="fieldrequired">'.$langs->trans(
"DefaultTaxRate").
'</td><td>';
2015 print
'<tr><td class="fieldrequired">';
2016 print $langs->trans(
'PriceBase');
2019 print $form->selectPriceBaseType(
$object->price_base_type,
"price_base_type");
2024 print
'<tr><td class="fieldrequired">';
2025 $text = $langs->trans(
'SellingPrice');
2026 print $form->textwithpicto($text, $langs->trans(
"PrecisionUnitIsLimitedToXDecimals",
getDolGlobalString(
'MAIN_MAX_DECIMALS_UNIT')), 1,
'help');
2028 if (
$object->price_base_type ==
'TTC') {
2029 print
'<input name="price" size="10" value="'.price(
$object->price_ttc).
'">';
2031 print
'<input name="price" size="10" value="'.price(
$object->price).
'">';
2037 $text = $langs->trans(
'MinPrice');
2038 print $form->textwithpicto($text, $langs->trans(
"PrecisionUnitIsLimitedToXDecimals",
getDolGlobalString(
'MAIN_MAX_DECIMALS_UNIT')), 1,
'help');
2039 if (
$object->price_base_type ==
'TTC') {
2040 print
'<td><input name="price_min" size="10" value="'.price(
$object->price_min_ttc).
'">';
2042 print
'<td><input name="price_min" size="10" value="'.price(
$object->price_min).
'">';
2045 print
'<td class="left">'.$langs->trans(
"MinimumRecommendedPrice",
price($maxpricesupplier, 0,
'', 1, -1, -1,
'auto')).
' '.
img_warning().
'</td>';
2051 print $langs->trans(
'PriceLabel');
2053 print
'<input name="price_label" maxlength="255" class="minwidth300 maxwidth400onsmartphone" value="'.$object->price_label.
'">';
2059 print
'<tr><td>'.$langs->trans(
"Discount").
'</td><td>';
2060 print
'<input name="discount_percent" size="10" value="'.price($discount_percent).
'">';
2064 $extrafields->fetch_name_optionals_label(
"product_customer_price");
2065 $extralabels = !empty($extrafields->attributes[
"product_customer_price"][
'label']) ? $extrafields->attributes[
"product_customer_price"][
'label'] :
'';
2066 $extrafield_values = $extrafields->getOptionalsFromPost(
"product_customer_price");
2067 if (!empty($extralabels)) {
2068 if (empty($prodcustprice->id)) {
2069 foreach ($extralabels as $key => $value) {
2070 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))) {
2071 if (!empty($extrafields->attributes[
"product_customer_price"][
'langfile'][$key])) {
2072 $langs->load($extrafields->attributes[
"product_customer_price"][
'langfile'][$key]);
2075 print
'<tr><td'.($extrafields->attributes[
"product_customer_price"][
'required'][$key] ?
' class="fieldrequired"' :
'').
'>';
2076 if (!empty($extrafields->attributes[
"product_customer_price"][
'help'][$key])) {
2077 print $form->textwithpicto($langs->trans($value), $langs->trans($extrafields->attributes[
"product_customer_price"][
'help'][$key]));
2079 print $langs->trans($value);
2081 print
'</td><td>'.$extrafields->showInputField($key,
GETPOSTISSET(
'options_'.$key) ? $extrafield_values[
'options_'.$key] :
'',
'',
'',
'',
'', 0,
'product_customer_price').
'</td></tr>';
2092 print
'<div class="center">';
2095 print
'<div class="marginbottomonly">';
2096 print
'<input type="checkbox" name="updatechildprice" id="updatechildprice" value="1"> ';
2097 print
'<label for="updatechildprice">'.$langs->trans(
'ForceUpdateChildPriceSoc').
'</label>';
2100 print $form->buttonsSaveCancel();
2103 } elseif ($action ==
'edit_customer_price') {
2105 $maxpricesupplier =
$object->min_recommended_price();
2107 print
'<!-- edit_customer_price -->';
2110 $result = $prodcustprice->fetch(
GETPOSTINT(
'lineid'));
2115 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'" method="POST">';
2116 print
'<input type="hidden" name="token" value="'.newToken().
'">';
2117 print
'<input type="hidden" name="action" value="update_customer_price_confirm">';
2118 print
'<input type="hidden" name="lineid" value="'.$prodcustprice->id.
'">';
2120 print
'<table class="liste centpercent">';
2122 print
'<td class="titlefield fieldrequired">'.$langs->trans(
'ThirdParty').
'</td>';
2124 $staticsoc->fetch($prodcustprice->fk_soc);
2125 print
"<td>".$staticsoc->getNomUrl(1).
"</td>";
2129 print
'<tr><td>' . $langs->trans(
'RefCustomer') .
'</td>';
2130 print
'<td><input name="ref_customer" size="12" value="' .
dol_escape_htmltag($prodcustprice->ref_customer) .
'"></td></tr>';
2133 print
'<tr><td>'.$langs->trans(
"AppliedPricesFrom").
'</td><td>';
2134 print $form->selectDate($prodcustprice->date_begin,
"date_begin", 0, 0, 1,
"date_begin");
2138 print
'<tr><td>'.$langs->trans(
"AppliedPricesTo").
'</td><td>';
2139 print $form->selectDate($prodcustprice->date_end,
"date_end", 0, 0, 1,
"date_end");
2143 print
'<tr><td class="fieldrequired">'.$langs->trans(
"DefaultTaxRate").
'</td><td>';
2144 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);
2148 print
'<tr><td class="fieldrequired">';
2149 print $langs->trans(
'PriceBase');
2152 print $form->selectPriceBaseType($prodcustprice->price_base_type,
"price_base_type");
2157 print
'<tr><td class="fieldrequired">';
2158 $text = $langs->trans(
'SellingPrice');
2159 print $form->textwithpicto($text, $langs->trans(
"PrecisionUnitIsLimitedToXDecimals",
getDolGlobalString(
'MAIN_MAX_DECIMALS_UNIT')), 1,
'help');
2161 if ($prodcustprice->price_base_type ==
'TTC') {
2162 print
'<input name="price" size="10" value="'.price($prodcustprice->price_ttc).
'">';
2164 print
'<input name="price" size="10" value="'.price($prodcustprice->price).
'">';
2170 $text = $langs->trans(
'MinPrice');
2171 print $form->textwithpicto($text, $langs->trans(
"PrecisionUnitIsLimitedToXDecimals",
getDolGlobalString(
'MAIN_MAX_DECIMALS_UNIT')), 1,
'help');
2173 if ($prodcustprice->price_base_type ==
'TTC') {
2174 print
'<input name="price_min" size="10" value="'.price($prodcustprice->price_min_ttc).
'">';
2176 print
'<input name="price_min" size="10" value="'.price($prodcustprice->price_min).
'">';
2180 print
'<td class="left">'.$langs->trans(
"MinimumRecommendedPrice",
price($maxpricesupplier, 0,
'', 1, -1, -1,
'auto')).
' '.
img_warning().
'</td>';
2186 print $langs->trans(
'PriceLabel');
2188 print
'<input name="price_label" maxlength="255" class="minwidth300 maxwidth400onsmartphone" value="'.$prodcustprice->price_label.
'">';
2193 print
'<tr><td>'.$langs->trans(
"Discount").
'</td><td>';
2194 print
'<input name="discount_percent" size="10" value="'.price($prodcustprice->discount_percent).
'">';
2198 $extrafields->fetch_name_optionals_label(
"product_customer_price");
2199 $extralabels = !empty($extrafields->attributes[
"product_customer_price"][
'label']) ? $extrafields->attributes[
"product_customer_price"][
'label'] :
'';
2200 $extrafield_values = $extrafields->getOptionalsFromPost(
"product_customer_price");
2201 if (!empty($extralabels)) {
2203 foreach ($extralabels as $key => $value) {
2204 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_price" && $extrafields->attributes[
"product_customer_price"][
'list'][$key] == 4))) {
2205 if (!empty($extrafields->attributes[
"product_customer_price"][
'langfile'][$key])) {
2206 $langs->load($extrafields->attributes[
"product_customer_price"][
'langfile'][$key]);
2209 print
'<tr><td'.($extrafields->attributes[
"product_customer_price"][
'required'][$key] ?
' class="fieldrequired"' :
'').
'>';
2210 if (!empty($extrafields->attributes[
"product_customer_price"][
'help'][$key])) {
2211 print $form->textwithpicto($langs->trans($value), $langs->trans($extrafields->attributes[
"product_customer_price"][
'help'][$key]));
2213 print $langs->trans($value);
2215 print
'</td><td>'.$extrafields->showInputField($key,
GETPOSTISSET(
'options_'.$key) ? $extrafield_values[
'options_'.$key] :
'',
'',
'',
'',
'', 0,
'product_customer_price').
'</td></tr>';
2220 $sql .=
" fk_object";
2221 foreach ($extralabels as $key => $value) {
2222 $sql .=
", ".$db->sanitize($key);
2224 $sql .=
" FROM ".MAIN_DB_PREFIX.
"product_customer_price_extrafields";
2225 $sql .=
" WHERE fk_object = ".((int) $prodcustprice->id);
2226 $resql =
$db->query($sql);
2228 $obj =
$db->fetch_object($resql);
2229 foreach ($extralabels as $key => $value) {
2230 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_price" && $extrafields->attributes[
"product_customer_price"][
'list'][$key] == 4))) {
2231 if (!empty($extrafields->attributes[
"product_customer_price"][
'langfile'][$key])) {
2232 $langs->load($extrafields->attributes[
"product_customer_price"][
'langfile'][$key]);
2235 print
'<tr><td'.($extrafields->attributes[
"product_customer_price"][
'required'][$key] ?
' class="fieldrequired"' :
'').
'>';
2236 if (!empty($extrafields->attributes[
"product_customer_price"][
'help'][$key])) {
2237 print $form->textwithpicto($langs->trans($value), $langs->trans($extrafields->attributes[
"product_customer_price"][
'help'][$key]));
2239 print $langs->trans($value);
2241 print
'</td><td>'.$extrafields->showInputField($key,
GETPOSTISSET(
'options_'.$key) ? $extrafield_values[
'options_'.$key] : $obj->{$key},
'',
'',
'',
'', 0,
'product_customer_price');
2253 print
'<div class="center">';
2254 print
'<div class="marginbottomonly">';
2255 print
'<input type="checkbox" name="updatechildprice" id="updatechildprice" value="1"> ';
2256 print
'<label for="updatechildprice">'.$langs->trans(
'ForceUpdateChildPriceSoc').
'</label>';
2259 print $form->buttonsSaveCancel();
2261 print
'<br></form>';
2262 } elseif ($action ==
'showlog_customer_price') {
2264 print
'<!-- list of all log of prices per customer -->'.
"\n";
2266 $sortfield =
't.datec';
2267 $filter = array(
't.fk_product' => (
string)
$object->id,
't.fk_soc' => (
string)
GETPOSTINT(
'socid'));
2270 $nbtotalofrecords =
'';
2272 $nbtotalofrecords = $prodcustprice->fetchAllLog($sortorder, $sortfield,
$conf->liste_limit, $offset, $filter);
2275 $result = $prodcustprice->fetchAllLog($sortorder, $sortfield,
$conf->liste_limit, $offset, $filter);
2280 $option =
'&socid='.GETPOSTINT(
'socid').
'&id='.
$object->id;
2285 $title = $langs->trans(
'PriceByCustomerLog');
2286 $title .=
' - '.$staticsoc->getNomUrl(1);
2288 $backbutton =
'<a class="justalink" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'">'.$langs->trans(
"GoBack").
'</a>';
2291 print_barre_liste($title, $page, $_SERVER[
'PHP_SELF'], $option, $sortfield, $sortorder, $backbutton, count($prodcustprice->lines), $nbtotalofrecords,
'title_accountancy.png');
2293 if (count($prodcustprice->lines) > 0) {
2294 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'" method="POST">';
2295 print
'<input type="hidden" name="token" value="'.newToken().
'">';
2296 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
2298 print
'<div class="div-table-responsive-no-min">';
2299 print
'<table class="liste centpercent">';
2301 print
'<tr class="liste_titre">';
2302 print
'<td>'.$langs->trans(
"ThirdParty").
'</td>';
2303 print
'<td>'.$langs->trans(
'RefCustomer').
'</td>';
2304 print
'<td>'.$langs->trans(
"AppliedPricesFrom").
'</td>';
2305 print
'<td>'.$langs->trans(
"AppliedPricesTo").
'</td>';
2306 print
'<td class="center">'.$langs->trans(
"PriceBase").
'</td>';
2307 print
'<td class="right">'.$langs->trans(
"DefaultTaxRate").
'</td>';
2308 print
'<td class="right">'.$langs->trans(
"HT").
'</td>';
2309 print
'<td class="right">'.$langs->trans(
"TTC").
'</td>';
2310 if (
$mysoc->localtax1_assuj ==
"1" ||
$mysoc->localtax2_assuj ==
"1") {
2311 print
'<td class="right">'.$langs->trans(
"INCT").
'</td>';
2313 print
'<td class="right">'.$langs->trans(
"MinPrice").
' '.$langs->trans(
"HT").
'</td>';
2314 print
'<td class="right">'.$langs->trans(
"MinPrice").
' '.$langs->trans(
"TTC").
'</td>';
2315 print
'<td class="right">'.$langs->trans(
"PriceLabel").
'</td>';
2316 print
'<td class="right">'.$langs->trans(
"Discount").
'</td>';
2317 print
'<td class="right">'.$langs->trans(
"ChangedBy").
'</td>';
2318 print
'<td>'.$langs->trans(
"DateCreation").
'</td>';
2321 foreach ($prodcustprice->lines as $line) {
2324 $staticsoc->fetch($line->fk_soc);
2326 $tva_tx = $line->default_vat_code ? $line->tva_tx.
' ('.$line->default_vat_code.
')' : $line->tva_tx;
2329 if ($line->price_base_type ==
'HT') {
2332 $pu = $line->price_ttc;
2336 $localtaxarray =
getLocalTaxesFromRate($line->tva_tx.($line->default_vat_code ?
' ('.$line->default_vat_code.
')' :
''), 0, $staticsoc,
$mysoc);
2338 $resultarray =
calcul_price_total(1, $pu, 0, (
float) $line->tva_tx, 1, 1, 0, $line->price_base_type, $line->recuperableonly,
$object->type,
$mysoc, $localtaxarray);
2340 $total_ht = $resultarray[0];
2341 $total_vat = $resultarray[1];
2342 $total_localtax1 = $resultarray[9];
2343 $total_localtax2 = $resultarray[10];
2344 $total_ttc = $resultarray[2];
2346 print
'<tr class="oddeven">';
2348 print
'<td class="tdoverflowmax125">'.$staticsoc->getNomUrl(1).
"</td>";
2349 print
'<td>'.$line->ref_customer.
'</td>';
2350 print
"<td>".dol_print_date($line->date_begin,
"day",
'tzuserrel').
"</td>";
2351 print
"<td>".dol_print_date($line->date_end,
"day",
'tzuserrel').
"</td>";
2352 print
'<td class="center">'.$langs->trans($line->price_base_type).
"</td>";
2353 print
'<td class="right nowraponall">';
2355 $positiverates =
'';
2357 $positiverates .= ($positiverates ?
'/' :
'').
price2num($line->tva_tx);
2360 $positiverates .= ($positiverates ?
'/' :
'').
price2num($line->localtax1_tx);
2363 $positiverates .= ($positiverates ?
'/' :
'').
price2num($line->localtax2_tx);
2365 if (empty($positiverates)) {
2366 $positiverates =
'0';
2369 echo
vatrate($positiverates.($line->default_vat_code ?
' ('.$line->default_vat_code.
')' :
''), true, ($line->tva_npr ? $line->tva_npr : $line->recuperableonly));
2373 print
'<td class="right"><span class="amount">'.price($line->price).
"</span></td>";
2375 print
'<td class="right"><span class="amount">'.price($line->price_ttc).
"</span></td>";
2376 if (
$mysoc->localtax1_assuj ==
"1" ||
$mysoc->localtax2_assuj ==
"1") {
2377 print
'<td class="right">'.price($resultarray[2]).
'</td>';
2380 print
'<td class="right">'.price($line->price_min).
'</td>';
2381 print
'<td class="right">'.price($line->price_min_ttc).
'</td>';
2382 print
'<td class="right">'.dolPrintHTML($line->price_label).
'</td>';
2383 print
'<td class="right">'.price($line->discount_percent).
'</td>';
2386 print
'<td class="tdoverflowmax125">';
2388 if ($line->fk_user > 0) {
2390 $userstatic->fetch($line->fk_user);
2391 print $userstatic->getNomUrl(1,
'', 0, 0, 24, 0,
'login');
2395 print
"<td>".dol_print_date($line->datec,
"dayhour",
'tzuserrel').
"</td>";
2401 print $langs->trans(
'None');
2403 } elseif ($action !=
'showlog_default_price' && $action !=
'edit_price' && $action !=
'edit_level_price') {
2405 print
'<!-- list of all prices per customer -->'.
"\n";
2408 $nbtotalofrecords =
'';
2410 $nbtotalofrecords = $prodcustprice->fetchAll($sortorder, $sortfield, 0, 0, $filter);
2413 $result = $prodcustprice->fetchAll($sortorder, $sortfield,
$conf->liste_limit, $offset, $filter);
2418 $option =
'&search_soc='.$search_soc.
'&id='.
$object->id;
2421 print_barre_liste($langs->trans(
'PriceByCustomer'), $page, $_SERVER [
'PHP_SELF'], $option, $sortfield, $sortorder,
'', count($prodcustprice->lines), $nbtotalofrecords,
'title_accountancy.png');
2423 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'" method="POST">';
2424 print
'<input type="hidden" name="token" value="'.newToken().
'">';
2425 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
2427 print
'<!-- List of prices per customer -->'.
"\n";
2428 print
'<div class="div-table-responsive-no-min">'.
"\n";
2429 print
'<table class="liste centpercent">'.
"\n";
2431 if (count($prodcustprice->lines) > 0 || $search_soc) {
2432 $extrafields->fetch_name_optionals_label(
"product_customer_price");
2433 $custom_price_extralabels = !empty($extrafields->attributes[
"product_customer_price"][
'label']) ? $extrafields->attributes[
"product_customer_price"][
'label'] :
'';
2439 if (
$mysoc->localtax1_assuj ==
"1" ||
$mysoc->localtax2_assuj ==
"1") {
2442 if (!empty($custom_price_extralabels) && is_array($custom_price_extralabels)) {
2443 $colspan += count($custom_price_extralabels);
2446 print
'<tr class="liste_titre">';
2447 print
'<td class="liste_titre"><input type="text" class="flat maxwidth125" name="search_soc" value="'.$search_soc.
'"></td>';
2448 print
'<td class="liste_titre" colspan="'.$colspan.
'"> </td>';
2450 print
'<td class="liste_titre maxwidthsearch">';
2451 $searchpicto = $form->showFilterAndCheckAddButtons(0);
2457 print
'<tr class="liste_titre">';
2458 print
'<td>'.$langs->trans(
"ThirdParty").
'</td>';
2459 print
'<td>'.$langs->trans(
'RefCustomer').
'</td>';
2460 print
'<td>'.$langs->trans(
"AppliedPricesFrom").
'</td>';
2461 print
'<td>'.$langs->trans(
"AppliedPricesTo").
'</td>';
2462 print
'<td class="center">'.$langs->trans(
"PriceBase").
'</td>';
2463 print
'<td class="right">'.$langs->trans(
"DefaultTaxRate").
'</td>';
2464 print
'<td class="right">'.$langs->trans(
"HT").
'</td>';
2465 print
'<td class="right">'.$langs->trans(
"TTC").
'</td>';
2466 if (
$mysoc->localtax1_assuj ==
"1" ||
$mysoc->localtax2_assuj ==
"1") {
2467 print
'<td class="right">'.$langs->trans(
"INCT").
'</td>';
2469 print
'<td class="right">'.$langs->trans(
"MinPrice").
' '.$langs->trans(
"HT").
'</td>';
2470 print
'<td class="right">'.$langs->trans(
"MinPrice").
' '.$langs->trans(
"TTC").
'</td>';
2471 print
'<td class="right">'.$langs->trans(
"PriceLabel").
'</td>';
2472 print
'<td class="right">'.$langs->trans(
"Discount").
'</td>';
2474 $extrafields->fetch_name_optionals_label(
"product_customer_price");
2475 if ($extrafields->attributes[
"product_customer_price"] && array_key_exists(
'label', $extrafields->attributes[
"product_customer_price"])) {
2476 $extralabels = $extrafields->attributes[
"product_customer_price"][
'label'];
2477 if (!empty($extralabels)) {
2478 foreach ($extralabels as $key => $value) {
2480 if (!empty($extrafields->attributes[
"product_customer_price"][
'list'][$key]) && $extrafields->attributes[
"product_customer_price"][
'list'][$key] != 3) {
2481 if (!empty($extrafields->attributes[
"product_customer_price"][
'langfile'][$key])) {
2482 $langs->load($extrafields->attributes[
"product_customer_price"][
'langfile'][$key]);
2484 if (!empty($extrafields->attributes[
"product_customer_price"][
'help'][$key])) {
2485 $extratitle = $form->textwithpicto($langs->trans($value), $langs->trans($extrafields->attributes[
"product_customer_price"][
'help'][$key]));
2487 $extratitle = $langs->trans($value);
2489 print
'<td style="text-align: right">'.$extratitle.
'</td>';
2494 print
'<td>'.$langs->trans(
"ChangedBy").
'</td>';
2499 if (
$object->price_base_type ==
'HT') {
2508 $resultarray =
calcul_price_total(1, $pu, 0,
$object->tva_tx, 1, 1, 0,
$object->price_base_type, 0,
$object->type,
$mysoc, $localtaxarray);
2510 $total_ht = $resultarray[0];
2511 $total_vat = $resultarray[1];
2512 $total_localtax1 = $resultarray[9];
2513 $total_localtax2 = $resultarray[10];
2514 $total_ttc = $resultarray[2];
2517 print
'<!-- PRODUIT_CUSTOMER_PRICES_AND_MULTIPRICES -->'.
"\n";
2518 print
'<tr class="oddeven">';
2519 print
'<td colspan="4">' . $langs->trans(
'Default') .
'</td>';
2521 print
'<td class="center">'.$langs->trans(
$object->price_base_type).
"</td>";
2524 print
'<td class="right nowraponall">';
2526 $positiverates =
'';
2531 $positiverates .= ($positiverates ?
'/' :
'').
price2num(
$object->localtax1_tx);
2534 $positiverates .= ($positiverates ?
'/' :
'').
price2num(
$object->localtax2_tx);
2536 if (empty($positiverates)) {
2537 $positiverates =
'0';
2539 echo
vatrate($positiverates.($object->default_vat_code ?
' ('.$object->default_vat_code.
')' :
''), true,
$object->tva_npr);
2543 print
'<td class="right"><span class="amount">'.price(
$object->price).
"</span></td>";
2545 print
'<td class="right"><span class="amount">'.price(
$object->price_ttc).
"</span></td>";
2546 if (
$mysoc->localtax1_assuj ==
"1" ||
$mysoc->localtax2_assuj ==
"1") {
2548 print
'<td class="right"><span class="amount">'.price($resultarray[2]).
'</span></td>';
2551 print
'<td class="right">'.price(
$object->price_min).
'</td>';
2552 print
'<td class="right">'.price(
$object->price_min_ttc).
'</td>';
2553 print
'<td class="right">'.dolPrintHTML(
$object->price_label).
'</td>';
2554 print
'<td class="right"></td>';
2555 print
'<td class="right"></td>';
2556 if (!empty($extralabels)) {
2557 foreach ($extralabels as $key) {
2559 if (!empty($extrafields->attributes[
"product_customer_price"][
'list'][$key]) && $extrafields->attributes[
"product_customer_price"][
'list'][$key] != 3) {
2560 print
'<td class="right"></td>';
2564 if ($user->hasRight(
'produit',
'supprimer') || $user->hasRight(
'service',
'supprimer')) {
2565 print
'<td class="nowraponall">';
2566 print
'<a class="marginleftonly marginrightonly" href="'.$_SERVER[
"PHP_SELF"].
'?action=showlog_default_price&token='.
newToken().
'&id='.
$object->id.
'">';
2567 print
img_info($langs->trans(
'PriceByCustomerLog'));
2570 print
'<a class="marginleftonly marginrightonly editfielda" href="'.$_SERVER[
"PHP_SELF"].
'?action=edit_price&token='.
newToken().
'&id='.
$object->id.
'">';
2571 print
img_edit(
'default', 0,
'style="vertical-align: middle;"');
2578 if (count($prodcustprice->lines) > 0) {
2579 foreach ($prodcustprice->lines as $line) {
2582 $staticsoc->fetch($line->fk_soc);
2584 $tva_tx = $line->default_vat_code ? $line->tva_tx.
' ('.$line->default_vat_code.
')' : $line->tva_tx;
2587 if ($line->price_base_type ==
'HT') {
2590 $pu = $line->price_ttc;
2594 $localtaxarray =
getLocalTaxesFromRate($line->tva_tx.($line->default_vat_code ?
' ('.$line->default_vat_code.
')' :
''), 0, $staticsoc,
$mysoc);
2596 $resultarray =
calcul_price_total(1, $pu, 0, (
float) $line->tva_tx, 1, 1, 0, $line->price_base_type, $line->recuperableonly,
$object->type,
$mysoc, $localtaxarray);
2598 $total_ht = $resultarray[0];
2599 $total_vat = $resultarray[1];
2600 $total_localtax1 = $resultarray[9];
2601 $total_localtax2 = $resultarray[10];
2602 $total_ttc = $resultarray[2];
2604 print
'<tr class="oddeven">';
2606 print
'<td class="tdoverflowmax125">'.$staticsoc->getNomUrl(1).
"</td>";
2607 print
'<td>'.dolPrintHTML($line->ref_customer).
'</td>';
2608 print
"<td>".dol_print_date($line->date_begin,
"day",
'tzuserrel').
"</td>";
2609 print
"<td>".dol_print_date($line->date_end,
"day",
'tzuserrel').
"</td>";
2610 print
'<td class="center">'.$langs->trans($line->price_base_type).
"</td>";
2612 print
'<td class="right nowraponall">';
2614 $positiverates =
'';
2616 $positiverates .= ($positiverates ?
'/' :
'').
price2num($line->tva_tx);
2619 $positiverates .= ($positiverates ?
'/' :
'').
price2num($line->localtax1_tx);
2622 $positiverates .= ($positiverates ?
'/' :
'').
price2num($line->localtax2_tx);
2624 if (empty($positiverates)) {
2625 $positiverates =
'0';
2628 echo
vatrate($positiverates.($line->default_vat_code ?
' ('.$line->default_vat_code.
')' :
''), true, (!empty($line->tva_npr) ? $line->tva_npr : $line->recuperableonly));
2632 print
'<td class="right"><span class="amount">'.price($line->price).
"</span></td>";
2634 print
'<td class="right"><span class="amount">'.price($line->price_ttc).
"</span></td>";
2635 if (
$mysoc->localtax1_assuj ==
"1" ||
$mysoc->localtax2_assuj ==
"1") {
2637 print
'<td class="right"><span class="amount">'.price($resultarray[2]).
'</span></td>';
2640 print
'<td class="right">'.price($line->price_min).
'</td>';
2641 print
'<td class="right">'.price($line->price_min_ttc).
'</td>';
2642 print
'<td class="right">'.dolPrintHTMLForAttribute($line->price_label).
'</td>';
2643 print
'<td class="right">'.price($line->discount_percent).
'</td>';
2646 $extrafields->fetch_name_optionals_label(
"product_customer_price");
2647 $extralabels = $extrafields->attributes[
"product_customer_price"][
'label'] ?? array();
2648 if (!empty($extralabels)) {
2650 $sql .=
" fk_object";
2651 foreach ($extralabels as $key => $value) {
2652 $sql .=
", ".$db->sanitize($key);
2654 $sql .=
" FROM ".MAIN_DB_PREFIX.
"product_customer_price_extrafields";
2655 $sql .=
" WHERE fk_object = ".((int) $line->id);
2656 $resql =
$db->query($sql);
2658 if (
$db->num_rows($resql) != 1) {
2659 foreach ($extralabels as $key => $value) {
2660 if (!empty($extrafields->attributes[
"product_customer_price"][
'list'][$key]) && $extrafields->attributes[
"product_customer_price"][
'list'][$key] != 3) {
2665 $obj =
$db->fetch_object($resql);
2666 foreach ($extralabels as $key => $value) {
2667 if (!empty($extrafields->attributes[
"product_customer_price"][
'list'][$key]) && $extrafields->attributes[
"product_customer_price"][
'list'][$key] != 3) {
2668 print
'<td align="right">'.$extrafields->showOutputField($key, $obj->{$key},
'',
'product_customer_price').
"</td>";
2677 print
'<td class="tdoverflowmax125">';
2678 if ($line->fk_user > 0) {
2680 $userstatic->fetch($line->fk_user);
2682 print $userstatic->getNomUrl(-1,
'', 0, 0, 24, 0,
'login');
2688 print
'<td class="right nowraponall">';
2689 if ($user->hasRight(
'produit',
'creer') || $user->hasRight(
'service',
'creer')) {
2690 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=showlog_customer_price&token='.
newToken().
'&id='.
$object->id.
'&socid='.$line->fk_soc.
'">';
2691 print
img_info($langs->trans(
'PriceByCustomerLog'));
2694 print
'<a class="marginleftonly editfielda" href="'.$_SERVER[
"PHP_SELF"].
'?action=edit_customer_price&token='.
newToken().
'&id='.
$object->id.
'&lineid='.$line->id.
'">';
2695 print
img_edit(
'default', 0,
'style="vertical-align: middle;"');
2699 if ($user->hasRight(
'produit',
'supprimer') || $user->hasRight(
'service',
'supprimer')) {
2700 print
'<a class="marginleftonly" href="'.$_SERVER[
"PHP_SELF"].
'?action=ask_remove_customer_price&token='.
newToken().
'&id='.
$object->id.
'&lineid='.$line->id.
'">';
2701 print
img_delete(
'default',
'style="vertical-align: middle;"');
2719if ((!
getDolGlobalString(
'PRODUIT_CUSTOMER_PRICES') || $action ==
'showlog_default_price') && !in_array($action, array(
'edit_price',
'edit_level_price',
'edit_vat'))) {
2720 $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,";
2721 $sql .=
" p.price_level, p.price_min, p.price_min_ttc,p.price_by_qty,";
2722 $sql .=
" p.date_price as dp, p.fk_price_expression, u.rowid as user_id, u.login";
2723 $sql .=
" ,p.price_label";
2724 $sql .=
" FROM ".MAIN_DB_PREFIX.
"product_price as p,";
2725 $sql .=
" ".MAIN_DB_PREFIX.
"user as u";
2726 $sql .=
" WHERE fk_product = ".((int)
$object->id);
2727 $sql .=
" AND p.entity IN (".getEntity(
'productprice').
")";
2728 $sql .=
" AND p.fk_user_author = u.rowid";
2730 $sql .=
" AND p.price_level = ".((int) $soc->price_level);
2732 $sql .=
" ORDER BY p.date_price DESC, p.rowid DESC, p.price_level ASC";
2736 $result =
$db->query($sql);
2738 print
'<div class="divlogofpreviouscustomerprice">';
2740 $num =
$db->num_rows($result);
2749 $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);
2751 $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);
2757 $result =
$db->query($sql);
2758 $num =
$db->num_rows($result);
2765 $backbutton =
'<a class="justalink" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'">'.$langs->trans(
"GoBack").
'</a>';
2769 print_barre_liste($langs->trans(
"DefaultPriceLog"), 0, $_SERVER[
"PHP_SELF"],
'',
'',
'', $backbutton, 0, $num,
'title_accountancy.png');
2772 print_barre_liste($langs->trans(
"PriceByCustomerLog"), 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', 0, $num,
'title_accountancy.png');
2775 print
'<!-- List of log prices -->'.
"\n";
2776 print
'<div class="div-table-responsive">'.
"\n";
2777 print
'<table class="liste centpercent noborder">'.
"\n";
2779 print
'<tr class="liste_titre">';
2780 print
'<th>'.$langs->trans(
"AppliedPricesFrom").
'</tg>';
2783 print
'<th class="center">'.$langs->trans(
"PriceLevel").
'</th>';
2786 print
'<th class="center">'.$langs->trans(
"Type").
'</th>';
2789 print
'<th class="center">'.$langs->trans(
"PriceBase").
'</th>';
2791 print
'<th class="right">'.$langs->trans(
"DefaultTaxRate").
'</th>';
2793 print
'<th class="right">'.$langs->trans(
"HT").
'</th>';
2794 print
'<th class="right">'.$langs->trans(
"TTC").
'</th>';
2795 if (
$mysoc->localtax1_assuj ==
"1" ||
$mysoc->localtax2_assuj ==
"1") {
2796 print
'<th class="right">'.$langs->trans(
"INCT").
'</th>';
2799 print
'<th class="right">'.$langs->trans(
"PriceExpressionSelected").
'</th>';
2801 print
'<th class="right">'.$langs->trans(
"MinPrice").
' '.$langs->trans(
"HT").
'</th>';
2802 print
'<th class="right">'.$langs->trans(
"MinPrice").
' '.$langs->trans(
"TTC").
'</th>';
2803 print
'<th class="right">'.$langs->trans(
"Label").
'</th>';
2804 print
'<th>'.$langs->trans(
"ChangedBy").
'</th>';
2805 if ($user->hasRight(
'produit',
'supprimer')) {
2806 print
'<th class="right"> </th>';
2810 $notfirstlineforlevel = array();
2814 $objp =
$db->fetch_object($result);
2816 print
'<tr class="oddeven">';
2818 print
"<td>".dol_print_date(
$db->jdate($objp->dp),
"dayhour",
'tzuserrel').
"</td>";
2822 print
'<td class="center">'.$objp->price_level.
"</td>";
2826 $type = ($objp->price_by_qty == 1) ?
'PriceByQuantity' :
'Standard';
2827 print
'<td class="center">'.$langs->trans($type).
"</td>";
2830 print
'<td class="center">';
2831 if (empty($objp->price_by_qty)) {
2832 print $langs->trans($objp->price_base_type);
2837 print
'<td class="right">';
2839 if (empty($objp->price_by_qty)) {
2840 $positiverates =
'';
2842 $positiverates .= ($positiverates ?
'/' :
'').
price2num($objp->tva_tx);
2845 $positiverates .= ($positiverates ?
'/' :
'').
price2num($objp->localtax1_tx);
2848 $positiverates .= ($positiverates ?
'/' :
'').
price2num($objp->localtax2_tx);
2850 if (empty($positiverates)) {
2851 $positiverates =
'0';
2853 echo
vatrate($positiverates.($objp->default_vat_code ?
' ('.$objp->default_vat_code.
')' :
''), true, !empty($objp->tva_npr) ? $objp->tva_npr : 0);
2866 if ($objp->price_base_type ==
'HT') {
2869 $pu = $objp->price_ttc;
2875 $resultarray =
calcul_price_total(1, $pu, 0, $objp->tva_tx, 1, 1, 0, $objp->price_base_type, $objp->recuperableonly,
$object->type,
$mysoc, $localtaxarray);
2877 $total_ht = $resultarray[0];
2878 $total_vat = $resultarray[1];
2879 $total_localtax1 = $resultarray[9];
2880 $total_localtax2 = $resultarray[10];
2881 $total_ttc = $resultarray[2];
2884 if (!empty($objp->fk_price_expression) && !empty(
$conf->dynamicprices->enabled)) {
2886 $res = $price_expression->fetch($objp->fk_price_expression);
2887 $title = $price_expression->title;
2888 print
'<td class="right"></td>';
2889 print
'<td class="right"></td>';
2890 if (
$mysoc->localtax1_assuj ==
"1" ||
$mysoc->localtax2_assuj ==
"1") {
2891 print
'<td class="right"></td>';
2893 print
'<td class="right">'.$title.
"</td>";
2896 print
'<td class="right">';
2897 if (empty($objp->price_by_qty)) {
2898 print
'<span class="amount">'.price($objp->price).
'</span>';
2902 print
'<td class="right">';
2903 if (empty($objp->price_by_qty)) {
2904 $price_ttc = $objp->price_ttc;
2905 print
'<span class="amount">'.price($price_ttc).
'<span>';
2908 if (
$mysoc->localtax1_assuj ==
"1" ||
$mysoc->localtax2_assuj ==
"1") {
2909 print
'<td class="right">';
2910 print $resultarray[2];
2914 print
'<td class="right"></td>';
2919 print
'<td class="right">';
2920 if (empty($objp->price_by_qty)) {
2921 print
price($objp->price_min);
2926 print
'<td class="right">';
2927 if (empty($objp->price_by_qty)) {
2928 $price_min_ttc = $objp->price_min_ttc;
2929 print
price($price_min_ttc);
2939 print
'<td class="tdoverflowmax125">';
2940 if ($objp->user_id > 0) {
2943 $userstatic->fetch($objp->user_id);
2944 print $userstatic->getNomUrl(-1,
'', 0, 0, 24, 0,
'login');
2949 if ($user->hasRight(
'produit',
'supprimer')) {
2952 if (empty($notfirstlineforlevel[$objp->price_level])) {
2953 $notfirstlineforlevel[$objp->price_level] = 1;
2961 print
'<td class="right">';
2962 if ($candelete || (
$db->jdate($objp->dp) >=
dol_now())) {
2963 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=delete&token='.
newToken().
'&id='.
$object->id.
'&lineid='.$objp->rowid.
'">';
$id
Support class for third parties, contacts, members, users or resources.
if(! $sortfield) if(! $sortorder) $object
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.
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...
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
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.
print_barre_liste($title, $page, $file, $options='', $sortfield='', $sortorder='', $morehtmlcenter='', $num=-1, $totalnboflines='', $picto='generic', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limit=-1, $selectlimitsuffix=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow='')
Print a title with navigation controls for pagination.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
Show picto whatever it's its name (generic function)
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
img_delete($titlealt='default', $other='class="pictodelete"', $morecss='')
Show delete logo.
dolPrintHTML($s, $allowiframe=0, $moreallowedtags=array())
Return a string (that can be on several lines) ready to be output on a HTML page.
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.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
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_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
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.
img_edit($titlealt='default', $float=0, $other='')
Show logo edit/modify fiche.
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,...
img_info($titlealt='default')
Show info logo.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
print $langs trans("Show") . '< td style="' . $timeColor . '" align="center"> s</td > badge status0 badge status4 badge status3 Error badge status8< td align="center">< span class="badge ' . $badge . '"></span ></td >< td align="center">< a href="#" class="button button-small" onclick="openLogModal(this)" data-req="' . dol_escape_htmltag($reqSafe) . '" data-res="' . dol_escape_htmltag($resSafe) . '" data-err="' . dol_escape_htmltag($errSafe) . '">< span class="fa fa-search-plus"></span ></a ></td ></tr >< tr >< td colspan="' . $colspan . '" class="opacitymedium"></td ></tr ></table ></div ></form > logModal none logModal none s a JSON string
buildzip.php
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.
if(preg_match('/(crypted|dolcrypt):/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
'integer', 'integer:ObjectClass:PathToClass[:AddCreateButtonOrNot[:Filter[:Sortfield]]]',...
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.