38 require
'../main.inc.php';
39 require_once DOL_DOCUMENT_ROOT.
'/core/lib/product.lib.php';
40 require_once DOL_DOCUMENT_ROOT.
'/core/lib/price.lib.php';
41 require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
42 require_once DOL_DOCUMENT_ROOT.
'/product/dynamic_price/class/price_expression.class.php';
43 require_once DOL_DOCUMENT_ROOT.
'/product/dynamic_price/class/price_parser.class.php';
45 if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) {
46 require_once DOL_DOCUMENT_ROOT.
'/product/class/productcustomerprice.class.php';
52 $langs->loadLangs(array(
'products',
'bills',
'companies',
'other'));
59 $action =
GETPOST(
'action',
'aZ09');
60 $cancel =
GETPOST(
'cancel',
'alpha');
63 $search_soc =
GETPOST(
'search_soc');
66 $fieldvalue = (!empty($id) ? $id : (!empty($ref) ? $ref :
''));
67 $fieldtype = (!empty($ref) ?
'ref' :
'rowid');
69 $socid = $user->socid;
72 if ($id > 0 || !empty($ref)) {
74 $object->fetch($id, $ref);
78 if ((!empty($conf->global->PRODUIT_MULTIPRICES) || !empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) && empty($conf->global->PRODUIT_MULTIPRICES_LIMIT)) {
79 $conf->global->PRODUIT_MULTIPRICES_LIMIT = 5;
83 $hookmanager->initHooks(array(
'productpricecard',
'globalcard'));
85 if ($object->id > 0) {
86 if ($object->type == $object::TYPE_PRODUCT) {
87 restrictedArea($user,
'produit', $object->id,
'product&product',
'',
'');
89 if ($object->type == $object::TYPE_SERVICE) {
90 restrictedArea($user,
'service', $object->id,
'product&product',
'',
'');
93 restrictedArea($user,
'produit|service', $fieldvalue,
'product&product',
'',
'', $fieldtype);
105 $parameters = array(
'id'=>$id,
'ref'=>$ref);
106 $reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
111 if (empty($reshook)) {
112 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
116 if ($action ==
'setlabelsellingprice' && $user->admin) {
117 require_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
118 $keyforlabel =
'PRODUIT_MULTIPRICES_LABEL'.GETPOST(
'pricelevel');
123 if (($action ==
'update_vat') && !$cancel && ($user->rights->produit->creer || $user->rights->service->creer)) {
124 $tva_tx_txt =
GETPOST(
'tva_tx',
'alpha');
127 $tva_tx = $tva_tx_txt;
130 if (preg_match(
'/\((.*)\)/', $tva_tx_txt, $reg)) {
131 $vatratecode = $reg[1];
132 $tva_tx = preg_replace(
'/\s*\(.*\)/',
'', $tva_tx_txt);
135 $tva_tx =
price2num(preg_replace(
'/\*/',
'', $tva_tx));
136 $npr = preg_match(
'/\*/', $tva_tx_txt) ? 1 : 0;
137 $localtax1 = 0; $localtax2 = 0; $localtax1_type =
'0'; $localtax2_type =
'0';
140 if (preg_match(
'/\((.*)\)/', $tva_tx_txt, $reg)) {
142 $vatratecode = $reg[1];
144 $sql =
"SELECT t.rowid, t.code, t.recuperableonly, t.localtax1, t.localtax2, t.localtax1_type, t.localtax2_type";
145 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_tva as t, ".MAIN_DB_PREFIX.
"c_country as c";
146 $sql .=
" WHERE t.fk_pays = c.rowid AND c.code = '".$db->escape($mysoc->country_code).
"'";
147 $sql .=
" AND t.taux = ".((float) $tva_tx).
" AND t.active = 1";
148 $sql .=
" AND t.code = '".$db->escape($vatratecode).
"'";
149 $resql = $db->query($sql);
151 $obj = $db->fetch_object(
$resql);
153 $npr = $obj->recuperableonly;
154 $localtax1 = $obj->localtax1;
155 $localtax2 = $obj->localtax2;
156 $localtax1_type = $obj->localtax1_type;
157 $localtax2_type = $obj->localtax2_type;
162 $sql =
"SELECT t.rowid, t.code, t.recuperableonly, t.localtax1, t.localtax2, t.localtax1_type, t.localtax2_type";
163 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_tva as t, ".MAIN_DB_PREFIX.
"c_country as c";
164 $sql .=
" WHERE t.fk_pays = c.rowid AND c.code = '".$db->escape($mysoc->country_code).
"'";
165 $sql .=
" AND t.taux = ".((float) $tva_tx).
" AND t.active = 1";
166 $sql .=
" AND t.code = ''";
167 $resql = $db->query($sql);
169 $obj = $db->fetch_object(
$resql);
171 $npr = $obj->recuperableonly;
172 $localtax1 = $obj->localtax1;
173 $localtax2 = $obj->localtax2;
174 $localtax1_type = $obj->localtax1_type;
175 $localtax2_type = $obj->localtax2_type;
180 $object->default_vat_code = $vatratecode;
181 $object->tva_tx = $tva_tx;
182 $object->tva_npr = $npr;
183 $object->localtax1_tx = $localtax1;
184 $object->localtax2_tx = $localtax2;
185 $object->localtax1_type = $localtax1_type;
186 $object->localtax2_type = $localtax2_type;
190 $resql = $object->update($object->id, $user);
197 if (!empty($conf->global->PRODUIT_MULTIPRICES) || !empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) {
198 for ($i = 1; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i++) {
200 if ($object->multiprices_base_type[$i] ==
'HT') {
201 $oldprice = $object->multiprices[$i];
202 $oldminprice = $object->multiprices_min[$i];
204 $oldprice = $object->multiprices_ttc[$i];
205 $oldminprice = $object->multiprices_min_ttc[$i];
207 $oldpricebasetype = $object->multiprices_base_type[$i];
208 $oldnpr = $object->multiprices_recuperableonly[$i];
211 $localtaxarray = array();
213 $ret = $object->updatePrice($oldprice, $oldpricebasetype, $user, $tva_tx, $oldminprice, $level, $oldnpr, 0, 0, $localtaxarray, $vatratecode);
222 if ($object->price_base_type ==
'HT') {
223 $oldprice = $object->price;
224 $oldminprice = $object->price_min;
226 $oldprice = $object->price_ttc;
227 $oldminprice = $object->price_min_ttc;
229 $oldpricebasetype = $object->price_base_type;
230 $oldnpr = $object->tva_npr;
233 $localtaxarray = array();
235 $ret = $object->updatePrice($oldprice, $oldpricebasetype, $user, $tva_tx, $oldminprice, $level, $oldnpr, 0, 0, $localtaxarray, $vatratecode);
253 if (($action ==
'update_price') && !$cancel && $object->getRights()->creer) {
255 $pricestoupdate = array();
258 $psq = empty($newpsq) ? 0 : $newpsq;
259 $maxpricesupplier = $object->min_recommended_price();
262 $object->fk_price_expression = empty($eid) ? 0 : $eid;
264 if ($object->fk_price_expression != 0) {
266 require_once DOL_DOCUMENT_ROOT.
'/product/dynamic_price/class/price_parser.class.php';
269 if ($priceparser->parseProduct($object) < 0) {
277 if (!$error && (!empty($conf->global->PRODUIT_MULTIPRICES) || !empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES))) {
278 $newprice =
GETPOST(
'price',
'array');
279 $newprice_min =
GETPOST(
'price_min',
'array');
280 $newpricebase =
GETPOST(
'multiprices_base_type',
'array');
281 $newvattx =
GETPOST(
'tva_tx',
'array');
282 $newvatnpr =
GETPOST(
'tva_npr',
'array');
283 $newlocaltax1_tx =
GETPOST(
'localtax1_tx',
'array');
284 $newlocaltax1_type =
GETPOST(
'localtax1_type',
'array');
285 $newlocaltax2_tx =
GETPOST(
'localtax2_tx',
'array');
286 $newlocaltax2_type =
GETPOST(
'localtax2_type',
'array');
289 $object->price_autogen =
GETPOST(
'usePriceRules') ==
'on';
291 for ($i = 1; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i++) {
292 if (!isset($newprice[$i])) {
296 $tva_tx_txt = $newvattx[$i];
298 $tva_tx = $tva_tx_txt;
301 if (preg_match(
'/\((.*)\)/', $tva_tx_txt, $reg)) {
302 $vat_src_code = $reg[1];
303 $tva_tx = preg_replace(
'/\s*\(.*\)/',
'', $tva_tx_txt);
305 $tva_tx =
price2num(preg_replace(
'/\*/',
'', $tva_tx));
307 $npr = preg_match(
'/\*/', $tva_tx_txt) ? 1 : 0;
308 $localtax1 = $newlocaltax1_tx[$i];
309 $localtax1_type = $newlocaltax1_type[$i];
310 $localtax2 = $newlocaltax2_tx[$i];
311 $localtax2_type = $newlocaltax2_type[$i];
312 if (preg_match(
'/\((.*)\)/', $tva_tx_txt, $reg)) {
314 $vatratecode = $reg[1];
316 $sql =
"SELECT t.rowid, t.code, t.recuperableonly, t.localtax1, t.localtax2, t.localtax1_type, t.localtax2_type";
317 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_tva as t, ".MAIN_DB_PREFIX.
"c_country as c";
318 $sql .=
" WHERE t.fk_pays = c.rowid AND c.code = '".$db->escape($mysoc->country_code).
"'";
319 $sql .=
" AND t.taux = ".((float) $tva_tx).
" AND t.active = 1";
320 $sql .=
" AND t.code ='".$db->escape($vatratecode).
"'";
321 $resql = $db->query($sql);
323 $obj = $db->fetch_object(
$resql);
325 $npr = $obj->recuperableonly;
326 $localtax1 = $obj->localtax1;
327 $localtax2 = $obj->localtax2;
328 $localtax1_type = $obj->localtax1_type;
329 $localtax2_type = $obj->localtax2_type;
333 if (in_array($mysoc->country_code, array(
'ES'))) {
340 $sql =
"SELECT t.rowid, t.code, t.recuperableonly, t.localtax1, t.localtax2, t.localtax1_type, t.localtax2_type";
341 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_tva as t, ".MAIN_DB_PREFIX.
"c_country as c";
342 $sql .=
" WHERE t.fk_pays = c.rowid AND c.code = '".$db->escape($mysoc->country_code).
"'";
343 $sql .=
" AND t.taux = ".((float) $tva_tx).
" AND t.active = 1";
344 $sql .=
" AND t.code = ''";
345 $resql = $db->query($sql);
347 $obj = $db->fetch_object(
$resql);
349 $npr = $obj->recuperableonly;
350 $localtax1 = $obj->localtax1;
351 $localtax2 = $obj->localtax2;
352 $localtax1_type = $obj->localtax1_type;
353 $localtax2_type = $obj->localtax2_type;
358 $pricestoupdate[$i] = array(
359 'price' =>
price2num($newprice[$i],
'', 2),
360 'price_min' =>
price2num($newprice_min[$i],
'', 2),
361 'price_base_type' => $newpricebase[$i],
362 'default_vat_code' => $vatratecode,
365 'localtaxes_array' => array(
'0'=>$localtax1_type,
'1'=>$localtax1,
'2'=>$localtax2_type,
'3'=>$localtax2)
369 if ($object->price_autogen) {
376 $newpricebase =
GETPOST(
'price_base_type',
'alpha');
377 $tva_tx_txt =
GETPOST(
'tva_tx',
'alpha');
379 $tva_tx = $tva_tx_txt;
382 if (preg_match(
'/\((.*)\)/', $tva_tx_txt, $reg)) {
383 $vat_src_code = $reg[1];
384 $tva_tx = preg_replace(
'/\s*\(.*\)/',
'', $tva_tx_txt);
386 $tva_tx =
price2num(preg_replace(
'/\*/',
'', $tva_tx));
388 $npr = preg_match(
'/\*/', $tva_tx_txt) ? 1 : 0;
389 $localtax1 = 0; $localtax2 = 0; $localtax1_type =
'0'; $localtax2_type =
'0';
391 if (preg_match(
'/\((.*)\)/', $tva_tx_txt, $reg)) {
393 $vatratecode = $reg[1];
395 $sql =
"SELECT t.rowid, t.code, t.recuperableonly, t.localtax1, t.localtax2, t.localtax1_type, t.localtax2_type";
396 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_tva as t, ".MAIN_DB_PREFIX.
"c_country as c";
397 $sql .=
" WHERE t.fk_pays = c.rowid AND c.code = '".$db->escape($mysoc->country_code).
"'";
398 $sql .=
" AND t.taux = ".((float) $tva_tx).
" AND t.active = 1";
399 $sql .=
" AND t.code ='".$db->escape($vatratecode).
"'";
400 $resql = $db->query($sql);
402 $obj = $db->fetch_object(
$resql);
404 $npr = $obj->recuperableonly;
405 $localtax1 = $obj->localtax1;
406 $localtax2 = $obj->localtax2;
407 $localtax1_type = $obj->localtax1_type;
408 $localtax2_type = $obj->localtax2_type;
412 if (in_array($mysoc->country_code, array(
'ES'))) {
419 $sql =
"SELECT t.rowid, t.code, t.recuperableonly, t.localtax1, t.localtax2, t.localtax1_type, t.localtax2_type";
420 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_tva as t, ".MAIN_DB_PREFIX.
"c_country as c";
421 $sql .=
" WHERE t.fk_pays = c.rowid AND c.code = '".$db->escape($mysoc->country_code).
"'";
422 $sql .=
" AND t.taux = ".((float) $tva_tx).
" AND t.active = 1";
423 $sql .=
" AND t.code = ''";
424 $resql = $db->query($sql);
426 $obj = $db->fetch_object(
$resql);
428 $npr = $obj->recuperableonly;
429 $localtax1 = $obj->localtax1;
430 $localtax2 = $obj->localtax2;
431 $localtax1_type = $obj->localtax1_type;
432 $localtax2_type = $obj->localtax2_type;
437 $pricestoupdate[0] = array(
438 'price' => $newprice,
439 'price_min' => $newprice_min,
440 'price_base_type' => $newpricebase,
441 'default_vat_code' => $vatratecode,
444 'localtaxes_array' => array(
'0'=>$localtax1_type,
'1'=>$localtax1,
'2'=>$localtax2_type,
'3'=>$localtax2)
451 foreach ($pricestoupdate as $key => $val) {
452 $newprice = $val[
'price'];
454 if ($val[
'price'] < $val[
'price_min'] && !empty($object->fk_price_expression)) {
455 $newprice = $val[
'price_min'];
459 $newprice_min =
price2num($val[
'price_min'],
'MU');
462 if (!empty($conf->global->PRODUCT_MINIMUM_RECOMMENDED_PRICE) && $newprice_min < $maxpricesupplier) {
463 setEventMessages($langs->trans(
"MinimumPriceLimit",
price($maxpricesupplier, 0,
'', 1, - 1, - 1,
'auto')),
null,
'errors');
469 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) {
470 $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']);
483 if (!$error && $object->update($object->id, $user) < 0) {
493 $action =
'edit_price';
499 if ($action ==
'delete' && $user->rights->produit->supprimer) {
500 $result = $object->log_price_delete($user,
GETPOST(
'lineid',
'int'));
507 if ($action ==
'activate_price_by_qty') {
509 $level =
GETPOST(
'level',
'int');
510 $ret = $object->updatePrice(0, $object->price_base_type, $user, $object->tva_tx, 0, $level, $object->tva_npr, 1);
517 if ($action ==
'disable_price_by_qty') {
519 $level =
GETPOST(
'level',
'int');
520 $ret = $object->updatePrice(0, $object->price_base_type, $user, $object->tva_tx, 0, $level, $object->tva_npr, 0);
527 if ($action ==
'edit_price_by_qty') {
528 $rowid =
GETPOST(
'rowid',
'int');
532 if ($action ==
'update_price_by_qty') {
534 $rowid =
GETPOST(
'rowid',
'int');
535 $priceid =
GETPOST(
'priceid',
'int');
542 if (empty($quantity)) {
544 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Qty")),
null,
'errors');
546 if (empty($newprice)) {
548 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Price")),
null,
'errors');
552 if ($object->price_base_type ==
'TTC') {
553 $price =
price2num($newprice) / (1 + ($object->tva_tx / 100));
557 $unitPrice =
price2num($price / $quantity,
'MU');
561 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"product_price_by_qty SET";
562 $sql .=
" price=".((float) $price).
",";
563 $sql .=
" unitprice=".((float) $unitPrice).
",";
564 $sql .=
" quantity=".((float) $quantity).
",";
565 $sql .=
" remise_percent=".((float) $remise_percent).
",";
566 $sql .=
" remise=".((float) $remise);
567 $sql .=
" WHERE rowid = ".((int) $rowid);
569 $result = $db->query($sql);
574 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"product_price_by_qty (fk_product_price,price,unitprice,quantity,remise_percent,remise) values (";
575 $sql .= ((int) $priceid).
','.((
float) $price).
','.((
float) $unitPrice).
','.((
float) $quantity).
','.((
float) $remise_percent).
','.((
float) $remise).
')';
577 $result = $db->query($sql);
579 if ($db->lasterrno() ==
'DB_ERROR_RECORD_ALREADY_EXISTS') {
589 if ($action ==
'delete_price_by_qty') {
590 $rowid =
GETPOST(
'rowid',
'int');
591 if (!empty($rowid)) {
592 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"product_price_by_qty";
593 $sql .=
" WHERE rowid = ".((int) $rowid);
595 $result = $db->query($sql);
597 setEventMessages((
'delete_price_by_qty'.$langs->transnoentities(
'MissingIds')),
null,
'errors');
601 if ($action ==
'delete_all_price_by_qty') {
602 $priceid =
GETPOST(
'priceid',
'int');
603 if (!empty($rowid)) {
604 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"product_price_by_qty";
605 $sql .=
" WHERE fk_product_price = ".((int) $priceid);
607 $result = $db->query($sql);
609 setEventMessages((
'delete_price_by_qty'.$langs->transnoentities(
'MissingIds')),
null,
'errors');
618 if ($action ==
'add_customer_price_confirm' && !$cancel && ($user->rights->produit->creer || $user->rights->service->creer)) {
619 $maxpricesupplier = $object->min_recommended_price();
621 $update_child_soc =
GETPOST(
'updatechildprice',
'int');
624 $prodcustprice->fk_soc =
GETPOST(
'socid',
'int');
625 $prodcustprice->ref_customer =
GETPOST(
'ref_customer',
'alpha');
626 $prodcustprice->fk_product = $object->id;
629 $prodcustprice->price_base_type =
GETPOST(
"price_base_type",
'alpha');
631 $tva_tx_txt =
GETPOST(
"tva_tx",
'alpha');
633 $tva_tx = $tva_tx_txt;
635 if (preg_match(
'/\((.*)\)/', $tva_tx_txt, $reg)) {
636 $vat_src_code = $reg[1];
637 $tva_tx = preg_replace(
'/\s*\(.*\)/',
'', $tva_tx_txt);
639 $tva_tx =
price2num(preg_replace(
'/\*/',
'', $tva_tx));
641 $npr = preg_match(
'/\*/', $tva_tx_txt) ? 1 : 0;
642 $localtax1 = 0; $localtax2 = 0; $localtax1_type =
'0'; $localtax2_type =
'0';
644 if (preg_match(
'/\((.*)\)/', $tva_tx_txt, $reg)) {
646 $vatratecode = $reg[1];
648 $sql =
"SELECT t.rowid, t.code, t.recuperableonly, t.localtax1, t.localtax2, t.localtax1_type, t.localtax2_type";
649 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_tva as t, ".MAIN_DB_PREFIX.
"c_country as c";
650 $sql .=
" WHERE t.fk_pays = c.rowid AND c.code = '".$db->escape($mysoc->country_code).
"'";
651 $sql .=
" AND t.taux = ".((float) $tva_tx).
" AND t.active = 1";
652 $sql .=
" AND t.code ='".$db->escape($vatratecode).
"'";
653 $resql = $db->query($sql);
655 $obj = $db->fetch_object(
$resql);
657 $npr = $obj->recuperableonly;
658 $localtax1 = $obj->localtax1;
659 $localtax2 = $obj->localtax2;
660 $localtax1_type = $obj->localtax1_type;
661 $localtax2_type = $obj->localtax2_type;
665 if (in_array($mysoc->country_code, array(
'ES'))) {
672 $sql =
"SELECT t.rowid, t.code, t.recuperableonly, t.localtax1, t.localtax2, t.localtax1_type, t.localtax2_type";
673 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_tva as t, ".MAIN_DB_PREFIX.
"c_country as c";
674 $sql .=
" WHERE t.fk_pays = c.rowid AND c.code = '".$db->escape($mysoc->country_code).
"'";
675 $sql .=
" AND t.taux = ".((float) $tva_tx).
" AND t.active = 1";
676 $sql .=
" AND t.code = ''";
677 $resql = $db->query($sql);
679 $obj = $db->fetch_object(
$resql);
681 $npr = $obj->recuperableonly;
682 $localtax1 = $obj->localtax1;
683 $localtax2 = $obj->localtax2;
684 $localtax1_type = $obj->localtax1_type;
685 $localtax2_type = $obj->localtax2_type;
690 $prodcustprice->default_vat_code = $vatratecode;
691 $prodcustprice->tva_tx = $tva_tx;
692 $prodcustprice->recuperableonly = $npr;
693 $prodcustprice->localtax1_tx = $localtax1;
694 $prodcustprice->localtax2_tx = $localtax2;
695 $prodcustprice->localtax1_type = $localtax1_type;
696 $prodcustprice->localtax2_type = $localtax2_type;
698 if (!($prodcustprice->fk_soc > 0)) {
699 $langs->load(
"errors");
700 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"ThirdParty")),
null,
'errors');
702 $action =
'add_customer_price';
704 if (!empty($conf->global->PRODUCT_MINIMUM_RECOMMENDED_PRICE) && $prodcustprice->price_min < $maxpricesupplier) {
705 $langs->load(
"errors");
706 setEventMessages($langs->trans(
"MinimumPriceLimit",
price($maxpricesupplier, 0,
'', 1, -1, -1,
'auto')),
null,
'errors');
708 $action =
'add_customer_price';
712 $result = $prodcustprice->create($user, 0, $update_child_soc);
724 if ($action ==
'delete_customer_price' && ($user->rights->produit->supprimer || $user->rights->service->supprimer)) {
726 $prodcustprice->id =
GETPOST(
'lineid',
'int');
727 $result = $prodcustprice->delete($user);
737 if ($action ==
'update_customer_price_confirm' && !$cancel && ($user->rights->produit->creer || $user->rights->service->creer)) {
738 $maxpricesupplier = $object->min_recommended_price();
740 $update_child_soc =
GETPOST(
'updatechildprice',
'int');
742 $prodcustprice->fetch(
GETPOST(
'lineid',
'int'));
745 $prodcustprice->ref_customer =
GETPOST(
'ref_customer',
'alpha');
748 $prodcustprice->price_base_type =
GETPOST(
"price_base_type",
'alpha');
750 $tva_tx_txt =
GETPOST(
"tva_tx");
752 $tva_tx = $tva_tx_txt;
754 if (preg_match(
'/\((.*)\)/', $tva_tx_txt, $reg)) {
755 $vat_src_code = $reg[1];
756 $tva_tx = preg_replace(
'/\s*\(.*\)/',
'', $tva_tx_txt);
758 $tva_tx =
price2num(preg_replace(
'/\*/',
'', $tva_tx));
760 $npr = preg_match(
'/\*/', $tva_tx_txt) ? 1 : 0;
761 $localtax1 = 0; $localtax2 = 0; $localtax1_type =
'0'; $localtax2_type =
'0';
763 if (preg_match(
'/\((.*)\)/', $tva_tx_txt, $reg)) {
765 $vatratecode = $reg[1];
767 $sql =
"SELECT t.rowid, t.code, t.recuperableonly, t.localtax1, t.localtax2, t.localtax1_type, t.localtax2_type";
768 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_tva as t, ".MAIN_DB_PREFIX.
"c_country as c";
769 $sql .=
" WHERE t.fk_pays = c.rowid AND c.code = '".$db->escape($mysoc->country_code).
"'";
770 $sql .=
" AND t.taux = ".((float) $tva_tx).
" AND t.active = 1";
771 $sql .=
" AND t.code ='".$db->escape($vatratecode).
"'";
772 $resql = $db->query($sql);
774 $obj = $db->fetch_object(
$resql);
776 $npr = $obj->recuperableonly;
777 $localtax1 = $obj->localtax1;
778 $localtax2 = $obj->localtax2;
779 $localtax1_type = $obj->localtax1_type;
780 $localtax2_type = $obj->localtax2_type;
784 if (in_array($mysoc->country_code, array(
'ES'))) {
791 $sql =
"SELECT t.rowid, t.code, t.recuperableonly, t.localtax1, t.localtax2, t.localtax1_type, t.localtax2_type";
792 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_tva as t, ".MAIN_DB_PREFIX.
"c_country as c";
793 $sql .=
" WHERE t.fk_pays = c.rowid AND c.code = '".$db->escape($mysoc->country_code).
"'";
794 $sql .=
" AND t.taux = ".((float) $tva_tx).
" AND t.active = 1";
795 $sql .=
" AND t.code = ''";
796 $resql = $db->query($sql);
798 $obj = $db->fetch_object(
$resql);
800 $npr = $obj->recuperableonly;
801 $localtax1 = $obj->localtax1;
802 $localtax2 = $obj->localtax2;
803 $localtax1_type = $obj->localtax1_type;
804 $localtax2_type = $obj->localtax2_type;
809 $prodcustprice->default_vat_code = $vatratecode;
810 $prodcustprice->tva_tx = $tva_tx;
811 $prodcustprice->recuperableonly = $npr;
812 $prodcustprice->localtax1_tx = $localtax1;
813 $prodcustprice->localtax2_tx = $localtax2;
814 $prodcustprice->localtax1_type = $localtax1_type;
815 $prodcustprice->localtax2_type = $localtax2_type;
817 if ($prodcustprice->price_min < $maxpricesupplier && !empty($conf->global->PRODUCT_MINIMUM_RECOMMENDED_PRICE)) {
818 setEventMessages($langs->trans(
"MinimumPriceLimit",
price($maxpricesupplier, 0,
'', 1, -1, -1,
'auto')),
null,
'errors');
820 $action =
'update_customer_price';
824 $result = $prodcustprice->update($user, 0, $update_child_soc);
844 if (!empty($id) || !empty($ref)) {
846 $object->fetch($id, $ref);
849 $title = $langs->trans(
'ProductServiceCard');
851 $shortlabel =
dol_trunc($object->label, 16);
853 $title = $langs->trans(
'Product').
" ".$shortlabel.
" - ".$langs->trans(
'SellingPrices');
854 $helpurl =
'EN:Module_Products|FR:Module_Produits|ES:Módulo_Productos';
857 $title = $langs->trans(
'Service').
" ".$shortlabel.
" - ".$langs->trans(
'SellingPrices');
858 $helpurl =
'EN:Module_Services_En|FR:Module_Services|ES:Módulo_Servicios';
861 llxHeader(
'', $title, $helpurl,
'', 0, 0,
'',
'',
'',
'classforhorizontalscrolloftabs');
864 $titre = $langs->trans(
"CardProduct".$object->type);
869 $linkback =
'<a href="'.DOL_URL_ROOT.
'/product/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
870 $object->next_prev_filter =
" fk_product_type = ".$object->type;
873 if ($user->socid && !in_array(
'product', explode(
',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) {
880 print
'<div class="fichecenter">';
882 print
'<div class="underbanner clearboth"></div>';
883 print
'<table class="border tableforfield centpercent">';
886 if (!empty($conf->global->PRODUIT_MULTIPRICES) || !empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) {
888 if (!empty($socid)) {
895 $typeformat =
'select;0:'.$langs->trans(
"Product").
',1:'.$langs->trans(
"Service");
896 print
'<tr><td class="">';
897 print (empty($conf->global->PRODUCT_DENY_CHANGE_PRODUCT_TYPE)) ?
$form->editfieldkey(
"Type",
'fk_product_type', $object->type, $object, 0, $typeformat) : $langs->trans(
'Type');
899 print
$form->editfieldval(
"Type",
'fk_product_type', $object->type, $object, 0, $typeformat);
904 print
'<tr><td class="titlefieldcreate">';
905 print $langs->trans(
"SellingPrice");
907 print
'<td colspan="2">';
908 if ($object->multiprices_base_type[$soc->price_level] ==
'TTC') {
909 print
'<span class="amount">'.price($object->multiprices_ttc[$soc->price_level]).
'</span>';
911 print
'<span class="amount">'.price($object->multiprices[$soc->price_level]).
'</span>';
913 if ($object->multiprices_base_type[$soc->price_level]) {
914 print
' '.$langs->trans($object->multiprices_base_type[$soc->price_level]);
916 print
' '.$langs->trans($object->price_base_type);
921 print
'<tr><td>'.$langs->trans(
"MinPrice").
'</td><td colspan="2">';
922 if ($object->multiprices_base_type[$soc->price_level] ==
'TTC') {
923 print
price($object->multiprices_min_ttc[$soc->price_level]).
' '.$langs->trans($object->multiprices_base_type[$soc->price_level]);
925 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]);
929 if (!empty($conf->global->PRODUIT_MULTIPRICES_USE_VAT_PER_LEVEL)) {
931 print
'<tr><td>'.$langs->trans(
"DefaultTaxRate").
'</td><td colspan="2">';
934 if (
price2num($object->multiprices_tva_tx[$soc->price_level])) {
935 $positiverates .= ($positiverates ?
'/' :
'').
price2num($object->multiprices_tva_tx[$soc->price_level]);
937 if (
price2num($object->multiprices_localtax1_type[$soc->price_level])) {
938 $positiverates .= ($positiverates ?
'/' :
'').
price2num($object->multiprices_localtax1_tx[$soc->price_level]);
940 if (
price2num($object->multiprices_localtax2_type[$soc->price_level])) {
941 $positiverates .= ($positiverates ?
'/' :
'').
price2num($object->multiprices_localtax2_tx[$soc->price_level]);
943 if (empty($positiverates)) {
944 $positiverates =
'0';
946 echo
vatrate($positiverates.($object->default_vat_code ?
' ('.$object->default_vat_code.
')' :
''),
'%', $object->tva_npr);
951 print
'<tr><td>'.$langs->trans(
"DefaultTaxRate").
'</td><td>';
955 $positiverates .= ($positiverates ?
'/' :
'').
price2num($object->tva_tx);
957 if (
price2num($object->localtax1_type)) {
958 $positiverates .= ($positiverates ?
'/' :
'').
price2num($object->localtax1_tx);
960 if (
price2num($object->localtax2_type)) {
961 $positiverates .= ($positiverates ?
'/' :
'').
price2num($object->localtax2_tx);
963 if (empty($positiverates)) {
964 $positiverates =
'0';
966 echo
vatrate($positiverates.($object->default_vat_code ?
' ('.$object->default_vat_code.
')' :
''),
'%', $object->tva_npr);
976 if (!empty($conf->global->PRODUIT_MULTIPRICES_USE_VAT_PER_LEVEL)) {
979 $typeformat =
'select;0:'.$langs->trans(
"Product").
',1:'.$langs->trans(
"Service");
980 print
'<tr><td class="">';
981 print (empty($conf->global->PRODUCT_DENY_CHANGE_PRODUCT_TYPE)) ?
$form->editfieldkey(
"Type",
'fk_product_type', $object->type, $object, 0, $typeformat) : $langs->trans(
'Type');
983 print
$form->editfieldval(
"Type",
'fk_product_type', $object->type, $object, 0, $typeformat);
988 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"DefaultTaxRate").
'</td>';
989 print
'<td colspan="2">'.vatrate($object->multiprices_tva_tx[1],
true).
'</td>';
994 $typeformat =
'select;0:'.$langs->trans(
"Product").
',1:'.$langs->trans(
"Service");
995 print
'<tr><td class="">';
996 print (empty($conf->global->PRODUCT_DENY_CHANGE_PRODUCT_TYPE)) ?
$form->editfieldkey(
"Type",
'fk_product_type', $object->type, $object, 0, $typeformat) : $langs->trans(
'Type');
998 print
$form->editfieldval(
"Type",
'fk_product_type', $object->type, $object, 0, $typeformat);
1003 print
'<!-- Default VAT Rate -->';
1004 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"DefaultTaxRate").
'</td><td>';
1007 $positiverates =
'';
1009 $positiverates .= ($positiverates ?
'<span class="opacitymedium">/</span>' :
'').
price2num($object->tva_tx);
1011 if (
price2num($object->localtax1_type)) {
1012 $positiverates .= ($positiverates ?
'<span class="opacitymedium">/</span>' :
'').
price2num($object->localtax1_tx);
1014 if (
price2num($object->localtax2_type)) {
1015 $positiverates .= ($positiverates ?
'<span class="opacitymedium">/</span>' :
'').
price2num($object->localtax2_tx);
1017 if (empty($positiverates)) {
1018 $positiverates =
'0';
1021 print
vatrate($positiverates.($object->default_vat_code ?
' ('.$object->default_vat_code.
')' :
''),
true, $object->tva_npr, 1);
1034 print
'<table class="noborder tableforfield centpercent">';
1035 print
'<tr class="liste_titre"><td>';
1036 print $langs->trans(
"PriceLevel");
1038 print
' <a class="editfielda" href="'.$_SERVER[
"PHP_SELF"].
'?action=editlabelsellingprice&token='.
newToken().
'&pricelevel='.$i.
'&id='.$object->id.
'">'.
img_edit($langs->trans(
'EditSellingPriceLabel'), 0).
'</a>';
1041 print
'<td style="text-align: right">'.$langs->trans(
"SellingPrice").
'</td>';
1042 print
'<td style="text-align: right">'.$langs->trans(
"MinPrice").
'</td>';
1045 for ($i = 1; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i++) {
1046 print
'<tr class="oddeven">';
1050 $keyforlabel =
'PRODUIT_MULTIPRICES_LABEL'.$i;
1051 if (preg_match(
'/editlabelsellingprice/', $action)) {
1052 print
'<form method="post" action="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'">';
1053 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1054 print
'<input type="hidden" name="action" value="setlabelsellingprice">';
1055 print
'<input type="hidden" name="pricelevel" value="'.$i.
'">';
1056 print $langs->trans(
"SellingPrice").
' '.$i.
' - ';
1057 print
'<input class="maxwidthonsmartphone" type="text" name="labelsellingprice" value="'.$conf->global->$keyforlabel.
'">';
1058 print
' <input type="submit" class="button smallpaddingimp" value="'.$langs->trans(
"Modify").
'">';
1061 print $langs->trans(
"SellingPrice").
' '.$i;
1062 if (!empty($conf->global->$keyforlabel)) {
1063 print
' - '.$langs->trans($conf->global->$keyforlabel);
1068 if ($object->multiprices_base_type [$i] ==
'TTC') {
1069 print
'<td class="right"><span class="amount">'.price($object->multiprices_ttc[$i]);
1071 print
'<td class="right"><span class="amount">'.price($object->multiprices[$i]);
1074 if ($object->multiprices_base_type[$i]) {
1075 print
' '.$langs->trans($object->multiprices_base_type [$i]).
'</span></td>';
1077 print
' '.$langs->trans($object->price_base_type).
'</span></td>';
1081 print
'<td style="text-align: right">';
1082 if (empty($object->multiprices_base_type[$i])) {
1083 $object->multiprices_base_type[$i] =
"HT";
1085 if ($object->multiprices_base_type[$i] ==
'TTC') {
1086 print
price($object->multiprices_min_ttc[$i]).
' '.$langs->trans($object->multiprices_base_type[$i]);
1088 print
price($object->multiprices_min[$i]).
' '.$langs->trans($object->multiprices_base_type[$i]);
1093 if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY) || !empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) {
1094 print
'<tr><td>'.$langs->trans(
"PriceByQuantity").
' '.$i;
1095 if (!empty($conf->global->$keyforlabel)) {
1096 print
' - '.$langs->trans($conf->global->$keyforlabel);
1098 print
'</td><td colspan="2">';
1100 if ($object->prices_by_qty[$i] == 1) {
1101 print
'<table width="50%" class="border" summary="List of quantities">';
1103 print
'<tr class="liste_titre">';
1104 print
'<td>'.$langs->trans(
"PriceByQuantityRange").
' '.$i.
'</td>';
1105 print
'<td class="right">'.$langs->trans(
"HT").
'</td>';
1106 print
'<td class="right">'.$langs->trans(
"UnitPrice").
'</td>';
1107 print
'<td class="right">'.$langs->trans(
"Discount").
'</td>';
1108 print
'<td> </td>';
1110 foreach ($object->prices_by_qty_list[$i] as $ii => $prices) {
1111 if ($action ==
'edit_price_by_qty' && $rowid == $prices[
'rowid'] && ($user->rights->produit->creer || $user->rights->service->creer)) {
1112 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'" method="POST">';
1113 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1114 print
'<input type="hidden" name="action" value="update_price_by_qty">';
1115 print
'<input type="hidden" name="priceid" value="'.$object->prices_by_qty_id[$i].
'">';
1116 print
'<input type="hidden" value="'.$prices[
'rowid'].
'" name="rowid">';
1117 print
'<tr class="'.($ii % 2 == 0 ?
'pair' :
'impair').
'">';
1118 print
'<td><input size="5" type="text" value="'.$prices[
'quantity'].
'" name="quantity"></td>';
1119 print
'<td class="right" colspan="2"><input size="10" type="text" value="'.price2num($prices[
'price'],
'MU').
'" name="price"> '.$object->price_base_type.
'</td>';
1120 print
'<td class="right nowraponall"><input size="5" type="text" value="'.$prices[
'remise_percent'].
'" name="remise_percent"> %</td>';
1121 print
'<td class="center"><input type="submit" value="'.$langs->trans(
"Modify").
'" class="button"></td>';
1125 print
'<tr class="'.($ii % 2 == 0 ?
'pair' :
'impair').
'">';
1126 print
'<td>'.$prices[
'quantity'].
'</td>';
1127 print
'<td class="right">'.price($prices[
'price']).
'</td>';
1128 print
'<td class="right">'.price($prices[
'unitprice']).
'</td>';
1129 print
'<td class="right">'.price($prices[
'remise_percent']).
' %</td>';
1130 print
'<td class="center">';
1131 if (($user->rights->produit->creer || $user->rights->service->creer)) {
1132 print
'<a class="editfielda marginleftonly marginrightonly" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=edit_price_by_qty&token='.
newToken().
'&rowid='.$prices[
"rowid"].
'">';
1134 print
'<a class="marginleftonly marginrightonly" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=delete_price_by_qty&token='.
newToken().
'&rowid='.$prices[
"rowid"].
'">';
1143 if ($action !=
'edit_price_by_qty' && ($user->rights->produit->creer || $user->rights->service->creer)) {
1144 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'" method="POST">';
1145 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1146 print
'<input type="hidden" name="action" value="update_price_by_qty">';
1147 print
'<input type="hidden" name="priceid" value="'.$object->prices_by_qty_id[$i].
'">';
1148 print
'<input type="hidden" value="0" name="rowid">';
1149 print
'<tr class="'.($ii % 2 == 0 ?
'pair' :
'impair').
'">';
1150 print
'<td><input size="5" type="text" value="1" name="quantity"></td>';
1151 print
'<td class="right" class="nowrap"><input size="10" type="text" value="0" name="price"> '.$object->price_base_type.
'</td>';
1152 print
'<td class="right"> </td>';
1153 print
'<td class="right" class="nowraponall"><input size="5" type="text" value="0" name="remise_percent"> %</td>';
1154 print
'<td class="center"><input type="submit" value="'.$langs->trans(
"Add").
'" class="button"></td>';
1160 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>';
1162 print $langs->trans(
"No");
1163 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>';
1171 print
'<tr><td class="titlefield">'.$langs->trans(
"DefaultTaxRate").
'</td><td>';
1173 $positiverates =
'';
1175 $positiverates .= ($positiverates ?
'/' :
'').
price2num($object->tva_tx);
1177 if (
price2num($object->localtax1_type)) {
1178 $positiverates .= ($positiverates ?
'/' :
'').
price2num($object->localtax1_tx);
1180 if (
price2num($object->localtax2_type)) {
1181 $positiverates .= ($positiverates ?
'/' :
'').
price2num($object->localtax2_tx);
1183 if (empty($positiverates)) {
1184 $positiverates =
'0';
1186 echo
vatrate($positiverates.($object->default_vat_code ?
' ('.$object->default_vat_code.
')' :
''),
'%', $object->tva_npr, 0, 1);
1196 print
'<tr class="field_selling_price"><td>'.$langs->trans(
"SellingPrice").
'</td><td>';
1197 if ($object->price_base_type ==
'TTC') {
1198 print
price($object->price_ttc).
' '.$langs->trans($object->price_base_type);
1200 print
price($object->price).
' '.$langs->trans($object->price_base_type);
1201 if (!empty($conf->global->PRODUCT_DISPLAY_VAT_INCL_PRICES) && !empty($object->price_ttc)) {
1202 print
'<i class="opacitymedium"> - ' .
price($object->price_ttc).
' '.$langs->trans(
'TTC') .
'</i>';
1209 print
'<tr class="field_min_price"><td>'.$langs->trans(
"MinPrice").
'</td><td>';
1210 if ($object->price_base_type ==
'TTC') {
1211 print
price($object->price_min_ttc).
' '.$langs->trans($object->price_base_type);
1213 print
price($object->price_min).
' '.$langs->trans($object->price_base_type);
1214 if (!empty($conf->global->PRODUCT_DISPLAY_VAT_INCL_PRICES) && !empty($object->price_min_ttc)) {
1215 print
'<i class="opacitymedium"> - ' .
price($object->price_min_ttc).
' '.$langs->trans(
'TTC') .
'</i>';
1222 if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY) || !empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) {
1223 print
'<tr><td>'.$langs->trans(
"PriceByQuantity");
1224 if ($object->prices_by_qty[0] == 0) {
1225 print
' <a href="'.$_SERVER[
'PHP_SELF'].
'?id='.$object->id.
'&action=activate_price_by_qty&level=1&token='.
newToken().
'">('.$langs->trans(
"Activate").
')';
1227 print
' <a href="'.$_SERVER[
'PHP_SELF'].
'?id='.$object->id.
'&action=disable_price_by_qty&level=1&token='.
newToken().
'">('.$langs->trans(
"DisablePriceByQty").
')';
1231 if ($object->prices_by_qty[0] == 1) {
1232 print
'<table width="50%" class="border" summary="List of quantities">';
1233 print
'<tr class="liste_titre">';
1235 print
'<td>'.$langs->trans(
"Quantity").
'</td>';
1236 print
'<td class="right">'.$langs->trans(
"Price").
'</td>';
1237 print
'<td class="right"></td>';
1238 print
'<td class="right">'.$langs->trans(
"UnitPrice").
'</td>';
1239 print
'<td class="right">'.$langs->trans(
"Discount").
'</td>';
1240 print
'<td> </td>';
1242 if ($action !=
'edit_price_by_qty') {
1243 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'" method="POST">';
1244 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1245 print
'<input type="hidden" name="action" value="update_price_by_qty">';
1246 print
'<input type="hidden" name="priceid" value="'.$object->prices_by_qty_id[0].
'">';
1247 print
'<input type="hidden" value="0" name="rowid">';
1249 print
'<tr class="'.($ii % 2 == 0 ?
'pair' :
'impair').
'">';
1250 print
'<td><input size="5" type="text" value="1" name="quantity"></td>';
1251 print
'<td class="right"><input class="width50 right" type="text" value="0" name="price"></td>';
1255 print
'<td class="right"> </td>';
1256 print
'<td class="right nowraponall"><input type="text" class="width50 right" value="0" name="remise_percent"> %</td>';
1257 print
'<td class="center"><input type="submit" value="'.$langs->trans(
"Add").
'" class="button"></td>';
1262 foreach ($object->prices_by_qty_list[0] as $ii => $prices) {
1263 if ($action ==
'edit_price_by_qty' && $rowid == $prices[
'rowid'] && ($user->rights->produit->creer || $user->rights->service->creer)) {
1264 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'" method="POST">';
1265 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1266 print
'<input type="hidden" name="action" value="update_price_by_qty">';
1267 print
'<input type="hidden" name="priceid" value="'.$object->prices_by_qty_id[0].
'">';
1268 print
'<input type="hidden" value="'.$prices[
'rowid'].
'" name="rowid">';
1269 print
'<tr class="'.($ii % 2 == 0 ?
'pair' :
'impair').
'">';
1270 print
'<td><input size="5" type="text" value="'.$prices[
'quantity'].
'" name="quantity"></td>';
1271 print
'<td class="right"><input class="width50 right" type="text" value="'.price2num($prices[
'price'],
'MU').
'" name="price"></td>';
1272 print
'<td class="right">';
1274 print $prices[
'price_base_type'];
1276 print
'<td class="right"> </td>';
1277 print
'<td class="right nowraponall"><input class="width50 right" type="text" value="'.$prices[
'remise_percent'].
'" name="remise_percent"> %</td>';
1278 print
'<td class="center"><input type="submit" value="'.$langs->trans(
"Modify").
'" class="button"></td>';
1282 print
'<tr class="'.($ii % 2 == 0 ?
'pair' :
'impair').
'">';
1283 print
'<td>'.$prices[
'quantity'].
'</td>';
1284 print
'<td class="right">'.price($prices[
'price']).
'</td>';
1285 print
'<td class="right">';
1287 print $prices[
'price_base_type'];
1289 print
'<td class="right">'.price($prices[
'unitprice']).
'</td>';
1290 print
'<td class="right">'.price($prices[
'remise_percent']).
' %</td>';
1291 print
'<td class="center">';
1292 if (($user->rights->produit->creer || $user->rights->service->creer)) {
1293 print
'<a class="editfielda marginleftonly marginrightonly" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=edit_price_by_qty&token='.
newToken().
'&rowid='.$prices[
"rowid"].
'">';
1295 print
'<a class="marginleftonly marginrightonly" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=delete_price_by_qty&token='.
newToken().
'&rowid='.$prices[
"rowid"].
'">';
1306 print $langs->trans(
"No");
1315 print
'<div style="clear:both"></div>';
1327 if (!$action || $action ==
'delete' || $action ==
'showlog_customer_price' || $action ==
'showlog_default_price' || $action ==
'add_customer_price'
1328 || $action ==
'activate_price_by_qty' || $action ==
'disable_price_by_qty') {
1329 print
"\n".
'<div class="tabsAction">'.
"\n";
1332 $parameters = array();
1333 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters, $object, $action);
1334 if (empty($reshook)) {
1335 if ($object->isVariant()) {
1336 if ($user->rights->produit->creer || $user->rights->service->creer) {
1337 print
'<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="' .
dol_escape_htmltag($langs->trans(
"NoEditVariants")) .
'">' . $langs->trans(
"UpdateDefaultPrice") .
'</a></div>';
1340 if (empty($conf->global->PRODUIT_MULTIPRICES) && empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) {
1341 if ($user->rights->produit->creer || $user->rights->service->creer) {
1342 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>';
1344 print
'<div class="inline-block divButAction"><span class="butActionRefused" title="'.dol_escape_htmltag($langs->trans(
"NotEnoughPermissions")).
'">' . $langs->trans(
"UpdateDefaultPrice") .
'</span></div>';
1348 if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) {
1349 if ($user->rights->produit->creer || $user->rights->service->creer) {
1350 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>';
1352 print
'<div class="inline-block divButAction"><span class="butActionRefused" title="'.dol_escape_htmltag($langs->trans(
"NotEnoughPermissions")).
'">' . $langs->trans(
"AddCustomerPrice") .
'</span></div>';
1356 if (!empty($conf->global->PRODUIT_MULTIPRICES) || !empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) {
1357 if ($user->rights->produit->creer || $user->rights->service->creer) {
1358 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>';
1360 print
'<div class="inline-block divButAction"><span class="butActionRefused" title="'.dol_escape_htmltag($langs->trans(
"NotEnoughPermissions")).
'">' . $langs->trans(
"UpdateVAT") .
'</span></div>';
1363 if ($user->rights->produit->creer || $user->rights->service->creer) {
1364 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>';
1366 print
'<div class="inline-block divButAction"><span class="butActionRefused" title="'.dol_escape_htmltag($langs->trans(
"NotEnoughPermissions")).
'">' . $langs->trans(
"UpdateLevelPrices") .
'</span></div>';
1381 if ($action ==
'edit_vat' && ($user->rights->produit->creer || $user->rights->service->creer)) {
1384 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'" method="POST">';
1385 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1386 print
'<input type="hidden" name="action" value="update_vat">';
1387 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
1391 print
'<table class="border centpercent">';
1394 print
'<tr><td>'.$langs->trans(
"DefaultTaxRate").
'</td><td>';
1395 print
$form->load_tva(
"tva_tx", $object->default_vat_code ? $object->tva_tx.
' ('.$object->default_vat_code.
')' : $object->tva_tx, $mysoc,
'', $object->id, $object->tva_npr, $object->type,
false, 1);
1402 print
$form->buttonsSaveCancel();
1404 print
'<br></form><br>';
1407 if ($action ==
'edit_price' && $object->getRights()->creer) {
1411 if (empty($conf->global->PRODUIT_MULTIPRICES) && empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) {
1412 print
'<!-- Edit price -->'.
"\n";
1413 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'" method="POST">';
1414 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1415 print
'<input type="hidden" name="action" value="update_price">';
1416 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
1420 print
'<div class="div-table-responsive-no-min">';
1421 print
'<table class="border centpercent">';
1424 print
'<tr><td class="titlefield">'.$langs->trans(
"DefaultTaxRate").
'</td><td>';
1425 print
$form->load_tva(
"tva_tx", $object->default_vat_code ? $object->tva_tx.
' ('.$object->default_vat_code.
')' : $object->tva_tx, $mysoc,
'', $object->id, $object->tva_npr, $object->type,
false, 1);
1430 print $langs->trans(
'PriceBase');
1433 print
$form->selectPriceBaseType($object->price_base_type,
"price_base_type");
1438 if (!empty($conf->dynamicprices->enabled)) {
1440 print
'<!-- Show price mode of dynamicprices editor -->'.
"\n";
1441 print
'<tr><td>'.$langs->trans(
"PriceMode").
'</td><td>';
1442 print
img_picto(
'',
'dynamicprice',
'class="pictofixedwidth"');
1444 $price_expression_list = array(0 => $langs->trans(
"Numeric").
' <span class="opacitymedium">('.$langs->trans(
"NoDynamicPrice").
')</span>');
1445 foreach ($price_expression->list_price_expression() as $entry) {
1446 $price_expression_list[$entry->id] = $entry->title;
1448 $price_expression_preselection =
GETPOST(
'eid') ?
GETPOST(
'eid') : ($object->fk_price_expression ? $object->fk_price_expression :
'0');
1449 print
$form->selectarray(
'eid', $price_expression_list, $price_expression_preselection);
1450 print
' <a id="expression_editor" class="classlink">'.$langs->trans(
"PriceExpressionEditor").
'</a>';
1456 <script
type=
"text/javascript">
1457 jQuery(document).ready(
function() {
1458 jQuery(
"#expression_editor").click(
function() {
1459 window.location =
"<?php echo DOL_URL_ROOT ?>/product/dynamic_price/editor.php?id=<?php echo $id ?>&tab=price&eid=" + $(
"#eid").val();
1461 jQuery(
"#eid").change(on_change);
1464 function on_change() {
1465 if ($(
"#eid").val() == 0) {
1466 jQuery(
"#price_numeric").show();
1468 jQuery(
"#price_numeric").hide();
1477 $product->fetch($id, $ref,
'', 1);
1478 print
'<tr id="price_numeric"><td>';
1479 $text = $langs->trans(
'SellingPrice');
1480 print
$form->textwithpicto($text, $langs->trans(
"PrecisionUnitIsLimitedToXDecimals", $conf->global->MAIN_MAX_DECIMALS_UNIT), 1, 1);
1482 if ($object->price_base_type ==
'TTC') {
1483 print
'<input name="price" size="10" value="'.price($product->price_ttc).
'">';
1485 print
'<input name="price" size="10" value="'.price($product->price).
'">';
1491 $text = $langs->trans(
'MinPrice');
1492 print
$form->textwithpicto($text, $langs->trans(
"PrecisionUnitIsLimitedToXDecimals", $conf->global->MAIN_MAX_DECIMALS_UNIT), 1, 1);
1494 if ($object->price_base_type ==
'TTC') {
1495 print
'<input name="price_min" size="10" value="'.price($object->price_min_ttc).
'">';
1497 print
'<input name="price_min" size="10" value="'.price($object->price_min).
'">';
1499 if (!empty($conf->global->PRODUCT_MINIMUM_RECOMMENDED_PRICE)) {
1500 print
' '.$langs->trans(
"MinimumRecommendedPrice",
price($maxpricesupplier, 0,
'', 1, -1, -1,
'auto')).
' '.
img_warning().
'</td>';
1505 $parameters = array();
1506 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters, $object, $action);
1513 print
$form->buttonsSaveCancel();
1517 print
'<!-- Edit price per level -->'.
"\n";
1521 var showHidePriceRules =
function () {
1522 var otherPrices = $(
'div.fiche form table tbody tr:not(:first)');
1523 var minPrice1 = $(
'div.fiche form input[name="price_min[1]"]');
1525 if (jQuery(
'input#usePriceRules').prop(
'checked')) {
1534 jQuery(document).ready(
function () {
1535 showHidePriceRules();
1537 jQuery(
'input#usePriceRules').click(showHidePriceRules);
1542 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'" method="POST">';
1543 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1544 print
'<input type="hidden" name="action" value="update_price">';
1545 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
1549 if ((!empty($conf->global->PRODUIT_MULTIPRICES) || !empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) && !empty($conf->global->PRODUIT_MULTIPRICES_ALLOW_AUTOCALC_PRICELEVEL)) {
1550 print $langs->trans(
'UseMultipriceRules').
' <input type="checkbox" id="usePriceRules" name="usePriceRules" '.($object->price_autogen ?
'checked' :
'').
'><br><br>';
1553 print
'<div class="div-table-responsive-no-min">';
1554 print
'<table class="noborder">';
1555 print
'<thead><tr class="liste_titre">';
1557 print
'<td>'.$langs->trans(
"PriceLevel").
'</td>';
1559 if (!empty($conf->global->PRODUIT_MULTIPRICES_USE_VAT_PER_LEVEL)) {
1560 print
'<td style="text-align: center">'.$langs->trans(
"DefaultTaxRate").
'</td>';
1565 print
'<td class="center">'.$langs->trans(
"SellingPrice").
'</td>';
1567 print
'<td class="center">'.$langs->trans(
"MinPrice").
'</td>';
1569 if (!empty($conf->global->PRODUCT_MINIMUM_RECOMMENDED_PRICE)) {
1572 print
'</tr></thead>';
1576 for ($i = 1; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i++) {
1577 print
'<tr class="oddeven">';
1579 $text = $langs->trans(
'SellingPrice').
' '.$i;
1580 print
$form->textwithpicto($text, $langs->trans(
"PrecisionUnitIsLimitedToXDecimals", $conf->global->MAIN_MAX_DECIMALS_UNIT), 1, 1);
1584 if (empty($conf->global->PRODUIT_MULTIPRICES_USE_VAT_PER_LEVEL)) {
1586 print
'<input type="hidden" name="tva_tx['.$i.
']" value="'.($object->default_vat_code ? $object->tva_tx.
' ('.$object->default_vat_code.
')' : $object->tva_tx).
'">';
1587 print
'<input type="hidden" name="tva_npr['.$i.
']" value="'.$object->tva_npr.
'">';
1588 print
'<input type="hidden" name="localtax1_tx['.$i.
']" value="'.$object->localtax1_tx.
'">';
1589 print
'<input type="hidden" name="localtax1_type['.$i.
']" value="'.$object->localtax1_type.
'">';
1590 print
'<input type="hidden" name="localtax2_tx['.$i.
']" value="'.$object->localtax2_tx.
'">';
1591 print
'<input type="hidden" name="localtax2_type['.$i.
']" value="'.$object->localtax2_type.
'">';
1595 print
'<td style="text-align: center">';
1596 print
$form->load_tva(
"tva_tx[".$i.
']', $object->multiprices_tva_tx[$i], $mysoc,
'', $object->id,
false, $object->type,
false, 1);
1601 print
'<td style="text-align: center">';
1602 if ($object->multiprices_base_type [$i] ==
'TTC') {
1603 print
'<input name="price['.$i.
']" size="10" value="'.
price($object->multiprices_ttc [$i]).
'">';
1605 print
'<input name="price['.$i.
']" size="10" value="'.
price($object->multiprices [$i]).
'">';
1607 print
' '.$form->selectPriceBaseType($object->multiprices_base_type [$i],
"multiprices_base_type[".$i.
"]");
1611 print
'<td style="text-align: center">';
1612 if ($object->multiprices_base_type [$i] ==
'TTC') {
1613 print
'<input name="price_min['.$i.
']" size="10" value="'.
price($object->multiprices_min_ttc [$i]).
'">';
1615 print
'<input name="price_min['.$i.
']" size="10" value="'.
price($object->multiprices_min [$i]).
'">';
1617 if (!empty($conf->global->PRODUCT_MINIMUM_RECOMMENDED_PRICE)) {
1618 print
'<td class="left">'.$langs->trans(
"MinimumRecommendedPrice",
price($maxpricesupplier, 0,
'', 1, -1, -1,
'auto')).
' '.
img_warning().
'</td>';
1632 print
$form->buttonsSaveCancel();
1641 if ((empty($conf->global->PRODUIT_CUSTOMER_PRICES) || $action ==
'showlog_default_price') && !in_array($action, array(
'edit_price',
'edit_vat'))) {
1642 $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,";
1643 $sql .=
" p.price_level, p.price_min, p.price_min_ttc,p.price_by_qty,";
1644 $sql .=
" p.date_price as dp, p.fk_price_expression, u.rowid as user_id, u.login";
1645 $sql .=
" FROM ".MAIN_DB_PREFIX.
"product_price as p,";
1646 $sql .=
" ".MAIN_DB_PREFIX.
"user as u";
1647 $sql .=
" WHERE fk_product = ".((int) $object->id);
1648 $sql .=
" AND p.entity IN (".getEntity(
'productprice').
")";
1649 $sql .=
" AND p.fk_user_author = u.rowid";
1650 if (!empty($socid) && !empty($conf->global->PRODUIT_MULTIPRICES)) {
1651 $sql .=
" AND p.price_level = ".((int) $soc->price_level);
1653 $sql .=
" ORDER BY p.date_price DESC, p.rowid DESC, p.price_level ASC";
1657 $result = $db->query($sql);
1659 print
'<div class="divlogofpreviouscustomerprice">';
1661 $num = $db->num_rows($result);
1669 if (!empty($conf->global->PRODUIT_MULTIPRICES)) {
1670 $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);
1672 $ret = $object->updatePrice(($object->price_base_type ==
'TTC' ? $object->price_ttc : $object->price), $object->price_base_type, $user, $object->tva_tx, ($object->price_base_type ==
'TTC' ? $object->price_min_ttc : $object->price_min));
1678 $result = $db->query($sql);
1679 $num = $db->num_rows($result);
1686 $backbutton =
'<a class="justalink" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'">'.$langs->trans(
"Back").
'</a>';
1688 if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) {
1689 print_barre_liste($langs->trans(
"DefaultPriceLog"), 0, $_SERVER[
"PHP_SELF"],
'',
'',
'', $backbutton, 0, $num,
'title_accountancy.png');
1691 print_barre_liste($langs->trans(
"PriceByCustomerLog"), 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', 0, $num,
'title_accountancy.png');
1694 print
'<!-- List of log prices -->'.
"\n";
1695 print
'<div class="div-table-responsive">'.
"\n";
1696 print
'<table class="liste centpercent">'.
"\n";
1698 print
'<tr class="liste_titre">';
1699 print
'<td>'.$langs->trans(
"AppliedPricesFrom").
'</td>';
1701 if (!empty($conf->global->PRODUIT_MULTIPRICES) || !empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) {
1702 print
'<td class="center">'.$langs->trans(
"PriceLevel").
'</td>';
1704 if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY) || !empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) {
1705 print
'<td class="center">'.$langs->trans(
"Type").
'</td>';
1708 print
'<td class="center">'.$langs->trans(
"PriceBase").
'</td>';
1709 if (empty($conf->global->PRODUIT_MULTIPRICES) && empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) {
1710 print
'<td class="right">'.$langs->trans(
"DefaultTaxRate").
'</td>';
1712 print
'<td class="right">'.$langs->trans(
"HT").
'</td>';
1713 print
'<td class="right">'.$langs->trans(
"TTC").
'</td>';
1714 if ($mysoc->localtax1_assuj ==
"1" || $mysoc->localtax2_assuj ==
"1") {
1715 print
'<td class="right">'.$langs->trans(
"INCT").
'</td>';
1717 if (!empty($conf->dynamicprices->enabled)) {
1718 print
'<td class="right">'.$langs->trans(
"PriceExpressionSelected").
'</td>';
1720 print
'<td class="right">'.$langs->trans(
"MinPrice").
' '.$langs->trans(
"HT").
'</td>';
1721 print
'<td class="right">'.$langs->trans(
"MinPrice").
' '.$langs->trans(
"TTC").
'</td>';
1722 print
'<td class="right">'.$langs->trans(
"ChangedBy").
'</td>';
1723 if ($user->rights->produit->supprimer) {
1724 print
'<td class="right"> </td>';
1728 $notfirstlineforlevel = array();
1732 $objp = $db->fetch_object($result);
1734 print
'<tr class="oddeven">';
1736 print
"<td>".dol_print_date($db->jdate($objp->dp),
"dayhour",
'tzuserrel').
"</td>";
1739 if (!empty($conf->global->PRODUIT_MULTIPRICES) || !empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) {
1740 print
'<td class="center">'.$objp->price_level.
"</td>";
1743 if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY) || !empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) {
1744 $type = ($objp->price_by_qty == 1) ?
'PriceByQuantity' :
'Standard';
1745 print
'<td class="center">'.$langs->trans($type).
"</td>";
1748 print
'<td class="center">';
1749 if (empty($objp->price_by_qty)) {
1750 print $langs->trans($objp->price_base_type);
1754 if (empty($conf->global->PRODUIT_MULTIPRICES) && empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) {
1755 print
'<td class="right">';
1757 if (empty($objp->price_by_qty)) {
1758 $positiverates =
'';
1760 $positiverates .= ($positiverates ?
'/' :
'').
price2num($objp->tva_tx);
1763 $positiverates .= ($positiverates ?
'/' :
'').
price2num($objp->localtax1_tx);
1766 $positiverates .= ($positiverates ?
'/' :
'').
price2num($objp->localtax2_tx);
1768 if (empty($positiverates)) {
1769 $positiverates =
'0';
1771 echo
vatrate($positiverates.($objp->default_vat_code ?
' ('.$objp->default_vat_code.
')' :
''),
'%', !empty($objp->tva_npr) ? $objp->tva_npr : 0);
1784 if ($objp->price_base_type ==
'HT') {
1787 $pu = $objp->price_ttc;
1791 $localtaxarray =
getLocalTaxesFromRate($objp->tva_tx.($object->default_vat_code ?
' ('.$object->default_vat_code.
')' :
''), 0, $mysoc, $mysoc);
1793 $resultarray =
calcul_price_total(1, $pu, 0, $objp->tva_tx, 1, 1, 0, $objp->price_base_type, $objp->recuperableonly, $object->type, $mysoc, $localtaxarray);
1795 $total_ht = $resultarray[0];
1796 $total_vat = $resultarray[1];
1797 $total_localtax1 = $resultarray[9];
1798 $total_localtax2 = $resultarray[10];
1799 $total_ttc = $resultarray[2];
1802 if (!empty($objp->fk_price_expression) && !empty($conf->dynamicprices->enabled)) {
1804 $res = $price_expression->fetch($objp->fk_price_expression);
1805 $title = $price_expression->title;
1806 print
'<td class="right"></td>';
1807 print
'<td class="right"></td>';
1808 if ($mysoc->localtax1_assuj ==
"1" || $mysoc->localtax2_assuj ==
"1") {
1809 print
'<td class="right"></td>';
1811 print
'<td class="right">'.$title.
"</td>";
1814 print
'<td class="right">';
1815 if (empty($objp->price_by_qty)) {
1816 print
'<span class="amount">'.price($objp->price).
'</span>';
1820 print
'<td class="right">';
1821 if (empty($objp->price_by_qty)) {
1822 $price_ttc = $objp->price_ttc;
1823 print
'<span class="amount">'.price($price_ttc).
'<span>';
1826 if ($mysoc->localtax1_assuj ==
"1" || $mysoc->localtax2_assuj ==
"1") {
1827 print
'<td class="right">';
1828 print $resultarray[2];
1831 if (!empty($conf->dynamicprices->enabled)) {
1832 print
'<td class="right"></td>';
1837 print
'<td class="right">';
1838 if (empty($objp->price_by_qty)) {
1839 print
price($objp->price_min);
1844 print
'<td class="right">';
1845 if (empty($objp->price_by_qty)) {
1846 $price_min_ttc = $objp->price_min_ttc;
1847 print
price($price_min_ttc);
1852 print
'<td class="right">';
1853 if ($objp->user_id > 0) {
1854 $userstatic =
new User($db);
1855 $userstatic->fetch($objp->user_id);
1856 print $userstatic->getNomUrl(1,
'', 0, 0, 24, 0,
'login');
1861 if ($user->rights->produit->supprimer) {
1863 if (!empty($conf->global->PRODUIT_MULTIPRICES) || !empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) {
1864 if (empty($notfirstlineforlevel[$objp->price_level])) {
1865 $notfirstlineforlevel[$objp->price_level] = 1;
1873 print
'<td class="right">';
1874 if ($candelete || ($db->jdate($objp->dp) >=
dol_now())) {
1875 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=delete&token='.
newToken().
'&id='.$object->id.
'&lineid='.$objp->rowid.
'">';
1902 if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) {
1905 $limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
1906 $sortfield =
GETPOST(
'sortfield',
'aZ09comma');
1907 $sortorder =
GETPOST(
'sortorder',
'aZ09comma');
1909 if (empty($page) || $page == -1) {
1912 $offset = $limit * $page;
1913 $pageprev = $page - 1;
1914 $pagenext = $page + 1;
1919 $sortfield =
"soc.nom";
1923 $filter = array(
't.fk_product' => $object->id);
1925 if (!empty($search_soc)) {
1926 $filter[
'soc.nom'] = $search_soc;
1929 if ($action ==
'add_customer_price') {
1931 $maxpricesupplier = $object->min_recommended_price();
1933 print
'<!-- add_customer_price -->';
1936 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'" method="POST">';
1937 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1938 print
'<input type="hidden" name="action" value="add_customer_price_confirm">';
1939 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
1941 print
'<div class="tabBar tabBarWithBottom">';
1943 print
'<table class="border centpercent">';
1945 print
'<td class="fieldrequired">'.$langs->trans(
'ThirdParty').
'</td>';
1947 print
img_picto(
'',
'company').$form->select_company(
'',
'socid',
's.client IN (1,2,3)',
'SelectThirdParty', 0, 0, array(), 0,
'minwidth300');
1952 print
'<tr><td>' . $langs->trans(
'RefCustomer') .
'</td>';
1953 print
'<td><input name="ref_customer" size="12"></td></tr>';
1956 print
'<tr><td class="fieldrequired">'.$langs->trans(
"DefaultTaxRate").
'</td><td>';
1957 print
$form->load_tva(
"tva_tx", $object->default_vat_code ? $object->tva_tx.
' ('.$object->default_vat_code.
')' : $object->tva_tx, $mysoc,
'', $object->id, $object->tva_npr, $object->type,
false, 1);
1961 print
'<tr><td class="fieldrequired">';
1962 print $langs->trans(
'PriceBase');
1965 print
$form->selectPriceBaseType($object->price_base_type,
"price_base_type");
1970 print
'<tr><td class="fieldrequired">';
1971 $text = $langs->trans(
'SellingPrice');
1972 print
$form->textwithpicto($text, $langs->trans(
"PrecisionUnitIsLimitedToXDecimals", $conf->global->MAIN_MAX_DECIMALS_UNIT), 1, 1);
1974 if ($object->price_base_type ==
'TTC') {
1975 print
'<input name="price" size="10" value="'.price($object->price_ttc).
'">';
1977 print
'<input name="price" size="10" value="'.price($object->price).
'">';
1983 $text = $langs->trans(
'MinPrice');
1984 print
$form->textwithpicto($text, $langs->trans(
"PrecisionUnitIsLimitedToXDecimals", $conf->global->MAIN_MAX_DECIMALS_UNIT), 1, 1);
1985 if ($object->price_base_type ==
'TTC') {
1986 print
'<td><input name="price_min" size="10" value="'.price($object->price_min_ttc).
'">';
1988 print
'<td><input name="price_min" size="10" value="'.price($object->price_min).
'">';
1990 if (!empty($conf->global->PRODUCT_MINIMUM_RECOMMENDED_PRICE)) {
1991 print
'<td class="left">'.$langs->trans(
"MinimumRecommendedPrice",
price($maxpricesupplier, 0,
'', 1, -1, -1,
'auto')).
' '.
img_warning().
'</td>';
2000 print
'<div class="center">';
2003 print
'<div class="marginbottomonly">';
2004 print
'<input type="checkbox" name="updatechildprice" id="updatechildprice" value="1"> ';
2005 print
'<label for="updatechildprice">'.$langs->trans(
'ForceUpdateChildPriceSoc').
'</label>';
2008 print
$form->buttonsSaveCancel();
2011 } elseif ($action ==
'edit_customer_price') {
2013 $maxpricesupplier = $object->min_recommended_price();
2015 print
'<!-- edit_customer_price -->';
2018 $result = $prodcustprice->fetch(
GETPOST(
'lineid',
'int'));
2023 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'" method="POST">';
2024 print
'<input type="hidden" name="token" value="'.newToken().
'">';
2025 print
'<input type="hidden" name="action" value="update_customer_price_confirm">';
2026 print
'<input type="hidden" name="lineid" value="'.$prodcustprice->id.
'">';
2028 print
'<table class="liste centpercent">';
2030 print
'<td class="titlefield fieldrequired">'.$langs->trans(
'ThirdParty').
'</td>';
2031 $staticsoc =
new Societe($db);
2032 $staticsoc->fetch($prodcustprice->fk_soc);
2033 print
"<td>".$staticsoc->getNomUrl(1).
"</td>";
2037 print
'<tr><td>' . $langs->trans(
'RefCustomer') .
'</td>';
2038 print
'<td><input name="ref_customer" size="12" value="' .
dol_escape_htmltag($prodcustprice->ref_customer) .
'"></td></tr>';
2041 print
'<tr><td class="fieldrequired">'.$langs->trans(
"DefaultTaxRate").
'</td><td>';
2042 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);
2046 print
'<tr><td class="fieldrequired">';
2047 print $langs->trans(
'PriceBase');
2050 print
$form->selectPriceBaseType($prodcustprice->price_base_type,
"price_base_type");
2055 print
'<tr><td class="fieldrequired">';
2056 $text = $langs->trans(
'SellingPrice');
2057 print
$form->textwithpicto($text, $langs->trans(
"PrecisionUnitIsLimitedToXDecimals", $conf->global->MAIN_MAX_DECIMALS_UNIT), 1, 1);
2059 if ($prodcustprice->price_base_type ==
'TTC') {
2060 print
'<input name="price" size="10" value="'.price($prodcustprice->price_ttc).
'">';
2062 print
'<input name="price" size="10" value="'.price($prodcustprice->price).
'">';
2068 $text = $langs->trans(
'MinPrice');
2069 print
$form->textwithpicto($text, $langs->trans(
"PrecisionUnitIsLimitedToXDecimals", $conf->global->MAIN_MAX_DECIMALS_UNIT), 1, 1);
2071 if ($prodcustprice->price_base_type ==
'TTC') {
2072 print
'<input name="price_min" size="10" value="'.price($prodcustprice->price_min_ttc).
'">';
2074 print
'<input name="price_min" size="10" value="'.price($prodcustprice->price_min).
'">';
2077 if (!empty($conf->global->PRODUCT_MINIMUM_RECOMMENDED_PRICE)) {
2078 print
'<td class="left">'.$langs->trans(
"MinimumRecommendedPrice",
price($maxpricesupplier, 0,
'', 1, -1, -1,
'auto')).
' '.
img_warning().
'</td>';
2085 print
'<div class="center">';
2086 print
'<div class="marginbottomonly">';
2087 print
'<input type="checkbox" name="updatechildprice" id="updatechildprice" value="1"> ';
2088 print
'<label for="updatechildprice">'.$langs->trans(
'ForceUpdateChildPriceSoc').
'</label>';
2091 print
$form->buttonsSaveCancel();
2093 print
'<br></form>';
2094 } elseif ($action ==
'showlog_customer_price') {
2096 print
'<!-- list of all log of prices per customer -->'.
"\n";
2098 $filter = array(
't.fk_product' => $object->id,
't.fk_soc' =>
GETPOST(
'socid',
'int'));
2102 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
2103 $nbtotalofrecords = $prodcustprice->fetch_all_log($sortorder, $sortfield, $conf->liste_limit, $offset, $filter);
2106 $result = $prodcustprice->fetch_all_log($sortorder, $sortfield, $conf->liste_limit, $offset, $filter);
2111 $option =
'&socid='.GETPOST(
'socid',
'int').
'&id='.$object->id;
2113 $staticsoc =
new Societe($db);
2114 $staticsoc->fetch(
GETPOST(
'socid',
'int'));
2116 $title = $langs->trans(
'PriceByCustomerLog');
2117 $title .=
' - '.$staticsoc->getNomUrl(1);
2119 $backbutton =
'<a class="justalink" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'">'.$langs->trans(
"Back").
'</a>';
2121 print_barre_liste($title, $page, $_SERVER[
'PHP_SELF'], $option, $sortfield, $sortorder, $backbutton, count($prodcustprice->lines),
$nbtotalofrecords,
'title_accountancy.png');
2123 if (count($prodcustprice->lines) > 0) {
2124 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'" method="POST">';
2125 print
'<input type="hidden" name="token" value="'.newToken().
'">';
2126 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
2128 print
'<div class="div-table-responsive-no-min">';
2129 print
'<table class="liste centpercent">';
2131 print
'<tr class="liste_titre">';
2132 print
'<td>'.$langs->trans(
"ThirdParty").
'</td>';
2133 print
'<td>'.$langs->trans(
'RefCustomer').
'</td>';
2134 print
'<td>'.$langs->trans(
"AppliedPricesFrom").
'</td>';
2135 print
'<td class="center">'.$langs->trans(
"PriceBase").
'</td>';
2136 print
'<td class="right">'.$langs->trans(
"DefaultTaxRate").
'</td>';
2137 print
'<td class="right">'.$langs->trans(
"HT").
'</td>';
2138 print
'<td class="right">'.$langs->trans(
"TTC").
'</td>';
2139 if ($mysoc->localtax1_assuj ==
"1" || $mysoc->localtax2_assuj ==
"1") {
2140 print
'<td class="right">'.$langs->trans(
"INCT").
'</td>';
2142 print
'<td class="right">'.$langs->trans(
"MinPrice").
' '.$langs->trans(
"HT").
'</td>';
2143 print
'<td class="right">'.$langs->trans(
"MinPrice").
' '.$langs->trans(
"TTC").
'</td>';
2144 print
'<td class="right">'.$langs->trans(
"ChangedBy").
'</td>';
2145 print
'<td> </td>';
2148 foreach ($prodcustprice->lines as $line) {
2150 $staticsoc =
new Societe($db);
2151 $staticsoc->fetch($line->fk_soc);
2153 $tva_tx = $line->default_vat_code ? $line->tva_tx.
' ('.$line->default_vat_code.
')' : $line->tva_tx;
2156 if ($line->price_base_type ==
'HT') {
2159 $pu = $line->price_ttc;
2163 $localtaxarray =
getLocalTaxesFromRate($line->tva_tx.($line->default_vat_code ?
' ('.$line->default_vat_code.
')' :
''), 0, $staticsoc, $mysoc);
2165 $resultarray =
calcul_price_total(1, $pu, 0, $line->tva_tx, 1, 1, 0, $line->price_base_type, $line->recuperableonly, $object->type, $mysoc, $localtaxarray);
2167 $total_ht = $resultarray[0];
2168 $total_vat = $resultarray[1];
2169 $total_localtax1 = $resultarray[9];
2170 $total_localtax2 = $resultarray[10];
2171 $total_ttc = $resultarray[2];
2173 print
'<tr class="oddeven">';
2175 print
"<td>".$staticsoc->getNomUrl(1).
"</td>";
2176 print
'<td>'.$line->ref_customer.
'</td>';
2177 print
"<td>".dol_print_date($line->datec,
"dayhour",
'tzuserrel').
"</td>";
2178 print
'<td class="center">'.$langs->trans($line->price_base_type).
"</td>";
2179 print
'<td class="right">';
2181 $positiverates =
'';
2183 $positiverates .= ($positiverates ?
'/' :
'').
price2num($line->tva_tx);
2186 $positiverates .= ($positiverates ?
'/' :
'').
price2num($line->localtax1_tx);
2189 $positiverates .= ($positiverates ?
'/' :
'').
price2num($line->localtax2_tx);
2191 if (empty($positiverates)) {
2192 $positiverates =
'0';
2195 echo
vatrate($positiverates.($line->default_vat_code ?
' ('.$line->default_vat_code.
')' :
''),
'%', ($line->tva_npr ? $line->tva_npr : $line->recuperableonly));
2199 print
'<td class="right"><span class="amount">'.price($line->price).
"</span></td>";
2201 print
'<td class="right"><span class="amount">'.price($line->price_ttc).
"</span></td>";
2202 if ($mysoc->localtax1_assuj ==
"1" || $mysoc->localtax2_assuj ==
"1") {
2203 print
'<td class="right">'.price($resultarray[2]).
'</td>';
2206 print
'<td class="right">'.price($line->price_min).
'</td>';
2207 print
'<td class="right">'.price($line->price_min_ttc).
'</td>';
2210 $userstatic =
new User($db);
2211 $userstatic->fetch($line->fk_user);
2212 print
'<td class="right">';
2213 print $userstatic->getNomUrl(1,
'', 0, 0, 24, 0,
'login');
2221 print $langs->trans(
'None');
2223 } elseif ($action !=
'showlog_default_price' && $action !=
'edit_price') {
2225 print
'<!-- list of all prices per customer -->'.
"\n";
2229 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
2230 $nbtotalofrecords = $prodcustprice->fetchAll($sortorder, $sortfield, 0, 0, $filter);
2233 $result = $prodcustprice->fetchAll($sortorder, $sortfield, $conf->liste_limit, $offset, $filter);
2238 $option =
'&search_soc='.$search_soc.
'&id='.$object->id;
2240 print_barre_liste($langs->trans(
'PriceByCustomer'), $page, $_SERVER [
'PHP_SELF'], $option, $sortfield, $sortorder,
'', count($prodcustprice->lines),
$nbtotalofrecords,
'title_accountancy.png');
2242 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'" method="POST">';
2243 print
'<input type="hidden" name="token" value="'.newToken().
'">';
2244 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
2246 print
'<!-- List of prices per customer -->'.
"\n";
2247 print
'<div class="div-table-responsive-no-min">'.
"\n";
2248 print
'<table class="liste centpercent">'.
"\n";
2250 if (count($prodcustprice->lines) > 0 || $search_soc) {
2252 if ($mysoc->localtax1_assuj ==
"1" || $mysoc->localtax2_assuj ==
"1") {
2256 print
'<tr class="liste_titre">';
2257 print
'<td class="liste_titre"><input type="text" class="flat maxwidth125" name="search_soc" value="'.$search_soc.
'"></td>';
2258 print
'<td class="liste_titre" colspan="'.$colspan.
'"> </td>';
2260 print
'<td class="liste_titre maxwidthsearch">';
2261 $searchpicto =
$form->showFilterAndCheckAddButtons(0);
2267 print
'<tr class="liste_titre">';
2268 print
'<td>'.$langs->trans(
"ThirdParty").
'</td>';
2269 print
'<td>'.$langs->trans(
'RefCustomer').
'</td>';
2270 print
'<td>'.$langs->trans(
"AppliedPricesFrom").
'</td>';
2271 print
'<td class="center">'.$langs->trans(
"PriceBase").
'</td>';
2272 print
'<td class="right">'.$langs->trans(
"DefaultTaxRate").
'</td>';
2273 print
'<td class="right">'.$langs->trans(
"HT").
'</td>';
2274 print
'<td class="right">'.$langs->trans(
"TTC").
'</td>';
2275 if ($mysoc->localtax1_assuj ==
"1" || $mysoc->localtax2_assuj ==
"1") {
2276 print
'<td class="right">'.$langs->trans(
"INCT").
'</td>';
2278 print
'<td class="right">'.$langs->trans(
"MinPrice").
' '.$langs->trans(
"HT").
'</td>';
2279 print
'<td class="right">'.$langs->trans(
"MinPrice").
' '.$langs->trans(
"TTC").
'</td>';
2280 print
'<td class="right">'.$langs->trans(
"ChangedBy").
'</td>';
2285 if ($object->price_base_type ==
'HT') {
2286 $pu = $object->price;
2288 $pu = $object->price_ttc;
2292 $localtaxarray =
getLocalTaxesFromRate($object->tva_tx.($object->default_vat_code ?
' ('.$object->default_vat_code.
')' :
''), 0, $mysoc, $mysoc);
2294 $resultarray =
calcul_price_total(1, $pu, 0, $object->tva_tx, 1, 1, 0, $object->price_base_type, $object->recuperableonly, $object->type, $mysoc, $localtaxarray);
2296 $total_ht = $resultarray[0];
2297 $total_vat = $resultarray[1];
2298 $total_localtax1 = $resultarray[9];
2299 $total_localtax2 = $resultarray[10];
2300 $total_ttc = $resultarray[2];
2302 print
'<tr class="oddeven">';
2303 print
'<td colspan="3">' . $langs->trans(
'Default') .
'</td>';
2305 print
'<td class="center">'.$langs->trans($object->price_base_type).
"</td>";
2308 print
'<td class="right">';
2310 $positiverates =
'';
2312 $positiverates .= ($positiverates ?
'/' :
'').
price2num($object->tva_tx);
2314 if (
price2num($object->localtax1_type)) {
2315 $positiverates .= ($positiverates ?
'/' :
'').
price2num($object->localtax1_tx);
2317 if (
price2num($object->localtax2_type)) {
2318 $positiverates .= ($positiverates ?
'/' :
'').
price2num($object->localtax2_tx);
2320 if (empty($positiverates)) {
2321 $positiverates =
'0';
2323 echo
vatrate($positiverates.($object->default_vat_code ?
' ('.$object->default_vat_code.
')' :
''),
'%', $object->tva_npr);
2329 print
'<td class="right"><span class="amount">'.price($object->price).
"</span></td>";
2331 print
'<td class="right"><span class="amount">'.price($object->price_ttc).
"</span></td>";
2332 if ($mysoc->localtax1_assuj ==
"1" || $mysoc->localtax2_assuj ==
"1") {
2334 print
'<td class="right"><span class="amount">'.price($resultarray[2]).
'</span></td>';
2337 print
'<td class="right">'.price($object->price_min).
'</td>';
2338 print
'<td class="right">'.price($object->price_min_ttc).
'</td>';
2339 print
'<td class="right">';
2341 if ($user->rights->produit->supprimer || $user->rights->service->supprimer) {
2342 print
'<td class="nowraponall">';
2343 print
'<a class="marginleftonly marginrightonly" href="'.$_SERVER[
"PHP_SELF"].
'?action=showlog_default_price&token='.
newToken().
'&id='.$object->id.
'">';
2344 print
img_info($langs->trans(
'PriceByCustomerLog'));
2347 print
'<a class="marginleftonly marginrightonly editfielda" href="'.$_SERVER[
"PHP_SELF"].
'?action=edit_price&token='.
newToken().
'&id='.$object->id.
'">';
2348 print
img_edit(
'default', 0,
'style="vertical-align: middle;"');
2354 if (count($prodcustprice->lines) > 0) {
2355 foreach ($prodcustprice->lines as $line) {
2357 $staticsoc =
new Societe($db);
2358 $staticsoc->fetch($line->fk_soc);
2360 $tva_tx = $line->default_vat_code ? $line->tva_tx.
' ('.$line->default_vat_code.
')' : $line->tva_tx;
2363 if ($line->price_base_type ==
'HT') {
2366 $pu = $line->price_ttc;
2370 $localtaxarray =
getLocalTaxesFromRate($line->tva_tx.($line->default_vat_code ?
' ('.$line->default_vat_code.
')' :
''), 0, $staticsoc, $mysoc);
2372 $resultarray =
calcul_price_total(1, $pu, 0, $line->tva_tx, 1, 1, 0, $line->price_base_type, $line->recuperableonly, $object->type, $mysoc, $localtaxarray);
2374 $total_ht = $resultarray[0];
2375 $total_vat = $resultarray[1];
2376 $total_localtax1 = $resultarray[9];
2377 $total_localtax2 = $resultarray[10];
2378 $total_ttc = $resultarray[2];
2380 print
'<tr class="oddeven">';
2382 print
"<td>".$staticsoc->getNomUrl(1).
"</td>";
2383 print
'<td>'.dol_escape_htmltag($line->ref_customer).
'</td>';
2384 print
"<td>".dol_print_date($line->datec,
"dayhour",
'tzuserrel').
"</td>";
2385 print
'<td class="center">'.$langs->trans($line->price_base_type).
"</td>";
2387 print
'<td class="right">';
2389 $positiverates =
'';
2391 $positiverates .= ($positiverates ?
'/' :
'').
price2num($line->tva_tx);
2394 $positiverates .= ($positiverates ?
'/' :
'').
price2num($line->localtax1_tx);
2397 $positiverates .= ($positiverates ?
'/' :
'').
price2num($line->localtax2_tx);
2399 if (empty($positiverates)) {
2400 $positiverates =
'0';
2403 echo
vatrate($positiverates.($line->default_vat_code ?
' ('.$line->default_vat_code.
')' :
''),
'%', ($line->tva_npr ? $line->tva_npr : $line->recuperableonly));
2407 print
'<td class="right"><span class="amount">'.price($line->price).
"</span></td>";
2409 print
'<td class="right"><span class="amount">'.price($line->price_ttc).
"</span></td>";
2410 if ($mysoc->localtax1_assuj ==
"1" || $mysoc->localtax2_assuj ==
"1") {
2412 print
'<td class="right"><span class="amount">'.price($resultarray[2]).
'</span></td>';
2415 print
'<td class="right">'.price($line->price_min).
'</td>';
2416 print
'<td class="right">'.price($line->price_min_ttc).
'</td>';
2419 $userstatic =
new User($db);
2420 $userstatic->fetch($line->fk_user);
2421 print
'<td class="right">';
2422 print $userstatic->getNomUrl(1,
'', 0, 0, 24, 0,
'login');
2427 if ($user->rights->produit->supprimer || $user->rights->service->supprimer) {
2428 print
'<td class="right nowraponall">';
2429 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=showlog_customer_price&token='.
newToken().
'&id='.$object->id.
'&socid='.$line->fk_soc.
'">';
2430 print
img_info($langs->trans(
'PriceByCustomerLog'));
2433 print
'<a class="marginleftonly editfielda" href="'.$_SERVER[
"PHP_SELF"].
'?action=edit_customer_price&token='.
newToken().
'&id='.$object->id.
'&lineid='.$line->id.
'">';
2434 print
img_edit(
'default', 0,
'style="vertical-align: middle;"');
2437 print
'<a class="marginleftonly" href="'.$_SERVER[
"PHP_SELF"].
'?action=delete_customer_price&token='.
newToken().
'&id='.$object->id.
'&lineid='.$line->id.
'">';
2438 print
img_delete(
'default',
'style="vertical-align: middle;"');
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 accesing price expression table.
Class to parse product price expressions.
Class to manage products or services.
const TYPE_PRODUCT
Regular product.
const TYPE_SERVICE
Service.
File of class to manage predefined price products or services by customer.
Class to manage third parties objects (customers, suppliers, prospects...)
Class to manage Dolibarr users.
if(isModEnabled('facture') &&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') &&!empty($user->rights->don->lire)) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->hasRight("commande", "lire") &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
dol_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='rowid', $fieldref='ref', $morehtmlref='', $moreparam='', $nodbprefix=0, $morehtmlleft='', $morehtmlstatus='', $onlybanner=0, $morehtmlright='')
Show tab footer of a card.
vatrate($rate, $addpercent=false, $info_bits=0, $usestarfornpr=0, $html=0)
Return a string with VAT rate label formated for view output Used into pdf and HTML pages.
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='')
Show tabs of a record.
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
img_delete($titlealt='default', $other='class="pictodelete"', $morecss='')
Show delete logo.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dol_get_fiche_end($notab=0)
Return tab footer of a card.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
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.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
getLocalTaxesFromRate($vatrate, $local, $buyer, $seller, $firstparamisid=0)
Get type and rate of localtaxes for a particular vat rate/country of a thirdparty.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
print_barre_liste($titre, $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.
get_localtax($vatrate, $local, $thirdparty_buyer="", $thirdparty_seller="", $vatnpr=0)
Return localtax rate for a particular vat, when selling a product with vat $vatrate,...
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.
isModEnabled($module)
Is Dolibarr module enabled.
img_edit($titlealt='default', $float=0, $other='')
Show logo editer/modifier fiche.
img_info($titlealt='default')
Show info logo.
div float
Buy price without taxes.
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.
$nbtotalofrecords
Count total nb of records.
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.