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'));
72$action =
GETPOST(
'action',
'aZ09');
73$cancel =
GETPOST(
'cancel',
'alpha');
76$search_soc =
GETPOST(
'search_soc');
79$fieldvalue = (!empty($id) ?
$id : (!empty($ref) ? $ref :
''));
80$fieldtype = (!empty($ref) ?
'ref' :
'rowid');
82 $socid = $user->socid;
86if ($id > 0 || !empty($ref)) {
94 $conf->global->PRODUIT_MULTIPRICES_LIMIT = 5;
98$hookmanager->initHooks(array(
'productpricecard',
'globalcard'));
101 if (
$object->type == $object::TYPE_PRODUCT) {
104 if (
$object->type == $object::TYPE_SERVICE) {
108 restrictedArea($user,
'produit|service', $fieldvalue,
'product&product',
'',
'', $fieldtype);
111$maxpricesupplier = 0;
114 $permissiontoadd =
$object->getRights()->creer;
116 $permissiontoadd = ($user->hasRight(
'produit',
'creer') || $user->hasRight(
'service',
'creer'));
128$parameters = array(
'id' => $id,
'ref' => $ref);
129$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
134if (empty($reshook)) {
135 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
139 if ($action ==
'setlabelsellingprice' && $user->admin) {
140 require_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
141 $keyforlabel =
'PRODUIT_MULTIPRICES_LABEL'.GETPOST(
'pricelevel');
146 if (($action ==
'update_vat') && !$cancel && $permissiontoadd) {
147 $tva_tx_txt =
GETPOST(
'tva_tx',
'alpha');
149 $price_label =
GETPOST(
'price_label',
'alpha');
152 $tva_tx = $tva_tx_txt;
155 if (preg_match(
'/\((.*)\)/', $tva_tx_txt, $reg)) {
156 $vatratecode = $reg[1];
157 $tva_tx = preg_replace(
'/\s*\(.*\)/',
'', $tva_tx_txt);
160 $tva_tx =
price2num(preg_replace(
'/\*/',
'', $tva_tx));
161 $npr = preg_match(
'/\*/', $tva_tx_txt) ? 1 : 0;
164 $localtax1_type =
'0';
165 $localtax2_type =
'0';
168 if (preg_match(
'/\((.*)\)/', $tva_tx_txt, $reg)) {
170 $vatratecode = $reg[1];
172 $sql =
"SELECT t.rowid, t.type_vat, t.code, t.recuperableonly, t.localtax1, t.localtax2, t.localtax1_type, t.localtax2_type";
173 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_tva as t, ".MAIN_DB_PREFIX.
"c_country as c";
174 $sql .=
" WHERE t.fk_pays = c.rowid AND c.code = '".$db->escape($mysoc->country_code).
"'";
175 $sql .=
" AND t.taux = ".((float) $tva_tx).
" AND t.active = 1";
176 $sql .=
" AND t.code = '".$db->escape($vatratecode).
"'";
177 $sql .=
" AND t.type_vat IN (0, 1)";
178 $sql .=
" AND t.entity IN (".getEntity(
'c_tva').
")";
179 $resql = $db->query($sql);
181 $obj = $db->fetch_object($resql);
183 $npr = $obj->recuperableonly;
184 $localtax1 = $obj->localtax1;
185 $localtax2 = $obj->localtax2;
186 $localtax1_type = $obj->localtax1_type;
187 $localtax2_type = $obj->localtax2_type;
192 $sql =
"SELECT t.rowid, t.code, t.recuperableonly, t.localtax1, t.localtax2, t.localtax1_type, t.localtax2_type";
193 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_tva as t, ".MAIN_DB_PREFIX.
"c_country as c";
194 $sql .=
" WHERE t.fk_pays = c.rowid AND c.code = '".$db->escape($mysoc->country_code).
"'";
195 $sql .=
" AND t.taux = ".((float) $tva_tx).
" AND t.active = 1";
196 $sql .=
" AND t.code = ''";
197 $sql .=
" AND t.entity IN (".getEntity(
'c_tva').
")";
198 $resql = $db->query($sql);
200 $obj = $db->fetch_object($resql);
202 $npr = $obj->recuperableonly;
203 $localtax1 = $obj->localtax1;
204 $localtax2 = $obj->localtax2;
205 $localtax1_type = $obj->localtax1_type;
206 $localtax2_type = $obj->localtax2_type;
211 $object->default_vat_code = $vatratecode;
214 $object->localtax1_tx = $localtax1;
215 $object->localtax2_tx = $localtax2;
216 $object->localtax1_type = $localtax1_type;
217 $object->localtax2_type = $localtax2_type;
218 $object->price_label = $price_label;
230 $produit_multiprices_limit =
getDolGlobalInt(
'PRODUIT_MULTIPRICES_LIMIT');
231 for ($i = 1; $i <= $produit_multiprices_limit; $i++) {
233 if (
$object->multiprices_base_type[$i] ==
'HT') {
234 $oldprice =
$object->multiprices[$i];
235 $oldminprice =
$object->multiprices_min[$i];
237 $oldprice =
$object->multiprices_ttc[$i];
238 $oldminprice =
$object->multiprices_min_ttc[$i];
240 $oldpricebasetype =
$object->multiprices_base_type[$i];
241 $oldnpr =
$object->multiprices_recuperableonly[$i];
244 $localtaxarray = array();
246 $ret =
$object->updatePrice($oldprice, $oldpricebasetype, $user, (
float) $tva_tx, $oldminprice, $level, $oldnpr, 0, 0, $localtaxarray, $vatratecode, $price_label);
255 if (
$object->price_base_type ==
'HT') {
257 $oldminprice =
$object->price_min;
259 $oldprice =
$object->price_ttc;
260 $oldminprice =
$object->price_min_ttc;
262 $oldpricebasetype =
$object->price_base_type;
266 $localtaxarray = array();
268 $ret =
$object->updatePrice($oldprice, $oldpricebasetype, $user, (
float) $tva_tx, $oldminprice, $level, $oldnpr, 0, 0, $localtaxarray, $vatratecode, $price_label);
286 $maxpricesupplier = 0;
288 if (($action ==
'update_price' || $action ==
'update_level_price') && !$cancel && $permissiontoadd) {
290 $pricestoupdate = array();
295 $maxpricesupplier =
$object->min_recommended_price();
300 if (isModEnabled(
'dynamicprices')) {
301 $object->fk_price_expression = empty($eid) ? 0 : $eid;
303 if (
$object->fk_price_expression != 0) {
305 require_once DOL_DOCUMENT_ROOT.
'/product/dynamic_price/class/price_parser.class.php';
308 if ($priceparser->parseProduct($object) < 0) {
317 || ($action ==
'update_level_price' &&
getDolGlobalString(
'PRODUIT_CUSTOMER_PRICES_AND_MULTIPRICES')))) {
318 $newprice =
GETPOST(
'price',
'array');
319 $newprice_min =
GETPOST(
'price_min',
'array');
320 $newpricebase =
GETPOST(
'multiprices_base_type',
'array');
321 $newvattx =
GETPOST(
'tva_tx',
'array');
322 $newvatnpr =
GETPOST(
'tva_npr',
'array');
323 $newlocaltax1_tx =
GETPOST(
'localtax1_tx',
'array');
324 $newlocaltax1_type =
GETPOST(
'localtax1_type',
'array');
325 $newlocaltax2_tx =
GETPOST(
'localtax2_tx',
'array');
326 $newlocaltax2_type =
GETPOST(
'localtax2_type',
'array');
329 $object->price_autogen = (int) (
GETPOST(
'usePriceRules') ==
'on');
331 $produit_multiprices_limit =
getDolGlobalInt(
'PRODUIT_MULTIPRICES_LIMIT');
332 for ($i = 1; $i <= $produit_multiprices_limit; $i++) {
333 if (!isset($newprice[$i])) {
337 $tva_tx_txt = $newvattx[$i];
339 $tva_tx = $tva_tx_txt;
342 if (preg_match(
'/\((.*)\)/', $tva_tx_txt, $reg)) {
343 $vat_src_code = $reg[1];
344 $tva_tx = preg_replace(
'/\s*\(.*\)/',
'', $tva_tx_txt);
346 $tva_tx =
price2num(preg_replace(
'/\*/',
'', $tva_tx));
348 $npr = preg_match(
'/\*/', $tva_tx_txt) ? 1 : 0;
349 $localtax1 = $newlocaltax1_tx[$i];
350 $localtax1_type = $newlocaltax1_type[$i];
351 $localtax2 = $newlocaltax2_tx[$i];
352 $localtax2_type = $newlocaltax2_type[$i];
353 if (preg_match(
'/\((.*)\)/', $tva_tx_txt, $reg)) {
355 $vatratecode = $reg[1];
357 $sql =
"SELECT t.rowid, t.code, t.recuperableonly, t.localtax1, t.localtax2, t.localtax1_type, t.localtax2_type";
358 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_tva as t, ".MAIN_DB_PREFIX.
"c_country as c";
359 $sql .=
" WHERE t.fk_pays = c.rowid AND c.code = '".$db->escape($mysoc->country_code).
"'";
360 $sql .=
" AND t.taux = ".((float) $tva_tx).
" AND t.active = 1";
361 $sql .=
" AND t.code ='".$db->escape($vatratecode).
"'";
362 $sql .=
" AND t.entity IN (".getEntity(
'c_tva').
")";
363 $resql = $db->query($sql);
365 $obj = $db->fetch_object($resql);
367 $npr = $obj->recuperableonly;
368 $localtax1 = $obj->localtax1;
369 $localtax2 = $obj->localtax2;
370 $localtax1_type = $obj->localtax1_type;
371 $localtax2_type = $obj->localtax2_type;
375 if (in_array($mysoc->country_code, array(
'ES'))) {
382 $sql =
"SELECT t.rowid, t.code, t.recuperableonly, t.localtax1, t.localtax2, t.localtax1_type, t.localtax2_type";
383 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_tva as t, ".MAIN_DB_PREFIX.
"c_country as c";
384 $sql .=
" WHERE t.fk_pays = c.rowid AND c.code = '".$db->escape($mysoc->country_code).
"'";
385 $sql .=
" AND t.taux = ".((float) $tva_tx).
" AND t.active = 1";
386 $sql .=
" AND t.code = ''";
387 $resql = $db->query($sql);
389 $obj = $db->fetch_object($resql);
391 $npr = $obj->recuperableonly;
392 $localtax1 = $obj->localtax1;
393 $localtax2 = $obj->localtax2;
394 $localtax1_type = $obj->localtax1_type;
395 $localtax2_type = $obj->localtax2_type;
400 $pricestoupdate[$i] = array(
401 'price' =>
price2num($newprice[$i],
'', 2),
402 'price_min' =>
price2num($newprice_min[$i],
'', 2),
403 'price_base_type' => $newpricebase[$i],
404 'default_vat_code' => $vatratecode,
407 'localtaxes_array' => array(
'0' => $localtax1_type,
'1' => $localtax1,
'2' => $localtax2_type,
'3' => $localtax2)
418 $newpricebase =
GETPOST(
'price_base_type',
'alpha');
419 $tva_tx_txt =
GETPOST(
'tva_tx',
'alpha');
420 $price_label =
GETPOST(
'price_label',
'alpha');
422 $tva_tx = $tva_tx_txt;
425 if (preg_match(
'/\((.*)\)/', $tva_tx_txt, $reg)) {
426 $vat_src_code = $reg[1];
427 $tva_tx = preg_replace(
'/\s*\(.*\)/',
'', $tva_tx_txt);
429 $tva_tx =
price2num(preg_replace(
'/\*/',
'', $tva_tx));
431 $npr = preg_match(
'/\*/', $tva_tx_txt) ? 1 : 0;
434 $localtax1_type =
'0';
435 $localtax2_type =
'0';
437 if (preg_match(
'/\((.*)\)/', $tva_tx_txt, $reg)) {
439 $vatratecode = $reg[1];
441 $sql =
"SELECT t.rowid, t.code, t.recuperableonly, t.localtax1, t.localtax2, t.localtax1_type, t.localtax2_type";
442 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_tva as t, ".MAIN_DB_PREFIX.
"c_country as c";
443 $sql .=
" WHERE t.fk_pays = c.rowid AND c.code = '".$db->escape($mysoc->country_code).
"'";
444 $sql .=
" AND t.taux = ".((float) $tva_tx).
" AND t.active = 1";
445 $sql .=
" AND t.code ='".$db->escape($vatratecode).
"'";
446 $sql .=
" AND t.entity IN (".getEntity(
'c_tva').
")";
447 $resql = $db->query($sql);
449 $obj = $db->fetch_object($resql);
451 $npr = $obj->recuperableonly;
452 $localtax1 = $obj->localtax1;
453 $localtax2 = $obj->localtax2;
454 $localtax1_type = $obj->localtax1_type;
455 $localtax2_type = $obj->localtax2_type;
459 if (in_array($mysoc->country_code, array(
'ES'))) {
466 $sql =
"SELECT t.rowid, t.code, t.recuperableonly, t.localtax1, t.localtax2, t.localtax1_type, t.localtax2_type";
467 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_tva as t, ".MAIN_DB_PREFIX.
"c_country as c";
468 $sql .=
" WHERE t.fk_pays = c.rowid AND c.code = '".$db->escape($mysoc->country_code).
"'";
469 $sql .=
" AND t.taux = ".((float) $tva_tx).
" AND t.active = 1";
470 $sql .=
" AND t.code = ''";
471 $resql = $db->query($sql);
473 $obj = $db->fetch_object($resql);
475 $npr = $obj->recuperableonly;
476 $localtax1 = $obj->localtax1;
477 $localtax2 = $obj->localtax2;
478 $localtax1_type = $obj->localtax1_type;
479 $localtax2_type = $obj->localtax2_type;
484 $pricestoupdate[0] = array(
485 'price' => $newprice,
486 'price_label' => $price_label,
487 'price_min' => $newprice_min,
488 'price_base_type' => $newpricebase,
489 'default_vat_code' => $vatratecode,
492 'localtaxes_array' => array(
'0' => $localtax1_type,
'1' => $localtax1,
'2' => $localtax2_type,
'3' => $localtax2)
501 $object->packaging = (float) $packaging;
504 foreach ($pricestoupdate as $key => $val) {
505 $newprice = $val[
'price'];
507 if ($val[
'price'] < $val[
'price_min'] && !empty(
$object->fk_price_expression)) {
508 $newprice = $val[
'price_min'];
512 $newprice_min =
price2num($val[
'price_min'],
'MU');
515 if (
getDolGlobalString(
'PRODUCT_MINIMUM_RECOMMENDED_PRICE') && $newprice_min < $maxpricesupplier) {
516 setEventMessages($langs->trans(
"MinimumPriceLimit",
price($maxpricesupplier, 0,
'', 1, - 1, - 1,
'auto')),
null,
'errors');
521 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) {
522 $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']);
534 $price_extralabels = $extrafields->fetch_name_optionals_label(
"product_price");
536 $sql =
"SELECT rowid";
537 $sql .=
" FROM ".$object->db->prefix().
"product_price";
538 $sql .=
" WHERE entity IN (".getEntity(
'productprice').
")";
539 $sql .=
" AND price_level=".((int) $key);
540 $sql .=
" AND fk_product = ".((int)
$object->id);
541 $sql .=
" ORDER BY date_price DESC, rowid DESC";
543 $resql =
$object->db->query($sql);
545 $lineid =
$object->db->fetch_object($resql);
548 if (!empty($lineid->rowid)) {
549 foreach ($price_extralabels as $code => $label) {
550 $code_array =
GETPOST($code,
'array');
551 $object->array_options[
'options_'.$code] = $code_array[$key];
555 $object->table_element =
'product_price';
556 $result =
$object->insertExtraFields();
559 $object->table_element =
'product';
578 $action =
'edit_price';
584 if ($action ==
'delete' && $user->hasRight(
'produit',
'supprimer')) {
592 if ($action ==
'activate_price_by_qty' && $permissiontoadd) {
604 if ($action ==
'disable_price_by_qty' && $permissiontoadd) {
616 if ($action ==
'edit_price_by_qty') {
621 if ($action ==
'update_price_by_qty' && $permissiontoadd) {
631 if (empty($quantity)) {
633 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Qty")),
null,
'errors');
635 if (empty($newprice)) {
637 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Price")),
null,
'errors');
641 if (
$object->price_base_type ==
'TTC') {
646 $unitPrice =
price2num((
float) $price / (
float) $quantity,
'MU');
650 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"product_price_by_qty SET";
651 $sql .=
" price=".((float) $price).
",";
652 $sql .=
" unitprice=".((float) $unitPrice).
",";
653 $sql .=
" quantity=".((float) $quantity).
",";
654 $sql .=
" remise_percent=".((float) $remise_percent).
",";
655 $sql .=
" remise=".((float) $remise);
656 $sql .=
" WHERE rowid = ".((int) $rowid);
658 $result = $db->query($sql);
663 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"product_price_by_qty (fk_product_price,price,unitprice,quantity,remise_percent,remise) values (";
664 $sql .= ((int) $priceid).
','.((float) $price).
','.((float) $unitPrice).
','.((float) $quantity).
','.((float) $remise_percent).
','.((float) $remise).
')';
666 $result = $db->query($sql);
668 if ($db->lasterrno() ==
'DB_ERROR_RECORD_ALREADY_EXISTS') {
678 if ($action ==
'delete_price_by_qty' && $permissiontoadd) {
680 if (!empty($rowid)) {
681 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"product_price_by_qty";
682 $sql .=
" WHERE rowid = ".((int) $rowid);
684 $result = $db->query($sql);
686 setEventMessages((
'delete_price_by_qty'.$langs->transnoentities(
'MissingIds')),
null,
'errors');
690 if ($action ==
'delete_all_price_by_qty' && $permissiontoadd) {
692 if (!empty($rowid)) {
693 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"product_price_by_qty";
694 $sql .=
" WHERE fk_product_price = ".((int) $priceid);
696 $result = $db->query($sql);
698 setEventMessages((
'delete_price_by_qty'.$langs->transnoentities(
'MissingIds')),
null,
'errors');
707 if ($action ==
'add_customer_price_confirm' && !$cancel && $prodcustprice !==
null && ($user->hasRight(
'produit',
'creer') || $user->hasRight(
'service',
'creer'))) {
708 $maxpricesupplier =
$object->min_recommended_price();
710 $update_child_soc =
GETPOSTINT(
'updatechildprice');
714 $prodcustprice->ref_customer =
GETPOST(
'ref_customer',
'alpha');
715 $prodcustprice->fk_product =
$object->id;
718 $prodcustprice->price_base_type =
GETPOST(
"price_base_type",
'alpha');
719 $prodcustprice->price_label =
GETPOST(
"price_label",
'alpha');
724 $extralabels = $extrafields->fetch_name_optionals_label(
"product_customer_price");
725 $extrafield_values = $extrafields->getOptionalsFromPost(
"product_customer_price");
727 $tva_tx_txt =
GETPOST(
"tva_tx",
'alpha');
729 $tva_tx = $tva_tx_txt;
731 if (preg_match(
'/\((.*)\)/', $tva_tx_txt, $reg)) {
732 $vat_src_code = $reg[1];
733 $tva_tx = preg_replace(
'/\s*\(.*\)/',
'', $tva_tx_txt);
735 $tva_tx =
price2num(preg_replace(
'/\*/',
'', $tva_tx));
737 $npr = preg_match(
'/\*/', $tva_tx_txt) ? 1 : 0;
740 $localtax1_type =
'0';
741 $localtax2_type =
'0';
743 if (preg_match(
'/\((.*)\)/', $tva_tx_txt, $reg)) {
745 $vatratecode = $reg[1];
747 $sql =
"SELECT t.rowid, t.code, t.recuperableonly, t.localtax1, t.localtax2, t.localtax1_type, t.localtax2_type";
748 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_tva as t, ".MAIN_DB_PREFIX.
"c_country as c";
749 $sql .=
" WHERE t.fk_pays = c.rowid AND c.code = '".$db->escape($mysoc->country_code).
"'";
750 $sql .=
" AND t.taux = ".((float) $tva_tx).
" AND t.active = 1";
751 $sql .=
" AND t.code ='".$db->escape($vatratecode).
"'";
752 $sql .=
" AND t.entity IN (".getEntity(
'c_tva').
")";
753 $resql = $db->query($sql);
755 $obj = $db->fetch_object($resql);
757 $npr = $obj->recuperableonly;
758 $localtax1 = $obj->localtax1;
759 $localtax2 = $obj->localtax2;
760 $localtax1_type = $obj->localtax1_type;
761 $localtax2_type = $obj->localtax2_type;
765 if (in_array($mysoc->country_code, array(
'ES'))) {
772 $sql =
"SELECT t.rowid, t.code, t.recuperableonly, t.localtax1, t.localtax2, t.localtax1_type, t.localtax2_type";
773 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_tva as t, ".MAIN_DB_PREFIX.
"c_country as c";
774 $sql .=
" WHERE t.fk_pays = c.rowid AND c.code = '".$db->escape($mysoc->country_code).
"'";
775 $sql .=
" AND t.taux = ".((float) $tva_tx).
" AND t.active = 1";
776 $sql .=
" AND t.code = ''";
777 $resql = $db->query($sql);
779 $obj = $db->fetch_object($resql);
781 $npr = $obj->recuperableonly;
782 $localtax1 = $obj->localtax1;
783 $localtax2 = $obj->localtax2;
784 $localtax1_type = $obj->localtax1_type;
785 $localtax2_type = $obj->localtax2_type;
790 $prodcustprice->default_vat_code = $vatratecode;
791 $prodcustprice->tva_tx = $tva_tx;
792 $prodcustprice->recuperableonly = $npr;
793 $prodcustprice->localtax1_tx = $localtax1;
794 $prodcustprice->localtax2_tx = $localtax2;
795 $prodcustprice->localtax1_type = $localtax1_type;
796 $prodcustprice->localtax2_type = $localtax2_type;
798 if (!($prodcustprice->fk_soc > 0)) {
799 $langs->load(
"errors");
800 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"ThirdParty")),
null,
'errors');
802 $action =
'add_customer_price';
804 if (
getDolGlobalString(
'PRODUCT_MINIMUM_RECOMMENDED_PRICE') && $prodcustprice->price_min < (
float) $maxpricesupplier) {
805 $langs->load(
"errors");
806 setEventMessages($langs->trans(
"MinimumPriceLimit",
price((
float) $maxpricesupplier, 0,
'', 1, -1, -1,
'auto')),
null,
'errors');
808 $action =
'add_customer_price';
812 $result = $prodcustprice->create($user, 0, $update_child_soc);
814 if (!empty($extrafield_values) && is_array($extrafield_values)) {
816 $res = $productcustomerprice->fetch($prodcustprice->id);
818 foreach ($extrafield_values as $key => $value) {
819 $productcustomerprice->array_options[$key] = $value;
821 $result2 = $productcustomerprice->insertExtraFields();
823 $prodcustprice->error = $productcustomerprice->error;
824 $prodcustprice->errors = $productcustomerprice->errors;
833 $action =
'add_customer_price';
841 if ($action ==
'delete_customer_price' && $prodcustprice !==
null && ($user->hasRight(
'produit',
'supprimer') || $user->hasRight(
'service',
'supprimer'))) {
844 $result = $prodcustprice->delete($user);
847 $db->query(
"DELETE FROM ".MAIN_DB_PREFIX.
"product_customer_price_extrafields WHERE fk_object = ".((
int) $prodcustprice->id));
862 if ($action ==
'update_customer_price_confirm' && !$cancel && $prodcustprice !==
null && ($user->hasRight(
'produit',
'creer') || $user->hasRight(
'service',
'creer'))) {
863 $maxpricesupplier =
$object->min_recommended_price();
865 $update_child_soc =
GETPOSTINT(
'updatechildprice');
870 $prodcustprice->ref_customer =
GETPOST(
'ref_customer',
'alpha');
873 $prodcustprice->price_base_type =
GETPOST(
"price_base_type",
'alpha');
874 $prodcustprice->price_label =
GETPOST(
"price_label",
'alpha');
879 $extralabels = $extrafields->fetch_name_optionals_label(
"product_customer_price");
880 $extrafield_values = $extrafields->getOptionalsFromPost(
"product_customer_price");
882 $tva_tx_txt =
GETPOST(
"tva_tx");
884 $tva_tx = $tva_tx_txt;
886 if (preg_match(
'/\((.*)\)/', $tva_tx_txt, $reg)) {
887 $vat_src_code = $reg[1];
888 $tva_tx = preg_replace(
'/\s*\(.*\)/',
'', $tva_tx_txt);
890 $tva_tx =
price2num(preg_replace(
'/\*/',
'', $tva_tx));
892 $npr = preg_match(
'/\*/', $tva_tx_txt) ? 1 : 0;
895 $localtax1_type =
'0';
896 $localtax2_type =
'0';
898 if (preg_match(
'/\((.*)\)/', $tva_tx_txt, $reg)) {
900 $vatratecode = $reg[1];
902 $sql =
"SELECT t.rowid, t.code, t.recuperableonly, t.localtax1, t.localtax2, t.localtax1_type, t.localtax2_type";
903 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_tva as t, ".MAIN_DB_PREFIX.
"c_country as c";
904 $sql .=
" WHERE t.fk_pays = c.rowid AND c.code = '".$db->escape($mysoc->country_code).
"'";
905 $sql .=
" AND t.taux = ".((float) $tva_tx).
" AND t.active = 1";
906 $sql .=
" AND t.code ='".$db->escape($vatratecode).
"'";
907 $sql .=
" AND t.entity IN (".getEntity(
'c_tva').
")";
908 $resql = $db->query($sql);
910 $obj = $db->fetch_object($resql);
912 $npr = $obj->recuperableonly;
913 $localtax1 = $obj->localtax1;
914 $localtax2 = $obj->localtax2;
915 $localtax1_type = $obj->localtax1_type;
916 $localtax2_type = $obj->localtax2_type;
920 if (in_array($mysoc->country_code, array(
'ES'))) {
927 $sql =
"SELECT t.rowid, t.code, t.recuperableonly, t.localtax1, t.localtax2, t.localtax1_type, t.localtax2_type";
928 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_tva as t, ".MAIN_DB_PREFIX.
"c_country as c";
929 $sql .=
" WHERE t.fk_pays = c.rowid AND c.code = '".$db->escape($mysoc->country_code).
"'";
930 $sql .=
" AND t.taux = ".((float) $tva_tx).
" AND t.active = 1";
931 $sql .=
" AND t.code = ''";
932 $resql = $db->query($sql);
934 $obj = $db->fetch_object($resql);
936 $npr = $obj->recuperableonly;
937 $localtax1 = $obj->localtax1;
938 $localtax2 = $obj->localtax2;
939 $localtax1_type = $obj->localtax1_type;
940 $localtax2_type = $obj->localtax2_type;
945 $prodcustprice->default_vat_code = $vatratecode;
946 $prodcustprice->tva_tx = $tva_tx;
947 $prodcustprice->recuperableonly = $npr;
948 $prodcustprice->localtax1_tx = $localtax1;
949 $prodcustprice->localtax2_tx = $localtax2;
950 $prodcustprice->localtax1_type = $localtax1_type;
951 $prodcustprice->localtax2_type = $localtax2_type;
953 if ($prodcustprice->price_min < $maxpricesupplier &&
getDolGlobalString(
'PRODUCT_MINIMUM_RECOMMENDED_PRICE')) {
954 setEventMessages($langs->trans(
"MinimumPriceLimit",
price($maxpricesupplier, 0,
'', 1, -1, -1,
'auto')),
null,
'errors');
956 $action =
'update_customer_price';
960 $result = $prodcustprice->update($user, 0, $update_child_soc);
962 if (!empty($extrafield_values) && is_array($extrafield_values)) {
964 $res = $productcustomerprice->fetch($prodcustprice->id);
966 foreach ($extrafield_values as $key => $value) {
967 $productcustomerprice->array_options[$key] = $value;
969 $result2 = $productcustomerprice->insertExtraFields();
971 $prodcustprice->error = $productcustomerprice->error;
972 $prodcustprice->errors = $productcustomerprice->errors;
981 $action =
'update_customer_price';
995$form =
new Form($db);
997if (!empty($id) || !empty($ref)) {
1002$title = $langs->trans(
'ProductServiceCard');
1006 $title = $langs->trans(
'Product').
" ".$shortlabel.
" - ".$langs->trans(
'SellingPrices');
1007 $helpurl =
'EN:Module_Products|FR:Module_Produits|ES:Módulo_Productos';
1010 $title = $langs->trans(
'Service').
" ".$shortlabel.
" - ".$langs->trans(
'SellingPrices');
1011 $helpurl =
'EN:Module_Services_En|FR:Module_Services|ES:Módulo_Servicios';
1014llxHeader(
'', $title, $helpurl,
'', 0, 0,
'',
'',
'',
'classforhorizontalscrolloftabs mod-product page-price');
1017$titre = $langs->trans(
"CardProduct".
$object->type);
1022$linkback =
'<a href="'.DOL_URL_ROOT.
'/product/list.php?restore_lastsearch_values=1&type='.
$object->type.
'">'.$langs->trans(
"BackToList").
'</a>';
1023$object->next_prev_filter =
"(te.fk_product_type:=:".((int)
$object->type).
")";
1026if ($user->socid && !in_array(
'product', explode(
',',
getDolGlobalString(
'MAIN_MODULES_FOR_EXTERNAL')))) {
1030dol_banner_tab($object,
'ref', $linkback, $shownav,
'ref');
1033print
'<div class="fichecenter">';
1035print
'<div class="underbanner clearboth"></div>';
1036print
'<table class="border tableforfield centpercent">';
1043 if (!empty($socid)) {
1046 $soc->fetch($socid);
1049 if (isModEnabled(
"product") && isModEnabled(
"service")) {
1050 $typeformat =
'select;0:'.$langs->trans(
"Product").
',1:'.$langs->trans(
"Service");
1051 print
'<tr><td class="">';
1052 print (!
getDolGlobalString(
'PRODUCT_DENY_CHANGE_PRODUCT_TYPE')) ? $form->editfieldkey(
"Type",
'fk_product_type', (
string)
$object->type, $object, 0, $typeformat) : $langs->trans(
'Type');
1054 print $form->editfieldval(
"Type",
'fk_product_type',
$object->type, $object, 0, $typeformat);
1059 print
'<tr><td class="titlefieldcreate">';
1060 print $langs->trans(
"SellingPrice");
1062 print
'<td colspan="2">';
1063 if (
$object->multiprices_base_type[$soc->price_level] ==
'TTC') {
1064 print
'<span class="amount">'.price(
$object->multiprices_ttc[$soc->price_level]).
'</span>';
1066 print
'<span class="amount">'.price(
$object->multiprices[$soc->price_level]).
'</span>';
1068 if (
$object->multiprices_base_type[$soc->price_level]) {
1069 print
' '.$langs->trans(
$object->multiprices_base_type[$soc->price_level]);
1071 print
' '.$langs->trans(
$object->price_base_type);
1076 print
'<tr><td>'.$langs->trans(
"MinPrice").
'</td><td colspan="2">';
1077 if (
$object->multiprices_base_type[$soc->price_level] ==
'TTC') {
1078 print
price(
$object->multiprices_min_ttc[$soc->price_level]).
' '.$langs->trans(
$object->multiprices_base_type[$soc->price_level]);
1080 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]);
1086 print
'<tr><td>'.$langs->trans(
"DefaultTaxRate").
'</td><td colspan="2">';
1088 $positiverates =
'';
1090 $positiverates .= ($positiverates ?
'/' :
'').
price2num(
$object->multiprices_tva_tx[$soc->price_level]);
1093 $positiverates .= ($positiverates ?
'/' :
'').
price2num(
$object->multiprices_localtax1_tx[$soc->price_level]);
1096 $positiverates .= ($positiverates ?
'/' :
'').
price2num(
$object->multiprices_localtax2_tx[$soc->price_level]);
1098 if (empty($positiverates)) {
1099 $positiverates =
'0';
1101 echo
vatrate($positiverates.($object->default_vat_code ?
' ('.$object->default_vat_code.
')' :
''), true,
$object->tva_npr);
1106 print
'<tr><td>'.$langs->trans(
"DefaultTaxRate").
'</td><td>';
1108 $positiverates =
'';
1113 $positiverates .= ($positiverates ?
'/' :
'').
price2num(
$object->localtax1_tx);
1116 $positiverates .= ($positiverates ?
'/' :
'').
price2num(
$object->localtax2_tx);
1118 if (empty($positiverates)) {
1119 $positiverates =
'0';
1121 echo
vatrate($positiverates.($object->default_vat_code ?
' ('.$object->default_vat_code.
')' :
''), true,
$object->tva_npr);
1133 if (isModEnabled(
"product") && isModEnabled(
"service")) {
1134 $typeformat =
'select;0:'.$langs->trans(
"Product").
',1:'.$langs->trans(
"Service");
1135 print
'<tr><td class="">';
1136 print (!
getDolGlobalString(
'PRODUCT_DENY_CHANGE_PRODUCT_TYPE')) ? $form->editfieldkey(
"Type",
'fk_product_type', (
string)
$object->type, $object, 0, $typeformat) : $langs->trans(
'Type');
1138 print $form->editfieldval(
"Type",
'fk_product_type',
$object->type, $object, 0, $typeformat);
1143 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"DefaultTaxRate").
'</td>';
1144 print
'<td colspan="2">'.vatrate(
$object->multiprices_tva_tx[1],
true).
'</td>';
1148 if (isModEnabled(
"product") && isModEnabled(
"service")) {
1149 $typeformat =
'select;0:'.$langs->trans(
"Product").
',1:'.$langs->trans(
"Service");
1150 print
'<tr><td class="">';
1151 print (!
getDolGlobalString(
'PRODUCT_DENY_CHANGE_PRODUCT_TYPE')) ? $form->editfieldkey(
"Type",
'fk_product_type', (
string)
$object->type, $object, 0, $typeformat) : $langs->trans(
'Type');
1153 print $form->editfieldval(
"Type",
'fk_product_type',
$object->type, $object, 0, $typeformat);
1158 print
'<!-- Default VAT Rate -->';
1159 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"DefaultTaxRate").
'</td><td>';
1162 $positiverates =
'';
1164 $positiverates .= ($positiverates ?
'<span class="opacitymedium">/</span>' :
'').
price2num(
$object->tva_tx);
1167 $positiverates .= ($positiverates ?
'<span class="opacitymedium">/</span>' :
'').
price2num(
$object->localtax1_tx);
1170 $positiverates .= ($positiverates ?
'<span class="opacitymedium">/</span>' :
'').
price2num(
$object->localtax2_tx);
1172 if (empty($positiverates)) {
1173 $positiverates =
'0';
1176 print
vatrate($positiverates.($object->default_vat_code ?
' ('.$object->default_vat_code.
')' :
''), true,
$object->tva_npr, 1);
1189 print
'<table class="liste centpercent">';
1190 print
'<tr class="liste_titre"><td>';
1191 print $langs->trans(
"PriceLevel");
1193 print
' <a class="editfielda" href="'.$_SERVER[
"PHP_SELF"].
'?action=editlabelsellingprice&token='.
newToken().
'&pricelevel='.$i.
'&id='.
$object->id.
'">'.
img_edit($langs->trans(
'EditSellingPriceLabel'), 0).
'</a>';
1196 print
'<td style="text-align: right">'.$langs->trans(
"SellingPrice").
'</td>';
1197 print
'<td style="text-align: right">'.$langs->trans(
"MinPrice").
'</td>';
1199 $extrafields->fetch_name_optionals_label(
"product_price");
1200 if ($extrafields->attributes[
"product_price"] && array_key_exists(
'label', $extrafields->attributes[
"product_price"])) {
1201 $extralabels = $extrafields->attributes[
"product_price"][
'label'];
1202 if (!empty($extralabels)) {
1203 foreach ($extralabels as $key => $value) {
1205 if (!empty($extrafields->attributes[
"product_price"][
'list'][$key]) && $extrafields->attributes[
"product_price"][
'list'][$key] != 3) {
1206 if (!empty($extrafields->attributes[
"product_price"][
'langfile'][$key])) {
1207 $langs->load($extrafields->attributes[
"product_price"][
'langfile'][$key]);
1209 if (!empty($extrafields->attributes[
"product_price"][
'help'][$key])) {
1210 $extratitle = $form->textwithpicto($langs->trans($value), $langs->trans($extrafields->attributes[
"product_price"][
'help'][$key]));
1212 $extratitle = $langs->trans($value);
1214 $field =
'ef.' . $key;
1215 print
'<td style="text-align: right">'.$extratitle.
'</td>';
1222 $produit_multiprices_limit =
getDolGlobalInt(
'PRODUIT_MULTIPRICES_LIMIT');
1223 for ($i = 1; $i <= $produit_multiprices_limit; $i++) {
1224 print
'<tr class="oddeven">';
1228 $keyforlabel =
'PRODUIT_MULTIPRICES_LABEL'.$i;
1229 if (preg_match(
'/editlabelsellingprice/', $action)) {
1230 print
'<form method="post" action="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'">';
1231 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1232 print
'<input type="hidden" name="action" value="setlabelsellingprice">';
1233 print
'<input type="hidden" name="pricelevel" value="'.$i.
'">';
1234 print $langs->trans(
"SellingPrice").
' '.$i.
' - ';
1235 print
'<input class="maxwidthonsmartphone" type="text" name="labelsellingprice" value="' .
getDolGlobalString($keyforlabel).
'">';
1236 print
' <input type="submit" class="button smallpaddingimp" value="'.$langs->trans(
"Modify").
'">';
1239 print $langs->trans(
"SellingPrice").
' '.$i;
1246 if (
$object->multiprices_base_type [$i] ==
'TTC') {
1247 print
'<td class="right"><span class="amount">'.price(
$object->multiprices_ttc[$i]);
1249 print
'<td class="right"><span class="amount">'.price(
$object->multiprices[$i]);
1252 if (
$object->multiprices_base_type[$i]) {
1253 print
' '.$langs->trans(
$object->multiprices_base_type [$i]).
'</span></td>';
1255 print
' '.$langs->trans(
$object->price_base_type).
'</span></td>';
1259 print
'<td style="text-align: right">';
1260 if (empty(
$object->multiprices_base_type[$i])) {
1261 $object->multiprices_base_type[$i] =
"HT";
1263 if (
$object->multiprices_base_type[$i] ==
'TTC') {
1264 print
price(
$object->multiprices_min_ttc[$i]).
' '.$langs->trans(
$object->multiprices_base_type[$i]);
1266 print
price(
$object->multiprices_min[$i]).
' '.$langs->trans(
$object->multiprices_base_type[$i]);
1269 if (!empty($extralabels)) {
1270 $sql1 =
"SELECT rowid";
1271 $sql1 .=
" FROM ".$object->db->prefix().
"product_price";
1272 $sql1 .=
" WHERE entity IN (".getEntity(
'productprice').
")";
1273 $sql1 .=
" AND price_level=".((int) $i);
1274 $sql1 .=
" AND fk_product = ".((int)
$object->id);
1275 $sql1 .=
" ORDER BY date_price DESC, rowid DESC";
1276 $sql1 .=
" LIMIT 1";
1277 $resql1 =
$object->db->query($sql1);
1279 $lineid =
$object->db->fetch_object($resql1);
1282 $sql2 .=
" fk_object";
1283 foreach ($extralabels as $key => $value) {
1284 $sql2 .=
", ".$db->sanitize($key);
1286 $sql2 .=
" FROM ".MAIN_DB_PREFIX.
"product_price_extrafields";
1287 $sql2 .=
" WHERE fk_object = ".((int) $lineid->rowid);
1288 $resql2 = $db->query($sql2);
1290 if ($db->num_rows($resql2) != 1) {
1291 foreach ($extralabels as $key => $value) {
1292 if (!empty($extrafields->attributes[
"product_price"][
'list'][$key]) && $extrafields->attributes[
"product_price"][
'list'][$key] != 3) {
1293 print
'<td align="right"></td>';
1297 $obj = $db->fetch_object($resql2);
1298 foreach ($extralabels as $key => $value) {
1299 if (!empty($extrafields->attributes[
"product_price"][
'list'][$key]) && $extrafields->attributes[
"product_price"][
'list'][$key] != 3) {
1300 print
'<td align="right">'.$extrafields->showOutputField($key, $obj->{$key},
'',
'product_price').
"</td>";
1312 print
'<tr><td>'.$langs->trans(
"PriceByQuantity").
' '.$i;
1316 print
'</td><td colspan="2">';
1318 if (
$object->prices_by_qty[$i] == 1) {
1319 print
'<table width="50%" class="border" summary="List of quantities">';
1321 print
'<tr class="liste_titre">';
1322 print
'<td>'.$langs->trans(
"PriceByQuantityRange").
' '.$i.
'</td>';
1323 print
'<td class="right">'.$langs->trans(
"HT").
'</td>';
1324 print
'<td class="right">'.$langs->trans(
"UnitPrice").
'</td>';
1325 print
'<td class="right">'.$langs->trans(
"Discount").
'</td>';
1326 print
'<td> </td>';
1329 foreach (
$object->prices_by_qty_list[$i] as $ii => $prices) {
1330 if ($action ==
'edit_price_by_qty' && $rowid == $prices[
'rowid'] && ($user->hasRight(
'produit',
'creer') || $user->hasRight(
'service',
'creer'))) {
1331 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'" method="POST">';
1332 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1333 print
'<input type="hidden" name="action" value="update_price_by_qty">';
1334 print
'<input type="hidden" name="priceid" value="'.$object->prices_by_qty_id[$i].
'">';
1335 print
'<input type="hidden" value="'.$prices[
'rowid'].
'" name="rowid">';
1336 print
'<tr class="'.($ii % 2 == 0 ?
'pair' :
'impair').
'">';
1337 print
'<td><input size="5" type="text" value="'.$prices[
'quantity'].
'" name="quantity"></td>';
1338 print
'<td class="right" colspan="2"><input size="10" type="text" value="'.price2num($prices[
'price'],
'MU').
'" name="price"> '.
$object->price_base_type.
'</td>';
1339 print
'<td class="right nowraponall"><input size="5" type="text" value="'.$prices[
'remise_percent'].
'" name="remise_percent"> %</td>';
1340 print
'<td class="center"><input type="submit" value="'.$langs->trans(
"Modify").
'" class="button"></td>';
1344 print
'<tr class="'.($ii % 2 == 0 ?
'pair' :
'impair').
'">';
1345 print
'<td>'.$prices[
'quantity'].
'</td>';
1346 print
'<td class="right">'.price($prices[
'price']).
'</td>';
1347 print
'<td class="right">'.price($prices[
'unitprice']).
'</td>';
1348 print
'<td class="right">'.price($prices[
'remise_percent']).
' %</td>';
1349 print
'<td class="center">';
1350 if (($user->hasRight(
'produit',
'creer') || $user->hasRight(
'service',
'creer'))) {
1351 print
'<a class="editfielda marginleftonly marginrightonly" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=edit_price_by_qty&token='.
newToken().
'&rowid='.$prices[
"rowid"].
'">';
1353 print
'<a class="marginleftonly marginrightonly" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=delete_price_by_qty&token='.
newToken().
'&rowid='.$prices[
"rowid"].
'">';
1362 if ($action !=
'edit_price_by_qty' && ($user->hasRight(
'produit',
'creer') || $user->hasRight(
'service',
'creer'))) {
1363 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'" method="POST">';
1364 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1365 print
'<input type="hidden" name="action" value="update_price_by_qty">';
1366 print
'<input type="hidden" name="priceid" value="'.$object->prices_by_qty_id[$i].
'">';
1367 print
'<input type="hidden" value="0" name="rowid">';
1368 print
'<tr class="'.($ii % 2 == 0 ?
'pair' :
'impair').
'">';
1369 print
'<td><input size="5" type="text" value="1" name="quantity"></td>';
1370 print
'<td class="right" class="nowrap"><input size="10" type="text" value="0" name="price"> '.$object->price_base_type.
'</td>';
1371 print
'<td class="right"> </td>';
1372 print
'<td class="right" class="nowraponall"><input size="5" type="text" value="0" name="remise_percent"> %</td>';
1373 print
'<td class="center"><input type="submit" value="'.$langs->trans(
"Add").
'" class="button"></td>';
1379 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>';
1381 print $langs->trans(
"No");
1382 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>';
1390 print
'<tr><td class="titlefield">'.$langs->trans(
"DefaultTaxRate").
'</td><td>';
1392 $positiverates =
'';
1397 $positiverates .= ($positiverates ?
'/' :
'').
price2num(
$object->localtax1_tx);
1400 $positiverates .= ($positiverates ?
'/' :
'').
price2num(
$object->localtax2_tx);
1402 if (empty($positiverates)) {
1403 $positiverates =
'0';
1405 echo
vatrate($positiverates.($object->default_vat_code ?
' ('.$object->default_vat_code.
')' :
''), true,
$object->tva_npr, 0, 1);
1415 print
'<tr class="field_selling_price"><td>'.$langs->trans(
"SellingPrice").
'</td><td>';
1416 if (
$object->price_base_type ==
'TTC') {
1421 print
'<i class="opacitymedium"> - ' .
price(
$object->price_ttc).
' '.$langs->trans(
'TTC') .
'</i>';
1428 print
'<tr class="field_min_price"><td>'.$langs->trans(
"MinPrice").
'</td><td>';
1429 if (
$object->price_base_type ==
'TTC') {
1434 print
'<i class="opacitymedium"> - ' .
price(
$object->price_min_ttc).
' '.$langs->trans(
'TTC') .
'</i>';
1441 print
'<tr class="field_price_label"><td>'.$form->textwithpicto($langs->trans(
"PackagingForThisProduct"), $langs->trans(
"PackagingForThisProductSellDesc")).
'</td><td>';
1447 print
'<tr class="field_price_label"><td>'.$langs->trans(
"PriceLabel").
'</td><td>';
1454 print
'<tr><td>'.$langs->trans(
"PriceByQuantity");
1455 if (
$object->prices_by_qty[0] == 0) {
1456 print
' <a href="'.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&action=activate_price_by_qty&level=1&token='.
newToken().
'">('.$langs->trans(
"Activate").
')';
1458 print
' <a href="'.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&action=disable_price_by_qty&level=1&token='.
newToken().
'">('.$langs->trans(
"DisablePriceByQty").
')';
1462 if (
$object->prices_by_qty[0] == 1) {
1463 print
'<table width="50%" class="border" summary="List of quantities">';
1464 print
'<tr class="liste_titre">';
1466 print
'<td>'.$langs->trans(
"Quantity").
'</td>';
1467 print
'<td class="right">'.$langs->trans(
"Price").
'</td>';
1468 print
'<td class="right"></td>';
1469 print
'<td class="right">'.$langs->trans(
"UnitPrice").
'</td>';
1470 print
'<td class="right">'.$langs->trans(
"Discount").
'</td>';
1471 print
'<td> </td>';
1473 if ($action !=
'edit_price_by_qty') {
1474 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'" method="POST">';
1475 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1476 print
'<input type="hidden" name="action" value="update_price_by_qty">';
1477 print
'<input type="hidden" name="priceid" value="'.$object->prices_by_qty_id[0].
'">';
1478 print
'<input type="hidden" value="0" name="rowid">';
1480 print
'<tr class="'.(($ii % 2) == 0 ?
'pair' :
'impair').
'">';
1481 print
'<td><input size="5" type="text" value="1" name="quantity"></td>';
1482 print
'<td class="right"><input class="width50 right" type="text" value="0" name="price"></td>';
1486 print
'<td class="right"> </td>';
1487 print
'<td class="right nowraponall"><input type="text" class="width50 right" value="0" name="remise_percent"> %</td>';
1488 print
'<td class="center"><input type="submit" value="'.$langs->trans(
"Add").
'" class="button"></td>';
1493 foreach (
$object->prices_by_qty_list[0] as $ii => $prices) {
1494 if ($action ==
'edit_price_by_qty' && $rowid == $prices[
'rowid'] && ($user->hasRight(
'produit',
'creer') || $user->hasRight(
'service',
'creer'))) {
1495 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'" method="POST">';
1496 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1497 print
'<input type="hidden" name="action" value="update_price_by_qty">';
1498 print
'<input type="hidden" name="priceid" value="'.$object->prices_by_qty_id[0].
'">';
1499 print
'<input type="hidden" value="'.$prices[
'rowid'].
'" name="rowid">';
1500 print
'<tr class="'.($ii % 2 == 0 ?
'pair' :
'impair').
'">';
1501 print
'<td><input size="5" type="text" value="'.$prices[
'quantity'].
'" name="quantity"></td>';
1502 print
'<td class="right"><input class="width50 right" type="text" value="'.price2num($prices[
'price'],
'MU').
'" name="price"></td>';
1503 print
'<td class="right">';
1505 print $prices[
'price_base_type'];
1507 print
'<td class="right"> </td>';
1508 print
'<td class="right nowraponall"><input class="width50 right" type="text" value="'.$prices[
'remise_percent'].
'" name="remise_percent"> %</td>';
1509 print
'<td class="center"><input type="submit" value="'.$langs->trans(
"Modify").
'" class="button"></td>';
1513 print
'<tr class="'.($ii % 2 == 0 ?
'pair' :
'impair').
'">';
1514 print
'<td>'.$prices[
'quantity'].
'</td>';
1515 print
'<td class="right">'.price($prices[
'price']).
'</td>';
1516 print
'<td class="right">';
1518 print $prices[
'price_base_type'];
1520 print
'<td class="right">'.price($prices[
'unitprice']).
'</td>';
1521 print
'<td class="right">'.price($prices[
'remise_percent']).
' %</td>';
1522 print
'<td class="center">';
1523 if (($user->hasRight(
'produit',
'creer') || $user->hasRight(
'service',
'creer'))) {
1524 print
'<a class="editfielda marginleftonly marginrightonly" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=edit_price_by_qty&token='.
newToken().
'&rowid='.$prices[
"rowid"].
'">';
1526 print
'<a class="marginleftonly marginrightonly" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=delete_price_by_qty&token='.
newToken().
'&rowid='.$prices[
"rowid"].
'">';
1537 print $langs->trans(
"No");
1546print
'<div class="clearboth"></div>';
1558if (!$action || $action ==
'delete' || $action ==
'showlog_customer_price' || $action ==
'showlog_default_price' || $action ==
'add_customer_price'
1559 || $action ==
'activate_price_by_qty' || $action ==
'disable_price_by_qty') {
1560 print
"\n".
'<div class="tabsAction">'.
"\n";
1563 $parameters = array();
1564 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters, $object, $action);
1565 if (empty($reshook)) {
1567 if ($user->hasRight(
'produit',
'creer') || $user->hasRight(
'service',
'creer')) {
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");
1669 if (isModEnabled(
'dynamicprices')) {
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="'.price(
$object->price_min_ttc).
'">';
1728 print
'<input name="price_min" size="10" value="'.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(
"PackagingForThisProductSellDesc"));
1741 $packaging =
$object->packaging;
1742 print
'<input class="flat" name="packaging" size="5" value="' .
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">';
1869 print $form->load_tva(
"tva_tx[".$i.
']',
$object->multiprices_tva_tx[$i], $mysoc,
null,
$object->id, 0,
$object->type,
false, 1);
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 $sql1 =
"SELECT rowid";
1897 $sql1 .=
" FROM ".$object->db->prefix().
"product_price";
1898 $sql1 .=
" WHERE entity IN (".getEntity(
'productprice').
")";
1899 $sql1 .=
" AND price_level=".((int) $i);
1900 $sql1 .=
" AND fk_product = ".((int)
$object->id);
1901 $sql1 .=
" ORDER BY date_price DESC, rowid DESC";
1902 $sql1 .=
" LIMIT 1";
1903 $resql1 =
$object->db->query($sql1);
1905 $lineid =
$object->db->fetch_object($resql1);
1907 if (empty($lineid->rowid)) {
1908 foreach ($extralabels as $key => $value) {
1909 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))) {
1910 if (!empty($extrafields->attributes[
"product_price"][
'langfile'][$key])) {
1911 $langs->load($extrafields->attributes[
"product_price"][
'langfile'][$key]);
1914 $extravalue = GETPOSTISSET(
'options_'.$key) ? $extrafield_values[
'options_'.$key] : $obj->{$key};
1915 print
'<td align="center"><input name="'.$key.
'['.$i.
']" size="10" value="'.$extravalue.
'"></td>';
1920 $sql .=
" fk_object";
1921 foreach ($extralabels as $key => $value) {
1922 $sql .=
", ".$db->sanitize($key);
1924 $sql .=
" FROM ".MAIN_DB_PREFIX.
"product_price_extrafields";
1925 $sql .=
" WHERE fk_object = ".((int) $lineid->rowid);
1926 $resql = $db->query($sql);
1928 $obj = $db->fetch_object($resql);
1929 foreach ($extralabels as $key => $value) {
1930 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))) {
1931 if (!empty($extrafields->attributes[
"product_price"][
'langfile'][$key])) {
1932 $langs->load($extrafields->attributes[
"product_price"][
'langfile'][$key]);
1935 $extravalue = (GETPOSTISSET(
'options_'.$key) ? $extrafield_values[
'options_'.$key] : $obj->{$key} ??
'');
1936 print
'<td align="center"><input name="'.$key.
'['.$i.
']" size="10" value="'.$extravalue.
'"></td>';
1953 print $form->buttonsSaveCancel();
1964 $sortfield =
GETPOST(
'sortfield',
'aZ09comma');
1965 $sortorder =
GETPOST(
'sortorder',
'aZ09comma');
1967 if (empty($page) || $page == -1) {
1970 $offset = $limit * $page;
1971 $pageprev = $page - 1;
1972 $pagenext = $page + 1;
1974 $sortorder =
"ASC,ASC";
1977 $sortfield =
"soc.nom,t.date_begin";
1981 $filter = array(
't.fk_product' => (
string)
$object->id);
1983 if (!empty($search_soc)) {
1984 $filter[
'soc.nom'] = (string) $search_soc;
1987 if ($action ==
'add_customer_price') {
1989 $maxpricesupplier =
$object->min_recommended_price();
1991 print
'<!-- add_customer_price -->';
1994 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'" method="POST">';
1995 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1996 print
'<input type="hidden" name="action" value="add_customer_price_confirm">';
1997 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
1999 print
'<div class="tabBar tabBarWithBottom">';
2001 print
'<table class="border centpercent">';
2003 print
'<td class="fieldrequired">'.$langs->trans(
'ThirdParty').
'</td>';
2005 $filter =
'(s.client:IN:1,2,3)';
2006 print
img_picto(
'',
'company').$form->select_company(
GETPOSTINT(
'socid'),
'socid', $filter,
'SelectThirdParty', 0, 0, array(), 0,
'minwidth300');
2011 print
'<tr><td>' . $langs->trans(
'RefCustomer') .
'</td>';
2012 print
'<td><input name="ref_customer" size="12"></td></tr>';
2016 print
'<tr><td>'.$langs->trans(
"AppliedPricesFrom").
'</td><td>';
2017 print $form->selectDate(!empty($date_begin) ? $date_begin :
dol_now(),
"date_begin", 0, 0, 1,
"date_begin");
2022 print
'<tr><td>'.$langs->trans(
"AppliedPricesTo").
'</td><td>';
2023 print $form->selectDate($date_end,
"date_end", 0, 0, 1,
"date_end");
2027 print
'<tr><td class="fieldrequired">'.$langs->trans(
"DefaultTaxRate").
'</td><td>';
2032 print
'<tr><td class="fieldrequired">';
2033 print $langs->trans(
'PriceBase');
2036 print $form->selectPriceBaseType(
$object->price_base_type,
"price_base_type");
2041 print
'<tr><td class="fieldrequired">';
2042 $text = $langs->trans(
'SellingPrice');
2043 print $form->textwithpicto($text, $langs->trans(
"PrecisionUnitIsLimitedToXDecimals",
getDolGlobalString(
'MAIN_MAX_DECIMALS_UNIT')), 1,
'help');
2045 if (
$object->price_base_type ==
'TTC') {
2046 print
'<input name="price" size="10" value="'.price(
$object->price_ttc).
'">';
2048 print
'<input name="price" size="10" value="'.price(
$object->price).
'">';
2054 $text = $langs->trans(
'MinPrice');
2055 print $form->textwithpicto($text, $langs->trans(
"PrecisionUnitIsLimitedToXDecimals",
getDolGlobalString(
'MAIN_MAX_DECIMALS_UNIT')), 1,
'help');
2056 if (
$object->price_base_type ==
'TTC') {
2057 print
'<td><input name="price_min" size="10" value="'.price(
$object->price_min_ttc).
'">';
2059 print
'<td><input name="price_min" size="10" value="'.price(
$object->price_min).
'">';
2062 print
'<td class="left">'.$langs->trans(
"MinimumRecommendedPrice",
price($maxpricesupplier, 0,
'', 1, -1, -1,
'auto')).
' '.
img_warning().
'</td>';
2068 print $langs->trans(
'PriceLabel');
2070 print
'<input name="price_label" maxlength="255" class="minwidth300 maxwidth400onsmartphone" value="'.$object->price_label.
'">';
2076 print
'<tr><td>'.$langs->trans(
"Discount").
'</td><td>';
2077 print
'<input name="discount_percent" size="10" value="'.price($discount_percent).
'">';
2081 $extrafields->fetch_name_optionals_label(
"product_customer_price");
2082 $extralabels = !empty($extrafields->attributes[
"product_customer_price"][
'label']) ? $extrafields->attributes[
"product_customer_price"][
'label'] :
'';
2083 $extrafield_values = $extrafields->getOptionalsFromPost(
"product_customer_price");
2084 if (!empty($extralabels)) {
2085 if (empty($prodcustprice->id)) {
2086 foreach ($extralabels as $key => $value) {
2087 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))) {
2088 if (!empty($extrafields->attributes[
"product_customer_price"][
'langfile'][$key])) {
2089 $langs->load($extrafields->attributes[
"product_customer_price"][
'langfile'][$key]);
2092 print
'<tr><td'.($extrafields->attributes[
"product_customer_price"][
'required'][$key] ?
' class="fieldrequired"' :
'').
'>';
2093 if (!empty($extrafields->attributes[
"product_customer_price"][
'help'][$key])) {
2094 print $form->textwithpicto($langs->trans($value), $langs->trans($extrafields->attributes[
"product_customer_price"][
'help'][$key]));
2096 print $langs->trans($value);
2098 print
'</td><td>'.$extrafields->showInputField($key, GETPOSTISSET(
'options_'.$key) ? $extrafield_values[
'options_'.$key] :
'',
'',
'',
'',
'', 0,
'product_customer_price').
'</td></tr>';
2109 print
'<div class="center">';
2112 print
'<div class="marginbottomonly">';
2113 print
'<input type="checkbox" name="updatechildprice" id="updatechildprice" value="1"> ';
2114 print
'<label for="updatechildprice">'.$langs->trans(
'ForceUpdateChildPriceSoc').
'</label>';
2117 print $form->buttonsSaveCancel();
2120 } elseif ($action ==
'edit_customer_price') {
2122 $maxpricesupplier =
$object->min_recommended_price();
2124 print
'<!-- edit_customer_price -->';
2127 $result = $prodcustprice->fetch(
GETPOSTINT(
'lineid'));
2132 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'" method="POST">';
2133 print
'<input type="hidden" name="token" value="'.newToken().
'">';
2134 print
'<input type="hidden" name="action" value="update_customer_price_confirm">';
2135 print
'<input type="hidden" name="lineid" value="'.$prodcustprice->id.
'">';
2137 print
'<table class="liste centpercent">';
2139 print
'<td class="titlefield fieldrequired">'.$langs->trans(
'ThirdParty').
'</td>';
2140 $staticsoc =
new Societe($db);
2141 $staticsoc->fetch($prodcustprice->fk_soc);
2142 print
"<td>".$staticsoc->getNomUrl(1).
"</td>";
2146 print
'<tr><td>' . $langs->trans(
'RefCustomer') .
'</td>';
2147 print
'<td><input name="ref_customer" size="12" value="' .
dol_escape_htmltag($prodcustprice->ref_customer) .
'"></td></tr>';
2150 print
'<tr><td>'.$langs->trans(
"AppliedPricesFrom").
'</td><td>';
2151 print $form->selectDate($prodcustprice->date_begin,
"date_begin", 0, 0, 1,
"date_begin");
2155 print
'<tr><td>'.$langs->trans(
"AppliedPricesTo").
'</td><td>';
2156 print $form->selectDate($prodcustprice->date_end,
"date_end", 0, 0, 1,
"date_end");
2160 print
'<tr><td class="fieldrequired">'.$langs->trans(
"DefaultTaxRate").
'</td><td>';
2161 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);
2165 print
'<tr><td class="fieldrequired">';
2166 print $langs->trans(
'PriceBase');
2169 print $form->selectPriceBaseType($prodcustprice->price_base_type,
"price_base_type");
2174 print
'<tr><td class="fieldrequired">';
2175 $text = $langs->trans(
'SellingPrice');
2176 print $form->textwithpicto($text, $langs->trans(
"PrecisionUnitIsLimitedToXDecimals",
getDolGlobalString(
'MAIN_MAX_DECIMALS_UNIT')), 1,
'help');
2178 if ($prodcustprice->price_base_type ==
'TTC') {
2179 print
'<input name="price" size="10" value="'.price($prodcustprice->price_ttc).
'">';
2181 print
'<input name="price" size="10" value="'.price($prodcustprice->price).
'">';
2187 $text = $langs->trans(
'MinPrice');
2188 print $form->textwithpicto($text, $langs->trans(
"PrecisionUnitIsLimitedToXDecimals",
getDolGlobalString(
'MAIN_MAX_DECIMALS_UNIT')), 1,
'help');
2190 if ($prodcustprice->price_base_type ==
'TTC') {
2191 print
'<input name="price_min" size="10" value="'.price($prodcustprice->price_min_ttc).
'">';
2193 print
'<input name="price_min" size="10" value="'.price($prodcustprice->price_min).
'">';
2197 print
'<td class="left">'.$langs->trans(
"MinimumRecommendedPrice",
price($maxpricesupplier, 0,
'', 1, -1, -1,
'auto')).
' '.
img_warning().
'</td>';
2203 print $langs->trans(
'PriceLabel');
2205 print
'<input name="price_label" maxlength="255" class="minwidth300 maxwidth400onsmartphone" value="'.$prodcustprice->price_label.
'">';
2210 print
'<tr><td>'.$langs->trans(
"Discount").
'</td><td>';
2211 print
'<input name="discount_percent" size="10" value="'.price($prodcustprice->discount_percent).
'">';
2215 $extrafields->fetch_name_optionals_label(
"product_customer_price");
2216 $extralabels = !empty($extrafields->attributes[
"product_customer_price"][
'label']) ? $extrafields->attributes[
"product_customer_price"][
'label'] :
'';
2217 $extrafield_values = $extrafields->getOptionalsFromPost(
"product_customer_price");
2218 if (!empty($extralabels)) {
2220 foreach ($extralabels as $key => $value) {
2221 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))) {
2222 if (!empty($extrafields->attributes[
"product_customer_price"][
'langfile'][$key])) {
2223 $langs->load($extrafields->attributes[
"product_customer_price"][
'langfile'][$key]);
2226 print
'<tr><td'.($extrafields->attributes[
"product_customer_price"][
'required'][$key] ?
' class="fieldrequired"' :
'').
'>';
2227 if (!empty($extrafields->attributes[
"product_customer_price"][
'help'][$key])) {
2228 print $form->textwithpicto($langs->trans($value), $langs->trans($extrafields->attributes[
"product_customer_price"][
'help'][$key]));
2230 print $langs->trans($value);
2232 print
'</td><td>'.$extrafields->showInputField($key, GETPOSTISSET(
'options_'.$key) ? $extrafield_values[
'options_'.$key] :
'',
'',
'',
'',
'', 0,
'product_customer_price').
'</td></tr>';
2237 $sql .=
" fk_object";
2238 foreach ($extralabels as $key => $value) {
2239 $sql .=
", ".$db->sanitize($key);
2241 $sql .=
" FROM ".MAIN_DB_PREFIX.
"product_customer_price_extrafields";
2242 $sql .=
" WHERE fk_object = ".((int) $prodcustprice->id);
2243 $resql = $db->query($sql);
2245 $obj = $db->fetch_object($resql);
2246 foreach ($extralabels as $key => $value) {
2247 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))) {
2248 if (!empty($extrafields->attributes[
"product_customer_price"][
'langfile'][$key])) {
2249 $langs->load($extrafields->attributes[
"product_customer_price"][
'langfile'][$key]);
2252 print
'<tr><td'.($extrafields->attributes[
"product_customer_price"][
'required'][$key] ?
' class="fieldrequired"' :
'').
'>';
2253 if (!empty($extrafields->attributes[
"product_customer_price"][
'help'][$key])) {
2254 print $form->textwithpicto($langs->trans($value), $langs->trans($extrafields->attributes[
"product_customer_price"][
'help'][$key]));
2256 print $langs->trans($value);
2258 print
'</td><td>'.$extrafields->showInputField($key, GETPOSTISSET(
'options_'.$key) ? $extrafield_values[
'options_'.$key] : $obj->{$key},
'',
'',
'',
'', 0,
'product_customer_price');
2270 print
'<div class="center">';
2271 print
'<div class="marginbottomonly">';
2272 print
'<input type="checkbox" name="updatechildprice" id="updatechildprice" value="1"> ';
2273 print
'<label for="updatechildprice">'.$langs->trans(
'ForceUpdateChildPriceSoc').
'</label>';
2276 print $form->buttonsSaveCancel();
2278 print
'<br></form>';
2279 } elseif ($action ==
'showlog_customer_price') {
2281 print
'<!-- list of all log of prices per customer -->'.
"\n";
2283 $sortfield =
't.datec';
2284 $filter = array(
't.fk_product' => (
string)
$object->id,
't.fk_soc' => (
string)
GETPOSTINT(
'socid'));
2287 $nbtotalofrecords =
'';
2289 $nbtotalofrecords = $prodcustprice->fetchAllLog($sortorder, $sortfield,
$conf->liste_limit, $offset, $filter);
2292 $result = $prodcustprice->fetchAllLog($sortorder, $sortfield,
$conf->liste_limit, $offset, $filter);
2297 $option =
'&socid='.GETPOSTINT(
'socid').
'&id='.
$object->id;
2299 $staticsoc =
new Societe($db);
2302 $title = $langs->trans(
'PriceByCustomerLog');
2303 $title .=
' - '.$staticsoc->getNomUrl(1);
2305 $backbutton =
'<a class="justalink" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'">'.$langs->trans(
"Back").
'</a>';
2308 print_barre_liste($title, $page, $_SERVER[
'PHP_SELF'], $option, $sortfield, $sortorder, $backbutton, count($prodcustprice->lines), $nbtotalofrecords,
'title_accountancy.png');
2310 if (count($prodcustprice->lines) > 0) {
2311 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'" method="POST">';
2312 print
'<input type="hidden" name="token" value="'.newToken().
'">';
2313 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
2315 print
'<div class="div-table-responsive-no-min">';
2316 print
'<table class="liste centpercent">';
2318 print
'<tr class="liste_titre">';
2319 print
'<td>'.$langs->trans(
"ThirdParty").
'</td>';
2320 print
'<td>'.$langs->trans(
'RefCustomer').
'</td>';
2321 print
'<td>'.$langs->trans(
"AppliedPricesFrom").
'</td>';
2322 print
'<td>'.$langs->trans(
"AppliedPricesTo").
'</td>';
2323 print
'<td class="center">'.$langs->trans(
"PriceBase").
'</td>';
2324 print
'<td class="right">'.$langs->trans(
"DefaultTaxRate").
'</td>';
2325 print
'<td class="right">'.$langs->trans(
"HT").
'</td>';
2326 print
'<td class="right">'.$langs->trans(
"TTC").
'</td>';
2327 if ($mysoc->localtax1_assuj ==
"1" || $mysoc->localtax2_assuj ==
"1") {
2328 print
'<td class="right">'.$langs->trans(
"INCT").
'</td>';
2330 print
'<td class="right">'.$langs->trans(
"MinPrice").
' '.$langs->trans(
"HT").
'</td>';
2331 print
'<td class="right">'.$langs->trans(
"MinPrice").
' '.$langs->trans(
"TTC").
'</td>';
2332 print
'<td class="right">'.$langs->trans(
"PriceLabel").
'</td>';
2333 print
'<td class="right">'.$langs->trans(
"Discount").
'</td>';
2334 print
'<td class="right">'.$langs->trans(
"ChangedBy").
'</td>';
2335 print
'<td>'.$langs->trans(
"DateCreation").
'</td>';
2338 foreach ($prodcustprice->lines as $line) {
2340 $staticsoc =
new Societe($db);
2341 $staticsoc->fetch($line->fk_soc);
2343 $tva_tx = $line->default_vat_code ? $line->tva_tx.
' ('.$line->default_vat_code.
')' : $line->tva_tx;
2346 if ($line->price_base_type ==
'HT') {
2349 $pu = $line->price_ttc;
2353 $localtaxarray =
getLocalTaxesFromRate($line->tva_tx.($line->default_vat_code ?
' ('.$line->default_vat_code.
')' :
''), 0, $staticsoc, $mysoc);
2355 $resultarray =
calcul_price_total(1, $pu, 0, (
float) $line->tva_tx, 1, 1, 0, $line->price_base_type, $line->recuperableonly,
$object->type, $mysoc, $localtaxarray);
2357 $total_ht = $resultarray[0];
2358 $total_vat = $resultarray[1];
2359 $total_localtax1 = $resultarray[9];
2360 $total_localtax2 = $resultarray[10];
2361 $total_ttc = $resultarray[2];
2363 print
'<tr class="oddeven">';
2365 print
'<td class="tdoverflowmax125">'.$staticsoc->getNomUrl(1).
"</td>";
2366 print
'<td>'.$line->ref_customer.
'</td>';
2367 print
"<td>".dol_print_date($line->date_begin,
"day",
'tzuserrel').
"</td>";
2368 print
"<td>".dol_print_date($line->date_end,
"day",
'tzuserrel').
"</td>";
2369 print
'<td class="center">'.$langs->trans($line->price_base_type).
"</td>";
2370 print
'<td class="right">';
2372 $positiverates =
'';
2374 $positiverates .= ($positiverates ?
'/' :
'').
price2num($line->tva_tx);
2377 $positiverates .= ($positiverates ?
'/' :
'').
price2num($line->localtax1_tx);
2380 $positiverates .= ($positiverates ?
'/' :
'').
price2num($line->localtax2_tx);
2382 if (empty($positiverates)) {
2383 $positiverates =
'0';
2386 echo
vatrate($positiverates.($line->default_vat_code ?
' ('.$line->default_vat_code.
')' :
''), true, ($line->tva_npr ? $line->tva_npr : $line->recuperableonly));
2390 print
'<td class="right"><span class="amount">'.price($line->price).
"</span></td>";
2392 print
'<td class="right"><span class="amount">'.price($line->price_ttc).
"</span></td>";
2393 if ($mysoc->localtax1_assuj ==
"1" || $mysoc->localtax2_assuj ==
"1") {
2394 print
'<td class="right">'.price($resultarray[2]).
'</td>';
2397 print
'<td class="right">'.price($line->price_min).
'</td>';
2398 print
'<td class="right">'.price($line->price_min_ttc).
'</td>';
2399 print
'<td class="right">'.$line->price_label.
'</td>';
2400 print
'<td class="right">'.price($line->discount_percent).
'</td>';
2403 $userstatic =
new User($db);
2404 $userstatic->fetch($line->fk_user);
2405 print
'<td class="right">';
2406 print $userstatic->getNomUrl(1,
'', 0, 0, 24, 0,
'login');
2409 print
"<td>".dol_print_date($line->datec,
"dayhour",
'tzuserrel').
"</td>";
2415 print $langs->trans(
'None');
2417 } elseif ($action !=
'showlog_default_price' && $action !=
'edit_price' && $action !=
'edit_level_price') {
2419 print
'<!-- list of all prices per customer -->'.
"\n";
2422 $nbtotalofrecords =
'';
2424 $nbtotalofrecords = $prodcustprice->fetchAll($sortorder, $sortfield, 0, 0, $filter);
2427 $result = $prodcustprice->fetchAll($sortorder, $sortfield,
$conf->liste_limit, $offset, $filter);
2432 $option =
'&search_soc='.$search_soc.
'&id='.
$object->id;
2435 print_barre_liste($langs->trans(
'PriceByCustomer'), $page, $_SERVER [
'PHP_SELF'], $option, $sortfield, $sortorder,
'', count($prodcustprice->lines), $nbtotalofrecords,
'title_accountancy.png');
2437 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'" method="POST">';
2438 print
'<input type="hidden" name="token" value="'.newToken().
'">';
2439 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
2441 print
'<!-- List of prices per customer -->'.
"\n";
2442 print
'<div class="div-table-responsive-no-min">'.
"\n";
2443 print
'<table class="liste centpercent">'.
"\n";
2445 if (count($prodcustprice->lines) > 0 || $search_soc) {
2446 $extrafields->fetch_name_optionals_label(
"product_customer_price");
2447 $custom_price_extralabels = !empty($extrafields->attributes[
"product_customer_price"][
'label']) ? $extrafields->attributes[
"product_customer_price"][
'label'] :
'';
2453 if ($mysoc->localtax1_assuj ==
"1" || $mysoc->localtax2_assuj ==
"1") {
2456 if (!empty($custom_price_extralabels) && is_array($custom_price_extralabels)) {
2457 $colspan += count($custom_price_extralabels);
2460 print
'<tr class="liste_titre">';
2461 print
'<td class="liste_titre"><input type="text" class="flat maxwidth125" name="search_soc" value="'.$search_soc.
'"></td>';
2462 print
'<td class="liste_titre" colspan="'.$colspan.
'"> </td>';
2464 print
'<td class="liste_titre maxwidthsearch">';
2465 $searchpicto = $form->showFilterAndCheckAddButtons(0);
2471 print
'<tr class="liste_titre">';
2472 print
'<td>'.$langs->trans(
"ThirdParty").
'</td>';
2473 print
'<td>'.$langs->trans(
'RefCustomer').
'</td>';
2474 print
'<td>'.$langs->trans(
"AppliedPricesFrom").
'</td>';
2475 print
'<td>'.$langs->trans(
"AppliedPricesTo").
'</td>';
2476 print
'<td class="center">'.$langs->trans(
"PriceBase").
'</td>';
2477 print
'<td class="right">'.$langs->trans(
"DefaultTaxRate").
'</td>';
2478 print
'<td class="right">'.$langs->trans(
"HT").
'</td>';
2479 print
'<td class="right">'.$langs->trans(
"TTC").
'</td>';
2480 if ($mysoc->localtax1_assuj ==
"1" || $mysoc->localtax2_assuj ==
"1") {
2481 print
'<td class="right">'.$langs->trans(
"INCT").
'</td>';
2483 print
'<td class="right">'.$langs->trans(
"MinPrice").
' '.$langs->trans(
"HT").
'</td>';
2484 print
'<td class="right">'.$langs->trans(
"MinPrice").
' '.$langs->trans(
"TTC").
'</td>';
2485 print
'<td class="right">'.$langs->trans(
"PriceLabel").
'</td>';
2486 print
'<td class="right">'.$langs->trans(
"Discount").
'</td>';
2488 $extrafields->fetch_name_optionals_label(
"product_customer_price");
2489 if ($extrafields->attributes[
"product_customer_price"] && array_key_exists(
'label', $extrafields->attributes[
"product_customer_price"])) {
2490 $extralabels = $extrafields->attributes[
"product_customer_price"][
'label'];
2491 if (!empty($extralabels)) {
2492 foreach ($extralabels as $key => $value) {
2494 if (!empty($extrafields->attributes[
"product_customer_price"][
'list'][$key]) && $extrafields->attributes[
"product_customer_price"][
'list'][$key] != 3) {
2495 if (!empty($extrafields->attributes[
"product_customer_price"][
'langfile'][$key])) {
2496 $langs->load($extrafields->attributes[
"product_customer_price"][
'langfile'][$key]);
2498 if (!empty($extrafields->attributes[
"product_customer_price"][
'help'][$key])) {
2499 $extratitle = $form->textwithpicto($langs->trans($value), $langs->trans($extrafields->attributes[
"product_customer_price"][
'help'][$key]));
2501 $extratitle = $langs->trans($value);
2503 print
'<td style="text-align: right">'.$extratitle.
'</td>';
2508 print
'<td>'.$langs->trans(
"ChangedBy").
'</td>';
2513 if (
$object->price_base_type ==
'HT') {
2520 $localtaxarray =
getLocalTaxesFromRate(
$object->tva_tx.($object->default_vat_code ?
' ('.$object->default_vat_code.
')' :
''), 0, $mysoc, $mysoc);
2522 $resultarray =
calcul_price_total(1, $pu, 0,
$object->tva_tx, 1, 1, 0,
$object->price_base_type, 0,
$object->type, $mysoc, $localtaxarray);
2524 $total_ht = $resultarray[0];
2525 $total_vat = $resultarray[1];
2526 $total_localtax1 = $resultarray[9];
2527 $total_localtax2 = $resultarray[10];
2528 $total_ttc = $resultarray[2];
2531 print
'<!-- PRODUIT_CUSTOMER_PRICES_AND_MULTIPRICES -->'.
"\n";
2532 print
'<tr class="oddeven">';
2533 print
'<td colspan="4">' . $langs->trans(
'Default') .
'</td>';
2535 print
'<td class="center">'.$langs->trans(
$object->price_base_type).
"</td>";
2538 print
'<td class="right">';
2540 $positiverates =
'';
2545 $positiverates .= ($positiverates ?
'/' :
'').
price2num(
$object->localtax1_tx);
2548 $positiverates .= ($positiverates ?
'/' :
'').
price2num(
$object->localtax2_tx);
2550 if (empty($positiverates)) {
2551 $positiverates =
'0';
2553 echo
vatrate($positiverates.($object->default_vat_code ?
' ('.$object->default_vat_code.
')' :
''), true,
$object->tva_npr);
2559 print
'<td class="right"><span class="amount">'.price(
$object->price).
"</span></td>";
2561 print
'<td class="right"><span class="amount">'.price(
$object->price_ttc).
"</span></td>";
2562 if ($mysoc->localtax1_assuj ==
"1" || $mysoc->localtax2_assuj ==
"1") {
2564 print
'<td class="right"><span class="amount">'.price($resultarray[2]).
'</span></td>';
2567 print
'<td class="right">'.price(
$object->price_min).
'</td>';
2568 print
'<td class="right">'.price(
$object->price_min_ttc).
'</td>';
2569 print
'<td class="right">'.$object->price_label.
'</td>';
2570 print
'<td class="right"></td>';
2571 print
'<td class="right"></td>';
2572 if (!empty($extralabels)) {
2573 foreach ($extralabels as $key) {
2575 if (!empty($extrafields->attributes[
"product_customer_price"][
'list'][$key]) && $extrafields->attributes[
"product_customer_price"][
'list'][$key] != 3) {
2576 print
'<td class="right"></td>';
2580 if ($user->hasRight(
'produit',
'supprimer') || $user->hasRight(
'service',
'supprimer')) {
2581 print
'<td class="nowraponall">';
2582 print
'<a class="marginleftonly marginrightonly" href="'.$_SERVER[
"PHP_SELF"].
'?action=showlog_default_price&token='.
newToken().
'&id='.
$object->id.
'">';
2583 print
img_info($langs->trans(
'PriceByCustomerLog'));
2586 print
'<a class="marginleftonly marginrightonly editfielda" href="'.$_SERVER[
"PHP_SELF"].
'?action=edit_price&token='.
newToken().
'&id='.
$object->id.
'">';
2587 print
img_edit(
'default', 0,
'style="vertical-align: middle;"');
2594 if (count($prodcustprice->lines) > 0) {
2595 foreach ($prodcustprice->lines as $line) {
2597 $staticsoc =
new Societe($db);
2598 $staticsoc->fetch($line->fk_soc);
2600 $tva_tx = $line->default_vat_code ? $line->tva_tx.
' ('.$line->default_vat_code.
')' : $line->tva_tx;
2603 if ($line->price_base_type ==
'HT') {
2606 $pu = $line->price_ttc;
2610 $localtaxarray =
getLocalTaxesFromRate($line->tva_tx.($line->default_vat_code ?
' ('.$line->default_vat_code.
')' :
''), 0, $staticsoc, $mysoc);
2612 $resultarray =
calcul_price_total(1, $pu, 0, (
float) $line->tva_tx, 1, 1, 0, $line->price_base_type, $line->recuperableonly,
$object->type, $mysoc, $localtaxarray);
2614 $total_ht = $resultarray[0];
2615 $total_vat = $resultarray[1];
2616 $total_localtax1 = $resultarray[9];
2617 $total_localtax2 = $resultarray[10];
2618 $total_ttc = $resultarray[2];
2620 print
'<tr class="oddeven">';
2622 print
'<td class="tdoverflowmax125">'.$staticsoc->getNomUrl(1).
"</td>";
2623 print
'<td>'.dol_escape_htmltag($line->ref_customer).
'</td>';
2624 print
"<td>".dol_print_date($line->date_begin,
"day",
'tzuserrel').
"</td>";
2625 print
"<td>".dol_print_date($line->date_end,
"day",
'tzuserrel').
"</td>";
2626 print
'<td class="center">'.$langs->trans($line->price_base_type).
"</td>";
2628 print
'<td class="right">';
2630 $positiverates =
'';
2632 $positiverates .= ($positiverates ?
'/' :
'').
price2num($line->tva_tx);
2635 $positiverates .= ($positiverates ?
'/' :
'').
price2num($line->localtax1_tx);
2638 $positiverates .= ($positiverates ?
'/' :
'').
price2num($line->localtax2_tx);
2640 if (empty($positiverates)) {
2641 $positiverates =
'0';
2644 echo
vatrate($positiverates.($line->default_vat_code ?
' ('.$line->default_vat_code.
')' :
''), true, (!empty($line->tva_npr) ? $line->tva_npr : $line->recuperableonly));
2648 print
'<td class="right"><span class="amount">'.price($line->price).
"</span></td>";
2650 print
'<td class="right"><span class="amount">'.price($line->price_ttc).
"</span></td>";
2651 if ($mysoc->localtax1_assuj ==
"1" || $mysoc->localtax2_assuj ==
"1") {
2653 print
'<td class="right"><span class="amount">'.price($resultarray[2]).
'</span></td>';
2656 print
'<td class="right">'.price($line->price_min).
'</td>';
2657 print
'<td class="right">'.price($line->price_min_ttc).
'</td>';
2658 print
'<td class="right">'.$line->price_label.
'</td>';
2659 print
'<td class="right">'.price($line->discount_percent).
'</td>';
2662 $extrafields->fetch_name_optionals_label(
"product_customer_price");
2663 $extralabels = $extrafields->attributes[
"product_customer_price"][
'label'] ?? array();
2664 if (!empty($extralabels)) {
2666 $sql .=
" fk_object";
2667 foreach ($extralabels as $key => $value) {
2668 $sql .=
", ".$db->sanitize($key);
2670 $sql .=
" FROM ".MAIN_DB_PREFIX.
"product_customer_price_extrafields";
2671 $sql .=
" WHERE fk_object = ".((int) $line->id);
2672 $resql = $db->query($sql);
2674 if ($db->num_rows($resql) != 1) {
2675 foreach ($extralabels as $key => $value) {
2676 if (!empty($extrafields->attributes[
"product_customer_price"][
'list'][$key]) && $extrafields->attributes[
"product_customer_price"][
'list'][$key] != 3) {
2681 $obj = $db->fetch_object($resql);
2682 foreach ($extralabels as $key => $value) {
2683 if (!empty($extrafields->attributes[
"product_customer_price"][
'list'][$key]) && $extrafields->attributes[
"product_customer_price"][
'list'][$key] != 3) {
2684 print
'<td align="right">'.$extrafields->showOutputField($key, $obj->{$key},
'',
'product_customer_price').
"</td>";
2693 $userstatic =
new User($db);
2694 $userstatic->fetch($line->fk_user);
2697 print $userstatic->getNomUrl(-1,
'', 0, 0, 24, 0,
'login');
2702 if ($user->hasRight(
'produit',
'supprimer') || $user->hasRight(
'service',
'supprimer')) {
2703 print
'<td class="right nowraponall">';
2704 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=showlog_customer_price&token='.
newToken().
'&id='.
$object->id.
'&socid='.$line->fk_soc.
'">';
2705 print
img_info($langs->trans(
'PriceByCustomerLog'));
2708 print
'<a class="marginleftonly editfielda" href="'.$_SERVER[
"PHP_SELF"].
'?action=edit_customer_price&token='.
newToken().
'&id='.
$object->id.
'&lineid='.$line->id.
'">';
2709 print
img_edit(
'default', 0,
'style="vertical-align: middle;"');
2712 print
'<a class="marginleftonly" href="'.$_SERVER[
"PHP_SELF"].
'?action=delete_customer_price&token='.
newToken().
'&id='.
$object->id.
'&lineid='.$line->id.
'">';
2713 print
img_delete(
'default',
'style="vertical-align: middle;"');
2731if ((!
getDolGlobalString(
'PRODUIT_CUSTOMER_PRICES') || $action ==
'showlog_default_price') && !in_array($action, array(
'edit_price',
'edit_level_price',
'edit_vat'))) {
2732 $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,";
2733 $sql .=
" p.price_level, p.price_min, p.price_min_ttc,p.price_by_qty,";
2734 $sql .=
" p.date_price as dp, p.fk_price_expression, u.rowid as user_id, u.login";
2735 $sql .=
" ,p.price_label";
2736 $sql .=
" FROM ".MAIN_DB_PREFIX.
"product_price as p,";
2737 $sql .=
" ".MAIN_DB_PREFIX.
"user as u";
2738 $sql .=
" WHERE fk_product = ".((int)
$object->id);
2739 $sql .=
" AND p.entity IN (".getEntity(
'productprice').
")";
2740 $sql .=
" AND p.fk_user_author = u.rowid";
2742 $sql .=
" AND p.price_level = ".((int) $soc->price_level);
2744 $sql .=
" ORDER BY p.date_price DESC, p.rowid DESC, p.price_level ASC";
2748 $result = $db->query($sql);
2750 print
'<div class="divlogofpreviouscustomerprice">';
2752 $num = $db->num_rows($result);
2761 $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);
2769 $result = $db->query($sql);
2770 $num = $db->num_rows($result);
2777 $backbutton =
'<a class="justalink" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'">'.$langs->trans(
"Back").
'</a>';
2781 print_barre_liste($langs->trans(
"DefaultPriceLog"), 0, $_SERVER[
"PHP_SELF"],
'',
'',
'', $backbutton, 0, $num,
'title_accountancy.png');
2784 print_barre_liste($langs->trans(
"PriceByCustomerLog"), 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', 0, $num,
'title_accountancy.png');
2787 print
'<!-- List of log prices -->'.
"\n";
2788 print
'<div class="div-table-responsive">'.
"\n";
2789 print
'<table class="liste centpercent noborder">'.
"\n";
2791 print
'<tr class="liste_titre">';
2792 print
'<th>'.$langs->trans(
"AppliedPricesFrom").
'</tg>';
2795 print
'<th class="center">'.$langs->trans(
"PriceLevel").
'</th>';
2798 print
'<th class="center">'.$langs->trans(
"Type").
'</th>';
2801 print
'<th class="center">'.$langs->trans(
"PriceBase").
'</th>';
2803 print
'<th class="right">'.$langs->trans(
"DefaultTaxRate").
'</th>';
2805 print
'<th class="right">'.$langs->trans(
"HT").
'</th>';
2806 print
'<th class="right">'.$langs->trans(
"TTC").
'</th>';
2807 if ($mysoc->localtax1_assuj ==
"1" || $mysoc->localtax2_assuj ==
"1") {
2808 print
'<th class="right">'.$langs->trans(
"INCT").
'</th>';
2810 if (isModEnabled(
'dynamicprices')) {
2811 print
'<th class="right">'.$langs->trans(
"PriceExpressionSelected").
'</th>';
2813 print
'<th class="right">'.$langs->trans(
"MinPrice").
' '.$langs->trans(
"HT").
'</th>';
2814 print
'<th class="right">'.$langs->trans(
"MinPrice").
' '.$langs->trans(
"TTC").
'</th>';
2815 print
'<th class="right">'.$langs->trans(
"Label").
'</th>';
2816 print
'<th>'.$langs->trans(
"ChangedBy").
'</th>';
2817 if ($user->hasRight(
'produit',
'supprimer')) {
2818 print
'<th class="right"> </th>';
2822 $notfirstlineforlevel = array();
2826 $objp = $db->fetch_object($result);
2828 print
'<tr class="oddeven">';
2830 print
"<td>".dol_print_date($db->jdate($objp->dp),
"dayhour",
'tzuserrel').
"</td>";
2834 print
'<td class="center">'.$objp->price_level.
"</td>";
2838 $type = ($objp->price_by_qty == 1) ?
'PriceByQuantity' :
'Standard';
2839 print
'<td class="center">'.$langs->trans($type).
"</td>";
2842 print
'<td class="center">';
2843 if (empty($objp->price_by_qty)) {
2844 print $langs->trans($objp->price_base_type);
2849 print
'<td class="right">';
2851 if (empty($objp->price_by_qty)) {
2852 $positiverates =
'';
2854 $positiverates .= ($positiverates ?
'/' :
'').
price2num($objp->tva_tx);
2857 $positiverates .= ($positiverates ?
'/' :
'').
price2num($objp->localtax1_tx);
2860 $positiverates .= ($positiverates ?
'/' :
'').
price2num($objp->localtax2_tx);
2862 if (empty($positiverates)) {
2863 $positiverates =
'0';
2865 echo
vatrate($positiverates.($objp->default_vat_code ?
' ('.$objp->default_vat_code.
')' :
''), true, !empty($objp->tva_npr) ? $objp->tva_npr : 0);
2878 if ($objp->price_base_type ==
'HT') {
2881 $pu = $objp->price_ttc;
2885 $localtaxarray =
getLocalTaxesFromRate($objp->tva_tx.($object->default_vat_code ?
' ('.$object->default_vat_code.
')' :
''), 0, $mysoc, $mysoc);
2887 $resultarray =
calcul_price_total(1, $pu, 0, $objp->tva_tx, 1, 1, 0, $objp->price_base_type, $objp->recuperableonly,
$object->type, $mysoc, $localtaxarray);
2889 $total_ht = $resultarray[0];
2890 $total_vat = $resultarray[1];
2891 $total_localtax1 = $resultarray[9];
2892 $total_localtax2 = $resultarray[10];
2893 $total_ttc = $resultarray[2];
2896 if (!empty($objp->fk_price_expression) && !empty(
$conf->dynamicprices->enabled)) {
2898 $res = $price_expression->fetch($objp->fk_price_expression);
2899 $title = $price_expression->title;
2900 print
'<td class="right"></td>';
2901 print
'<td class="right"></td>';
2902 if ($mysoc->localtax1_assuj ==
"1" || $mysoc->localtax2_assuj ==
"1") {
2903 print
'<td class="right"></td>';
2905 print
'<td class="right">'.$title.
"</td>";
2908 print
'<td class="right">';
2909 if (empty($objp->price_by_qty)) {
2910 print
'<span class="amount">'.price($objp->price).
'</span>';
2914 print
'<td class="right">';
2915 if (empty($objp->price_by_qty)) {
2916 $price_ttc = $objp->price_ttc;
2917 print
'<span class="amount">'.price($price_ttc).
'<span>';
2920 if ($mysoc->localtax1_assuj ==
"1" || $mysoc->localtax2_assuj ==
"1") {
2921 print
'<td class="right">';
2922 print $resultarray[2];
2925 if (isModEnabled(
'dynamicprices')) {
2926 print
'<td class="right"></td>';
2931 print
'<td class="right">';
2932 if (empty($objp->price_by_qty)) {
2933 print
price($objp->price_min);
2938 print
'<td class="right">';
2939 if (empty($objp->price_by_qty)) {
2940 $price_min_ttc = $objp->price_min_ttc;
2941 print
price($price_min_ttc);
2946 print
'<td class="right">';
2947 print $objp->price_label;
2952 if ($objp->user_id > 0) {
2953 $userstatic =
new User($db);
2954 $userstatic->fetch($objp->user_id);
2955 print $userstatic->getNomUrl(-1,
'', 0, 0, 24, 0,
'login');
2961 if ($user->hasRight(
'produit',
'supprimer')) {
2964 if (empty($notfirstlineforlevel[$objp->price_level])) {
2965 $notfirstlineforlevel[$objp->price_level] = 1;
2973 print
'<td class="right">';
2974 if ($candelete || ($db->jdate($objp->dp) >=
dol_now())) {
2975 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( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $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 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_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...
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
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.
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
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.
dol_now($mode='auto')
Return date for now.
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)
Return value of a param into GET or POST supervariable.
dol_clone($object, $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...
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.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
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, 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...
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
calcul_price_total($qty, $pu, $remise_percent_ligne, $txtva, $uselocaltax1_rate, $uselocaltax2_rate, $remise_percent_global, $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
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.