39require
'../main.inc.php';
40require_once DOL_DOCUMENT_ROOT.
'/core/lib/product.lib.php';
41require_once DOL_DOCUMENT_ROOT.
'/core/lib/price.lib.php';
42require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
43require_once DOL_DOCUMENT_ROOT.
'/product/dynamic_price/class/price_expression.class.php';
44require_once DOL_DOCUMENT_ROOT.
'/product/dynamic_price/class/price_parser.class.php';
47 require_once DOL_DOCUMENT_ROOT.
'/product/class/productcustomerprice.class.php';
53$langs->loadLangs(array(
'products',
'bills',
'companies',
'other'));
60$action =
GETPOST(
'action',
'aZ09');
61$cancel =
GETPOST(
'cancel',
'alpha');
64$search_soc =
GETPOST(
'search_soc');
67$fieldvalue = (!empty($id) ?
$id : (!empty($ref) ? $ref :
''));
68$fieldtype = (!empty($ref) ?
'ref' :
'rowid');
70 $socid = $user->socid;
74if ($id > 0 || !empty($ref)) {
80 $conf->global->PRODUIT_MULTIPRICES_LIMIT = 5;
84$hookmanager->initHooks(array(
'productpricecard',
'globalcard'));
87 if (
$object->type == $object::TYPE_PRODUCT) {
90 if (
$object->type == $object::TYPE_SERVICE) {
94 restrictedArea($user,
'produit|service', $fieldvalue,
'product&product',
'',
'', $fieldtype);
106$parameters = array(
'id' => $id,
'ref' => $ref);
107$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
112if (empty($reshook)) {
113 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
117 if ($action ==
'setlabelsellingprice' && $user->admin) {
118 require_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
119 $keyforlabel =
'PRODUIT_MULTIPRICES_LABEL'.GETPOST(
'pricelevel');
124 if (($action ==
'update_vat') && !$cancel && ($user->hasRight(
'produit',
'creer') || $user->hasRight(
'service',
'creer'))) {
125 $tva_tx_txt =
GETPOST(
'tva_tx',
'alpha');
127 $price_label =
GETPOST(
'price_label',
'alpha');
130 $tva_tx = $tva_tx_txt;
133 if (preg_match(
'/\((.*)\)/', $tva_tx_txt, $reg)) {
134 $vatratecode = $reg[1];
135 $tva_tx = preg_replace(
'/\s*\(.*\)/',
'', $tva_tx_txt);
138 $tva_tx =
price2num(preg_replace(
'/\*/',
'', $tva_tx));
139 $npr = preg_match(
'/\*/', $tva_tx_txt) ? 1 : 0;
142 $localtax1_type =
'0';
143 $localtax2_type =
'0';
146 if (preg_match(
'/\((.*)\)/', $tva_tx_txt, $reg)) {
148 $vatratecode = $reg[1];
150 $sql =
"SELECT t.rowid, t.type_vat, t.code, t.recuperableonly, t.localtax1, t.localtax2, t.localtax1_type, t.localtax2_type";
151 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_tva as t, ".MAIN_DB_PREFIX.
"c_country as c";
152 $sql .=
" WHERE t.fk_pays = c.rowid AND c.code = '".$db->escape($mysoc->country_code).
"'";
153 $sql .=
" AND t.taux = ".((float) $tva_tx).
" AND t.active = 1";
154 $sql .=
" AND t.code = '".$db->escape($vatratecode).
"'";
155 $sql .=
" AND t.type_vat IN (0, 1)";
156 $sql .=
" AND t.entity IN (".getEntity(
'c_tva').
")";
157 $resql = $db->query($sql);
159 $obj = $db->fetch_object($resql);
161 $npr = $obj->recuperableonly;
162 $localtax1 = $obj->localtax1;
163 $localtax2 = $obj->localtax2;
164 $localtax1_type = $obj->localtax1_type;
165 $localtax2_type = $obj->localtax2_type;
170 $sql =
"SELECT t.rowid, t.code, t.recuperableonly, t.localtax1, t.localtax2, t.localtax1_type, t.localtax2_type";
171 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_tva as t, ".MAIN_DB_PREFIX.
"c_country as c";
172 $sql .=
" WHERE t.fk_pays = c.rowid AND c.code = '".$db->escape($mysoc->country_code).
"'";
173 $sql .=
" AND t.taux = ".((float) $tva_tx).
" AND t.active = 1";
174 $sql .=
" AND t.code = ''";
175 $sql .=
" AND t.entity IN (".getEntity(
'c_tva').
")";
176 $resql = $db->query($sql);
178 $obj = $db->fetch_object($resql);
180 $npr = $obj->recuperableonly;
181 $localtax1 = $obj->localtax1;
182 $localtax2 = $obj->localtax2;
183 $localtax1_type = $obj->localtax1_type;
184 $localtax2_type = $obj->localtax2_type;
189 $object->default_vat_code = $vatratecode;
192 $object->localtax1_tx = $localtax1;
193 $object->localtax2_tx = $localtax2;
194 $object->localtax1_type = $localtax1_type;
195 $object->localtax2_type = $localtax2_type;
196 $object->price_label = $price_label;
208 $produit_multiprices_limit =
getDolGlobalInt(
'PRODUIT_MULTIPRICES_LIMIT');
209 for ($i = 1; $i <= $produit_multiprices_limit; $i++) {
211 if (
$object->multiprices_base_type[$i] ==
'HT') {
212 $oldprice =
$object->multiprices[$i];
213 $oldminprice =
$object->multiprices_min[$i];
215 $oldprice =
$object->multiprices_ttc[$i];
216 $oldminprice =
$object->multiprices_min_ttc[$i];
218 $oldpricebasetype =
$object->multiprices_base_type[$i];
219 $oldnpr =
$object->multiprices_recuperableonly[$i];
222 $localtaxarray = array();
224 $ret =
$object->updatePrice($oldprice, $oldpricebasetype, $user, $tva_tx, $oldminprice, $level, $oldnpr, 0, 0, $localtaxarray, $vatratecode, $price_label);
233 if (
$object->price_base_type ==
'HT') {
235 $oldminprice =
$object->price_min;
237 $oldprice =
$object->price_ttc;
238 $oldminprice =
$object->price_min_ttc;
240 $oldpricebasetype =
$object->price_base_type;
244 $localtaxarray = array();
246 $ret =
$object->updatePrice($oldprice, $oldpricebasetype, $user, $tva_tx, $oldminprice, $level, $oldnpr, 0, 0, $localtaxarray, $vatratecode, $price_label);
264 if (($action ==
'update_price' || $action ==
'update_level_price') && !$cancel &&
$object->getRights()->creer) {
266 $pricestoupdate = array();
269 $psq = empty($newpsq) ? 0 : $newpsq;
270 $maxpricesupplier =
$object->min_recommended_price();
272 if (isModEnabled(
'dynamicprices')) {
273 $object->fk_price_expression = empty($eid) ? 0 : $eid;
275 if (
$object->fk_price_expression != 0) {
277 require_once DOL_DOCUMENT_ROOT.
'/product/dynamic_price/class/price_parser.class.php';
280 if ($priceparser->parseProduct($object) < 0) {
289 $newprice =
GETPOST(
'price',
'array');
290 $newprice_min =
GETPOST(
'price_min',
'array');
291 $newpricebase =
GETPOST(
'multiprices_base_type',
'array');
292 $newvattx =
GETPOST(
'tva_tx',
'array');
293 $newvatnpr =
GETPOST(
'tva_npr',
'array');
294 $newlocaltax1_tx =
GETPOST(
'localtax1_tx',
'array');
295 $newlocaltax1_type =
GETPOST(
'localtax1_type',
'array');
296 $newlocaltax2_tx =
GETPOST(
'localtax2_tx',
'array');
297 $newlocaltax2_type =
GETPOST(
'localtax2_type',
'array');
300 $object->price_autogen = (int) (
GETPOST(
'usePriceRules') ==
'on');
302 $produit_multiprices_limit =
getDolGlobalInt(
'PRODUIT_MULTIPRICES_LIMIT');
303 for ($i = 1; $i <= $produit_multiprices_limit; $i++) {
304 if (!isset($newprice[$i])) {
308 $tva_tx_txt = $newvattx[$i];
310 $tva_tx = $tva_tx_txt;
313 if (preg_match(
'/\((.*)\)/', $tva_tx_txt, $reg)) {
314 $vat_src_code = $reg[1];
315 $tva_tx = preg_replace(
'/\s*\(.*\)/',
'', $tva_tx_txt);
317 $tva_tx =
price2num(preg_replace(
'/\*/',
'', $tva_tx));
319 $npr = preg_match(
'/\*/', $tva_tx_txt) ? 1 : 0;
320 $localtax1 = $newlocaltax1_tx[$i];
321 $localtax1_type = $newlocaltax1_type[$i];
322 $localtax2 = $newlocaltax2_tx[$i];
323 $localtax2_type = $newlocaltax2_type[$i];
324 if (preg_match(
'/\((.*)\)/', $tva_tx_txt, $reg)) {
326 $vatratecode = $reg[1];
328 $sql =
"SELECT t.rowid, t.code, t.recuperableonly, t.localtax1, t.localtax2, t.localtax1_type, t.localtax2_type";
329 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_tva as t, ".MAIN_DB_PREFIX.
"c_country as c";
330 $sql .=
" WHERE t.fk_pays = c.rowid AND c.code = '".$db->escape($mysoc->country_code).
"'";
331 $sql .=
" AND t.taux = ".((float) $tva_tx).
" AND t.active = 1";
332 $sql .=
" AND t.code ='".$db->escape($vatratecode).
"'";
333 $sql .=
" AND t.entity IN (".getEntity(
'c_tva').
")";
334 $resql = $db->query($sql);
336 $obj = $db->fetch_object($resql);
338 $npr = $obj->recuperableonly;
339 $localtax1 = $obj->localtax1;
340 $localtax2 = $obj->localtax2;
341 $localtax1_type = $obj->localtax1_type;
342 $localtax2_type = $obj->localtax2_type;
346 if (in_array($mysoc->country_code, array(
'ES'))) {
353 $sql =
"SELECT t.rowid, t.code, t.recuperableonly, t.localtax1, t.localtax2, t.localtax1_type, t.localtax2_type";
354 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_tva as t, ".MAIN_DB_PREFIX.
"c_country as c";
355 $sql .=
" WHERE t.fk_pays = c.rowid AND c.code = '".$db->escape($mysoc->country_code).
"'";
356 $sql .=
" AND t.taux = ".((float) $tva_tx).
" AND t.active = 1";
357 $sql .=
" AND t.code = ''";
358 $resql = $db->query($sql);
360 $obj = $db->fetch_object($resql);
362 $npr = $obj->recuperableonly;
363 $localtax1 = $obj->localtax1;
364 $localtax2 = $obj->localtax2;
365 $localtax1_type = $obj->localtax1_type;
366 $localtax2_type = $obj->localtax2_type;
371 $pricestoupdate[$i] = array(
372 'price' =>
price2num($newprice[$i],
'', 2),
373 'price_min' =>
price2num($newprice_min[$i],
'', 2),
374 'price_base_type' => $newpricebase[$i],
375 'default_vat_code' => $vatratecode,
378 'localtaxes_array' => array(
'0' => $localtax1_type,
'1' => $localtax1,
'2' => $localtax2_type,
'3' => $localtax2)
389 $newpricebase =
GETPOST(
'price_base_type',
'alpha');
390 $tva_tx_txt =
GETPOST(
'tva_tx',
'alpha');
391 $price_label =
GETPOST(
'price_label',
'alpha');
393 $tva_tx = $tva_tx_txt;
396 if (preg_match(
'/\((.*)\)/', $tva_tx_txt, $reg)) {
397 $vat_src_code = $reg[1];
398 $tva_tx = preg_replace(
'/\s*\(.*\)/',
'', $tva_tx_txt);
400 $tva_tx =
price2num(preg_replace(
'/\*/',
'', $tva_tx));
402 $npr = preg_match(
'/\*/', $tva_tx_txt) ? 1 : 0;
405 $localtax1_type =
'0';
406 $localtax2_type =
'0';
408 if (preg_match(
'/\((.*)\)/', $tva_tx_txt, $reg)) {
410 $vatratecode = $reg[1];
412 $sql =
"SELECT t.rowid, t.code, t.recuperableonly, t.localtax1, t.localtax2, t.localtax1_type, t.localtax2_type";
413 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_tva as t, ".MAIN_DB_PREFIX.
"c_country as c";
414 $sql .=
" WHERE t.fk_pays = c.rowid AND c.code = '".$db->escape($mysoc->country_code).
"'";
415 $sql .=
" AND t.taux = ".((float) $tva_tx).
" AND t.active = 1";
416 $sql .=
" AND t.code ='".$db->escape($vatratecode).
"'";
417 $sql .=
" AND t.entity IN (".getEntity(
'c_tva').
")";
418 $resql = $db->query($sql);
420 $obj = $db->fetch_object($resql);
422 $npr = $obj->recuperableonly;
423 $localtax1 = $obj->localtax1;
424 $localtax2 = $obj->localtax2;
425 $localtax1_type = $obj->localtax1_type;
426 $localtax2_type = $obj->localtax2_type;
430 if (in_array($mysoc->country_code, array(
'ES'))) {
437 $sql =
"SELECT t.rowid, t.code, t.recuperableonly, t.localtax1, t.localtax2, t.localtax1_type, t.localtax2_type";
438 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_tva as t, ".MAIN_DB_PREFIX.
"c_country as c";
439 $sql .=
" WHERE t.fk_pays = c.rowid AND c.code = '".$db->escape($mysoc->country_code).
"'";
440 $sql .=
" AND t.taux = ".((float) $tva_tx).
" AND t.active = 1";
441 $sql .=
" AND t.code = ''";
442 $resql = $db->query($sql);
444 $obj = $db->fetch_object($resql);
446 $npr = $obj->recuperableonly;
447 $localtax1 = $obj->localtax1;
448 $localtax2 = $obj->localtax2;
449 $localtax1_type = $obj->localtax1_type;
450 $localtax2_type = $obj->localtax2_type;
455 $pricestoupdate[0] = array(
456 'price' => $newprice,
457 'price_label' => $price_label,
458 'price_min' => $newprice_min,
459 'price_base_type' => $newpricebase,
460 'default_vat_code' => $vatratecode,
463 'localtaxes_array' => array(
'0' => $localtax1_type,
'1' => $localtax1,
'2' => $localtax2_type,
'3' => $localtax2)
470 foreach ($pricestoupdate as $key => $val) {
471 $newprice = $val[
'price'];
473 if ($val[
'price'] < $val[
'price_min'] && !empty(
$object->fk_price_expression)) {
474 $newprice = $val[
'price_min'];
478 $newprice_min =
price2num($val[
'price_min'],
'MU');
481 if (
getDolGlobalString(
'PRODUCT_MINIMUM_RECOMMENDED_PRICE') && $newprice_min < $maxpricesupplier) {
482 setEventMessages($langs->trans(
"MinimumPriceLimit",
price($maxpricesupplier, 0,
'', 1, - 1, - 1,
'auto')),
null,
'errors');
488 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) {
489 $res =
$object->updatePrice($newprice, $val[
'price_base_type'], $user, $val[
'vat_tx'], $newprice_min, $key, $val[
'npr'], $psq, 0, $val[
'localtaxes_array'], $val[
'default_vat_code'], $val[
'price_label']);
512 $action =
'edit_price';
518 if ($action ==
'delete' && $user->hasRight(
'produit',
'supprimer')) {
526 if ($action ==
'activate_price_by_qty') {
538 if ($action ==
'disable_price_by_qty') {
550 if ($action ==
'edit_price_by_qty') {
555 if ($action ==
'update_price_by_qty') {
565 if (empty($quantity)) {
567 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Qty")),
null,
'errors');
569 if (empty($newprice)) {
571 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Price")),
null,
'errors');
575 if (
$object->price_base_type ==
'TTC') {
580 $unitPrice =
price2num((
float) $price / (
float) $quantity,
'MU');
584 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"product_price_by_qty SET";
585 $sql .=
" price=".((float) $price).
",";
586 $sql .=
" unitprice=".((float) $unitPrice).
",";
587 $sql .=
" quantity=".((float) $quantity).
",";
588 $sql .=
" remise_percent=".((float) $remise_percent).
",";
589 $sql .=
" remise=".((float) $remise);
590 $sql .=
" WHERE rowid = ".((int) $rowid);
592 $result = $db->query($sql);
597 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"product_price_by_qty (fk_product_price,price,unitprice,quantity,remise_percent,remise) values (";
598 $sql .= ((int) $priceid).
','.((float) $price).
','.((float) $unitPrice).
','.((float) $quantity).
','.((float) $remise_percent).
','.((float) $remise).
')';
600 $result = $db->query($sql);
602 if ($db->lasterrno() ==
'DB_ERROR_RECORD_ALREADY_EXISTS') {
612 if ($action ==
'delete_price_by_qty') {
614 if (!empty($rowid)) {
615 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"product_price_by_qty";
616 $sql .=
" WHERE rowid = ".((int) $rowid);
618 $result = $db->query($sql);
620 setEventMessages((
'delete_price_by_qty'.$langs->transnoentities(
'MissingIds')),
null,
'errors');
624 if ($action ==
'delete_all_price_by_qty') {
626 if (!empty($rowid)) {
627 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"product_price_by_qty";
628 $sql .=
" WHERE fk_product_price = ".((int) $priceid);
630 $result = $db->query($sql);
632 setEventMessages((
'delete_price_by_qty'.$langs->transnoentities(
'MissingIds')),
null,
'errors');
641 if ($action ==
'add_customer_price_confirm' && !$cancel && ($user->hasRight(
'produit',
'creer') || $user->hasRight(
'service',
'creer'))) {
642 $maxpricesupplier =
$object->min_recommended_price();
644 $update_child_soc =
GETPOSTINT(
'updatechildprice');
648 $prodcustprice->ref_customer =
GETPOST(
'ref_customer',
'alpha');
649 $prodcustprice->fk_product =
$object->id;
652 $prodcustprice->price_base_type =
GETPOST(
"price_base_type",
'alpha');
653 $prodcustprice->price_label =
GETPOST(
"price_label",
'alpha');
655 $tva_tx_txt =
GETPOST(
"tva_tx",
'alpha');
657 $tva_tx = $tva_tx_txt;
659 if (preg_match(
'/\((.*)\)/', $tva_tx_txt, $reg)) {
660 $vat_src_code = $reg[1];
661 $tva_tx = preg_replace(
'/\s*\(.*\)/',
'', $tva_tx_txt);
663 $tva_tx =
price2num(preg_replace(
'/\*/',
'', $tva_tx));
665 $npr = preg_match(
'/\*/', $tva_tx_txt) ? 1 : 0;
668 $localtax1_type =
'0';
669 $localtax2_type =
'0';
671 if (preg_match(
'/\((.*)\)/', $tva_tx_txt, $reg)) {
673 $vatratecode = $reg[1];
675 $sql =
"SELECT t.rowid, t.code, t.recuperableonly, t.localtax1, t.localtax2, t.localtax1_type, t.localtax2_type";
676 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_tva as t, ".MAIN_DB_PREFIX.
"c_country as c";
677 $sql .=
" WHERE t.fk_pays = c.rowid AND c.code = '".$db->escape($mysoc->country_code).
"'";
678 $sql .=
" AND t.taux = ".((float) $tva_tx).
" AND t.active = 1";
679 $sql .=
" AND t.code ='".$db->escape($vatratecode).
"'";
680 $sql .=
" AND t.entity IN (".getEntity(
'c_tva').
")";
681 $resql = $db->query($sql);
683 $obj = $db->fetch_object($resql);
685 $npr = $obj->recuperableonly;
686 $localtax1 = $obj->localtax1;
687 $localtax2 = $obj->localtax2;
688 $localtax1_type = $obj->localtax1_type;
689 $localtax2_type = $obj->localtax2_type;
693 if (in_array($mysoc->country_code, array(
'ES'))) {
700 $sql =
"SELECT t.rowid, t.code, t.recuperableonly, t.localtax1, t.localtax2, t.localtax1_type, t.localtax2_type";
701 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_tva as t, ".MAIN_DB_PREFIX.
"c_country as c";
702 $sql .=
" WHERE t.fk_pays = c.rowid AND c.code = '".$db->escape($mysoc->country_code).
"'";
703 $sql .=
" AND t.taux = ".((float) $tva_tx).
" AND t.active = 1";
704 $sql .=
" AND t.code = ''";
705 $resql = $db->query($sql);
707 $obj = $db->fetch_object($resql);
709 $npr = $obj->recuperableonly;
710 $localtax1 = $obj->localtax1;
711 $localtax2 = $obj->localtax2;
712 $localtax1_type = $obj->localtax1_type;
713 $localtax2_type = $obj->localtax2_type;
718 $prodcustprice->default_vat_code = $vatratecode;
719 $prodcustprice->tva_tx = $tva_tx;
720 $prodcustprice->recuperableonly = $npr;
721 $prodcustprice->localtax1_tx = $localtax1;
722 $prodcustprice->localtax2_tx = $localtax2;
723 $prodcustprice->localtax1_type = $localtax1_type;
724 $prodcustprice->localtax2_type = $localtax2_type;
726 if (!($prodcustprice->fk_soc > 0)) {
727 $langs->load(
"errors");
728 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"ThirdParty")),
null,
'errors');
730 $action =
'add_customer_price';
732 if (
getDolGlobalString(
'PRODUCT_MINIMUM_RECOMMENDED_PRICE') && $prodcustprice->price_min < $maxpricesupplier) {
733 $langs->load(
"errors");
734 setEventMessages($langs->trans(
"MinimumPriceLimit",
price($maxpricesupplier, 0,
'', 1, -1, -1,
'auto')),
null,
'errors');
736 $action =
'add_customer_price';
740 $result = $prodcustprice->create($user, 0, $update_child_soc);
752 if ($action ==
'delete_customer_price' && ($user->hasRight(
'produit',
'supprimer') || $user->hasRight(
'service',
'supprimer'))) {
755 $result = $prodcustprice->delete($user);
765 if ($action ==
'update_customer_price_confirm' && !$cancel && ($user->hasRight(
'produit',
'creer') || $user->hasRight(
'service',
'creer'))) {
766 $maxpricesupplier =
$object->min_recommended_price();
768 $update_child_soc =
GETPOSTINT(
'updatechildprice');
773 $prodcustprice->ref_customer =
GETPOST(
'ref_customer',
'alpha');
776 $prodcustprice->price_base_type =
GETPOST(
"price_base_type",
'alpha');
777 $prodcustprice->price_label =
GETPOST(
"price_label",
'alpha');
779 $tva_tx_txt =
GETPOST(
"tva_tx");
781 $tva_tx = $tva_tx_txt;
783 if (preg_match(
'/\((.*)\)/', $tva_tx_txt, $reg)) {
784 $vat_src_code = $reg[1];
785 $tva_tx = preg_replace(
'/\s*\(.*\)/',
'', $tva_tx_txt);
787 $tva_tx =
price2num(preg_replace(
'/\*/',
'', $tva_tx));
789 $npr = preg_match(
'/\*/', $tva_tx_txt) ? 1 : 0;
792 $localtax1_type =
'0';
793 $localtax2_type =
'0';
795 if (preg_match(
'/\((.*)\)/', $tva_tx_txt, $reg)) {
797 $vatratecode = $reg[1];
799 $sql =
"SELECT t.rowid, t.code, t.recuperableonly, t.localtax1, t.localtax2, t.localtax1_type, t.localtax2_type";
800 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_tva as t, ".MAIN_DB_PREFIX.
"c_country as c";
801 $sql .=
" WHERE t.fk_pays = c.rowid AND c.code = '".$db->escape($mysoc->country_code).
"'";
802 $sql .=
" AND t.taux = ".((float) $tva_tx).
" AND t.active = 1";
803 $sql .=
" AND t.code ='".$db->escape($vatratecode).
"'";
804 $sql .=
" AND t.entity IN (".getEntity(
'c_tva').
")";
805 $resql = $db->query($sql);
807 $obj = $db->fetch_object($resql);
809 $npr = $obj->recuperableonly;
810 $localtax1 = $obj->localtax1;
811 $localtax2 = $obj->localtax2;
812 $localtax1_type = $obj->localtax1_type;
813 $localtax2_type = $obj->localtax2_type;
817 if (in_array($mysoc->country_code, array(
'ES'))) {
824 $sql =
"SELECT t.rowid, t.code, t.recuperableonly, t.localtax1, t.localtax2, t.localtax1_type, t.localtax2_type";
825 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_tva as t, ".MAIN_DB_PREFIX.
"c_country as c";
826 $sql .=
" WHERE t.fk_pays = c.rowid AND c.code = '".$db->escape($mysoc->country_code).
"'";
827 $sql .=
" AND t.taux = ".((float) $tva_tx).
" AND t.active = 1";
828 $sql .=
" AND t.code = ''";
829 $resql = $db->query($sql);
831 $obj = $db->fetch_object($resql);
833 $npr = $obj->recuperableonly;
834 $localtax1 = $obj->localtax1;
835 $localtax2 = $obj->localtax2;
836 $localtax1_type = $obj->localtax1_type;
837 $localtax2_type = $obj->localtax2_type;
842 $prodcustprice->default_vat_code = $vatratecode;
843 $prodcustprice->tva_tx = $tva_tx;
844 $prodcustprice->recuperableonly = $npr;
845 $prodcustprice->localtax1_tx = $localtax1;
846 $prodcustprice->localtax2_tx = $localtax2;
847 $prodcustprice->localtax1_type = $localtax1_type;
848 $prodcustprice->localtax2_type = $localtax2_type;
850 if ($prodcustprice->price_min < $maxpricesupplier &&
getDolGlobalString(
'PRODUCT_MINIMUM_RECOMMENDED_PRICE')) {
851 setEventMessages($langs->trans(
"MinimumPriceLimit",
price($maxpricesupplier, 0,
'', 1, -1, -1,
'auto')),
null,
'errors');
853 $action =
'update_customer_price';
857 $result = $prodcustprice->update($user, 0, $update_child_soc);
875$form =
new Form($db);
877if (!empty($id) || !empty($ref)) {
882$title = $langs->trans(
'ProductServiceCard');
886 $title = $langs->trans(
'Product').
" ".$shortlabel.
" - ".$langs->trans(
'SellingPrices');
887 $helpurl =
'EN:Module_Products|FR:Module_Produits|ES:Módulo_Productos';
890 $title = $langs->trans(
'Service').
" ".$shortlabel.
" - ".$langs->trans(
'SellingPrices');
891 $helpurl =
'EN:Module_Services_En|FR:Module_Services|ES:Módulo_Servicios';
894llxHeader(
'', $title, $helpurl,
'', 0, 0,
'',
'',
'',
'classforhorizontalscrolloftabs mod-product page-price');
897$titre = $langs->trans(
"CardProduct".
$object->type);
902$linkback =
'<a href="'.DOL_URL_ROOT.
'/product/list.php?restore_lastsearch_values=1&type='.
$object->type.
'">'.$langs->trans(
"BackToList").
'</a>';
903$object->next_prev_filter =
"fk_product_type = ".((int)
$object->type);
906if ($user->socid && !in_array(
'product', explode(
',',
getDolGlobalString(
'MAIN_MODULES_FOR_EXTERNAL')))) {
910dol_banner_tab($object,
'ref', $linkback, $shownav,
'ref');
913print
'<div class="fichecenter">';
915print
'<div class="underbanner clearboth"></div>';
916print
'<table class="border tableforfield centpercent">';
921 if (!empty($socid)) {
927 if (isModEnabled(
"product") && isModEnabled(
"service")) {
928 $typeformat =
'select;0:'.$langs->trans(
"Product").
',1:'.$langs->trans(
"Service");
929 print
'<tr><td class="">';
930 print (!
getDolGlobalString(
'PRODUCT_DENY_CHANGE_PRODUCT_TYPE')) ? $form->editfieldkey(
"Type",
'fk_product_type',
$object->type, $object, 0, $typeformat) : $langs->trans(
'Type');
932 print $form->editfieldval(
"Type",
'fk_product_type',
$object->type, $object, 0, $typeformat);
937 print
'<tr><td class="titlefieldcreate">';
938 print $langs->trans(
"SellingPrice");
940 print
'<td colspan="2">';
941 if (
$object->multiprices_base_type[$soc->price_level] ==
'TTC') {
942 print
'<span class="amount">'.price(
$object->multiprices_ttc[$soc->price_level]).
'</span>';
944 print
'<span class="amount">'.price(
$object->multiprices[$soc->price_level]).
'</span>';
946 if (
$object->multiprices_base_type[$soc->price_level]) {
947 print
' '.$langs->trans(
$object->multiprices_base_type[$soc->price_level]);
949 print
' '.$langs->trans(
$object->price_base_type);
954 print
'<tr><td>'.$langs->trans(
"MinPrice").
'</td><td colspan="2">';
955 if (
$object->multiprices_base_type[$soc->price_level] ==
'TTC') {
956 print
price(
$object->multiprices_min_ttc[$soc->price_level]).
' '.$langs->trans(
$object->multiprices_base_type[$soc->price_level]);
958 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]);
964 print
'<tr><td>'.$langs->trans(
"DefaultTaxRate").
'</td><td colspan="2">';
968 $positiverates .= ($positiverates ?
'/' :
'').
price2num(
$object->multiprices_tva_tx[$soc->price_level]);
971 $positiverates .= ($positiverates ?
'/' :
'').
price2num(
$object->multiprices_localtax1_tx[$soc->price_level]);
974 $positiverates .= ($positiverates ?
'/' :
'').
price2num(
$object->multiprices_localtax2_tx[$soc->price_level]);
976 if (empty($positiverates)) {
977 $positiverates =
'0';
979 echo
vatrate($positiverates.($object->default_vat_code ?
' ('.$object->default_vat_code.
')' :
''), true,
$object->tva_npr);
984 print
'<tr><td>'.$langs->trans(
"DefaultTaxRate").
'</td><td>';
991 $positiverates .= ($positiverates ?
'/' :
'').
price2num(
$object->localtax1_tx);
994 $positiverates .= ($positiverates ?
'/' :
'').
price2num(
$object->localtax2_tx);
996 if (empty($positiverates)) {
997 $positiverates =
'0';
999 echo
vatrate($positiverates.($object->default_vat_code ?
' ('.$object->default_vat_code.
')' :
''), true,
$object->tva_npr);
1011 if (isModEnabled(
"product") && isModEnabled(
"service")) {
1012 $typeformat =
'select;0:'.$langs->trans(
"Product").
',1:'.$langs->trans(
"Service");
1013 print
'<tr><td class="">';
1014 print (!
getDolGlobalString(
'PRODUCT_DENY_CHANGE_PRODUCT_TYPE')) ? $form->editfieldkey(
"Type",
'fk_product_type',
$object->type, $object, 0, $typeformat) : $langs->trans(
'Type');
1016 print $form->editfieldval(
"Type",
'fk_product_type',
$object->type, $object, 0, $typeformat);
1021 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"DefaultTaxRate").
'</td>';
1022 print
'<td colspan="2">'.vatrate(
$object->multiprices_tva_tx[1],
true).
'</td>';
1026 if (isModEnabled(
"product") && isModEnabled(
"service")) {
1027 $typeformat =
'select;0:'.$langs->trans(
"Product").
',1:'.$langs->trans(
"Service");
1028 print
'<tr><td class="">';
1029 print (!
getDolGlobalString(
'PRODUCT_DENY_CHANGE_PRODUCT_TYPE')) ? $form->editfieldkey(
"Type",
'fk_product_type',
$object->type, $object, 0, $typeformat) : $langs->trans(
'Type');
1031 print $form->editfieldval(
"Type",
'fk_product_type',
$object->type, $object, 0, $typeformat);
1036 print
'<!-- Default VAT Rate -->';
1037 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"DefaultTaxRate").
'</td><td>';
1040 $positiverates =
'';
1042 $positiverates .= ($positiverates ?
'<span class="opacitymedium">/</span>' :
'').
price2num(
$object->tva_tx);
1045 $positiverates .= ($positiverates ?
'<span class="opacitymedium">/</span>' :
'').
price2num(
$object->localtax1_tx);
1048 $positiverates .= ($positiverates ?
'<span class="opacitymedium">/</span>' :
'').
price2num(
$object->localtax2_tx);
1050 if (empty($positiverates)) {
1051 $positiverates =
'0';
1054 print
vatrate($positiverates.($object->default_vat_code ?
' ('.$object->default_vat_code.
')' :
''), true,
$object->tva_npr, 1);
1067 print
'<table class="noborder tableforfield centpercent">';
1068 print
'<tr class="liste_titre"><td>';
1069 print $langs->trans(
"PriceLevel");
1071 print
' <a class="editfielda" href="'.$_SERVER[
"PHP_SELF"].
'?action=editlabelsellingprice&token='.
newToken().
'&pricelevel='.$i.
'&id='.
$object->id.
'">'.
img_edit($langs->trans(
'EditSellingPriceLabel'), 0).
'</a>';
1074 print
'<td style="text-align: right">'.$langs->trans(
"SellingPrice").
'</td>';
1075 print
'<td style="text-align: right">'.$langs->trans(
"MinPrice").
'</td>';
1078 $produit_multiprices_limit =
getDolGlobalInt(
'PRODUIT_MULTIPRICES_LIMIT');
1079 for ($i = 1; $i <= $produit_multiprices_limit; $i++) {
1080 print
'<tr class="oddeven">';
1084 $keyforlabel =
'PRODUIT_MULTIPRICES_LABEL'.$i;
1085 if (preg_match(
'/editlabelsellingprice/', $action)) {
1086 print
'<form method="post" action="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'">';
1087 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1088 print
'<input type="hidden" name="action" value="setlabelsellingprice">';
1089 print
'<input type="hidden" name="pricelevel" value="'.$i.
'">';
1090 print $langs->trans(
"SellingPrice").
' '.$i.
' - ';
1091 print
'<input class="maxwidthonsmartphone" type="text" name="labelsellingprice" value="' .
getDolGlobalString($keyforlabel).
'">';
1092 print
' <input type="submit" class="button smallpaddingimp" value="'.$langs->trans(
"Modify").
'">';
1095 print $langs->trans(
"SellingPrice").
' '.$i;
1102 if (
$object->multiprices_base_type [$i] ==
'TTC') {
1103 print
'<td class="right"><span class="amount">'.price(
$object->multiprices_ttc[$i]);
1105 print
'<td class="right"><span class="amount">'.price(
$object->multiprices[$i]);
1108 if (
$object->multiprices_base_type[$i]) {
1109 print
' '.$langs->trans(
$object->multiprices_base_type [$i]).
'</span></td>';
1111 print
' '.$langs->trans(
$object->price_base_type).
'</span></td>';
1115 print
'<td style="text-align: right">';
1116 if (empty(
$object->multiprices_base_type[$i])) {
1117 $object->multiprices_base_type[$i] =
"HT";
1119 if (
$object->multiprices_base_type[$i] ==
'TTC') {
1120 print
price(
$object->multiprices_min_ttc[$i]).
' '.$langs->trans(
$object->multiprices_base_type[$i]);
1122 print
price(
$object->multiprices_min[$i]).
' '.$langs->trans(
$object->multiprices_base_type[$i]);
1128 print
'<tr><td>'.$langs->trans(
"PriceByQuantity").
' '.$i;
1132 print
'</td><td colspan="2">';
1134 if (
$object->prices_by_qty[$i] == 1) {
1135 print
'<table width="50%" class="border" summary="List of quantities">';
1137 print
'<tr class="liste_titre">';
1138 print
'<td>'.$langs->trans(
"PriceByQuantityRange").
' '.$i.
'</td>';
1139 print
'<td class="right">'.$langs->trans(
"HT").
'</td>';
1140 print
'<td class="right">'.$langs->trans(
"UnitPrice").
'</td>';
1141 print
'<td class="right">'.$langs->trans(
"Discount").
'</td>';
1142 print
'<td> </td>';
1144 foreach (
$object->prices_by_qty_list[$i] as $ii => $prices) {
1145 if ($action ==
'edit_price_by_qty' && $rowid == $prices[
'rowid'] && ($user->hasRight(
'produit',
'creer') || $user->hasRight(
'service',
'creer'))) {
1146 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'" method="POST">';
1147 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1148 print
'<input type="hidden" name="action" value="update_price_by_qty">';
1149 print
'<input type="hidden" name="priceid" value="'.$object->prices_by_qty_id[$i].
'">';
1150 print
'<input type="hidden" value="'.$prices[
'rowid'].
'" name="rowid">';
1151 print
'<tr class="'.($ii % 2 == 0 ?
'pair' :
'impair').
'">';
1152 print
'<td><input size="5" type="text" value="'.$prices[
'quantity'].
'" name="quantity"></td>';
1153 print
'<td class="right" colspan="2"><input size="10" type="text" value="'.price2num($prices[
'price'],
'MU').
'" name="price"> '.
$object->price_base_type.
'</td>';
1154 print
'<td class="right nowraponall"><input size="5" type="text" value="'.$prices[
'remise_percent'].
'" name="remise_percent"> %</td>';
1155 print
'<td class="center"><input type="submit" value="'.$langs->trans(
"Modify").
'" class="button"></td>';
1159 print
'<tr class="'.($ii % 2 == 0 ?
'pair' :
'impair').
'">';
1160 print
'<td>'.$prices[
'quantity'].
'</td>';
1161 print
'<td class="right">'.price($prices[
'price']).
'</td>';
1162 print
'<td class="right">'.price($prices[
'unitprice']).
'</td>';
1163 print
'<td class="right">'.price($prices[
'remise_percent']).
' %</td>';
1164 print
'<td class="center">';
1165 if (($user->hasRight(
'produit',
'creer') || $user->hasRight(
'service',
'creer'))) {
1166 print
'<a class="editfielda marginleftonly marginrightonly" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=edit_price_by_qty&token='.
newToken().
'&rowid='.$prices[
"rowid"].
'">';
1168 print
'<a class="marginleftonly marginrightonly" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=delete_price_by_qty&token='.
newToken().
'&rowid='.$prices[
"rowid"].
'">';
1177 if ($action !=
'edit_price_by_qty' && ($user->hasRight(
'produit',
'creer') || $user->hasRight(
'service',
'creer'))) {
1178 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'" method="POST">';
1179 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1180 print
'<input type="hidden" name="action" value="update_price_by_qty">';
1181 print
'<input type="hidden" name="priceid" value="'.$object->prices_by_qty_id[$i].
'">';
1182 print
'<input type="hidden" value="0" name="rowid">';
1183 print
'<tr class="'.($ii % 2 == 0 ?
'pair' :
'impair').
'">';
1184 print
'<td><input size="5" type="text" value="1" name="quantity"></td>';
1185 print
'<td class="right" class="nowrap"><input size="10" type="text" value="0" name="price"> '.$object->price_base_type.
'</td>';
1186 print
'<td class="right"> </td>';
1187 print
'<td class="right" class="nowraponall"><input size="5" type="text" value="0" name="remise_percent"> %</td>';
1188 print
'<td class="center"><input type="submit" value="'.$langs->trans(
"Add").
'" class="button"></td>';
1194 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>';
1196 print $langs->trans(
"No");
1197 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>';
1205 print
'<tr><td class="titlefield">'.$langs->trans(
"DefaultTaxRate").
'</td><td>';
1207 $positiverates =
'';
1212 $positiverates .= ($positiverates ?
'/' :
'').
price2num(
$object->localtax1_tx);
1215 $positiverates .= ($positiverates ?
'/' :
'').
price2num(
$object->localtax2_tx);
1217 if (empty($positiverates)) {
1218 $positiverates =
'0';
1220 echo
vatrate($positiverates.($object->default_vat_code ?
' ('.$object->default_vat_code.
')' :
''), true,
$object->tva_npr, 0, 1);
1230 print
'<tr class="field_selling_price"><td>'.$langs->trans(
"SellingPrice").
'</td><td>';
1231 if (
$object->price_base_type ==
'TTC') {
1236 print
'<i class="opacitymedium"> - ' .
price(
$object->price_ttc).
' '.$langs->trans(
'TTC') .
'</i>';
1243 print
'<tr class="field_min_price"><td>'.$langs->trans(
"MinPrice").
'</td><td>';
1244 if (
$object->price_base_type ==
'TTC') {
1249 print
'<i class="opacitymedium"> - ' .
price(
$object->price_min_ttc).
' '.$langs->trans(
'TTC') .
'</i>';
1255 print
'<tr class="field_price_label"><td>'.$langs->trans(
"PriceLabel").
'</td><td>';
1261 print
'<tr><td>'.$langs->trans(
"PriceByQuantity");
1262 if (
$object->prices_by_qty[0] == 0) {
1263 print
' <a href="'.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&action=activate_price_by_qty&level=1&token='.
newToken().
'">('.$langs->trans(
"Activate").
')';
1265 print
' <a href="'.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&action=disable_price_by_qty&level=1&token='.
newToken().
'">('.$langs->trans(
"DisablePriceByQty").
')';
1269 if (
$object->prices_by_qty[0] == 1) {
1270 print
'<table width="50%" class="border" summary="List of quantities">';
1271 print
'<tr class="liste_titre">';
1273 print
'<td>'.$langs->trans(
"Quantity").
'</td>';
1274 print
'<td class="right">'.$langs->trans(
"Price").
'</td>';
1275 print
'<td class="right"></td>';
1276 print
'<td class="right">'.$langs->trans(
"UnitPrice").
'</td>';
1277 print
'<td class="right">'.$langs->trans(
"Discount").
'</td>';
1278 print
'<td> </td>';
1280 if ($action !=
'edit_price_by_qty') {
1281 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'" method="POST">';
1282 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1283 print
'<input type="hidden" name="action" value="update_price_by_qty">';
1284 print
'<input type="hidden" name="priceid" value="'.$object->prices_by_qty_id[0].
'">';
1285 print
'<input type="hidden" value="0" name="rowid">';
1287 print
'<tr class="'.($ii % 2 == 0 ?
'pair' :
'impair').
'">';
1288 print
'<td><input size="5" type="text" value="1" name="quantity"></td>';
1289 print
'<td class="right"><input class="width50 right" type="text" value="0" name="price"></td>';
1293 print
'<td class="right"> </td>';
1294 print
'<td class="right nowraponall"><input type="text" class="width50 right" value="0" name="remise_percent"> %</td>';
1295 print
'<td class="center"><input type="submit" value="'.$langs->trans(
"Add").
'" class="button"></td>';
1300 foreach (
$object->prices_by_qty_list[0] as $ii => $prices) {
1301 if ($action ==
'edit_price_by_qty' && $rowid == $prices[
'rowid'] && ($user->hasRight(
'produit',
'creer') || $user->hasRight(
'service',
'creer'))) {
1302 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'" method="POST">';
1303 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1304 print
'<input type="hidden" name="action" value="update_price_by_qty">';
1305 print
'<input type="hidden" name="priceid" value="'.$object->prices_by_qty_id[0].
'">';
1306 print
'<input type="hidden" value="'.$prices[
'rowid'].
'" name="rowid">';
1307 print
'<tr class="'.($ii % 2 == 0 ?
'pair' :
'impair').
'">';
1308 print
'<td><input size="5" type="text" value="'.$prices[
'quantity'].
'" name="quantity"></td>';
1309 print
'<td class="right"><input class="width50 right" type="text" value="'.price2num($prices[
'price'],
'MU').
'" name="price"></td>';
1310 print
'<td class="right">';
1312 print $prices[
'price_base_type'];
1314 print
'<td class="right"> </td>';
1315 print
'<td class="right nowraponall"><input class="width50 right" type="text" value="'.$prices[
'remise_percent'].
'" name="remise_percent"> %</td>';
1316 print
'<td class="center"><input type="submit" value="'.$langs->trans(
"Modify").
'" class="button"></td>';
1320 print
'<tr class="'.($ii % 2 == 0 ?
'pair' :
'impair').
'">';
1321 print
'<td>'.$prices[
'quantity'].
'</td>';
1322 print
'<td class="right">'.price($prices[
'price']).
'</td>';
1323 print
'<td class="right">';
1325 print $prices[
'price_base_type'];
1327 print
'<td class="right">'.price($prices[
'unitprice']).
'</td>';
1328 print
'<td class="right">'.price($prices[
'remise_percent']).
' %</td>';
1329 print
'<td class="center">';
1330 if (($user->hasRight(
'produit',
'creer') || $user->hasRight(
'service',
'creer'))) {
1331 print
'<a class="editfielda marginleftonly marginrightonly" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=edit_price_by_qty&token='.
newToken().
'&rowid='.$prices[
"rowid"].
'">';
1333 print
'<a class="marginleftonly marginrightonly" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=delete_price_by_qty&token='.
newToken().
'&rowid='.$prices[
"rowid"].
'">';
1344 print $langs->trans(
"No");
1353print
'<div class="clearboth"></div>';
1365if (!$action || $action ==
'delete' || $action ==
'showlog_customer_price' || $action ==
'showlog_default_price' || $action ==
'add_customer_price'
1366 || $action ==
'activate_price_by_qty' || $action ==
'disable_price_by_qty') {
1367 print
"\n".
'<div class="tabsAction">'.
"\n";
1370 $parameters = array();
1371 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters, $object, $action);
1372 if (empty($reshook)) {
1374 if ($user->hasRight(
'produit',
'creer') || $user->hasRight(
'service',
'creer')) {
1375 print
'<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="' .
dol_escape_htmltag($langs->trans(
"NoEditVariants")) .
'">' . $langs->trans(
"UpdateDefaultPrice") .
'</a></div>';
1379 if ($user->hasRight(
'produit',
'creer') || $user->hasRight(
'service',
'creer')) {
1380 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>';
1382 print
'<div class="inline-block divButAction"><span class="butActionRefused" title="'.dol_escape_htmltag($langs->trans(
"NotEnoughPermissions")).
'">' . $langs->trans(
"UpdateDefaultPrice") .
'</span></div>';
1387 if ($user->hasRight(
'produit',
'creer') || $user->hasRight(
'service',
'creer')) {
1388 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>';
1390 print
'<div class="inline-block divButAction"><span class="butActionRefused" title="'.dol_escape_htmltag($langs->trans(
"NotEnoughPermissions")).
'">' . $langs->trans(
"AddCustomerPrice") .
'</span></div>';
1395 if ($user->hasRight(
'produit',
'creer') || $user->hasRight(
'service',
'creer')) {
1396 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>';
1398 print
'<div class="inline-block divButAction"><span class="butActionRefused" title="'.dol_escape_htmltag($langs->trans(
"NotEnoughPermissions")).
'">' . $langs->trans(
"UpdateVAT") .
'</span></div>';
1401 if ($user->hasRight(
'produit',
'creer') || $user->hasRight(
'service',
'creer')) {
1402 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>';
1404 print
'<div class="inline-block divButAction"><span class="butActionRefused" title="'.dol_escape_htmltag($langs->trans(
"NotEnoughPermissions")).
'">' . $langs->trans(
"UpdateLevelPrices") .
'</span></div>';
1419if ($action ==
'edit_vat' && ($user->hasRight(
'produit',
'creer') || $user->hasRight(
'service',
'creer'))) {
1422 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'" method="POST">';
1423 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1424 print
'<input type="hidden" name="action" value="update_vat">';
1425 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
1429 print
'<table class="border centpercent">';
1432 print
'<tr><td>'.$langs->trans(
"DefaultTaxRate").
'</td><td>';
1440 print $form->buttonsSaveCancel();
1442 print
'<br></form><br>';
1445if (($action ==
'edit_price' || $action ==
'edit_level_price') &&
$object->getRights()->creer) {
1450 print
'<!-- Edit price -->'.
"\n";
1451 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'" method="POST">';
1452 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1453 print
'<input type="hidden" name="action" value="update_price">';
1454 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
1458 print
'<div class="div-table-responsive-no-min">';
1459 print
'<table class="border centpercent">';
1462 print
'<tr><td class="titlefield">'.$langs->trans(
"DefaultTaxRate").
'</td><td>';
1468 print $langs->trans(
'PriceBase');
1471 print $form->selectPriceBaseType(
$object->price_base_type,
"price_base_type");
1476 if (!empty($conf->dynamicprices->enabled)) {
1478 print
'<!-- Show price mode of dynamicprices editor -->'.
"\n";
1479 print
'<tr><td>'.$langs->trans(
"PriceMode").
'</td><td>';
1480 print
img_picto(
'',
'dynamicprice',
'class="pictofixedwidth"');
1482 $price_expression_list = array(0 => $langs->trans(
"Numeric").
' <span class="opacitymedium">('.$langs->trans(
"NoDynamicPrice").
')</span>');
1483 foreach ($price_expression->list_price_expression() as $entry) {
1484 $price_expression_list[$entry->id] = $entry->title;
1486 $price_expression_preselection =
GETPOST(
'eid') ?
GETPOST(
'eid') : (
$object->fk_price_expression ?
$object->fk_price_expression :
'0');
1487 print $form->selectarray(
'eid', $price_expression_list, $price_expression_preselection);
1488 print
' <a id="expression_editor" class="classlink">'.$langs->trans(
"PriceExpressionEditor").
'</a>';
1494 <script
type=
"text/javascript">
1495 jQuery(document).ready(
function() {
1496 jQuery(
"#expression_editor").click(
function() {
1497 window.location =
"<?php echo DOL_URL_ROOT ?>/product/dynamic_price/editor.php?id=<?php echo $id ?>&tab=price&eid=" + $(
"#eid").val();
1499 jQuery(
"#eid").change(on_change);
1502 function on_change() {
1503 if ($(
"#eid").val() == 0) {
1504 jQuery(
"#price_numeric").show();
1506 jQuery(
"#price_numeric").hide();
1515 $product->fetch($id, $ref,
'', 1);
1516 print
'<tr id="price_numeric"><td>';
1517 $text = $langs->trans(
'SellingPrice');
1518 print $form->textwithpicto($text, $langs->trans(
"PrecisionUnitIsLimitedToXDecimals",
getDolGlobalString(
'MAIN_MAX_DECIMALS_UNIT')), 1, 1);
1520 if (
$object->price_base_type ==
'TTC') {
1521 print
'<input name="price" size="10" value="'.price($product->price_ttc).
'">';
1523 print
'<input name="price" size="10" value="'.price($product->price).
'">';
1529 $text = $langs->trans(
'MinPrice');
1530 print $form->textwithpicto($text, $langs->trans(
"PrecisionUnitIsLimitedToXDecimals",
getDolGlobalString(
'MAIN_MAX_DECIMALS_UNIT')), 1, 1);
1532 if (
$object->price_base_type ==
'TTC') {
1533 print
'<input name="price_min" size="10" value="'.price(
$object->price_min_ttc).
'">';
1535 print
'<input name="price_min" size="10" value="'.price(
$object->price_min).
'">';
1538 print
' '.$langs->trans(
"MinimumRecommendedPrice",
price($maxpricesupplier, 0,
'', 1, -1, -1,
'auto')).
' '.
img_warning().
'</td>';
1545 print $langs->trans(
'PriceLabel');
1547 print
'<input name="price_label" maxlength="255" class="minwidth300 maxwidth400onsmartphone" value="'.$object->price_label.
'">';
1551 $parameters = array();
1552 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters, $object, $action);
1559 print $form->buttonsSaveCancel();
1562 } elseif ($action ==
'edit_level_price' &&
$object->getRights()->creer) {
1563 print
'<!-- Edit price per level -->'.
"\n"; ?>
1566 var showHidePriceRules =
function () {
1567 var otherPrices = $(
'div.fiche form table tbody tr:not(:first)');
1568 var minPrice1 = $(
'div.fiche form input[name="price_min[1]"]');
1570 if (jQuery(
'input#usePriceRules').prop(
'checked')) {
1579 jQuery(document).ready(
function () {
1580 showHidePriceRules();
1582 jQuery(
'input#usePriceRules').click(showHidePriceRules);
1587 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'" method="POST">';
1588 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1589 print
'<input type="hidden" name="action" value="update_level_price">';
1590 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
1595 print $langs->trans(
'UseMultipriceRules').
' <input type="checkbox" id="usePriceRules" name="usePriceRules" '.(
$object->price_autogen ?
'checked' :
'').
'><br><br>';
1598 print
'<div class="div-table-responsive-no-min">';
1599 print
'<table class="noborder">';
1600 print
'<thead><tr class="liste_titre">';
1602 print
'<td>'.$langs->trans(
"PriceLevel").
'</td>';
1605 print
'<td style="text-align: center">'.$langs->trans(
"DefaultTaxRate").
'</td>';
1610 print
'<td class="center">'.$langs->trans(
"SellingPrice").
'</td>';
1612 print
'<td class="center">'.$langs->trans(
"MinPrice").
'</td>';
1617 print
'</tr></thead>';
1621 $produit_multiprices_limit =
getDolGlobalInt(
'PRODUIT_MULTIPRICES_LIMIT');
1622 for ($i = 1; $i <= $produit_multiprices_limit; $i++) {
1623 print
'<tr class="oddeven">';
1625 $keyforlabel =
'PRODUIT_MULTIPRICES_LABEL'.$i;
1627 print $form->textwithpicto($text, $langs->trans(
"PrecisionUnitIsLimitedToXDecimals",
getDolGlobalString(
'MAIN_MAX_DECIMALS_UNIT')), 1, 1);
1633 print
'<input type="hidden" name="tva_tx['.$i.
']" value="'.(
$object->default_vat_code ?
$object->tva_tx.
' ('.
$object->default_vat_code.
')' :
$object->tva_tx).
'">';
1634 print
'<input type="hidden" name="tva_npr['.$i.
']" value="'.
$object->tva_npr.
'">';
1635 print
'<input type="hidden" name="localtax1_tx['.$i.
']" value="'.
$object->localtax1_tx.
'">';
1636 print
'<input type="hidden" name="localtax1_type['.$i.
']" value="'.
$object->localtax1_type.
'">';
1637 print
'<input type="hidden" name="localtax2_tx['.$i.
']" value="'.
$object->localtax2_tx.
'">';
1638 print
'<input type="hidden" name="localtax2_type['.$i.
']" value="'.
$object->localtax2_type.
'">';
1642 print
'<td style="text-align: center">';
1643 print $form->load_tva(
"tva_tx[".$i.
']',
$object->multiprices_tva_tx[$i], $mysoc,
'',
$object->id,
false,
$object->type,
false, 1);
1648 print
'<td style="text-align: center">';
1649 if (
$object->multiprices_base_type [$i] ==
'TTC') {
1650 print
'<input name="price['.$i.
']" size="10" value="'.
price(
$object->multiprices_ttc [$i]).
'">';
1652 print
'<input name="price['.$i.
']" size="10" value="'.
price(
$object->multiprices [$i]).
'">';
1654 print
' '.$form->selectPriceBaseType(
$object->multiprices_base_type [$i],
"multiprices_base_type[".$i.
"]");
1658 print
'<td style="text-align: center">';
1659 if (
$object->multiprices_base_type [$i] ==
'TTC') {
1660 print
'<input name="price_min['.$i.
']" size="10" value="'.
price(
$object->multiprices_min_ttc [$i]).
'">';
1662 print
'<input name="price_min['.$i.
']" size="10" value="'.
price(
$object->multiprices_min [$i]).
'">';
1665 print
'<td class="left">'.$langs->trans(
"MinimumRecommendedPrice",
price($maxpricesupplier, 0,
'', 1, -1, -1,
'auto')).
' '.
img_warning().
'</td>';
1679 print $form->buttonsSaveCancel();
1690 $sortfield =
GETPOST(
'sortfield',
'aZ09comma');
1691 $sortorder =
GETPOST(
'sortorder',
'aZ09comma');
1693 if (empty($page) || $page == -1) {
1696 $offset = $limit * $page;
1697 $pageprev = $page - 1;
1698 $pagenext = $page + 1;
1703 $sortfield =
"soc.nom";
1707 $filter = array(
't.fk_product' =>
$object->id);
1709 if (!empty($search_soc)) {
1710 $filter[
'soc.nom'] = $search_soc;
1713 if ($action ==
'add_customer_price') {
1715 $maxpricesupplier =
$object->min_recommended_price();
1717 print
'<!-- add_customer_price -->';
1720 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'" method="POST">';
1721 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1722 print
'<input type="hidden" name="action" value="add_customer_price_confirm">';
1723 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
1725 print
'<div class="tabBar tabBarWithBottom">';
1727 print
'<table class="border centpercent">';
1729 print
'<td class="fieldrequired">'.$langs->trans(
'ThirdParty').
'</td>';
1731 $filter =
'(s.client:IN:1,2,3)';
1732 print
img_picto(
'',
'company').$form->select_company(
'',
'socid', $filter,
'SelectThirdParty', 0, 0, array(), 0,
'minwidth300');
1737 print
'<tr><td>' . $langs->trans(
'RefCustomer') .
'</td>';
1738 print
'<td><input name="ref_customer" size="12"></td></tr>';
1741 print
'<tr><td class="fieldrequired">'.$langs->trans(
"DefaultTaxRate").
'</td><td>';
1746 print
'<tr><td class="fieldrequired">';
1747 print $langs->trans(
'PriceBase');
1750 print $form->selectPriceBaseType(
$object->price_base_type,
"price_base_type");
1755 print
'<tr><td class="fieldrequired">';
1756 $text = $langs->trans(
'SellingPrice');
1757 print $form->textwithpicto($text, $langs->trans(
"PrecisionUnitIsLimitedToXDecimals",
getDolGlobalString(
'MAIN_MAX_DECIMALS_UNIT')), 1, 1);
1759 if (
$object->price_base_type ==
'TTC') {
1760 print
'<input name="price" size="10" value="'.price(
$object->price_ttc).
'">';
1762 print
'<input name="price" size="10" value="'.price(
$object->price).
'">';
1768 $text = $langs->trans(
'MinPrice');
1769 print $form->textwithpicto($text, $langs->trans(
"PrecisionUnitIsLimitedToXDecimals",
getDolGlobalString(
'MAIN_MAX_DECIMALS_UNIT')), 1, 1);
1770 if (
$object->price_base_type ==
'TTC') {
1771 print
'<td><input name="price_min" size="10" value="'.price(
$object->price_min_ttc).
'">';
1773 print
'<td><input name="price_min" size="10" value="'.price(
$object->price_min).
'">';
1776 print
'<td class="left">'.$langs->trans(
"MinimumRecommendedPrice",
price($maxpricesupplier, 0,
'', 1, -1, -1,
'auto')).
' '.
img_warning().
'</td>';
1782 print $langs->trans(
'PriceLabel');
1784 print
'<input name="price_label" maxlength="255" class="minwidth300 maxwidth400onsmartphone" value="'.$object->price_label.
'">';
1793 print
'<div class="center">';
1796 print
'<div class="marginbottomonly">';
1797 print
'<input type="checkbox" name="updatechildprice" id="updatechildprice" value="1"> ';
1798 print
'<label for="updatechildprice">'.$langs->trans(
'ForceUpdateChildPriceSoc').
'</label>';
1801 print $form->buttonsSaveCancel();
1804 } elseif ($action ==
'edit_customer_price') {
1806 $maxpricesupplier =
$object->min_recommended_price();
1808 print
'<!-- edit_customer_price -->';
1811 $result = $prodcustprice->fetch(
GETPOSTINT(
'lineid'));
1816 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'" method="POST">';
1817 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1818 print
'<input type="hidden" name="action" value="update_customer_price_confirm">';
1819 print
'<input type="hidden" name="lineid" value="'.$prodcustprice->id.
'">';
1821 print
'<table class="liste centpercent">';
1823 print
'<td class="titlefield fieldrequired">'.$langs->trans(
'ThirdParty').
'</td>';
1824 $staticsoc =
new Societe($db);
1825 $staticsoc->fetch($prodcustprice->fk_soc);
1826 print
"<td>".$staticsoc->getNomUrl(1).
"</td>";
1830 print
'<tr><td>' . $langs->trans(
'RefCustomer') .
'</td>';
1831 print
'<td><input name="ref_customer" size="12" value="' .
dol_escape_htmltag($prodcustprice->ref_customer) .
'"></td></tr>';
1834 print
'<tr><td class="fieldrequired">'.$langs->trans(
"DefaultTaxRate").
'</td><td>';
1835 print $form->load_tva(
"tva_tx", $prodcustprice->default_vat_code ? $prodcustprice->tva_tx.
' ('.$prodcustprice->default_vat_code.
')' : $prodcustprice->tva_tx, $mysoc,
'',
$object->id, $prodcustprice->recuperableonly,
$object->
type, false, 1);
1839 print
'<tr><td class="fieldrequired">';
1840 print $langs->trans(
'PriceBase');
1843 print $form->selectPriceBaseType($prodcustprice->price_base_type,
"price_base_type");
1848 print
'<tr><td class="fieldrequired">';
1849 $text = $langs->trans(
'SellingPrice');
1850 print $form->textwithpicto($text, $langs->trans(
"PrecisionUnitIsLimitedToXDecimals",
getDolGlobalString(
'MAIN_MAX_DECIMALS_UNIT')), 1, 1);
1852 if ($prodcustprice->price_base_type ==
'TTC') {
1853 print
'<input name="price" size="10" value="'.price($prodcustprice->price_ttc).
'">';
1855 print
'<input name="price" size="10" value="'.price($prodcustprice->price).
'">';
1861 $text = $langs->trans(
'MinPrice');
1862 print $form->textwithpicto($text, $langs->trans(
"PrecisionUnitIsLimitedToXDecimals",
getDolGlobalString(
'MAIN_MAX_DECIMALS_UNIT')), 1, 1);
1864 if ($prodcustprice->price_base_type ==
'TTC') {
1865 print
'<input name="price_min" size="10" value="'.price($prodcustprice->price_min_ttc).
'">';
1867 print
'<input name="price_min" size="10" value="'.price($prodcustprice->price_min).
'">';
1871 print
'<td class="left">'.$langs->trans(
"MinimumRecommendedPrice",
price($maxpricesupplier, 0,
'', 1, -1, -1,
'auto')).
' '.
img_warning().
'</td>';
1879 print $langs->trans(
'PriceLabel');
1881 print
'<input name="price_label" maxlength="255" class="minwidth300 maxwidth400onsmartphone" value="'.$prodcustprice->price_label.
'">';
1888 print
'<div class="center">';
1889 print
'<div class="marginbottomonly">';
1890 print
'<input type="checkbox" name="updatechildprice" id="updatechildprice" value="1"> ';
1891 print
'<label for="updatechildprice">'.$langs->trans(
'ForceUpdateChildPriceSoc').
'</label>';
1894 print $form->buttonsSaveCancel();
1896 print
'<br></form>';
1897 } elseif ($action ==
'showlog_customer_price') {
1899 print
'<!-- list of all log of prices per customer -->'.
"\n";
1901 $filter = array(
't.fk_product' =>
$object->id,
't.fk_soc' =>
GETPOSTINT(
'socid'));
1904 $nbtotalofrecords =
'';
1906 $nbtotalofrecords = $prodcustprice->fetchAllLog($sortorder, $sortfield, $conf->liste_limit, $offset, $filter);
1909 $result = $prodcustprice->fetchAllLog($sortorder, $sortfield, $conf->liste_limit, $offset, $filter);
1914 $option =
'&socid='.GETPOSTINT(
'socid').
'&id='.
$object->id;
1916 $staticsoc =
new Societe($db);
1919 $title = $langs->trans(
'PriceByCustomerLog');
1920 $title .=
' - '.$staticsoc->getNomUrl(1);
1922 $backbutton =
'<a class="justalink" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'">'.$langs->trans(
"Back").
'</a>';
1925 print_barre_liste($title, $page, $_SERVER[
'PHP_SELF'], $option, $sortfield, $sortorder, $backbutton, count($prodcustprice->lines), $nbtotalofrecords,
'title_accountancy.png');
1927 if (count($prodcustprice->lines) > 0) {
1928 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'" method="POST">';
1929 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1930 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
1932 print
'<div class="div-table-responsive-no-min">';
1933 print
'<table class="liste centpercent">';
1935 print
'<tr class="liste_titre">';
1936 print
'<td>'.$langs->trans(
"ThirdParty").
'</td>';
1937 print
'<td>'.$langs->trans(
'RefCustomer').
'</td>';
1938 print
'<td>'.$langs->trans(
"AppliedPricesFrom").
'</td>';
1939 print
'<td class="center">'.$langs->trans(
"PriceBase").
'</td>';
1940 print
'<td class="right">'.$langs->trans(
"DefaultTaxRate").
'</td>';
1941 print
'<td class="right">'.$langs->trans(
"HT").
'</td>';
1942 print
'<td class="right">'.$langs->trans(
"TTC").
'</td>';
1943 if ($mysoc->localtax1_assuj ==
"1" || $mysoc->localtax2_assuj ==
"1") {
1944 print
'<td class="right">'.$langs->trans(
"INCT").
'</td>';
1946 print
'<td class="right">'.$langs->trans(
"MinPrice").
' '.$langs->trans(
"HT").
'</td>';
1947 print
'<td class="right">'.$langs->trans(
"MinPrice").
' '.$langs->trans(
"TTC").
'</td>';
1948 print
'<td class="right">'.$langs->trans(
"PriceLabel").
'</td>';
1949 print
'<td class="right">'.$langs->trans(
"ChangedBy").
'</td>';
1950 print
'<td> </td>';
1953 foreach ($prodcustprice->lines as $line) {
1955 $staticsoc =
new Societe($db);
1956 $staticsoc->fetch($line->fk_soc);
1958 $tva_tx = $line->default_vat_code ? $line->tva_tx.
' ('.$line->default_vat_code.
')' : $line->tva_tx;
1961 if ($line->price_base_type ==
'HT') {
1964 $pu = $line->price_ttc;
1968 $localtaxarray =
getLocalTaxesFromRate($line->tva_tx.($line->default_vat_code ?
' ('.$line->default_vat_code.
')' :
''), 0, $staticsoc, $mysoc);
1970 $resultarray =
calcul_price_total(1, $pu, 0, $line->tva_tx, 1, 1, 0, $line->price_base_type, $line->recuperableonly,
$object->type, $mysoc, $localtaxarray);
1972 $total_ht = $resultarray[0];
1973 $total_vat = $resultarray[1];
1974 $total_localtax1 = $resultarray[9];
1975 $total_localtax2 = $resultarray[10];
1976 $total_ttc = $resultarray[2];
1978 print
'<tr class="oddeven">';
1980 print
'<td class="tdoverflowmax125">'.$staticsoc->getNomUrl(1).
"</td>";
1981 print
'<td>'.$line->ref_customer.
'</td>';
1982 print
"<td>".dol_print_date($line->datec,
"dayhour",
'tzuserrel').
"</td>";
1983 print
'<td class="center">'.$langs->trans($line->price_base_type).
"</td>";
1984 print
'<td class="right">';
1986 $positiverates =
'';
1988 $positiverates .= ($positiverates ?
'/' :
'').
price2num($line->tva_tx);
1991 $positiverates .= ($positiverates ?
'/' :
'').
price2num($line->localtax1_tx);
1994 $positiverates .= ($positiverates ?
'/' :
'').
price2num($line->localtax2_tx);
1996 if (empty($positiverates)) {
1997 $positiverates =
'0';
2000 echo
vatrate($positiverates.($line->default_vat_code ?
' ('.$line->default_vat_code.
')' :
''), true, ($line->tva_npr ? $line->tva_npr : $line->recuperableonly));
2004 print
'<td class="right"><span class="amount">'.price($line->price).
"</span></td>";
2006 print
'<td class="right"><span class="amount">'.price($line->price_ttc).
"</span></td>";
2007 if ($mysoc->localtax1_assuj ==
"1" || $mysoc->localtax2_assuj ==
"1") {
2008 print
'<td class="right">'.price($resultarray[2]).
'</td>';
2011 print
'<td class="right">'.price($line->price_min).
'</td>';
2012 print
'<td class="right">'.price($line->price_min_ttc).
'</td>';
2013 print
'<td class="right">'.$line->price_label.
'</td>';
2016 $userstatic =
new User($db);
2017 $userstatic->fetch($line->fk_user);
2018 print
'<td class="right">';
2019 print $userstatic->getNomUrl(1,
'', 0, 0, 24, 0,
'login');
2027 print $langs->trans(
'None');
2029 } elseif ($action !=
'showlog_default_price' && $action !=
'edit_price' && $action !=
'edit_level_price') {
2031 print
'<!-- list of all prices per customer -->'.
"\n";
2034 $nbtotalofrecords =
'';
2036 $nbtotalofrecords = $prodcustprice->fetchAll($sortorder, $sortfield, 0, 0, $filter);
2039 $result = $prodcustprice->fetchAll($sortorder, $sortfield, $conf->liste_limit, $offset, $filter);
2044 $option =
'&search_soc='.$search_soc.
'&id='.
$object->id;
2047 print_barre_liste($langs->trans(
'PriceByCustomer'), $page, $_SERVER [
'PHP_SELF'], $option, $sortfield, $sortorder,
'', count($prodcustprice->lines), $nbtotalofrecords,
'title_accountancy.png');
2049 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'" method="POST">';
2050 print
'<input type="hidden" name="token" value="'.newToken().
'">';
2051 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
2053 print
'<!-- List of prices per customer -->'.
"\n";
2054 print
'<div class="div-table-responsive-no-min">'.
"\n";
2055 print
'<table class="liste centpercent">'.
"\n";
2057 if (count($prodcustprice->lines) > 0 || $search_soc) {
2059 if ($mysoc->localtax1_assuj ==
"1" || $mysoc->localtax2_assuj ==
"1") {
2063 print
'<tr class="liste_titre">';
2064 print
'<td class="liste_titre"><input type="text" class="flat maxwidth125" name="search_soc" value="'.$search_soc.
'"></td>';
2065 print
'<td class="liste_titre" colspan="'.$colspan.
'"> </td>';
2067 print
'<td class="liste_titre maxwidthsearch">';
2068 $searchpicto = $form->showFilterAndCheckAddButtons(0);
2074 print
'<tr class="liste_titre">';
2075 print
'<td>'.$langs->trans(
"ThirdParty").
'</td>';
2076 print
'<td>'.$langs->trans(
'RefCustomer').
'</td>';
2077 print
'<td>'.$langs->trans(
"AppliedPricesFrom").
'</td>';
2078 print
'<td class="center">'.$langs->trans(
"PriceBase").
'</td>';
2079 print
'<td class="right">'.$langs->trans(
"DefaultTaxRate").
'</td>';
2080 print
'<td class="right">'.$langs->trans(
"HT").
'</td>';
2081 print
'<td class="right">'.$langs->trans(
"TTC").
'</td>';
2082 if ($mysoc->localtax1_assuj ==
"1" || $mysoc->localtax2_assuj ==
"1") {
2083 print
'<td class="right">'.$langs->trans(
"INCT").
'</td>';
2085 print
'<td class="right">'.$langs->trans(
"MinPrice").
' '.$langs->trans(
"HT").
'</td>';
2086 print
'<td class="right">'.$langs->trans(
"MinPrice").
' '.$langs->trans(
"TTC").
'</td>';
2087 print
'<td class="right">'.$langs->trans(
"PriceLabel").
'</td>';
2088 print
'<td>'.$langs->trans(
"ChangedBy").
'</td>';
2093 if (
$object->price_base_type ==
'HT') {
2100 $localtaxarray =
getLocalTaxesFromRate(
$object->tva_tx.($object->default_vat_code ?
' ('.$object->default_vat_code.
')' :
''), 0, $mysoc, $mysoc);
2102 $resultarray =
calcul_price_total(1, $pu, 0,
$object->tva_tx, 1, 1, 0,
$object->price_base_type, 0,
$object->type, $mysoc, $localtaxarray);
2104 $total_ht = $resultarray[0];
2105 $total_vat = $resultarray[1];
2106 $total_localtax1 = $resultarray[9];
2107 $total_localtax2 = $resultarray[10];
2108 $total_ttc = $resultarray[2];
2111 print
'<tr class="oddeven">';
2112 print
'<td colspan="3">' . $langs->trans(
'Default') .
'</td>';
2114 print
'<td class="center">'.$langs->trans(
$object->price_base_type).
"</td>";
2117 print
'<td class="right">';
2119 $positiverates =
'';
2124 $positiverates .= ($positiverates ?
'/' :
'').
price2num(
$object->localtax1_tx);
2127 $positiverates .= ($positiverates ?
'/' :
'').
price2num(
$object->localtax2_tx);
2129 if (empty($positiverates)) {
2130 $positiverates =
'0';
2132 echo
vatrate($positiverates.($object->default_vat_code ?
' ('.$object->default_vat_code.
')' :
''), true,
$object->tva_npr);
2138 print
'<td class="right"><span class="amount">'.price(
$object->price).
"</span></td>";
2140 print
'<td class="right"><span class="amount">'.price(
$object->price_ttc).
"</span></td>";
2141 if ($mysoc->localtax1_assuj ==
"1" || $mysoc->localtax2_assuj ==
"1") {
2143 print
'<td class="right"><span class="amount">'.price($resultarray[2]).
'</span></td>';
2146 print
'<td class="right">'.price(
$object->price_min).
'</td>';
2147 print
'<td class="right">'.price(
$object->price_min_ttc).
'</td>';
2148 print
'<td class="right">'.$object->price_label.
'</td>';
2149 print
'<td class="right">';
2151 if ($user->hasRight(
'produit',
'supprimer') || $user->hasRight(
'service',
'supprimer')) {
2152 print
'<td class="nowraponall">';
2153 print
'<a class="marginleftonly marginrightonly" href="'.$_SERVER[
"PHP_SELF"].
'?action=showlog_default_price&token='.
newToken().
'&id='.
$object->id.
'">';
2154 print
img_info($langs->trans(
'PriceByCustomerLog'));
2157 print
'<a class="marginleftonly marginrightonly editfielda" href="'.$_SERVER[
"PHP_SELF"].
'?action=edit_price&token='.
newToken().
'&id='.
$object->id.
'">';
2158 print
img_edit(
'default', 0,
'style="vertical-align: middle;"');
2165 if (count($prodcustprice->lines) > 0) {
2166 foreach ($prodcustprice->lines as $line) {
2168 $staticsoc =
new Societe($db);
2169 $staticsoc->fetch($line->fk_soc);
2171 $tva_tx = $line->default_vat_code ? $line->tva_tx.
' ('.$line->default_vat_code.
')' : $line->tva_tx;
2174 if ($line->price_base_type ==
'HT') {
2177 $pu = $line->price_ttc;
2181 $localtaxarray =
getLocalTaxesFromRate($line->tva_tx.($line->default_vat_code ?
' ('.$line->default_vat_code.
')' :
''), 0, $staticsoc, $mysoc);
2183 $resultarray =
calcul_price_total(1, $pu, 0, $line->tva_tx, 1, 1, 0, $line->price_base_type, $line->recuperableonly,
$object->type, $mysoc, $localtaxarray);
2185 $total_ht = $resultarray[0];
2186 $total_vat = $resultarray[1];
2187 $total_localtax1 = $resultarray[9];
2188 $total_localtax2 = $resultarray[10];
2189 $total_ttc = $resultarray[2];
2191 print
'<tr class="oddeven">';
2193 print
'<td class="tdoverflowmax125">'.$staticsoc->getNomUrl(1).
"</td>";
2194 print
'<td>'.dol_escape_htmltag($line->ref_customer).
'</td>';
2195 print
"<td>".dol_print_date($line->datec,
"dayhour",
'tzuserrel').
"</td>";
2196 print
'<td class="center">'.$langs->trans($line->price_base_type).
"</td>";
2198 print
'<td class="right">';
2200 $positiverates =
'';
2202 $positiverates .= ($positiverates ?
'/' :
'').
price2num($line->tva_tx);
2205 $positiverates .= ($positiverates ?
'/' :
'').
price2num($line->localtax1_tx);
2208 $positiverates .= ($positiverates ?
'/' :
'').
price2num($line->localtax2_tx);
2210 if (empty($positiverates)) {
2211 $positiverates =
'0';
2214 echo
vatrate($positiverates.($line->default_vat_code ?
' ('.$line->default_vat_code.
')' :
''), true, (!empty($line->tva_npr) ? $line->tva_npr : $line->recuperableonly));
2218 print
'<td class="right"><span class="amount">'.price($line->price).
"</span></td>";
2220 print
'<td class="right"><span class="amount">'.price($line->price_ttc).
"</span></td>";
2221 if ($mysoc->localtax1_assuj ==
"1" || $mysoc->localtax2_assuj ==
"1") {
2223 print
'<td class="right"><span class="amount">'.price($resultarray[2]).
'</span></td>';
2226 print
'<td class="right">'.price($line->price_min).
'</td>';
2227 print
'<td class="right">'.price($line->price_min_ttc).
'</td>';
2228 print
'<td class="right">'.$line->price_label.
'</td>';
2231 $userstatic =
new User($db);
2232 $userstatic->fetch($line->fk_user);
2235 print $userstatic->getNomUrl(-1,
'', 0, 0, 24, 0,
'login');
2240 if ($user->hasRight(
'produit',
'supprimer') || $user->hasRight(
'service',
'supprimer')) {
2241 print
'<td class="right nowraponall">';
2242 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=showlog_customer_price&token='.
newToken().
'&id='.
$object->id.
'&socid='.$line->fk_soc.
'">';
2243 print
img_info($langs->trans(
'PriceByCustomerLog'));
2246 print
'<a class="marginleftonly editfielda" href="'.$_SERVER[
"PHP_SELF"].
'?action=edit_customer_price&token='.
newToken().
'&id='.
$object->id.
'&lineid='.$line->id.
'">';
2247 print
img_edit(
'default', 0,
'style="vertical-align: middle;"');
2250 print
'<a class="marginleftonly" href="'.$_SERVER[
"PHP_SELF"].
'?action=delete_customer_price&token='.
newToken().
'&id='.
$object->id.
'&lineid='.$line->id.
'">';
2251 print
img_delete(
'default',
'style="vertical-align: middle;"');
2269if ((!
getDolGlobalString(
'PRODUIT_CUSTOMER_PRICES') || $action ==
'showlog_default_price') && !in_array($action, array(
'edit_price',
'edit_level_price',
'edit_vat'))) {
2270 $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,";
2271 $sql .=
" p.price_level, p.price_min, p.price_min_ttc,p.price_by_qty,";
2272 $sql .=
" p.date_price as dp, p.fk_price_expression, u.rowid as user_id, u.login";
2273 $sql .=
" ,p.price_label";
2274 $sql .=
" FROM ".MAIN_DB_PREFIX.
"product_price as p,";
2275 $sql .=
" ".MAIN_DB_PREFIX.
"user as u";
2276 $sql .=
" WHERE fk_product = ".((int)
$object->id);
2277 $sql .=
" AND p.entity IN (".getEntity(
'productprice').
")";
2278 $sql .=
" AND p.fk_user_author = u.rowid";
2280 $sql .=
" AND p.price_level = ".((int) $soc->price_level);
2282 $sql .=
" ORDER BY p.date_price DESC, p.rowid DESC, p.price_level ASC";
2286 $result = $db->query($sql);
2288 print
'<div class="divlogofpreviouscustomerprice">';
2290 $num = $db->num_rows($result);
2299 $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);
2307 $result = $db->query($sql);
2308 $num = $db->num_rows($result);
2315 $backbutton =
'<a class="justalink" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'">'.$langs->trans(
"Back").
'</a>';
2319 print_barre_liste($langs->trans(
"DefaultPriceLog"), 0, $_SERVER[
"PHP_SELF"],
'',
'',
'', $backbutton, 0, $num,
'title_accountancy.png');
2322 print_barre_liste($langs->trans(
"PriceByCustomerLog"), 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', 0, $num,
'title_accountancy.png');
2325 print
'<!-- List of log prices -->'.
"\n";
2326 print
'<div class="div-table-responsive">'.
"\n";
2327 print
'<table class="liste centpercent">'.
"\n";
2329 print
'<tr class="liste_titre">';
2330 print
'<td>'.$langs->trans(
"AppliedPricesFrom").
'</td>';
2333 print
'<td class="center">'.$langs->trans(
"PriceLevel").
'</td>';
2336 print
'<td class="center">'.$langs->trans(
"Type").
'</td>';
2339 print
'<td class="center">'.$langs->trans(
"PriceBase").
'</td>';
2341 print
'<td class="right">'.$langs->trans(
"DefaultTaxRate").
'</td>';
2343 print
'<td class="right">'.$langs->trans(
"HT").
'</td>';
2344 print
'<td class="right">'.$langs->trans(
"TTC").
'</td>';
2345 if ($mysoc->localtax1_assuj ==
"1" || $mysoc->localtax2_assuj ==
"1") {
2346 print
'<td class="right">'.$langs->trans(
"INCT").
'</td>';
2348 if (!empty($conf->dynamicprices->enabled)) {
2349 print
'<td class="right">'.$langs->trans(
"PriceExpressionSelected").
'</td>';
2351 print
'<td class="right">'.$langs->trans(
"MinPrice").
' '.$langs->trans(
"HT").
'</td>';
2352 print
'<td class="right">'.$langs->trans(
"MinPrice").
' '.$langs->trans(
"TTC").
'</td>';
2353 print
'<td class="right">'.$langs->trans(
"Label").
'</td>';
2354 print
'<td>'.$langs->trans(
"ChangedBy").
'</td>';
2355 if ($user->hasRight(
'produit',
'supprimer')) {
2356 print
'<td class="right"> </td>';
2360 $notfirstlineforlevel = array();
2364 $objp = $db->fetch_object($result);
2366 print
'<tr class="oddeven">';
2368 print
"<td>".dol_print_date($db->jdate($objp->dp),
"dayhour",
'tzuserrel').
"</td>";
2372 print
'<td class="center">'.$objp->price_level.
"</td>";
2376 $type = ($objp->price_by_qty == 1) ?
'PriceByQuantity' :
'Standard';
2377 print
'<td class="center">'.$langs->trans($type).
"</td>";
2380 print
'<td class="center">';
2381 if (empty($objp->price_by_qty)) {
2382 print $langs->trans($objp->price_base_type);
2387 print
'<td class="right">';
2389 if (empty($objp->price_by_qty)) {
2390 $positiverates =
'';
2392 $positiverates .= ($positiverates ?
'/' :
'').
price2num($objp->tva_tx);
2395 $positiverates .= ($positiverates ?
'/' :
'').
price2num($objp->localtax1_tx);
2398 $positiverates .= ($positiverates ?
'/' :
'').
price2num($objp->localtax2_tx);
2400 if (empty($positiverates)) {
2401 $positiverates =
'0';
2403 echo
vatrate($positiverates.($objp->default_vat_code ?
' ('.$objp->default_vat_code.
')' :
''), true, !empty($objp->tva_npr) ? $objp->tva_npr : 0);
2416 if ($objp->price_base_type ==
'HT') {
2419 $pu = $objp->price_ttc;
2423 $localtaxarray =
getLocalTaxesFromRate($objp->tva_tx.($object->default_vat_code ?
' ('.$object->default_vat_code.
')' :
''), 0, $mysoc, $mysoc);
2425 $resultarray =
calcul_price_total(1, $pu, 0, $objp->tva_tx, 1, 1, 0, $objp->price_base_type, $objp->recuperableonly,
$object->type, $mysoc, $localtaxarray);
2427 $total_ht = $resultarray[0];
2428 $total_vat = $resultarray[1];
2429 $total_localtax1 = $resultarray[9];
2430 $total_localtax2 = $resultarray[10];
2431 $total_ttc = $resultarray[2];
2434 if (!empty($objp->fk_price_expression) && !empty($conf->dynamicprices->enabled)) {
2436 $res = $price_expression->fetch($objp->fk_price_expression);
2437 $title = $price_expression->title;
2438 print
'<td class="right"></td>';
2439 print
'<td class="right"></td>';
2440 if ($mysoc->localtax1_assuj ==
"1" || $mysoc->localtax2_assuj ==
"1") {
2441 print
'<td class="right"></td>';
2443 print
'<td class="right">'.$title.
"</td>";
2446 print
'<td class="right">';
2447 if (empty($objp->price_by_qty)) {
2448 print
'<span class="amount">'.price($objp->price).
'</span>';
2452 print
'<td class="right">';
2453 if (empty($objp->price_by_qty)) {
2454 $price_ttc = $objp->price_ttc;
2455 print
'<span class="amount">'.price($price_ttc).
'<span>';
2458 if ($mysoc->localtax1_assuj ==
"1" || $mysoc->localtax2_assuj ==
"1") {
2459 print
'<td class="right">';
2460 print $resultarray[2];
2463 if (!empty($conf->dynamicprices->enabled)) {
2464 print
'<td class="right"></td>';
2469 print
'<td class="right">';
2470 if (empty($objp->price_by_qty)) {
2471 print
price($objp->price_min);
2476 print
'<td class="right">';
2477 if (empty($objp->price_by_qty)) {
2478 $price_min_ttc = $objp->price_min_ttc;
2479 print
price($price_min_ttc);
2484 print
'<td class="right">';
2485 print $objp->price_label;
2490 if ($objp->user_id > 0) {
2491 $userstatic =
new User($db);
2492 $userstatic->fetch($objp->user_id);
2493 print $userstatic->getNomUrl(-1,
'', 0, 0, 24, 0,
'login');
2499 if ($user->hasRight(
'produit',
'supprimer')) {
2502 if (empty($notfirstlineforlevel[$objp->price_level])) {
2503 $notfirstlineforlevel[$objp->price_level] = 1;
2511 print
'<td class="right">';
2512 if ($candelete || ($db->jdate($objp->dp) >=
dol_now())) {
2513 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=delete&token='.
newToken().
'&id='.
$object->id.
'&lineid='.$objp->rowid.
'">';
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).
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.
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.
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
img_delete($titlealt='default', $other='class="pictodelete"', $morecss='')
Show delete logo.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
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)
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'.
print_barre_liste($title, $page, $file, $options='', $sortfield='', $sortorder='', $morehtmlcenter='', $num=-1, $totalnboflines='', $picto='generic', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limit=-1, $hideselectlimit=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow='')
Print a title with navigation controls for pagination.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
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...
calcul_price_total($qty, $pu, $remise_percent_ligne, $txtva, $uselocaltax1_rate, $uselocaltax2_rate, $remise_percent_global, $price_base_type, $info_bits, $type, $seller='', $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:/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.