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 for ($i = 1; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i++) {
210 if (
$object->multiprices_base_type[$i] ==
'HT') {
211 $oldprice =
$object->multiprices[$i];
212 $oldminprice =
$object->multiprices_min[$i];
214 $oldprice =
$object->multiprices_ttc[$i];
215 $oldminprice =
$object->multiprices_min_ttc[$i];
217 $oldpricebasetype =
$object->multiprices_base_type[$i];
218 $oldnpr =
$object->multiprices_recuperableonly[$i];
221 $localtaxarray = array();
223 $ret =
$object->updatePrice($oldprice, $oldpricebasetype, $user, $tva_tx, $oldminprice, $level, $oldnpr, 0, 0, $localtaxarray, $vatratecode, $price_label);
232 if (
$object->price_base_type ==
'HT') {
234 $oldminprice =
$object->price_min;
236 $oldprice =
$object->price_ttc;
237 $oldminprice =
$object->price_min_ttc;
239 $oldpricebasetype =
$object->price_base_type;
243 $localtaxarray = array();
245 $ret =
$object->updatePrice($oldprice, $oldpricebasetype, $user, $tva_tx, $oldminprice, $level, $oldnpr, 0, 0, $localtaxarray, $vatratecode, $price_label);
263 if (($action ==
'update_price') && !$cancel &&
$object->getRights()->creer) {
265 $pricestoupdate = array();
268 $psq = empty($newpsq) ? 0 : $newpsq;
269 $maxpricesupplier =
$object->min_recommended_price();
271 if (isModEnabled(
'dynamicprices')) {
272 $object->fk_price_expression = empty($eid) ? 0 : $eid;
274 if (
$object->fk_price_expression != 0) {
276 require_once DOL_DOCUMENT_ROOT.
'/product/dynamic_price/class/price_parser.class.php';
279 if ($priceparser->parseProduct($object) < 0) {
288 $newprice =
GETPOST(
'price',
'array');
289 $newprice_min =
GETPOST(
'price_min',
'array');
290 $newpricebase =
GETPOST(
'multiprices_base_type',
'array');
291 $newvattx =
GETPOST(
'tva_tx',
'array');
292 $newvatnpr =
GETPOST(
'tva_npr',
'array');
293 $newlocaltax1_tx =
GETPOST(
'localtax1_tx',
'array');
294 $newlocaltax1_type =
GETPOST(
'localtax1_type',
'array');
295 $newlocaltax2_tx =
GETPOST(
'localtax2_tx',
'array');
296 $newlocaltax2_type =
GETPOST(
'localtax2_type',
'array');
299 $object->price_autogen = (int) (
GETPOST(
'usePriceRules') ==
'on');
301 for ($i = 1; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i++) {
302 if (!isset($newprice[$i])) {
306 $tva_tx_txt = $newvattx[$i];
308 $tva_tx = $tva_tx_txt;
311 if (preg_match(
'/\((.*)\)/', $tva_tx_txt, $reg)) {
312 $vat_src_code = $reg[1];
313 $tva_tx = preg_replace(
'/\s*\(.*\)/',
'', $tva_tx_txt);
315 $tva_tx =
price2num(preg_replace(
'/\*/',
'', $tva_tx));
317 $npr = preg_match(
'/\*/', $tva_tx_txt) ? 1 : 0;
318 $localtax1 = $newlocaltax1_tx[$i];
319 $localtax1_type = $newlocaltax1_type[$i];
320 $localtax2 = $newlocaltax2_tx[$i];
321 $localtax2_type = $newlocaltax2_type[$i];
322 if (preg_match(
'/\((.*)\)/', $tva_tx_txt, $reg)) {
324 $vatratecode = $reg[1];
326 $sql =
"SELECT t.rowid, t.code, t.recuperableonly, t.localtax1, t.localtax2, t.localtax1_type, t.localtax2_type";
327 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_tva as t, ".MAIN_DB_PREFIX.
"c_country as c";
328 $sql .=
" WHERE t.fk_pays = c.rowid AND c.code = '".$db->escape($mysoc->country_code).
"'";
329 $sql .=
" AND t.taux = ".((float) $tva_tx).
" AND t.active = 1";
330 $sql .=
" AND t.code ='".$db->escape($vatratecode).
"'";
331 $sql .=
" AND t.entity IN (".getEntity(
'c_tva').
")";
332 $resql = $db->query($sql);
334 $obj = $db->fetch_object($resql);
336 $npr = $obj->recuperableonly;
337 $localtax1 = $obj->localtax1;
338 $localtax2 = $obj->localtax2;
339 $localtax1_type = $obj->localtax1_type;
340 $localtax2_type = $obj->localtax2_type;
344 if (in_array($mysoc->country_code, array(
'ES'))) {
351 $sql =
"SELECT t.rowid, t.code, t.recuperableonly, t.localtax1, t.localtax2, t.localtax1_type, t.localtax2_type";
352 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_tva as t, ".MAIN_DB_PREFIX.
"c_country as c";
353 $sql .=
" WHERE t.fk_pays = c.rowid AND c.code = '".$db->escape($mysoc->country_code).
"'";
354 $sql .=
" AND t.taux = ".((float) $tva_tx).
" AND t.active = 1";
355 $sql .=
" AND t.code = ''";
356 $resql = $db->query($sql);
358 $obj = $db->fetch_object($resql);
360 $npr = $obj->recuperableonly;
361 $localtax1 = $obj->localtax1;
362 $localtax2 = $obj->localtax2;
363 $localtax1_type = $obj->localtax1_type;
364 $localtax2_type = $obj->localtax2_type;
369 $pricestoupdate[$i] = array(
370 'price' =>
price2num($newprice[$i],
'', 2),
371 'price_min' =>
price2num($newprice_min[$i],
'', 2),
372 'price_base_type' => $newpricebase[$i],
373 'default_vat_code' => $vatratecode,
376 'localtaxes_array' => array(
'0' => $localtax1_type,
'1' => $localtax1,
'2' => $localtax2_type,
'3' => $localtax2)
387 $newpricebase =
GETPOST(
'price_base_type',
'alpha');
388 $tva_tx_txt =
GETPOST(
'tva_tx',
'alpha');
389 $price_label =
GETPOST(
'price_label',
'alpha');
391 $tva_tx = $tva_tx_txt;
394 if (preg_match(
'/\((.*)\)/', $tva_tx_txt, $reg)) {
395 $vat_src_code = $reg[1];
396 $tva_tx = preg_replace(
'/\s*\(.*\)/',
'', $tva_tx_txt);
398 $tva_tx =
price2num(preg_replace(
'/\*/',
'', $tva_tx));
400 $npr = preg_match(
'/\*/', $tva_tx_txt) ? 1 : 0;
403 $localtax1_type =
'0';
404 $localtax2_type =
'0';
406 if (preg_match(
'/\((.*)\)/', $tva_tx_txt, $reg)) {
408 $vatratecode = $reg[1];
410 $sql =
"SELECT t.rowid, t.code, t.recuperableonly, t.localtax1, t.localtax2, t.localtax1_type, t.localtax2_type";
411 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_tva as t, ".MAIN_DB_PREFIX.
"c_country as c";
412 $sql .=
" WHERE t.fk_pays = c.rowid AND c.code = '".$db->escape($mysoc->country_code).
"'";
413 $sql .=
" AND t.taux = ".((float) $tva_tx).
" AND t.active = 1";
414 $sql .=
" AND t.code ='".$db->escape($vatratecode).
"'";
415 $sql .=
" AND t.entity IN (".getEntity(
'c_tva').
")";
416 $resql = $db->query($sql);
418 $obj = $db->fetch_object($resql);
420 $npr = $obj->recuperableonly;
421 $localtax1 = $obj->localtax1;
422 $localtax2 = $obj->localtax2;
423 $localtax1_type = $obj->localtax1_type;
424 $localtax2_type = $obj->localtax2_type;
428 if (in_array($mysoc->country_code, array(
'ES'))) {
435 $sql =
"SELECT t.rowid, t.code, t.recuperableonly, t.localtax1, t.localtax2, t.localtax1_type, t.localtax2_type";
436 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_tva as t, ".MAIN_DB_PREFIX.
"c_country as c";
437 $sql .=
" WHERE t.fk_pays = c.rowid AND c.code = '".$db->escape($mysoc->country_code).
"'";
438 $sql .=
" AND t.taux = ".((float) $tva_tx).
" AND t.active = 1";
439 $sql .=
" AND t.code = ''";
440 $resql = $db->query($sql);
442 $obj = $db->fetch_object($resql);
444 $npr = $obj->recuperableonly;
445 $localtax1 = $obj->localtax1;
446 $localtax2 = $obj->localtax2;
447 $localtax1_type = $obj->localtax1_type;
448 $localtax2_type = $obj->localtax2_type;
453 $pricestoupdate[0] = array(
454 'price' => $newprice,
455 'price_label' => $price_label,
456 'price_min' => $newprice_min,
457 'price_base_type' => $newpricebase,
458 'default_vat_code' => $vatratecode,
461 'localtaxes_array' => array(
'0' => $localtax1_type,
'1' => $localtax1,
'2' => $localtax2_type,
'3' => $localtax2)
468 foreach ($pricestoupdate as $key => $val) {
469 $newprice = $val[
'price'];
471 if ($val[
'price'] < $val[
'price_min'] && !empty(
$object->fk_price_expression)) {
472 $newprice = $val[
'price_min'];
476 $newprice_min =
price2num($val[
'price_min'],
'MU');
479 if (
getDolGlobalString(
'PRODUCT_MINIMUM_RECOMMENDED_PRICE') && $newprice_min < $maxpricesupplier) {
480 setEventMessages($langs->trans(
"MinimumPriceLimit",
price($maxpricesupplier, 0,
'', 1, - 1, - 1,
'auto')),
null,
'errors');
486 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) {
487 $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']);
510 $action =
'edit_price';
516 if ($action ==
'delete' && $user->hasRight(
'produit',
'supprimer')) {
524 if ($action ==
'activate_price_by_qty') {
536 if ($action ==
'disable_price_by_qty') {
548 if ($action ==
'edit_price_by_qty') {
553 if ($action ==
'update_price_by_qty') {
563 if (empty($quantity)) {
565 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Qty")),
null,
'errors');
567 if (empty($newprice)) {
569 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Price")),
null,
'errors');
573 if (
$object->price_base_type ==
'TTC') {
578 $unitPrice =
price2num((
float) $price / (
float) $quantity,
'MU');
582 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"product_price_by_qty SET";
583 $sql .=
" price=".((float) $price).
",";
584 $sql .=
" unitprice=".((float) $unitPrice).
",";
585 $sql .=
" quantity=".((float) $quantity).
",";
586 $sql .=
" remise_percent=".((float) $remise_percent).
",";
587 $sql .=
" remise=".((float) $remise);
588 $sql .=
" WHERE rowid = ".((int) $rowid);
590 $result = $db->query($sql);
595 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"product_price_by_qty (fk_product_price,price,unitprice,quantity,remise_percent,remise) values (";
596 $sql .= ((int) $priceid).
','.((float) $price).
','.((float) $unitPrice).
','.((float) $quantity).
','.((float) $remise_percent).
','.((float) $remise).
')';
598 $result = $db->query($sql);
600 if ($db->lasterrno() ==
'DB_ERROR_RECORD_ALREADY_EXISTS') {
610 if ($action ==
'delete_price_by_qty') {
612 if (!empty($rowid)) {
613 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"product_price_by_qty";
614 $sql .=
" WHERE rowid = ".((int) $rowid);
616 $result = $db->query($sql);
618 setEventMessages((
'delete_price_by_qty'.$langs->transnoentities(
'MissingIds')),
null,
'errors');
622 if ($action ==
'delete_all_price_by_qty') {
624 if (!empty($rowid)) {
625 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"product_price_by_qty";
626 $sql .=
" WHERE fk_product_price = ".((int) $priceid);
628 $result = $db->query($sql);
630 setEventMessages((
'delete_price_by_qty'.$langs->transnoentities(
'MissingIds')),
null,
'errors');
639 if ($action ==
'add_customer_price_confirm' && !$cancel && ($user->hasRight(
'produit',
'creer') || $user->hasRight(
'service',
'creer'))) {
640 $maxpricesupplier =
$object->min_recommended_price();
642 $update_child_soc =
GETPOSTINT(
'updatechildprice');
646 $prodcustprice->ref_customer =
GETPOST(
'ref_customer',
'alpha');
647 $prodcustprice->fk_product =
$object->id;
650 $prodcustprice->price_base_type =
GETPOST(
"price_base_type",
'alpha');
651 $prodcustprice->price_label =
GETPOST(
"price_label",
'alpha');
653 $tva_tx_txt =
GETPOST(
"tva_tx",
'alpha');
655 $tva_tx = $tva_tx_txt;
657 if (preg_match(
'/\((.*)\)/', $tva_tx_txt, $reg)) {
658 $vat_src_code = $reg[1];
659 $tva_tx = preg_replace(
'/\s*\(.*\)/',
'', $tva_tx_txt);
661 $tva_tx =
price2num(preg_replace(
'/\*/',
'', $tva_tx));
663 $npr = preg_match(
'/\*/', $tva_tx_txt) ? 1 : 0;
666 $localtax1_type =
'0';
667 $localtax2_type =
'0';
669 if (preg_match(
'/\((.*)\)/', $tva_tx_txt, $reg)) {
671 $vatratecode = $reg[1];
673 $sql =
"SELECT t.rowid, t.code, t.recuperableonly, t.localtax1, t.localtax2, t.localtax1_type, t.localtax2_type";
674 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_tva as t, ".MAIN_DB_PREFIX.
"c_country as c";
675 $sql .=
" WHERE t.fk_pays = c.rowid AND c.code = '".$db->escape($mysoc->country_code).
"'";
676 $sql .=
" AND t.taux = ".((float) $tva_tx).
" AND t.active = 1";
677 $sql .=
" AND t.code ='".$db->escape($vatratecode).
"'";
678 $sql .=
" AND t.entity IN (".getEntity(
'c_tva').
")";
679 $resql = $db->query($sql);
681 $obj = $db->fetch_object($resql);
683 $npr = $obj->recuperableonly;
684 $localtax1 = $obj->localtax1;
685 $localtax2 = $obj->localtax2;
686 $localtax1_type = $obj->localtax1_type;
687 $localtax2_type = $obj->localtax2_type;
691 if (in_array($mysoc->country_code, array(
'ES'))) {
698 $sql =
"SELECT t.rowid, t.code, t.recuperableonly, t.localtax1, t.localtax2, t.localtax1_type, t.localtax2_type";
699 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_tva as t, ".MAIN_DB_PREFIX.
"c_country as c";
700 $sql .=
" WHERE t.fk_pays = c.rowid AND c.code = '".$db->escape($mysoc->country_code).
"'";
701 $sql .=
" AND t.taux = ".((float) $tva_tx).
" AND t.active = 1";
702 $sql .=
" AND t.code = ''";
703 $resql = $db->query($sql);
705 $obj = $db->fetch_object($resql);
707 $npr = $obj->recuperableonly;
708 $localtax1 = $obj->localtax1;
709 $localtax2 = $obj->localtax2;
710 $localtax1_type = $obj->localtax1_type;
711 $localtax2_type = $obj->localtax2_type;
716 $prodcustprice->default_vat_code = $vatratecode;
717 $prodcustprice->tva_tx = $tva_tx;
718 $prodcustprice->recuperableonly = $npr;
719 $prodcustprice->localtax1_tx = $localtax1;
720 $prodcustprice->localtax2_tx = $localtax2;
721 $prodcustprice->localtax1_type = $localtax1_type;
722 $prodcustprice->localtax2_type = $localtax2_type;
724 if (!($prodcustprice->fk_soc > 0)) {
725 $langs->load(
"errors");
726 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"ThirdParty")),
null,
'errors');
728 $action =
'add_customer_price';
730 if (
getDolGlobalString(
'PRODUCT_MINIMUM_RECOMMENDED_PRICE') && $prodcustprice->price_min < $maxpricesupplier) {
731 $langs->load(
"errors");
732 setEventMessages($langs->trans(
"MinimumPriceLimit",
price($maxpricesupplier, 0,
'', 1, -1, -1,
'auto')),
null,
'errors');
734 $action =
'add_customer_price';
738 $result = $prodcustprice->create($user, 0, $update_child_soc);
750 if ($action ==
'delete_customer_price' && ($user->hasRight(
'produit',
'supprimer') || $user->hasRight(
'service',
'supprimer'))) {
753 $result = $prodcustprice->delete($user);
763 if ($action ==
'update_customer_price_confirm' && !$cancel && ($user->hasRight(
'produit',
'creer') || $user->hasRight(
'service',
'creer'))) {
764 $maxpricesupplier =
$object->min_recommended_price();
766 $update_child_soc =
GETPOSTINT(
'updatechildprice');
771 $prodcustprice->ref_customer =
GETPOST(
'ref_customer',
'alpha');
774 $prodcustprice->price_base_type =
GETPOST(
"price_base_type",
'alpha');
775 $prodcustprice->price_label =
GETPOST(
"price_label",
'alpha');
777 $tva_tx_txt =
GETPOST(
"tva_tx");
779 $tva_tx = $tva_tx_txt;
781 if (preg_match(
'/\((.*)\)/', $tva_tx_txt, $reg)) {
782 $vat_src_code = $reg[1];
783 $tva_tx = preg_replace(
'/\s*\(.*\)/',
'', $tva_tx_txt);
785 $tva_tx =
price2num(preg_replace(
'/\*/',
'', $tva_tx));
787 $npr = preg_match(
'/\*/', $tva_tx_txt) ? 1 : 0;
790 $localtax1_type =
'0';
791 $localtax2_type =
'0';
793 if (preg_match(
'/\((.*)\)/', $tva_tx_txt, $reg)) {
795 $vatratecode = $reg[1];
797 $sql =
"SELECT t.rowid, t.code, t.recuperableonly, t.localtax1, t.localtax2, t.localtax1_type, t.localtax2_type";
798 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_tva as t, ".MAIN_DB_PREFIX.
"c_country as c";
799 $sql .=
" WHERE t.fk_pays = c.rowid AND c.code = '".$db->escape($mysoc->country_code).
"'";
800 $sql .=
" AND t.taux = ".((float) $tva_tx).
" AND t.active = 1";
801 $sql .=
" AND t.code ='".$db->escape($vatratecode).
"'";
802 $sql .=
" AND t.entity IN (".getEntity(
'c_tva').
")";
803 $resql = $db->query($sql);
805 $obj = $db->fetch_object($resql);
807 $npr = $obj->recuperableonly;
808 $localtax1 = $obj->localtax1;
809 $localtax2 = $obj->localtax2;
810 $localtax1_type = $obj->localtax1_type;
811 $localtax2_type = $obj->localtax2_type;
815 if (in_array($mysoc->country_code, array(
'ES'))) {
822 $sql =
"SELECT t.rowid, t.code, t.recuperableonly, t.localtax1, t.localtax2, t.localtax1_type, t.localtax2_type";
823 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_tva as t, ".MAIN_DB_PREFIX.
"c_country as c";
824 $sql .=
" WHERE t.fk_pays = c.rowid AND c.code = '".$db->escape($mysoc->country_code).
"'";
825 $sql .=
" AND t.taux = ".((float) $tva_tx).
" AND t.active = 1";
826 $sql .=
" AND t.code = ''";
827 $resql = $db->query($sql);
829 $obj = $db->fetch_object($resql);
831 $npr = $obj->recuperableonly;
832 $localtax1 = $obj->localtax1;
833 $localtax2 = $obj->localtax2;
834 $localtax1_type = $obj->localtax1_type;
835 $localtax2_type = $obj->localtax2_type;
840 $prodcustprice->default_vat_code = $vatratecode;
841 $prodcustprice->tva_tx = $tva_tx;
842 $prodcustprice->recuperableonly = $npr;
843 $prodcustprice->localtax1_tx = $localtax1;
844 $prodcustprice->localtax2_tx = $localtax2;
845 $prodcustprice->localtax1_type = $localtax1_type;
846 $prodcustprice->localtax2_type = $localtax2_type;
848 if ($prodcustprice->price_min < $maxpricesupplier &&
getDolGlobalString(
'PRODUCT_MINIMUM_RECOMMENDED_PRICE')) {
849 setEventMessages($langs->trans(
"MinimumPriceLimit",
price($maxpricesupplier, 0,
'', 1, -1, -1,
'auto')),
null,
'errors');
851 $action =
'update_customer_price';
855 $result = $prodcustprice->update($user, 0, $update_child_soc);
873$form =
new Form($db);
875if (!empty($id) || !empty($ref)) {
880$title = $langs->trans(
'ProductServiceCard');
884 $title = $langs->trans(
'Product').
" ".$shortlabel.
" - ".$langs->trans(
'SellingPrices');
885 $helpurl =
'EN:Module_Products|FR:Module_Produits|ES:Módulo_Productos';
888 $title = $langs->trans(
'Service').
" ".$shortlabel.
" - ".$langs->trans(
'SellingPrices');
889 $helpurl =
'EN:Module_Services_En|FR:Module_Services|ES:Módulo_Servicios';
892llxHeader(
'', $title, $helpurl,
'', 0, 0,
'',
'',
'',
'classforhorizontalscrolloftabs mod-product page-price');
895$titre = $langs->trans(
"CardProduct".
$object->type);
900$linkback =
'<a href="'.DOL_URL_ROOT.
'/product/list.php?restore_lastsearch_values=1&type='.
$object->type.
'">'.$langs->trans(
"BackToList").
'</a>';
901$object->next_prev_filter =
"fk_product_type = ".((int)
$object->type);
904if ($user->socid && !in_array(
'product', explode(
',',
getDolGlobalString(
'MAIN_MODULES_FOR_EXTERNAL')))) {
908dol_banner_tab($object,
'ref', $linkback, $shownav,
'ref');
911print
'<div class="fichecenter">';
913print
'<div class="underbanner clearboth"></div>';
914print
'<table class="border tableforfield centpercent">';
919 if (!empty($socid)) {
925 if (isModEnabled(
"product") && isModEnabled(
"service")) {
926 $typeformat =
'select;0:'.$langs->trans(
"Product").
',1:'.$langs->trans(
"Service");
927 print
'<tr><td class="">';
928 print (!
getDolGlobalString(
'PRODUCT_DENY_CHANGE_PRODUCT_TYPE')) ? $form->editfieldkey(
"Type",
'fk_product_type',
$object->type, $object, 0, $typeformat) : $langs->trans(
'Type');
930 print $form->editfieldval(
"Type",
'fk_product_type',
$object->type, $object, 0, $typeformat);
935 print
'<tr><td class="titlefieldcreate">';
936 print $langs->trans(
"SellingPrice");
938 print
'<td colspan="2">';
939 if (
$object->multiprices_base_type[$soc->price_level] ==
'TTC') {
940 print
'<span class="amount">'.price(
$object->multiprices_ttc[$soc->price_level]).
'</span>';
942 print
'<span class="amount">'.price(
$object->multiprices[$soc->price_level]).
'</span>';
944 if (
$object->multiprices_base_type[$soc->price_level]) {
945 print
' '.$langs->trans(
$object->multiprices_base_type[$soc->price_level]);
947 print
' '.$langs->trans(
$object->price_base_type);
952 print
'<tr><td>'.$langs->trans(
"MinPrice").
'</td><td colspan="2">';
953 if (
$object->multiprices_base_type[$soc->price_level] ==
'TTC') {
954 print
price(
$object->multiprices_min_ttc[$soc->price_level]).
' '.$langs->trans(
$object->multiprices_base_type[$soc->price_level]);
956 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]);
962 print
'<tr><td>'.$langs->trans(
"DefaultTaxRate").
'</td><td colspan="2">';
966 $positiverates .= ($positiverates ?
'/' :
'').
price2num(
$object->multiprices_tva_tx[$soc->price_level]);
969 $positiverates .= ($positiverates ?
'/' :
'').
price2num(
$object->multiprices_localtax1_tx[$soc->price_level]);
972 $positiverates .= ($positiverates ?
'/' :
'').
price2num(
$object->multiprices_localtax2_tx[$soc->price_level]);
974 if (empty($positiverates)) {
975 $positiverates =
'0';
977 echo
vatrate($positiverates.($object->default_vat_code ?
' ('.$object->default_vat_code.
')' :
''),
'%',
$object->tva_npr);
982 print
'<tr><td>'.$langs->trans(
"DefaultTaxRate").
'</td><td>';
989 $positiverates .= ($positiverates ?
'/' :
'').
price2num(
$object->localtax1_tx);
992 $positiverates .= ($positiverates ?
'/' :
'').
price2num(
$object->localtax2_tx);
994 if (empty($positiverates)) {
995 $positiverates =
'0';
997 echo
vatrate($positiverates.($object->default_vat_code ?
' ('.$object->default_vat_code.
')' :
''),
'%',
$object->tva_npr);
1009 if (isModEnabled(
"product") && isModEnabled(
"service")) {
1010 $typeformat =
'select;0:'.$langs->trans(
"Product").
',1:'.$langs->trans(
"Service");
1011 print
'<tr><td class="">';
1012 print (!
getDolGlobalString(
'PRODUCT_DENY_CHANGE_PRODUCT_TYPE')) ? $form->editfieldkey(
"Type",
'fk_product_type',
$object->type, $object, 0, $typeformat) : $langs->trans(
'Type');
1014 print $form->editfieldval(
"Type",
'fk_product_type',
$object->type, $object, 0, $typeformat);
1019 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"DefaultTaxRate").
'</td>';
1020 print
'<td colspan="2">'.vatrate(
$object->multiprices_tva_tx[1],
true).
'</td>';
1024 if (isModEnabled(
"product") && isModEnabled(
"service")) {
1025 $typeformat =
'select;0:'.$langs->trans(
"Product").
',1:'.$langs->trans(
"Service");
1026 print
'<tr><td class="">';
1027 print (!
getDolGlobalString(
'PRODUCT_DENY_CHANGE_PRODUCT_TYPE')) ? $form->editfieldkey(
"Type",
'fk_product_type',
$object->type, $object, 0, $typeformat) : $langs->trans(
'Type');
1029 print $form->editfieldval(
"Type",
'fk_product_type',
$object->type, $object, 0, $typeformat);
1034 print
'<!-- Default VAT Rate -->';
1035 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"DefaultTaxRate").
'</td><td>';
1038 $positiverates =
'';
1040 $positiverates .= ($positiverates ?
'<span class="opacitymedium">/</span>' :
'').
price2num(
$object->tva_tx);
1043 $positiverates .= ($positiverates ?
'<span class="opacitymedium">/</span>' :
'').
price2num(
$object->localtax1_tx);
1046 $positiverates .= ($positiverates ?
'<span class="opacitymedium">/</span>' :
'').
price2num(
$object->localtax2_tx);
1048 if (empty($positiverates)) {
1049 $positiverates =
'0';
1052 print
vatrate($positiverates.($object->default_vat_code ?
' ('.$object->default_vat_code.
')' :
''), true,
$object->tva_npr, 1);
1065 print
'<table class="noborder tableforfield centpercent">';
1066 print
'<tr class="liste_titre"><td>';
1067 print $langs->trans(
"PriceLevel");
1069 print
' <a class="editfielda" href="'.$_SERVER[
"PHP_SELF"].
'?action=editlabelsellingprice&token='.
newToken().
'&pricelevel='.$i.
'&id='.
$object->id.
'">'.
img_edit($langs->trans(
'EditSellingPriceLabel'), 0).
'</a>';
1072 print
'<td style="text-align: right">'.$langs->trans(
"SellingPrice").
'</td>';
1073 print
'<td style="text-align: right">'.$langs->trans(
"MinPrice").
'</td>';
1076 for ($i = 1; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i++) {
1077 print
'<tr class="oddeven">';
1081 $keyforlabel =
'PRODUIT_MULTIPRICES_LABEL'.$i;
1082 if (preg_match(
'/editlabelsellingprice/', $action)) {
1083 print
'<form method="post" action="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'">';
1084 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1085 print
'<input type="hidden" name="action" value="setlabelsellingprice">';
1086 print
'<input type="hidden" name="pricelevel" value="'.$i.
'">';
1087 print $langs->trans(
"SellingPrice").
' '.$i.
' - ';
1088 print
'<input class="maxwidthonsmartphone" type="text" name="labelsellingprice" value="' .
getDolGlobalString($keyforlabel).
'">';
1089 print
' <input type="submit" class="button smallpaddingimp" value="'.$langs->trans(
"Modify").
'">';
1092 print $langs->trans(
"SellingPrice").
' '.$i;
1093 if (!empty($conf->global->$keyforlabel)) {
1099 if (
$object->multiprices_base_type [$i] ==
'TTC') {
1100 print
'<td class="right"><span class="amount">'.price(
$object->multiprices_ttc[$i]);
1102 print
'<td class="right"><span class="amount">'.price(
$object->multiprices[$i]);
1105 if (
$object->multiprices_base_type[$i]) {
1106 print
' '.$langs->trans(
$object->multiprices_base_type [$i]).
'</span></td>';
1108 print
' '.$langs->trans(
$object->price_base_type).
'</span></td>';
1112 print
'<td style="text-align: right">';
1113 if (empty(
$object->multiprices_base_type[$i])) {
1114 $object->multiprices_base_type[$i] =
"HT";
1116 if (
$object->multiprices_base_type[$i] ==
'TTC') {
1117 print
price(
$object->multiprices_min_ttc[$i]).
' '.$langs->trans(
$object->multiprices_base_type[$i]);
1119 print
price(
$object->multiprices_min[$i]).
' '.$langs->trans(
$object->multiprices_base_type[$i]);
1125 print
'<tr><td>'.$langs->trans(
"PriceByQuantity").
' '.$i;
1126 if (!empty($conf->global->$keyforlabel)) {
1129 print
'</td><td colspan="2">';
1131 if (
$object->prices_by_qty[$i] == 1) {
1132 print
'<table width="50%" class="border" summary="List of quantities">';
1134 print
'<tr class="liste_titre">';
1135 print
'<td>'.$langs->trans(
"PriceByQuantityRange").
' '.$i.
'</td>';
1136 print
'<td class="right">'.$langs->trans(
"HT").
'</td>';
1137 print
'<td class="right">'.$langs->trans(
"UnitPrice").
'</td>';
1138 print
'<td class="right">'.$langs->trans(
"Discount").
'</td>';
1139 print
'<td> </td>';
1141 foreach (
$object->prices_by_qty_list[$i] as $ii => $prices) {
1142 if ($action ==
'edit_price_by_qty' && $rowid == $prices[
'rowid'] && ($user->hasRight(
'produit',
'creer') || $user->hasRight(
'service',
'creer'))) {
1143 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'" method="POST">';
1144 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1145 print
'<input type="hidden" name="action" value="update_price_by_qty">';
1146 print
'<input type="hidden" name="priceid" value="'.$object->prices_by_qty_id[$i].
'">';
1147 print
'<input type="hidden" value="'.$prices[
'rowid'].
'" name="rowid">';
1148 print
'<tr class="'.($ii % 2 == 0 ?
'pair' :
'impair').
'">';
1149 print
'<td><input size="5" type="text" value="'.$prices[
'quantity'].
'" name="quantity"></td>';
1150 print
'<td class="right" colspan="2"><input size="10" type="text" value="'.price2num($prices[
'price'],
'MU').
'" name="price"> '.
$object->price_base_type.
'</td>';
1151 print
'<td class="right nowraponall"><input size="5" type="text" value="'.$prices[
'remise_percent'].
'" name="remise_percent"> %</td>';
1152 print
'<td class="center"><input type="submit" value="'.$langs->trans(
"Modify").
'" class="button"></td>';
1156 print
'<tr class="'.($ii % 2 == 0 ?
'pair' :
'impair').
'">';
1157 print
'<td>'.$prices[
'quantity'].
'</td>';
1158 print
'<td class="right">'.price($prices[
'price']).
'</td>';
1159 print
'<td class="right">'.price($prices[
'unitprice']).
'</td>';
1160 print
'<td class="right">'.price($prices[
'remise_percent']).
' %</td>';
1161 print
'<td class="center">';
1162 if (($user->hasRight(
'produit',
'creer') || $user->hasRight(
'service',
'creer'))) {
1163 print
'<a class="editfielda marginleftonly marginrightonly" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=edit_price_by_qty&token='.
newToken().
'&rowid='.$prices[
"rowid"].
'">';
1165 print
'<a class="marginleftonly marginrightonly" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=delete_price_by_qty&token='.
newToken().
'&rowid='.$prices[
"rowid"].
'">';
1174 if ($action !=
'edit_price_by_qty' && ($user->hasRight(
'produit',
'creer') || $user->hasRight(
'service',
'creer'))) {
1175 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'" method="POST">';
1176 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1177 print
'<input type="hidden" name="action" value="update_price_by_qty">';
1178 print
'<input type="hidden" name="priceid" value="'.$object->prices_by_qty_id[$i].
'">';
1179 print
'<input type="hidden" value="0" name="rowid">';
1180 print
'<tr class="'.($ii % 2 == 0 ?
'pair' :
'impair').
'">';
1181 print
'<td><input size="5" type="text" value="1" name="quantity"></td>';
1182 print
'<td class="right" class="nowrap"><input size="10" type="text" value="0" name="price"> '.$object->price_base_type.
'</td>';
1183 print
'<td class="right"> </td>';
1184 print
'<td class="right" class="nowraponall"><input size="5" type="text" value="0" name="remise_percent"> %</td>';
1185 print
'<td class="center"><input type="submit" value="'.$langs->trans(
"Add").
'" class="button"></td>';
1191 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>';
1193 print $langs->trans(
"No");
1194 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>';
1202 print
'<tr><td class="titlefield">'.$langs->trans(
"DefaultTaxRate").
'</td><td>';
1204 $positiverates =
'';
1209 $positiverates .= ($positiverates ?
'/' :
'').
price2num(
$object->localtax1_tx);
1212 $positiverates .= ($positiverates ?
'/' :
'').
price2num(
$object->localtax2_tx);
1214 if (empty($positiverates)) {
1215 $positiverates =
'0';
1217 echo
vatrate($positiverates.($object->default_vat_code ?
' ('.$object->default_vat_code.
')' :
''),
'%',
$object->tva_npr, 0, 1);
1227 print
'<tr class="field_selling_price"><td>'.$langs->trans(
"SellingPrice").
'</td><td>';
1228 if (
$object->price_base_type ==
'TTC') {
1233 print
'<i class="opacitymedium"> - ' .
price(
$object->price_ttc).
' '.$langs->trans(
'TTC') .
'</i>';
1240 print
'<tr class="field_min_price"><td>'.$langs->trans(
"MinPrice").
'</td><td>';
1241 if (
$object->price_base_type ==
'TTC') {
1246 print
'<i class="opacitymedium"> - ' .
price(
$object->price_min_ttc).
' '.$langs->trans(
'TTC') .
'</i>';
1252 print
'<tr class="field_price_label"><td>'.$langs->trans(
"PriceLabel").
'</td><td>';
1258 print
'<tr><td>'.$langs->trans(
"PriceByQuantity");
1259 if (
$object->prices_by_qty[0] == 0) {
1260 print
' <a href="'.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&action=activate_price_by_qty&level=1&token='.
newToken().
'">('.$langs->trans(
"Activate").
')';
1262 print
' <a href="'.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&action=disable_price_by_qty&level=1&token='.
newToken().
'">('.$langs->trans(
"DisablePriceByQty").
')';
1266 if (
$object->prices_by_qty[0] == 1) {
1267 print
'<table width="50%" class="border" summary="List of quantities">';
1268 print
'<tr class="liste_titre">';
1270 print
'<td>'.$langs->trans(
"Quantity").
'</td>';
1271 print
'<td class="right">'.$langs->trans(
"Price").
'</td>';
1272 print
'<td class="right"></td>';
1273 print
'<td class="right">'.$langs->trans(
"UnitPrice").
'</td>';
1274 print
'<td class="right">'.$langs->trans(
"Discount").
'</td>';
1275 print
'<td> </td>';
1277 if ($action !=
'edit_price_by_qty') {
1278 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'" method="POST">';
1279 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1280 print
'<input type="hidden" name="action" value="update_price_by_qty">';
1281 print
'<input type="hidden" name="priceid" value="'.$object->prices_by_qty_id[0].
'">';
1282 print
'<input type="hidden" value="0" name="rowid">';
1284 print
'<tr class="'.($ii % 2 == 0 ?
'pair' :
'impair').
'">';
1285 print
'<td><input size="5" type="text" value="1" name="quantity"></td>';
1286 print
'<td class="right"><input class="width50 right" type="text" value="0" name="price"></td>';
1290 print
'<td class="right"> </td>';
1291 print
'<td class="right nowraponall"><input type="text" class="width50 right" value="0" name="remise_percent"> %</td>';
1292 print
'<td class="center"><input type="submit" value="'.$langs->trans(
"Add").
'" class="button"></td>';
1297 foreach (
$object->prices_by_qty_list[0] as $ii => $prices) {
1298 if ($action ==
'edit_price_by_qty' && $rowid == $prices[
'rowid'] && ($user->hasRight(
'produit',
'creer') || $user->hasRight(
'service',
'creer'))) {
1299 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'" method="POST">';
1300 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1301 print
'<input type="hidden" name="action" value="update_price_by_qty">';
1302 print
'<input type="hidden" name="priceid" value="'.$object->prices_by_qty_id[0].
'">';
1303 print
'<input type="hidden" value="'.$prices[
'rowid'].
'" name="rowid">';
1304 print
'<tr class="'.($ii % 2 == 0 ?
'pair' :
'impair').
'">';
1305 print
'<td><input size="5" type="text" value="'.$prices[
'quantity'].
'" name="quantity"></td>';
1306 print
'<td class="right"><input class="width50 right" type="text" value="'.price2num($prices[
'price'],
'MU').
'" name="price"></td>';
1307 print
'<td class="right">';
1309 print $prices[
'price_base_type'];
1311 print
'<td class="right"> </td>';
1312 print
'<td class="right nowraponall"><input class="width50 right" type="text" value="'.$prices[
'remise_percent'].
'" name="remise_percent"> %</td>';
1313 print
'<td class="center"><input type="submit" value="'.$langs->trans(
"Modify").
'" class="button"></td>';
1317 print
'<tr class="'.($ii % 2 == 0 ?
'pair' :
'impair').
'">';
1318 print
'<td>'.$prices[
'quantity'].
'</td>';
1319 print
'<td class="right">'.price($prices[
'price']).
'</td>';
1320 print
'<td class="right">';
1322 print $prices[
'price_base_type'];
1324 print
'<td class="right">'.price($prices[
'unitprice']).
'</td>';
1325 print
'<td class="right">'.price($prices[
'remise_percent']).
' %</td>';
1326 print
'<td class="center">';
1327 if (($user->hasRight(
'produit',
'creer') || $user->hasRight(
'service',
'creer'))) {
1328 print
'<a class="editfielda marginleftonly marginrightonly" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=edit_price_by_qty&token='.
newToken().
'&rowid='.$prices[
"rowid"].
'">';
1330 print
'<a class="marginleftonly marginrightonly" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=delete_price_by_qty&token='.
newToken().
'&rowid='.$prices[
"rowid"].
'">';
1341 print $langs->trans(
"No");
1350print
'<div class="clearboth"></div>';
1362if (!$action || $action ==
'delete' || $action ==
'showlog_customer_price' || $action ==
'showlog_default_price' || $action ==
'add_customer_price'
1363 || $action ==
'activate_price_by_qty' || $action ==
'disable_price_by_qty') {
1364 print
"\n".
'<div class="tabsAction">'.
"\n";
1367 $parameters = array();
1368 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters, $object, $action);
1369 if (empty($reshook)) {
1371 if ($user->hasRight(
'produit',
'creer') || $user->hasRight(
'service',
'creer')) {
1372 print
'<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="' .
dol_escape_htmltag($langs->trans(
"NoEditVariants")) .
'">' . $langs->trans(
"UpdateDefaultPrice") .
'</a></div>';
1376 if ($user->hasRight(
'produit',
'creer') || $user->hasRight(
'service',
'creer')) {
1377 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>';
1379 print
'<div class="inline-block divButAction"><span class="butActionRefused" title="'.dol_escape_htmltag($langs->trans(
"NotEnoughPermissions")).
'">' . $langs->trans(
"UpdateDefaultPrice") .
'</span></div>';
1384 if ($user->hasRight(
'produit',
'creer') || $user->hasRight(
'service',
'creer')) {
1385 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>';
1387 print
'<div class="inline-block divButAction"><span class="butActionRefused" title="'.dol_escape_htmltag($langs->trans(
"NotEnoughPermissions")).
'">' . $langs->trans(
"AddCustomerPrice") .
'</span></div>';
1392 if ($user->hasRight(
'produit',
'creer') || $user->hasRight(
'service',
'creer')) {
1393 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>';
1395 print
'<div class="inline-block divButAction"><span class="butActionRefused" title="'.dol_escape_htmltag($langs->trans(
"NotEnoughPermissions")).
'">' . $langs->trans(
"UpdateVAT") .
'</span></div>';
1398 if ($user->hasRight(
'produit',
'creer') || $user->hasRight(
'service',
'creer')) {
1399 print
'<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER[
'PHP_SELF'] .
'?action=edit_price&token='.newToken().
'&id=' .
$object->id .
'">' . $langs->trans(
"UpdateLevelPrices") .
'</a></div>';
1401 print
'<div class="inline-block divButAction"><span class="butActionRefused" title="'.dol_escape_htmltag($langs->trans(
"NotEnoughPermissions")).
'">' . $langs->trans(
"UpdateLevelPrices") .
'</span></div>';
1416if ($action ==
'edit_vat' && ($user->hasRight(
'produit',
'creer') || $user->hasRight(
'service',
'creer'))) {
1419 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'" method="POST">';
1420 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1421 print
'<input type="hidden" name="action" value="update_vat">';
1422 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
1426 print
'<table class="border centpercent">';
1429 print
'<tr><td>'.$langs->trans(
"DefaultTaxRate").
'</td><td>';
1437 print $form->buttonsSaveCancel();
1439 print
'<br></form><br>';
1442if ($action ==
'edit_price' &&
$object->getRights()->creer) {
1447 print
'<!-- Edit price -->'.
"\n";
1448 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'" method="POST">';
1449 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1450 print
'<input type="hidden" name="action" value="update_price">';
1451 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
1455 print
'<div class="div-table-responsive-no-min">';
1456 print
'<table class="border centpercent">';
1459 print
'<tr><td class="titlefield">'.$langs->trans(
"DefaultTaxRate").
'</td><td>';
1465 print $langs->trans(
'PriceBase');
1468 print $form->selectPriceBaseType(
$object->price_base_type,
"price_base_type");
1473 if (!empty($conf->dynamicprices->enabled)) {
1475 print
'<!-- Show price mode of dynamicprices editor -->'.
"\n";
1476 print
'<tr><td>'.$langs->trans(
"PriceMode").
'</td><td>';
1477 print
img_picto(
'',
'dynamicprice',
'class="pictofixedwidth"');
1479 $price_expression_list = array(0 => $langs->trans(
"Numeric").
' <span class="opacitymedium">('.$langs->trans(
"NoDynamicPrice").
')</span>');
1480 foreach ($price_expression->list_price_expression() as $entry) {
1481 $price_expression_list[$entry->id] = $entry->title;
1483 $price_expression_preselection =
GETPOST(
'eid') ?
GETPOST(
'eid') : (
$object->fk_price_expression ?
$object->fk_price_expression :
'0');
1484 print $form->selectarray(
'eid', $price_expression_list, $price_expression_preselection);
1485 print
' <a id="expression_editor" class="classlink">'.$langs->trans(
"PriceExpressionEditor").
'</a>';
1491 <script
type=
"text/javascript">
1492 jQuery(document).ready(
function() {
1493 jQuery(
"#expression_editor").click(
function() {
1494 window.location =
"<?php echo DOL_URL_ROOT ?>/product/dynamic_price/editor.php?id=<?php echo $id ?>&tab=price&eid=" + $(
"#eid").val();
1496 jQuery(
"#eid").change(on_change);
1499 function on_change() {
1500 if ($(
"#eid").val() == 0) {
1501 jQuery(
"#price_numeric").show();
1503 jQuery(
"#price_numeric").hide();
1512 $product->fetch($id, $ref,
'', 1);
1513 print
'<tr id="price_numeric"><td>';
1514 $text = $langs->trans(
'SellingPrice');
1515 print $form->textwithpicto($text, $langs->trans(
"PrecisionUnitIsLimitedToXDecimals",
getDolGlobalString(
'MAIN_MAX_DECIMALS_UNIT')), 1, 1);
1517 if (
$object->price_base_type ==
'TTC') {
1518 print
'<input name="price" size="10" value="'.price($product->price_ttc).
'">';
1520 print
'<input name="price" size="10" value="'.price($product->price).
'">';
1526 $text = $langs->trans(
'MinPrice');
1527 print $form->textwithpicto($text, $langs->trans(
"PrecisionUnitIsLimitedToXDecimals",
getDolGlobalString(
'MAIN_MAX_DECIMALS_UNIT')), 1, 1);
1529 if (
$object->price_base_type ==
'TTC') {
1530 print
'<input name="price_min" size="10" value="'.price(
$object->price_min_ttc).
'">';
1532 print
'<input name="price_min" size="10" value="'.price(
$object->price_min).
'">';
1535 print
' '.$langs->trans(
"MinimumRecommendedPrice",
price($maxpricesupplier, 0,
'', 1, -1, -1,
'auto')).
' '.
img_warning().
'</td>';
1542 print $langs->trans(
'PriceLabel');
1544 print
'<input name="price_label" maxlength="255" class="minwidth300 maxwidth400onsmartphone" value="'.$object->price_label.
'">';
1548 $parameters = array();
1549 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters, $object, $action);
1556 print $form->buttonsSaveCancel();
1560 print
'<!-- Edit price per level -->'.
"\n"; ?>
1563 var showHidePriceRules =
function () {
1564 var otherPrices = $(
'div.fiche form table tbody tr:not(:first)');
1565 var minPrice1 = $(
'div.fiche form input[name="price_min[1]"]');
1567 if (jQuery(
'input#usePriceRules').prop(
'checked')) {
1576 jQuery(document).ready(
function () {
1577 showHidePriceRules();
1579 jQuery(
'input#usePriceRules').click(showHidePriceRules);
1584 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'" method="POST">';
1585 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1586 print
'<input type="hidden" name="action" value="update_price">';
1587 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
1592 print $langs->trans(
'UseMultipriceRules').
' <input type="checkbox" id="usePriceRules" name="usePriceRules" '.(
$object->price_autogen ?
'checked' :
'').
'><br><br>';
1595 print
'<div class="div-table-responsive-no-min">';
1596 print
'<table class="noborder">';
1597 print
'<thead><tr class="liste_titre">';
1599 print
'<td>'.$langs->trans(
"PriceLevel").
'</td>';
1602 print
'<td style="text-align: center">'.$langs->trans(
"DefaultTaxRate").
'</td>';
1607 print
'<td class="center">'.$langs->trans(
"SellingPrice").
'</td>';
1609 print
'<td class="center">'.$langs->trans(
"MinPrice").
'</td>';
1614 print
'</tr></thead>';
1618 for ($i = 1; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i++) {
1619 print
'<tr class="oddeven">';
1621 $keyforlabel =
'PRODUIT_MULTIPRICES_LABEL'.$i;
1623 print $form->textwithpicto($text, $langs->trans(
"PrecisionUnitIsLimitedToXDecimals",
getDolGlobalString(
'MAIN_MAX_DECIMALS_UNIT')), 1, 1);
1629 print
'<input type="hidden" name="tva_tx['.$i.
']" value="'.(
$object->default_vat_code ?
$object->tva_tx.
' ('.
$object->default_vat_code.
')' :
$object->tva_tx).
'">';
1630 print
'<input type="hidden" name="tva_npr['.$i.
']" value="'.
$object->tva_npr.
'">';
1631 print
'<input type="hidden" name="localtax1_tx['.$i.
']" value="'.
$object->localtax1_tx.
'">';
1632 print
'<input type="hidden" name="localtax1_type['.$i.
']" value="'.
$object->localtax1_type.
'">';
1633 print
'<input type="hidden" name="localtax2_tx['.$i.
']" value="'.
$object->localtax2_tx.
'">';
1634 print
'<input type="hidden" name="localtax2_type['.$i.
']" value="'.
$object->localtax2_type.
'">';
1638 print
'<td style="text-align: center">';
1639 print $form->load_tva(
"tva_tx[".$i.
']',
$object->multiprices_tva_tx[$i], $mysoc,
'',
$object->id,
false,
$object->type,
false, 1);
1644 print
'<td style="text-align: center">';
1645 if (
$object->multiprices_base_type [$i] ==
'TTC') {
1646 print
'<input name="price['.$i.
']" size="10" value="'.
price(
$object->multiprices_ttc [$i]).
'">';
1648 print
'<input name="price['.$i.
']" size="10" value="'.
price(
$object->multiprices [$i]).
'">';
1650 print
' '.$form->selectPriceBaseType(
$object->multiprices_base_type [$i],
"multiprices_base_type[".$i.
"]");
1654 print
'<td style="text-align: center">';
1655 if (
$object->multiprices_base_type [$i] ==
'TTC') {
1656 print
'<input name="price_min['.$i.
']" size="10" value="'.
price(
$object->multiprices_min_ttc [$i]).
'">';
1658 print
'<input name="price_min['.$i.
']" size="10" value="'.
price(
$object->multiprices_min [$i]).
'">';
1661 print
'<td class="left">'.$langs->trans(
"MinimumRecommendedPrice",
price($maxpricesupplier, 0,
'', 1, -1, -1,
'auto')).
' '.
img_warning().
'</td>';
1675 print $form->buttonsSaveCancel();
1684if ((!
getDolGlobalString(
'PRODUIT_CUSTOMER_PRICES') || $action ==
'showlog_default_price') && !in_array($action, array(
'edit_price',
'edit_vat'))) {
1685 $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,";
1686 $sql .=
" p.price_level, p.price_min, p.price_min_ttc,p.price_by_qty,";
1687 $sql .=
" p.date_price as dp, p.fk_price_expression, u.rowid as user_id, u.login";
1688 $sql .=
" ,p.price_label";
1689 $sql .=
" FROM ".MAIN_DB_PREFIX.
"product_price as p,";
1690 $sql .=
" ".MAIN_DB_PREFIX.
"user as u";
1691 $sql .=
" WHERE fk_product = ".((int)
$object->id);
1692 $sql .=
" AND p.entity IN (".getEntity(
'productprice').
")";
1693 $sql .=
" AND p.fk_user_author = u.rowid";
1695 $sql .=
" AND p.price_level = ".((int) $soc->price_level);
1697 $sql .=
" ORDER BY p.date_price DESC, p.rowid DESC, p.price_level ASC";
1701 $result = $db->query($sql);
1703 print
'<div class="divlogofpreviouscustomerprice">';
1705 $num = $db->num_rows($result);
1714 $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);
1722 $result = $db->query($sql);
1723 $num = $db->num_rows($result);
1730 $backbutton =
'<a class="justalink" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'">'.$langs->trans(
"Back").
'</a>';
1734 print_barre_liste($langs->trans(
"DefaultPriceLog"), 0, $_SERVER[
"PHP_SELF"],
'',
'',
'', $backbutton, 0, $num,
'title_accountancy.png');
1737 print_barre_liste($langs->trans(
"PriceByCustomerLog"), 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', 0, $num,
'title_accountancy.png');
1740 print
'<!-- List of log prices -->'.
"\n";
1741 print
'<div class="div-table-responsive">'.
"\n";
1742 print
'<table class="liste centpercent">'.
"\n";
1744 print
'<tr class="liste_titre">';
1745 print
'<td>'.$langs->trans(
"AppliedPricesFrom").
'</td>';
1748 print
'<td class="center">'.$langs->trans(
"PriceLevel").
'</td>';
1751 print
'<td class="center">'.$langs->trans(
"Type").
'</td>';
1754 print
'<td class="center">'.$langs->trans(
"PriceBase").
'</td>';
1756 print
'<td class="right">'.$langs->trans(
"DefaultTaxRate").
'</td>';
1758 print
'<td class="right">'.$langs->trans(
"HT").
'</td>';
1759 print
'<td class="right">'.$langs->trans(
"TTC").
'</td>';
1760 if ($mysoc->localtax1_assuj ==
"1" || $mysoc->localtax2_assuj ==
"1") {
1761 print
'<td class="right">'.$langs->trans(
"INCT").
'</td>';
1763 if (!empty($conf->dynamicprices->enabled)) {
1764 print
'<td class="right">'.$langs->trans(
"PriceExpressionSelected").
'</td>';
1766 print
'<td class="right">'.$langs->trans(
"MinPrice").
' '.$langs->trans(
"HT").
'</td>';
1767 print
'<td class="right">'.$langs->trans(
"MinPrice").
' '.$langs->trans(
"TTC").
'</td>';
1768 print
'<td class="right">'.$langs->trans(
"Label").
'</td>';
1769 print
'<td class="right">'.$langs->trans(
"ChangedBy").
'</td>';
1770 if ($user->hasRight(
'produit',
'supprimer')) {
1771 print
'<td class="right"> </td>';
1775 $notfirstlineforlevel = array();
1779 $objp = $db->fetch_object($result);
1781 print
'<tr class="oddeven">';
1783 print
"<td>".dol_print_date($db->jdate($objp->dp),
"dayhour",
'tzuserrel').
"</td>";
1787 print
'<td class="center">'.$objp->price_level.
"</td>";
1791 $type = ($objp->price_by_qty == 1) ?
'PriceByQuantity' :
'Standard';
1792 print
'<td class="center">'.$langs->trans($type).
"</td>";
1795 print
'<td class="center">';
1796 if (empty($objp->price_by_qty)) {
1797 print $langs->trans($objp->price_base_type);
1802 print
'<td class="right">';
1804 if (empty($objp->price_by_qty)) {
1805 $positiverates =
'';
1807 $positiverates .= ($positiverates ?
'/' :
'').
price2num($objp->tva_tx);
1810 $positiverates .= ($positiverates ?
'/' :
'').
price2num($objp->localtax1_tx);
1813 $positiverates .= ($positiverates ?
'/' :
'').
price2num($objp->localtax2_tx);
1815 if (empty($positiverates)) {
1816 $positiverates =
'0';
1818 echo
vatrate($positiverates.($objp->default_vat_code ?
' ('.$objp->default_vat_code.
')' :
''),
'%', !empty($objp->tva_npr) ? $objp->tva_npr : 0);
1831 if ($objp->price_base_type ==
'HT') {
1834 $pu = $objp->price_ttc;
1838 $localtaxarray =
getLocalTaxesFromRate($objp->tva_tx.($object->default_vat_code ?
' ('.$object->default_vat_code.
')' :
''), 0, $mysoc, $mysoc);
1840 $resultarray =
calcul_price_total(1, $pu, 0, $objp->tva_tx, 1, 1, 0, $objp->price_base_type, $objp->recuperableonly,
$object->type, $mysoc, $localtaxarray);
1842 $total_ht = $resultarray[0];
1843 $total_vat = $resultarray[1];
1844 $total_localtax1 = $resultarray[9];
1845 $total_localtax2 = $resultarray[10];
1846 $total_ttc = $resultarray[2];
1849 if (!empty($objp->fk_price_expression) && !empty($conf->dynamicprices->enabled)) {
1851 $res = $price_expression->fetch($objp->fk_price_expression);
1852 $title = $price_expression->title;
1853 print
'<td class="right"></td>';
1854 print
'<td class="right"></td>';
1855 if ($mysoc->localtax1_assuj ==
"1" || $mysoc->localtax2_assuj ==
"1") {
1856 print
'<td class="right"></td>';
1858 print
'<td class="right">'.$title.
"</td>";
1861 print
'<td class="right">';
1862 if (empty($objp->price_by_qty)) {
1863 print
'<span class="amount">'.price($objp->price).
'</span>';
1867 print
'<td class="right">';
1868 if (empty($objp->price_by_qty)) {
1869 $price_ttc = $objp->price_ttc;
1870 print
'<span class="amount">'.price($price_ttc).
'<span>';
1873 if ($mysoc->localtax1_assuj ==
"1" || $mysoc->localtax2_assuj ==
"1") {
1874 print
'<td class="right">';
1875 print $resultarray[2];
1878 if (!empty($conf->dynamicprices->enabled)) {
1879 print
'<td class="right"></td>';
1884 print
'<td class="right">';
1885 if (empty($objp->price_by_qty)) {
1886 print
price($objp->price_min);
1891 print
'<td class="right">';
1892 if (empty($objp->price_by_qty)) {
1893 $price_min_ttc = $objp->price_min_ttc;
1894 print
price($price_min_ttc);
1899 print
'<td class="right">';
1900 print $objp->price_label;
1904 print
'<td class="right">';
1905 if ($objp->user_id > 0) {
1906 $userstatic =
new User($db);
1907 $userstatic->fetch($objp->user_id);
1908 print $userstatic->getNomUrl(1,
'', 0, 0, 24, 0,
'login');
1914 if ($user->hasRight(
'produit',
'supprimer')) {
1917 if (empty($notfirstlineforlevel[$objp->price_level])) {
1918 $notfirstlineforlevel[$objp->price_level] = 1;
1926 print
'<td class="right">';
1927 if ($candelete || ($db->jdate($objp->dp) >=
dol_now())) {
1928 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=delete&token='.
newToken().
'&id='.
$object->id.
'&lineid='.$objp->rowid.
'">';
1959 $sortfield =
GETPOST(
'sortfield',
'aZ09comma');
1960 $sortorder =
GETPOST(
'sortorder',
'aZ09comma');
1962 if (empty($page) || $page == -1) {
1965 $offset = $limit * $page;
1966 $pageprev = $page - 1;
1967 $pagenext = $page + 1;
1972 $sortfield =
"soc.nom";
1976 $filter = array(
't.fk_product' =>
$object->id);
1978 if (!empty($search_soc)) {
1979 $filter[
'soc.nom'] = $search_soc;
1982 if ($action ==
'add_customer_price') {
1984 $maxpricesupplier =
$object->min_recommended_price();
1986 print
'<!-- add_customer_price -->';
1989 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'" method="POST">';
1990 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1991 print
'<input type="hidden" name="action" value="add_customer_price_confirm">';
1992 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
1994 print
'<div class="tabBar tabBarWithBottom">';
1996 print
'<table class="border centpercent">';
1998 print
'<td class="fieldrequired">'.$langs->trans(
'ThirdParty').
'</td>';
2000 $filter =
'(s.client:IN:1,2,3)';
2001 print
img_picto(
'',
'company').$form->select_company(
'',
'socid', $filter,
'SelectThirdParty', 0, 0, array(), 0,
'minwidth300');
2006 print
'<tr><td>' . $langs->trans(
'RefCustomer') .
'</td>';
2007 print
'<td><input name="ref_customer" size="12"></td></tr>';
2010 print
'<tr><td class="fieldrequired">'.$langs->trans(
"DefaultTaxRate").
'</td><td>';
2015 print
'<tr><td class="fieldrequired">';
2016 print $langs->trans(
'PriceBase');
2019 print $form->selectPriceBaseType(
$object->price_base_type,
"price_base_type");
2024 print
'<tr><td class="fieldrequired">';
2025 $text = $langs->trans(
'SellingPrice');
2026 print $form->textwithpicto($text, $langs->trans(
"PrecisionUnitIsLimitedToXDecimals",
getDolGlobalString(
'MAIN_MAX_DECIMALS_UNIT')), 1, 1);
2028 if (
$object->price_base_type ==
'TTC') {
2029 print
'<input name="price" size="10" value="'.price(
$object->price_ttc).
'">';
2031 print
'<input name="price" size="10" value="'.price(
$object->price).
'">';
2037 $text = $langs->trans(
'MinPrice');
2038 print $form->textwithpicto($text, $langs->trans(
"PrecisionUnitIsLimitedToXDecimals",
getDolGlobalString(
'MAIN_MAX_DECIMALS_UNIT')), 1, 1);
2039 if (
$object->price_base_type ==
'TTC') {
2040 print
'<td><input name="price_min" size="10" value="'.price(
$object->price_min_ttc).
'">';
2042 print
'<td><input name="price_min" size="10" value="'.price(
$object->price_min).
'">';
2045 print
'<td class="left">'.$langs->trans(
"MinimumRecommendedPrice",
price($maxpricesupplier, 0,
'', 1, -1, -1,
'auto')).
' '.
img_warning().
'</td>';
2051 print $langs->trans(
'PriceLabel');
2053 print
'<input name="price_label" maxlength="255" class="minwidth300 maxwidth400onsmartphone" value="'.$object->price_label.
'">';
2062 print
'<div class="center">';
2065 print
'<div class="marginbottomonly">';
2066 print
'<input type="checkbox" name="updatechildprice" id="updatechildprice" value="1"> ';
2067 print
'<label for="updatechildprice">'.$langs->trans(
'ForceUpdateChildPriceSoc').
'</label>';
2070 print $form->buttonsSaveCancel();
2073 } elseif ($action ==
'edit_customer_price') {
2075 $maxpricesupplier =
$object->min_recommended_price();
2077 print
'<!-- edit_customer_price -->';
2080 $result = $prodcustprice->fetch(
GETPOSTINT(
'lineid'));
2085 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'" method="POST">';
2086 print
'<input type="hidden" name="token" value="'.newToken().
'">';
2087 print
'<input type="hidden" name="action" value="update_customer_price_confirm">';
2088 print
'<input type="hidden" name="lineid" value="'.$prodcustprice->id.
'">';
2090 print
'<table class="liste centpercent">';
2092 print
'<td class="titlefield fieldrequired">'.$langs->trans(
'ThirdParty').
'</td>';
2093 $staticsoc =
new Societe($db);
2094 $staticsoc->fetch($prodcustprice->fk_soc);
2095 print
"<td>".$staticsoc->getNomUrl(1).
"</td>";
2099 print
'<tr><td>' . $langs->trans(
'RefCustomer') .
'</td>';
2100 print
'<td><input name="ref_customer" size="12" value="' .
dol_escape_htmltag($prodcustprice->ref_customer) .
'"></td></tr>';
2103 print
'<tr><td class="fieldrequired">'.$langs->trans(
"DefaultTaxRate").
'</td><td>';
2104 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);
2108 print
'<tr><td class="fieldrequired">';
2109 print $langs->trans(
'PriceBase');
2112 print $form->selectPriceBaseType($prodcustprice->price_base_type,
"price_base_type");
2117 print
'<tr><td class="fieldrequired">';
2118 $text = $langs->trans(
'SellingPrice');
2119 print $form->textwithpicto($text, $langs->trans(
"PrecisionUnitIsLimitedToXDecimals",
getDolGlobalString(
'MAIN_MAX_DECIMALS_UNIT')), 1, 1);
2121 if ($prodcustprice->price_base_type ==
'TTC') {
2122 print
'<input name="price" size="10" value="'.price($prodcustprice->price_ttc).
'">';
2124 print
'<input name="price" size="10" value="'.price($prodcustprice->price).
'">';
2130 $text = $langs->trans(
'MinPrice');
2131 print $form->textwithpicto($text, $langs->trans(
"PrecisionUnitIsLimitedToXDecimals",
getDolGlobalString(
'MAIN_MAX_DECIMALS_UNIT')), 1, 1);
2133 if ($prodcustprice->price_base_type ==
'TTC') {
2134 print
'<input name="price_min" size="10" value="'.price($prodcustprice->price_min_ttc).
'">';
2136 print
'<input name="price_min" size="10" value="'.price($prodcustprice->price_min).
'">';
2140 print
'<td class="left">'.$langs->trans(
"MinimumRecommendedPrice",
price($maxpricesupplier, 0,
'', 1, -1, -1,
'auto')).
' '.
img_warning().
'</td>';
2148 print $langs->trans(
'PriceLabel');
2150 print
'<input name="price_label" maxlength="255" class="minwidth300 maxwidth400onsmartphone" value="'.$prodcustprice->price_label.
'">';
2157 print
'<div class="center">';
2158 print
'<div class="marginbottomonly">';
2159 print
'<input type="checkbox" name="updatechildprice" id="updatechildprice" value="1"> ';
2160 print
'<label for="updatechildprice">'.$langs->trans(
'ForceUpdateChildPriceSoc').
'</label>';
2163 print $form->buttonsSaveCancel();
2165 print
'<br></form>';
2166 } elseif ($action ==
'showlog_customer_price') {
2168 print
'<!-- list of all log of prices per customer -->'.
"\n";
2170 $filter = array(
't.fk_product' =>
$object->id,
't.fk_soc' =>
GETPOSTINT(
'socid'));
2173 $nbtotalofrecords =
'';
2175 $nbtotalofrecords = $prodcustprice->fetchAllLog($sortorder, $sortfield, $conf->liste_limit, $offset, $filter);
2178 $result = $prodcustprice->fetchAllLog($sortorder, $sortfield, $conf->liste_limit, $offset, $filter);
2183 $option =
'&socid='.GETPOSTINT(
'socid').
'&id='.
$object->id;
2185 $staticsoc =
new Societe($db);
2188 $title = $langs->trans(
'PriceByCustomerLog');
2189 $title .=
' - '.$staticsoc->getNomUrl(1);
2191 $backbutton =
'<a class="justalink" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'">'.$langs->trans(
"Back").
'</a>';
2194 print_barre_liste($title, $page, $_SERVER[
'PHP_SELF'], $option, $sortfield, $sortorder, $backbutton, count($prodcustprice->lines), $nbtotalofrecords,
'title_accountancy.png');
2196 if (count($prodcustprice->lines) > 0) {
2197 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'" method="POST">';
2198 print
'<input type="hidden" name="token" value="'.newToken().
'">';
2199 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
2201 print
'<div class="div-table-responsive-no-min">';
2202 print
'<table class="liste centpercent">';
2204 print
'<tr class="liste_titre">';
2205 print
'<td>'.$langs->trans(
"ThirdParty").
'</td>';
2206 print
'<td>'.$langs->trans(
'RefCustomer').
'</td>';
2207 print
'<td>'.$langs->trans(
"AppliedPricesFrom").
'</td>';
2208 print
'<td class="center">'.$langs->trans(
"PriceBase").
'</td>';
2209 print
'<td class="right">'.$langs->trans(
"DefaultTaxRate").
'</td>';
2210 print
'<td class="right">'.$langs->trans(
"HT").
'</td>';
2211 print
'<td class="right">'.$langs->trans(
"TTC").
'</td>';
2212 if ($mysoc->localtax1_assuj ==
"1" || $mysoc->localtax2_assuj ==
"1") {
2213 print
'<td class="right">'.$langs->trans(
"INCT").
'</td>';
2215 print
'<td class="right">'.$langs->trans(
"MinPrice").
' '.$langs->trans(
"HT").
'</td>';
2216 print
'<td class="right">'.$langs->trans(
"MinPrice").
' '.$langs->trans(
"TTC").
'</td>';
2217 print
'<td class="right">'.$langs->trans(
"PriceLabel").
'</td>';
2218 print
'<td class="right">'.$langs->trans(
"ChangedBy").
'</td>';
2219 print
'<td> </td>';
2222 foreach ($prodcustprice->lines as $line) {
2224 $staticsoc =
new Societe($db);
2225 $staticsoc->fetch($line->fk_soc);
2227 $tva_tx = $line->default_vat_code ? $line->tva_tx.
' ('.$line->default_vat_code.
')' : $line->tva_tx;
2230 if ($line->price_base_type ==
'HT') {
2233 $pu = $line->price_ttc;
2237 $localtaxarray =
getLocalTaxesFromRate($line->tva_tx.($line->default_vat_code ?
' ('.$line->default_vat_code.
')' :
''), 0, $staticsoc, $mysoc);
2239 $resultarray =
calcul_price_total(1, $pu, 0, $line->tva_tx, 1, 1, 0, $line->price_base_type, $line->recuperableonly,
$object->type, $mysoc, $localtaxarray);
2241 $total_ht = $resultarray[0];
2242 $total_vat = $resultarray[1];
2243 $total_localtax1 = $resultarray[9];
2244 $total_localtax2 = $resultarray[10];
2245 $total_ttc = $resultarray[2];
2247 print
'<tr class="oddeven">';
2249 print
'<td class="tdoverflowmax125">'.$staticsoc->getNomUrl(1).
"</td>";
2250 print
'<td>'.$line->ref_customer.
'</td>';
2251 print
"<td>".dol_print_date($line->datec,
"dayhour",
'tzuserrel').
"</td>";
2252 print
'<td class="center">'.$langs->trans($line->price_base_type).
"</td>";
2253 print
'<td class="right">';
2255 $positiverates =
'';
2257 $positiverates .= ($positiverates ?
'/' :
'').
price2num($line->tva_tx);
2260 $positiverates .= ($positiverates ?
'/' :
'').
price2num($line->localtax1_tx);
2263 $positiverates .= ($positiverates ?
'/' :
'').
price2num($line->localtax2_tx);
2265 if (empty($positiverates)) {
2266 $positiverates =
'0';
2269 echo
vatrate($positiverates.($line->default_vat_code ?
' ('.$line->default_vat_code.
')' :
''),
'%', ($line->tva_npr ? $line->tva_npr : $line->recuperableonly));
2273 print
'<td class="right"><span class="amount">'.price($line->price).
"</span></td>";
2275 print
'<td class="right"><span class="amount">'.price($line->price_ttc).
"</span></td>";
2276 if ($mysoc->localtax1_assuj ==
"1" || $mysoc->localtax2_assuj ==
"1") {
2277 print
'<td class="right">'.price($resultarray[2]).
'</td>';
2280 print
'<td class="right">'.price($line->price_min).
'</td>';
2281 print
'<td class="right">'.price($line->price_min_ttc).
'</td>';
2282 print
'<td class="right">'.$line->price_label.
'</td>';
2285 $userstatic =
new User($db);
2286 $userstatic->fetch($line->fk_user);
2287 print
'<td class="right">';
2288 print $userstatic->getNomUrl(1,
'', 0, 0, 24, 0,
'login');
2296 print $langs->trans(
'None');
2298 } elseif ($action !=
'showlog_default_price' && $action !=
'edit_price') {
2300 print
'<!-- list of all prices per customer -->'.
"\n";
2303 $nbtotalofrecords =
'';
2305 $nbtotalofrecords = $prodcustprice->fetchAll($sortorder, $sortfield, 0, 0, $filter);
2308 $result = $prodcustprice->fetchAll($sortorder, $sortfield, $conf->liste_limit, $offset, $filter);
2313 $option =
'&search_soc='.$search_soc.
'&id='.
$object->id;
2316 print_barre_liste($langs->trans(
'PriceByCustomer'), $page, $_SERVER [
'PHP_SELF'], $option, $sortfield, $sortorder,
'', count($prodcustprice->lines), $nbtotalofrecords,
'title_accountancy.png');
2318 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'" method="POST">';
2319 print
'<input type="hidden" name="token" value="'.newToken().
'">';
2320 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
2322 print
'<!-- List of prices per customer -->'.
"\n";
2323 print
'<div class="div-table-responsive-no-min">'.
"\n";
2324 print
'<table class="liste centpercent">'.
"\n";
2326 if (count($prodcustprice->lines) > 0 || $search_soc) {
2328 if ($mysoc->localtax1_assuj ==
"1" || $mysoc->localtax2_assuj ==
"1") {
2332 print
'<tr class="liste_titre">';
2333 print
'<td class="liste_titre"><input type="text" class="flat maxwidth125" name="search_soc" value="'.$search_soc.
'"></td>';
2334 print
'<td class="liste_titre" colspan="'.$colspan.
'"> </td>';
2336 print
'<td class="liste_titre maxwidthsearch">';
2337 $searchpicto = $form->showFilterAndCheckAddButtons(0);
2343 print
'<tr class="liste_titre">';
2344 print
'<td>'.$langs->trans(
"ThirdParty").
'</td>';
2345 print
'<td>'.$langs->trans(
'RefCustomer').
'</td>';
2346 print
'<td>'.$langs->trans(
"AppliedPricesFrom").
'</td>';
2347 print
'<td class="center">'.$langs->trans(
"PriceBase").
'</td>';
2348 print
'<td class="right">'.$langs->trans(
"DefaultTaxRate").
'</td>';
2349 print
'<td class="right">'.$langs->trans(
"HT").
'</td>';
2350 print
'<td class="right">'.$langs->trans(
"TTC").
'</td>';
2351 if ($mysoc->localtax1_assuj ==
"1" || $mysoc->localtax2_assuj ==
"1") {
2352 print
'<td class="right">'.$langs->trans(
"INCT").
'</td>';
2354 print
'<td class="right">'.$langs->trans(
"MinPrice").
' '.$langs->trans(
"HT").
'</td>';
2355 print
'<td class="right">'.$langs->trans(
"MinPrice").
' '.$langs->trans(
"TTC").
'</td>';
2356 print
'<td class="right">'.$langs->trans(
"PriceLabel").
'</td>';
2357 print
'<td class="right">'.$langs->trans(
"ChangedBy").
'</td>';
2362 if (
$object->price_base_type ==
'HT') {
2369 $localtaxarray =
getLocalTaxesFromRate(
$object->tva_tx.($object->default_vat_code ?
' ('.$object->default_vat_code.
')' :
''), 0, $mysoc, $mysoc);
2371 $resultarray =
calcul_price_total(1, $pu, 0,
$object->tva_tx, 1, 1, 0,
$object->price_base_type, 0,
$object->type, $mysoc, $localtaxarray);
2373 $total_ht = $resultarray[0];
2374 $total_vat = $resultarray[1];
2375 $total_localtax1 = $resultarray[9];
2376 $total_localtax2 = $resultarray[10];
2377 $total_ttc = $resultarray[2];
2379 print
'<tr class="oddeven">';
2380 print
'<td colspan="3">' . $langs->trans(
'Default') .
'</td>';
2382 print
'<td class="center">'.$langs->trans(
$object->price_base_type).
"</td>";
2385 print
'<td class="right">';
2387 $positiverates =
'';
2392 $positiverates .= ($positiverates ?
'/' :
'').
price2num(
$object->localtax1_tx);
2395 $positiverates .= ($positiverates ?
'/' :
'').
price2num(
$object->localtax2_tx);
2397 if (empty($positiverates)) {
2398 $positiverates =
'0';
2400 echo
vatrate($positiverates.($object->default_vat_code ?
' ('.$object->default_vat_code.
')' :
''),
'%',
$object->tva_npr);
2406 print
'<td class="right"><span class="amount">'.price(
$object->price).
"</span></td>";
2408 print
'<td class="right"><span class="amount">'.price(
$object->price_ttc).
"</span></td>";
2409 if ($mysoc->localtax1_assuj ==
"1" || $mysoc->localtax2_assuj ==
"1") {
2411 print
'<td class="right"><span class="amount">'.price($resultarray[2]).
'</span></td>';
2414 print
'<td class="right">'.price(
$object->price_min).
'</td>';
2415 print
'<td class="right">'.price(
$object->price_min_ttc).
'</td>';
2416 print
'<td class="right">'.$object->price_label.
'</td>';
2417 print
'<td class="right">';
2419 if ($user->hasRight(
'produit',
'supprimer') || $user->hasRight(
'service',
'supprimer')) {
2420 print
'<td class="nowraponall">';
2421 print
'<a class="marginleftonly marginrightonly" href="'.$_SERVER[
"PHP_SELF"].
'?action=showlog_default_price&token='.
newToken().
'&id='.
$object->id.
'">';
2422 print
img_info($langs->trans(
'PriceByCustomerLog'));
2425 print
'<a class="marginleftonly marginrightonly editfielda" href="'.$_SERVER[
"PHP_SELF"].
'?action=edit_price&token='.
newToken().
'&id='.
$object->id.
'">';
2426 print
img_edit(
'default', 0,
'style="vertical-align: middle;"');
2432 if (count($prodcustprice->lines) > 0) {
2433 foreach ($prodcustprice->lines as $line) {
2435 $staticsoc =
new Societe($db);
2436 $staticsoc->fetch($line->fk_soc);
2438 $tva_tx = $line->default_vat_code ? $line->tva_tx.
' ('.$line->default_vat_code.
')' : $line->tva_tx;
2441 if ($line->price_base_type ==
'HT') {
2444 $pu = $line->price_ttc;
2448 $localtaxarray =
getLocalTaxesFromRate($line->tva_tx.($line->default_vat_code ?
' ('.$line->default_vat_code.
')' :
''), 0, $staticsoc, $mysoc);
2450 $resultarray =
calcul_price_total(1, $pu, 0, $line->tva_tx, 1, 1, 0, $line->price_base_type, $line->recuperableonly,
$object->type, $mysoc, $localtaxarray);
2452 $total_ht = $resultarray[0];
2453 $total_vat = $resultarray[1];
2454 $total_localtax1 = $resultarray[9];
2455 $total_localtax2 = $resultarray[10];
2456 $total_ttc = $resultarray[2];
2458 print
'<tr class="oddeven">';
2460 print
'<td class="tdoverflowmax125">'.$staticsoc->getNomUrl(1).
"</td>";
2461 print
'<td>'.dol_escape_htmltag($line->ref_customer).
'</td>';
2462 print
"<td>".dol_print_date($line->datec,
"dayhour",
'tzuserrel').
"</td>";
2463 print
'<td class="center">'.$langs->trans($line->price_base_type).
"</td>";
2465 print
'<td class="right">';
2467 $positiverates =
'';
2469 $positiverates .= ($positiverates ?
'/' :
'').
price2num($line->tva_tx);
2472 $positiverates .= ($positiverates ?
'/' :
'').
price2num($line->localtax1_tx);
2475 $positiverates .= ($positiverates ?
'/' :
'').
price2num($line->localtax2_tx);
2477 if (empty($positiverates)) {
2478 $positiverates =
'0';
2481 echo
vatrate($positiverates.($line->default_vat_code ?
' ('.$line->default_vat_code.
')' :
''),
'%', (!empty($line->tva_npr) ? $line->tva_npr : $line->recuperableonly));
2485 print
'<td class="right"><span class="amount">'.price($line->price).
"</span></td>";
2487 print
'<td class="right"><span class="amount">'.price($line->price_ttc).
"</span></td>";
2488 if ($mysoc->localtax1_assuj ==
"1" || $mysoc->localtax2_assuj ==
"1") {
2490 print
'<td class="right"><span class="amount">'.price($resultarray[2]).
'</span></td>';
2493 print
'<td class="right">'.price($line->price_min).
'</td>';
2494 print
'<td class="right">'.price($line->price_min_ttc).
'</td>';
2495 print
'<td class="right">'.$line->price_label.
'</td>';
2498 $userstatic =
new User($db);
2499 $userstatic->fetch($line->fk_user);
2501 print
'<td class="right">';
2502 print $userstatic->getNomUrl(-1,
'', 0, 0, 24, 0,
'login');
2507 if ($user->hasRight(
'produit',
'supprimer') || $user->hasRight(
'service',
'supprimer')) {
2508 print
'<td class="right nowraponall">';
2509 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=showlog_customer_price&token='.
newToken().
'&id='.
$object->id.
'&socid='.$line->fk_soc.
'">';
2510 print
img_info($langs->trans(
'PriceByCustomerLog'));
2513 print
'<a class="marginleftonly editfielda" href="'.$_SERVER[
"PHP_SELF"].
'?action=edit_customer_price&token='.
newToken().
'&id='.
$object->id.
'&lineid='.$line->id.
'">';
2514 print
img_edit(
'default', 0,
'style="vertical-align: middle;"');
2517 print
'<a class="marginleftonly" href="'.$_SERVER[
"PHP_SELF"].
'?action=delete_customer_price&token='.
newToken().
'&id='.
$object->id.
'&lineid='.$line->id.
'">';
2518 print
img_delete(
'default',
'style="vertical-align: middle;"');
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()
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.
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.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
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 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.