37 require
'../main.inc.php';
38 require_once DOL_DOCUMENT_ROOT.
'/core/lib/product.lib.php';
39 require_once DOL_DOCUMENT_ROOT.
'/core/lib/price.lib.php';
40 require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
41 require_once DOL_DOCUMENT_ROOT.
'/product/dynamic_price/class/price_expression.class.php';
42 require_once DOL_DOCUMENT_ROOT.
'/product/dynamic_price/class/price_parser.class.php';
44 if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) {
45 require_once DOL_DOCUMENT_ROOT.
'/product/class/productcustomerprice.class.php';
51 $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');
68 if ($user->socid) $socid = $user->socid;
69 $result =
restrictedArea($user,
'produit|service', $fieldvalue,
'product&product',
'',
'', $fieldtype);
71 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)) $conf->global->PRODUIT_MULTIPRICES_LIMIT = 5;
81 $hookmanager->initHooks(array(
'productpricecard',
'globalcard'));
88 if ($cancel) $action =
'';
90 $parameters = array(
'id'=>$id,
'ref'=>$ref);
91 $reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
92 if ($reshook < 0)
setEventMessages($hookmanager->error, $hookmanager->errors,
'errors');
96 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha'))
101 if ($action ==
'setlabelsellingprice' && $user->admin)
103 require_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
104 $keyforlabel =
'PRODUIT_MULTIPRICES_LABEL'.GETPOST(
'pricelevel');
109 if (($action ==
'update_vat') && !$cancel && ($user->rights->produit->creer || $user->rights->service->creer))
111 $tva_tx_txt =
GETPOST(
'tva_tx',
'alpha');
114 $tva_tx = $tva_tx_txt;
117 if (preg_match(
'/\((.*)\)/', $tva_tx_txt, $reg))
119 $vat_src_code = $reg[1];
120 $tva_tx = preg_replace(
'/\s*\(.*\)/',
'', $tva_tx_txt);
123 $tva_tx =
price2num(preg_replace(
'/\*/',
'', $tva_tx));
124 $npr = preg_match(
'/\*/', $tva_tx_txt) ? 1 : 0;
125 $localtax1 = 0; $localtax2 = 0; $localtax1_type =
'0'; $localtax2_type =
'0';
127 if (preg_match(
'/\((.*)\)/', $tva_tx_txt, $reg))
130 $vatratecode = $reg[1];
132 $sql =
"SELECT t.rowid, t.code, t.recuperableonly, t.localtax1, t.localtax2, t.localtax1_type, t.localtax2_type";
133 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_tva as t, ".MAIN_DB_PREFIX.
"c_country as c";
134 $sql .=
" WHERE t.fk_pays = c.rowid AND c.code = '".$db->escape($mysoc->country_code).
"'";
135 $sql .=
" AND t.taux = ".((float) $tva_tx).
" AND t.active = 1";
136 $sql .=
" AND t.code ='".$db->escape($vatratecode).
"'";
137 $resql = $db->query($sql);
140 $obj = $db->fetch_object(
$resql);
141 $npr = $obj->recuperableonly;
142 $localtax1 = $obj->localtax1;
143 $localtax2 = $obj->localtax2;
144 $localtax1_type = $obj->localtax1_type;
145 $localtax2_type = $obj->localtax2_type;
149 $object->default_vat_code = $vatratecode;
150 $object->tva_tx = $tva_tx;
151 $object->tva_npr = $npr;
152 $object->localtax1_tx = $localtax1;
153 $object->localtax2_tx = $localtax2;
154 $object->localtax1_type = $localtax1_type;
155 $object->localtax2_type = $localtax2_type;
159 $resql = $object->update($object->id, $user);
169 $localtaxarray = array();
170 $object->updatePrice(0, $object->price_base_type, $user, $tva_tx,
'', 0, $npr, 0, 0, $localtaxarray, $vatratecode);
183 if (($action ==
'update_price') && !$cancel && $object->getRights()->creer)
186 $pricestoupdate = array();
189 $psq = empty($newpsq) ? 0 : $newpsq;
190 $maxpricesupplier = $object->min_recommended_price();
192 if (!empty($conf->dynamicprices->enabled)) {
193 $object->fk_price_expression = empty($eid) ? 0 : $eid;
195 if ($object->fk_price_expression != 0) {
199 if ($priceparser->parseProduct($object) < 0) {
207 if (!$error && (!empty($conf->global->PRODUIT_MULTIPRICES) || !empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES))) {
208 $newprice =
GETPOST(
'price',
'array');
209 $newprice_min =
GETPOST(
'price_min',
'array');
210 $newpricebase =
GETPOST(
'multiprices_base_type',
'array');
211 $newvattx =
GETPOST(
'tva_tx',
'array');
212 $newvatnpr =
GETPOST(
'tva_npr',
'array');
213 $newlocaltax1_tx =
GETPOST(
'localtax1_tx',
'array');
214 $newlocaltax1_type =
GETPOST(
'localtax1_type',
'array');
215 $newlocaltax2_tx =
GETPOST(
'localtax2_tx',
'array');
216 $newlocaltax2_type =
GETPOST(
'localtax2_type',
'array');
219 $object->price_autogen =
GETPOST(
'usePriceRules') ==
'on';
221 for ($i = 1; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i++)
223 if (!isset($newprice[$i])) {
227 $tva_tx_txt = $newvattx[$i];
229 $tva_tx = $tva_tx_txt;
232 if (preg_match(
'/\((.*)\)/', $tva_tx_txt, $reg))
234 $vat_src_code = $reg[1];
235 $tva_tx = preg_replace(
'/\s*\(.*\)/',
'', $tva_tx_txt);
237 $tva_tx =
price2num(preg_replace(
'/\*/',
'', $tva_tx));
239 $npr = preg_match(
'/\*/', $tva_tx_txt) ? 1 : 0;
240 $localtax1 = $newlocaltax1_tx[$i];
241 $localtax1_type = $newlocaltax1_type[$i];
242 $localtax2 = $newlocaltax2_tx[$i];
243 $localtax2_type = $newlocaltax2_type[$i];
244 if (preg_match(
'/\((.*)\)/', $tva_tx_txt, $reg))
247 $vatratecode = $reg[1];
249 $sql =
"SELECT t.rowid, t.code, t.recuperableonly, t.localtax1, t.localtax2, t.localtax1_type, t.localtax2_type";
250 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_tva as t, ".MAIN_DB_PREFIX.
"c_country as c";
251 $sql .=
" WHERE t.fk_pays = c.rowid AND c.code = '".$db->escape($mysoc->country_code).
"'";
252 $sql .=
" AND t.taux = ".((float) $tva_tx).
" AND t.active = 1";
253 $sql .=
" AND t.code ='".$db->escape($vatratecode).
"'";
254 $resql = $db->query($sql);
257 $obj = $db->fetch_object(
$resql);
258 $npr = $obj->recuperableonly;
259 $localtax1 = $obj->localtax1;
260 $localtax2 = $obj->localtax2;
261 $localtax1_type = $obj->localtax1_type;
262 $localtax2_type = $obj->localtax2_type;
266 $pricestoupdate[$i] = array(
267 'price' =>
price2num($newprice[$i],
'', 2),
268 'price_min' =>
price2num($newprice_min[$i],
'', 2),
269 'price_base_type' => $newpricebase[$i],
270 'default_vat_code' => $vatratecode,
273 'localtaxes_array' => array(
'0'=>$localtax1_type,
'1'=>$localtax1,
'2'=>$localtax2_type,
'3'=>$localtax2)
277 if ($object->price_autogen) {
285 $newpricebase =
GETPOST(
'price_base_type',
'alpha');
286 $tva_tx_txt =
GETPOST(
'tva_tx',
'alpha');
288 $tva_tx = $tva_tx_txt;
291 if (preg_match(
'/\((.*)\)/', $tva_tx_txt, $reg))
293 $vat_src_code = $reg[1];
294 $tva_tx = preg_replace(
'/\s*\(.*\)/',
'', $tva_tx_txt);
296 $tva_tx =
price2num(preg_replace(
'/\*/',
'', $tva_tx));
298 $npr = preg_match(
'/\*/', $tva_tx_txt) ? 1 : 0;
299 $localtax1 = 0; $localtax2 = 0; $localtax1_type =
'0'; $localtax2_type =
'0';
301 if (preg_match(
'/\((.*)\)/', $tva_tx_txt, $reg))
304 $vatratecode = $reg[1];
306 $sql =
"SELECT t.rowid, t.code, t.recuperableonly, t.localtax1, t.localtax2, t.localtax1_type, t.localtax2_type";
307 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_tva as t, ".MAIN_DB_PREFIX.
"c_country as c";
308 $sql .=
" WHERE t.fk_pays = c.rowid AND c.code = '".$db->escape($mysoc->country_code).
"'";
309 $sql .=
" AND t.taux = ".$tva_tx.
" AND t.active = 1";
310 $sql .=
" AND t.code ='".$db->escape($vatratecode).
"'";
311 $resql = $db->query($sql);
314 $obj = $db->fetch_object(
$resql);
315 $npr = $obj->recuperableonly;
316 $localtax1 = $obj->localtax1;
317 $localtax2 = $obj->localtax2;
318 $localtax1_type = $obj->localtax1_type;
319 $localtax2_type = $obj->localtax2_type;
322 if (in_array($mysoc->country_code, array(
'ES')))
329 $pricestoupdate[0] = array(
330 'price' => $newprice,
331 'price_min' => $newprice_min,
332 'price_base_type' => $newpricebase,
333 'default_vat_code' => $vatratecode,
336 'localtaxes_array' => array(
'0'=>$localtax1_type,
'1'=>$localtax1,
'2'=>$localtax2_type,
'3'=>$localtax2)
343 foreach ($pricestoupdate as $key => $val) {
344 $newprice = $val[
'price'];
346 if ($val[
'price'] < $val[
'price_min'] && !empty($object->fk_price_expression)) {
347 $newprice = $val[
'price_min'];
351 $newprice_min =
price2num($val[
'price_min'],
'MU');
353 if (!empty($conf->global->PRODUCT_MINIMUM_RECOMMENDED_PRICE) && $newprice_min < $maxpricesupplier) {
354 setEventMessages($langs->trans(
"MinimumPriceLimit",
price($maxpricesupplier, 0,
'', 1, - 1, - 1,
'auto')), null,
'errors');
359 if ($object->multiprices[$key] != $newprice || $object->multiprices_min[$key] != $newprice_min || $object->multiprices_base_type[$key] != $val[
'price_base_type'])
360 $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']);
372 if (!$error && $object->update($object->id, $user) < 0) {
382 $action =
'edit_price';
388 if ($action ==
'delete' && $user->rights->produit->supprimer)
390 $result = $object->log_price_delete($user,
GETPOST(
'lineid',
'int'));
397 if ($action ==
'activate_price_by_qty')
400 $level =
GETPOST(
'level',
'int');
401 $object->updatePrice(0, $object->price_base_type, $user, $object->tva_tx, 0, $level, $object->tva_npr, 1);
404 if ($action ==
'disable_price_by_qty')
407 $level =
GETPOST(
'level',
'int');
408 $object->updatePrice(0, $object->price_base_type, $user, $object->tva_tx, 0, $level, $object->tva_npr, 0);
411 if ($action ==
'edit_price_by_qty')
413 $rowid =
GETPOST(
'rowid',
'int');
417 if ($action ==
'update_price_by_qty')
420 $rowid =
GETPOST(
'rowid',
'int');
421 $priceid =
GETPOST(
'priceid',
'int');
424 $quantity =
GETPOST(
'quantity',
'int');
428 if (empty($quantity)) {
430 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Qty")), null,
'errors');
432 if (empty($newprice)) {
434 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Price")), null,
'errors');
438 if ($object->price_base_type ==
'TTC') {
439 $price =
price2num($newprice) / (1 + ($object->tva_tx / 100));
443 $unitPrice =
price2num($price / $quantity,
'MU');
447 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"product_price_by_qty SET";
448 $sql .=
" price='".$db->escape($price).
"',";
449 $sql .=
" unitprice=".$unitPrice.
",";
450 $sql .=
" quantity=".$quantity.
",";
451 $sql .=
" remise_percent=".$remise_percent.
",";
452 $sql .=
" remise=".$remise;
453 $sql .=
" WHERE rowid = ".$rowid;
455 $result = $db->query($sql);
458 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"product_price_by_qty (fk_product_price,price,unitprice,quantity,remise_percent,remise) values (";
459 $sql .= $priceid.
','.$price.
','.$unitPrice.
','.$quantity.
','.$remise_percent.
','.$remise.
')';
461 $result = $db->query($sql);
463 if ($db->lasterrno() ==
'DB_ERROR_RECORD_ALREADY_EXISTS') {
473 if ($action ==
'delete_price_by_qty')
475 $rowid =
GETPOST(
'rowid',
'int');
476 if (!empty($rowid)) {
477 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"product_price_by_qty";
478 $sql .=
" WHERE rowid = ".$rowid;
480 $result = $db->query($sql);
482 setEventMessages((
'delete_price_by_qty'.$langs->transnoentities(
'MissingIds')), null,
'errors');
486 if ($action ==
'delete_all_price_by_qty') {
487 $priceid =
GETPOST(
'priceid',
'int');
488 if (!empty($rowid)) {
489 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"product_price_by_qty";
490 $sql .=
" WHERE fk_product_price = ".$priceid;
492 $result = $db->query($sql);
494 setEventMessages((
'delete_price_by_qty'.$langs->transnoentities(
'MissingIds')), null,
'errors');
503 if ($action ==
'add_customer_price_confirm' && !$cancel && ($user->rights->produit->creer || $user->rights->service->creer)) {
504 $maxpricesupplier = $object->min_recommended_price();
506 $update_child_soc =
GETPOST(
'updatechildprice',
'int');
509 $prodcustprice->fk_soc =
GETPOST(
'socid',
'int');
510 $prodcustprice->fk_product = $object->id;
513 $prodcustprice->price_base_type =
GETPOST(
"price_base_type",
'alpha');
515 $tva_tx_txt =
GETPOST(
"tva_tx",
'alpha');
517 $tva_tx = $tva_tx_txt;
519 if (preg_match(
'/\((.*)\)/', $tva_tx_txt, $reg))
521 $vat_src_code = $reg[1];
522 $tva_tx = preg_replace(
'/\s*\(.*\)/',
'', $tva_tx_txt);
524 $tva_tx =
price2num(preg_replace(
'/\*/',
'', $tva_tx));
526 $npr = preg_match(
'/\*/', $tva_tx_txt) ? 1 : 0;
527 $localtax1 = 0; $localtax2 = 0; $localtax1_type =
'0'; $localtax2_type =
'0';
529 if (preg_match(
'/\((.*)\)/', $tva_tx_txt, $reg))
532 $vatratecode = $reg[1];
534 $sql =
"SELECT t.rowid, t.code, t.recuperableonly, t.localtax1, t.localtax2, t.localtax1_type, t.localtax2_type";
535 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_tva as t, ".MAIN_DB_PREFIX.
"c_country as c";
536 $sql .=
" WHERE t.fk_pays = c.rowid AND c.code = '".$db->escape($mysoc->country_code).
"'";
537 $sql .=
" AND t.taux = ".$tva_tx.
" AND t.active = 1";
538 $sql .=
" AND t.code ='".$db->escape($vatratecode).
"'";
539 $resql = $db->query($sql);
542 $obj = $db->fetch_object(
$resql);
543 $npr = $obj->recuperableonly;
544 $localtax1 = $obj->localtax1;
545 $localtax2 = $obj->localtax2;
546 $localtax1_type = $obj->localtax1_type;
547 $localtax2_type = $obj->localtax2_type;
551 $prodcustprice->default_vat_code = $vatratecode;
552 $prodcustprice->tva_tx = $tva_tx;
553 $prodcustprice->recuperableonly = $npr;
554 $prodcustprice->localtax1_tx = $localtax1;
555 $prodcustprice->localtax2_tx = $localtax2;
556 $prodcustprice->localtax1_type = $localtax1_type;
557 $prodcustprice->localtax2_type = $localtax2_type;
559 if (!($prodcustprice->fk_soc > 0))
561 $langs->load(
"errors");
562 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"ThirdParty")), null,
'errors');
564 $action =
'add_customer_price';
566 if (!empty($conf->global->PRODUCT_MINIMUM_RECOMMENDED_PRICE) && $prodcustprice->price_min < $maxpricesupplier)
568 $langs->load(
"errors");
569 setEventMessages($langs->trans(
"MinimumPriceLimit",
price($maxpricesupplier, 0,
'', 1, -1, -1,
'auto')), null,
'errors');
571 $action =
'add_customer_price';
576 $result = $prodcustprice->create($user, 0, $update_child_soc);
588 if ($action ==
'delete_customer_price' && ($user->rights->produit->supprimer || $user->rights->service->supprimer))
591 $prodcustprice->id =
GETPOST(
'lineid');
592 $result = $prodcustprice->delete($user);
602 if ($action ==
'update_customer_price_confirm' && !$cancel && ($user->rights->produit->creer || $user->rights->service->creer))
604 $maxpricesupplier = $object->min_recommended_price();
606 $update_child_soc =
GETPOST(
'updatechildprice',
'int');
608 $prodcustprice->fetch(
GETPOST(
'lineid',
'int'));
613 $prodcustprice->price_base_type =
GETPOST(
"price_base_type",
'alpha');
615 $tva_tx_txt =
GETPOST(
"tva_tx");
617 $tva_tx = $tva_tx_txt;
619 if (preg_match(
'/\((.*)\)/', $tva_tx_txt, $reg))
621 $vat_src_code = $reg[1];
622 $tva_tx = preg_replace(
'/\s*\(.*\)/',
'', $tva_tx_txt);
624 $tva_tx =
price2num(preg_replace(
'/\*/',
'', $tva_tx));
626 $npr = preg_match(
'/\*/', $tva_tx_txt) ? 1 : 0;
627 $localtax1 = 0; $localtax2 = 0; $localtax1_type =
'0'; $localtax2_type =
'0';
629 if (preg_match(
'/\((.*)\)/', $tva_tx_txt, $reg))
632 $vatratecode = $reg[1];
634 $sql =
"SELECT t.rowid, t.code, t.recuperableonly, t.localtax1, t.localtax2, t.localtax1_type, t.localtax2_type";
635 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_tva as t, ".MAIN_DB_PREFIX.
"c_country as c";
636 $sql .=
" WHERE t.fk_pays = c.rowid AND c.code = '".$db->escape($mysoc->country_code).
"'";
637 $sql .=
" AND t.taux = ".$tva_tx.
" AND t.active = 1";
638 $sql .=
" AND t.code ='".$db->escape($vatratecode).
"'";
639 $resql = $db->query($sql);
642 $obj = $db->fetch_object(
$resql);
643 $npr = $obj->recuperableonly;
644 $localtax1 = $obj->localtax1;
645 $localtax2 = $obj->localtax2;
646 $localtax1_type = $obj->localtax1_type;
647 $localtax2_type = $obj->localtax2_type;
651 $prodcustprice->default_vat_code = $vatratecode;
652 $prodcustprice->tva_tx = $tva_tx;
653 $prodcustprice->recuperableonly = $npr;
654 $prodcustprice->localtax1_tx = $localtax1;
655 $prodcustprice->localtax2_tx = $localtax2;
656 $prodcustprice->localtax1_type = $localtax1_type;
657 $prodcustprice->localtax2_type = $localtax2_type;
659 if ($prodcustprice->price_min < $maxpricesupplier && !empty($conf->global->PRODUCT_MINIMUM_RECOMMENDED_PRICE))
661 setEventMessages($langs->trans(
"MinimumPriceLimit",
price($maxpricesupplier, 0,
'', 1, -1, -1,
'auto')), null,
'errors');
663 $action =
'update_customer_price';
668 $result = $prodcustprice->update($user, 0, $update_child_soc);
686 $form =
new Form($db);
688 if (!empty($id) || !empty($ref))
691 $object->fetch($id, $ref);
694 $title = $langs->trans(
'ProductServiceCard');
696 $shortlabel =
dol_trunc($object->label, 16);
699 $title = $langs->trans(
'Product').
" ".$shortlabel.
" - ".$langs->trans(
'SellingPrices');
700 $helpurl =
'EN:Module_Products|FR:Module_Produits|ES:Módulo_Productos';
704 $title = $langs->trans(
'Service').
" ".$shortlabel.
" - ".$langs->trans(
'SellingPrices');
705 $helpurl =
'EN:Module_Services_En|FR:Module_Services|ES:Módulo_Servicios';
708 llxHeader(
'', $title, $helpurl,
'', 0, 0,
'',
'',
'',
'classforhorizontalscrolloftabs');
711 $titre = $langs->trans(
"CardProduct".$object->type);
716 $linkback =
'<a href="'.DOL_URL_ROOT.
'/product/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
717 $object->next_prev_filter =
" fk_product_type = ".$object->type;
720 if ($user->socid && !in_array(
'product', explode(
',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav = 0;
725 print '<div class="fichecenter">';
727 print '<div class="underbanner clearboth"></div>';
728 print '<table class="border tableforfield" width="100%">';
731 if (!empty($conf->global->PRODUIT_MULTIPRICES) || !empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES))
741 print '<tr><td class="titlefield">';
742 print $langs->trans(
"SellingPrice");
744 print '<td colspan="2">';
745 if ($object->multiprices_base_type[$soc->price_level] ==
'TTC') {
746 print price($object->multiprices_ttc[$soc->price_level]);
748 print price($object->multiprices[$soc->price_level]);
750 if ($object->multiprices_base_type[$soc->price_level]) {
751 print ' '.$langs->trans($object->multiprices_base_type[$soc->price_level]);
753 print ' '.$langs->trans($object->price_base_type);
758 print '<tr><td>'.$langs->trans(
"MinPrice").
'</td><td colspan="2">';
759 if ($object->multiprices_base_type[$soc->price_level] ==
'TTC')
761 print price($object->multiprices_min_ttc[$soc->price_level]).
' '.$langs->trans($object->multiprices_base_type[$soc->price_level]);
763 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]);
767 if (!empty($conf->global->PRODUIT_MULTIPRICES_USE_VAT_PER_LEVEL))
770 print '<tr><td>'.$langs->trans(
"DefaultTaxRate").
'</td><td colspan="2">';
773 if (
price2num($object->multiprices_tva_tx[$soc->price_level])) $positiverates .= ($positiverates ?
'/' :
'').
price2num($object->multiprices_tva_tx[$soc->price_level]);
774 if (
price2num($object->multiprices_localtax1_type[$soc->price_level])) $positiverates .= ($positiverates ?
'/' :
'').price2num($object->multiprices_localtax1_tx[$soc->price_level]);
775 if (
price2num($object->multiprices_localtax2_type[$soc->price_level])) $positiverates .= ($positiverates ?
'/' :
'').
price2num($object->multiprices_localtax2_tx[$soc->price_level]);
776 if (empty($positiverates)) $positiverates =
'0';
777 echo
vatrate($positiverates.($object->default_vat_code ?
' ('.$object->default_vat_code.
')' :
''),
'%', $object->tva_npr);
782 print '<tr><td>'.$langs->trans(
"DefaultTaxRate").
'</td><td>';
785 if (
price2num($object->tva_tx)) $positiverates .= ($positiverates ?
'/' :
'').
price2num($object->tva_tx);
786 if (
price2num($object->localtax1_type)) $positiverates .= ($positiverates ?
'/' :
'').price2num($object->localtax1_tx);
787 if (
price2num($object->localtax2_type)) $positiverates .= ($positiverates ?
'/' :
'').
price2num($object->localtax2_tx);
788 if (empty($positiverates)) $positiverates =
'0';
789 echo
vatrate($positiverates.($object->default_vat_code ?
' ('.$object->default_vat_code.
')' :
''),
'%', $object->tva_npr);
799 if (!empty($conf->global->PRODUIT_MULTIPRICES_USE_VAT_PER_LEVEL))
802 print '<tr><td class="titlefield">'.$langs->trans(
"DefaultTaxRate").
'</td>';
803 print '<td colspan="2">'.vatrate($object->multiprices_tva_tx[1],
true).
'</td>';
807 print '<tr><td class="titlefield">'.$langs->trans(
"DefaultTaxRate").
'</td><td>';
810 if (
price2num($object->tva_tx)) $positiverates .= ($positiverates ?
'/' :
'').
price2num($object->tva_tx);
811 if (
price2num($object->localtax1_type)) $positiverates .= ($positiverates ?
'/' :
'').price2num($object->localtax1_tx);
812 if (
price2num($object->localtax2_type)) $positiverates .= ($positiverates ?
'/' :
'').
price2num($object->localtax2_tx);
813 if (empty($positiverates)) $positiverates =
'0';
814 echo
vatrate($positiverates.($object->default_vat_code ?
' ('.$object->default_vat_code.
')' :
''),
'%', $object->tva_npr);
827 print '<table class="noborder tableforfield" width="100%">';
828 print '<tr class="liste_titre"><td>';
829 print $langs->trans(
"PriceLevel");
830 if ($user->admin)
print ' <a class="editfielda" href="'.$_SERVER[
"PHP_SELF"].
'?action=editlabelsellingprice&pricelevel='.$i.
'&id='.$object->id.
'">'.
img_edit($langs->trans(
'EditSellingPriceLabel'), 0).
'</a>';
832 print
'<td style="text-align: right">'.$langs->trans(
"SellingPrice").
'</td>';
833 print
'<td style="text-align: right">'.$langs->trans(
"MinPrice").
'</td>';
836 for ($i = 1; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i++)
838 print
'<tr class="oddeven">';
842 $keyforlabel =
'PRODUIT_MULTIPRICES_LABEL'.$i;
843 if (preg_match(
'/editlabelsellingprice/', $action))
845 print
'<form method="post" action="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'">';
846 print
'<input type="hidden" name="token" value="'.newToken().
'">';
847 print
'<input type="hidden" name="action" value="setlabelsellingprice">';
848 print
'<input type="hidden" name="pricelevel" value="'.$i.
'">';
849 print $langs->trans(
"SellingPrice").
' '.$i.
' - ';
850 print
'<input class="maxwidthonsmartphone" type="text" name="labelsellingprice" value="'.$conf->global->$keyforlabel.
'">';
851 print
' <input type="submit" class="button smallpaddingimp" value="'.$langs->trans(
"Modify").
'">';
854 print $langs->trans(
"SellingPrice").
' '.$i;
855 if (!empty($conf->global->$keyforlabel)) print
' - '.$langs->trans($conf->global->$keyforlabel);
859 if ($object->multiprices_base_type [$i] ==
'TTC') {
860 print
'<td style="text-align: right">'.price($object->multiprices_ttc[$i]);
862 print
'<td style="text-align: right">'.price($object->multiprices[$i]);
865 if ($object->multiprices_base_type[$i]) {
866 print
' '.$langs->trans($object->multiprices_base_type [$i]).
'</td>';
868 print
' '.$langs->trans($object->price_base_type).
'</td>';
872 print
'<td style="text-align: right">';
873 if (empty($object->multiprices_base_type[$i])) $object->multiprices_base_type[$i] =
"HT";
874 if ($object->multiprices_base_type[$i] ==
'TTC')
876 print
price($object->multiprices_min_ttc[$i]).
' '.$langs->trans($object->multiprices_base_type[$i]);
878 print
price($object->multiprices_min[$i]).
' '.$langs->trans($object->multiprices_base_type[$i]);
883 if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY) || !empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES))
885 print
'<tr><td>'.$langs->trans(
"PriceByQuantity").
' '.$i;
886 if (!empty($conf->global->$keyforlabel)) print
' - '.$langs->trans($conf->global->$keyforlabel);
887 print
'</td><td colspan="2">';
889 if ($object->prices_by_qty[$i] == 1) {
890 print
'<table width="50%" class="border" summary="List of quantities">';
892 print
'<tr class="liste_titre">';
893 print
'<td>'.$langs->trans(
"PriceByQuantityRange").
' '.$i.
'</td>';
894 print
'<td class="right">'.$langs->trans(
"HT").
'</td>';
895 print
'<td class="right">'.$langs->trans(
"UnitPrice").
'</td>';
896 print
'<td class="right">'.$langs->trans(
"Discount").
'</td>';
897 print
'<td> </td>';
899 foreach ($object->prices_by_qty_list[$i] as $ii => $prices)
901 if ($action ==
'edit_price_by_qty' && $rowid == $prices[
'rowid'] && ($user->rights->produit->creer || $user->rights->service->creer)) {
902 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'" method="POST">';
903 print
'<input type="hidden" name="token" value="'.newToken().
'">';
904 print
'<input type="hidden" name="action" value="update_price_by_qty">';
905 print
'<input type="hidden" name="priceid" value="'.$object->prices_by_qty_id[$i].
'">';
906 print
'<input type="hidden" value="'.$prices[
'rowid'].
'" name="rowid">';
907 print
'<tr class="'.($ii % 2 == 0 ?
'pair' :
'impair').
'">';
908 print
'<td><input size="5" type="text" value="'.$prices[
'quantity'].
'" name="quantity"></td>';
909 print
'<td class="right" colspan="2"><input size="10" type="text" value="'.price2num($prices[
'price'],
'MU').
'" name="price"> '.$object->price_base_type.
'</td>';
910 print
'<td class="right nowraponall"><input size="5" type="text" value="'.$prices[
'remise_percent'].
'" name="remise_percent"> %</td>';
911 print
'<td class="center"><input type="submit" value="'.$langs->trans(
"Modify").
'" class="button"></td>';
915 print
'<tr class="'.($ii % 2 == 0 ?
'pair' :
'impair').
'">';
916 print
'<td>'.$prices[
'quantity'].
'</td>';
917 print
'<td class="right">'.price($prices[
'price']).
'</td>';
918 print
'<td class="right">'.price($prices[
'unitprice']).
'</td>';
919 print
'<td class="right">'.price($prices[
'remise_percent']).
' %</td>';
920 print
'<td class="center">';
921 if (($user->rights->produit->creer || $user->rights->service->creer)) {
922 print
'<a class="editfielda marginleftonly marginrightonly" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=edit_price_by_qty&rowid='.$prices[
"rowid"].
'">';
924 print
'<a class="marginleftonly marginrightonly" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=delete_price_by_qty&token='.
newToken().
'&rowid='.$prices[
"rowid"].
'">';
933 if ($action !=
'edit_price_by_qty' && ($user->rights->produit->creer || $user->rights->service->creer)) {
934 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'" method="POST">';
935 print
'<input type="hidden" name="token" value="'.newToken().
'">';
936 print
'<input type="hidden" name="action" value="update_price_by_qty">';
937 print
'<input type="hidden" name="priceid" value="'.$object->prices_by_qty_id[$i].
'">';
938 print
'<input type="hidden" value="0" name="rowid">';
939 print
'<tr class="'.($ii % 2 == 0 ?
'pair' :
'impair').
'">';
940 print
'<td><input size="5" type="text" value="1" name="quantity"></td>';
941 print
'<td class="right" class="nowrap"><input size="10" type="text" value="0" name="price"> '.$object->price_base_type.
'</td>';
942 print
'<td class="right"> </td>';
943 print
'<td class="right" class="nowraponall"><input size="5" type="text" value="0" name="remise_percent"> %</td>';
944 print
'<td class="center"><input type="submit" value="'.$langs->trans(
"Add").
'" class="button"></td>';
950 print
'<a class="editfielda marginleftonly marginrightonly" href="'.$_SERVER[
'PHP_SELF'].
'?id='.$object->id.
'&action=disable_price_by_qty&level='.$i.
'">('.$langs->trans(
"DisablePriceByQty").
')</a>';
952 print $langs->trans(
"No");
953 print
' <a class="marginleftonly marginrightonly" href="'.$_SERVER[
'PHP_SELF'].
'?id='.$object->id.
'&action=activate_price_by_qty&level='.$i.
'">('.$langs->trans(
"Activate").
')</a>';
961 print
'<tr><td class="titlefield">'.$langs->trans(
"DefaultTaxRate").
'</td><td>';
964 if (
price2num($object->tva_tx)) $positiverates .= ($positiverates ?
'/' :
'').
price2num($object->tva_tx);
965 if (
price2num($object->localtax1_type)) $positiverates .= ($positiverates ?
'/' :
'').price2num($object->localtax1_tx);
966 if (
price2num($object->localtax2_type)) $positiverates .= ($positiverates ?
'/' :
'').
price2num($object->localtax2_tx);
967 if (empty($positiverates)) $positiverates =
'0';
968 echo
vatrate($positiverates.($object->default_vat_code ?
' ('.$object->default_vat_code.
')' :
''),
'%', $object->tva_npr);
978 print
'<tr><td>'.$langs->trans(
"SellingPrice").
'</td><td>';
979 if ($object->price_base_type ==
'TTC') {
980 print
price($object->price_ttc).
' '.$langs->trans($object->price_base_type);
982 print
price($object->price).
' '.$langs->trans($object->price_base_type);
987 print
'<tr><td>'.$langs->trans(
"MinPrice").
'</td><td>';
988 if ($object->price_base_type ==
'TTC') {
989 print
price($object->price_min_ttc).
' '.$langs->trans($object->price_base_type);
991 print
price($object->price_min).
' '.$langs->trans($object->price_base_type);
996 if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY) || !empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES))
998 print
'<tr><td>'.$langs->trans(
"PriceByQuantity");
999 if ($object->prices_by_qty[0] == 0) {
1000 print
' <a href="'.$_SERVER[
'PHP_SELF'].
'?id='.$object->id.
'&action=activate_price_by_qty&level=1">('.$langs->trans(
"Activate").
')';
1002 print
' <a href="'.$_SERVER[
'PHP_SELF'].
'?id='.$object->id.
'&action=disable_price_by_qty&level=1">('.$langs->trans(
"DisablePriceByQty").
')';
1006 if ($object->prices_by_qty[0] == 1)
1008 print
'<table width="50%" class="border" summary="List of quantities">';
1009 print
'<tr class="liste_titre">';
1011 print
'<td>'.$langs->trans(
"Quantity").
'</td>';
1012 print
'<td class="right">'.$langs->trans(
"Price").
'</td>';
1013 print
'<td class="right"></td>';
1014 print
'<td class="right">'.$langs->trans(
"UnitPrice").
'</td>';
1015 print
'<td class="right">'.$langs->trans(
"Discount").
'</td>';
1016 print
'<td> </td>';
1018 if ($action !=
'edit_price_by_qty')
1020 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'" method="POST">';
1021 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1022 print
'<input type="hidden" name="action" value="update_price_by_qty">';
1023 print
'<input type="hidden" name="priceid" value="'.$object->prices_by_qty_id[0].
'">';
1024 print
'<input type="hidden" value="0" name="rowid">';
1026 print
'<tr class="'.($ii % 2 == 0 ?
'pair' :
'impair').
'">';
1027 print
'<td><input size="5" type="text" value="1" name="quantity"></td>';
1028 print
'<td class="right"><input class="width50 right" type="text" value="0" name="price"></td>';
1032 print
'<td class="right"> </td>';
1033 print
'<td class="right nowraponall"><input type="text" class="width50 right" value="0" name="remise_percent"> %</td>';
1034 print
'<td class="center"><input type="submit" value="'.$langs->trans(
"Add").
'" class="button"></td>';
1039 foreach ($object->prices_by_qty_list[0] as $ii => $prices)
1041 if ($action ==
'edit_price_by_qty' && $rowid == $prices[
'rowid'] && ($user->rights->produit->creer || $user->rights->service->creer))
1043 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'" method="POST">';
1044 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1045 print
'<input type="hidden" name="action" value="update_price_by_qty">';
1046 print
'<input type="hidden" name="priceid" value="'.$object->prices_by_qty_id[0].
'">';
1047 print
'<input type="hidden" value="'.$prices[
'rowid'].
'" name="rowid">';
1048 print
'<tr class="'.($ii % 2 == 0 ?
'pair' :
'impair').
'">';
1049 print
'<td><input size="5" type="text" value="'.$prices[
'quantity'].
'" name="quantity"></td>';
1050 print
'<td class="right"><input class="width50 right" type="text" value="'.price2num($prices[
'price'],
'MU').
'" name="price"></td>';
1051 print
'<td class="right">';
1053 print $prices[
'price_base_type'];
1055 print
'<td class="right"> </td>';
1056 print
'<td class="right nowraponall"><input class="width50 right" type="text" value="'.$prices[
'remise_percent'].
'" name="remise_percent"> %</td>';
1057 print
'<td class="center"><input type="submit" value="'.$langs->trans(
"Modify").
'" class="button"></td>';
1061 print
'<tr class="'.($ii % 2 == 0 ?
'pair' :
'impair').
'">';
1062 print
'<td>'.$prices[
'quantity'].
'</td>';
1063 print
'<td class="right">'.price($prices[
'price']).
'</td>';
1064 print
'<td class="right">';
1066 print $prices[
'price_base_type'];
1068 print
'<td class="right">'.price($prices[
'unitprice']).
'</td>';
1069 print
'<td class="right">'.price($prices[
'remise_percent']).
' %</td>';
1070 print
'<td class="center">';
1071 if (($user->rights->produit->creer || $user->rights->service->creer))
1073 print
'<a class="editfielda marginleftonly marginrightonly" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=edit_price_by_qty&rowid='.$prices[
"rowid"].
'">';
1075 print
'<a class="marginleftonly marginrightonly" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=delete_price_by_qty&token='.
newToken().
'&rowid='.$prices[
"rowid"].
'">';
1086 print $langs->trans(
"No");
1095 print
'<div style="clear:both"></div>';
1108 if (!$action || $action ==
'delete' || $action ==
'showlog_customer_price' || $action ==
'showlog_default_price' || $action ==
'add_customer_price'
1109 || $action ==
'activate_price_by_qty' || $action ==
'disable_price_by_qty')
1111 print
"\n".
'<div class="tabsAction">'.
"\n";
1113 if ($object->isVariant()) {
1114 if ($user->rights->produit->creer || $user->rights->service->creer) {
1115 print
'<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans(
"NoEditVariants")).
'">'.$langs->trans(
"UpdateDefaultPrice").
'</a></div>';
1118 if (empty($conf->global->PRODUIT_MULTIPRICES) && empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) {
1119 if ($user->rights->produit->creer || $user->rights->service->creer) {
1120 print
'<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER[
'PHP_SELF'].
'?action=edit_price&id='.$object->id.
'">'.$langs->trans(
"UpdateDefaultPrice").
'</a></div>';
1124 if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) {
1125 if ($user->rights->produit->creer || $user->rights->service->creer) {
1126 print
'<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?action=add_customer_price&id='.$object->id.
'">'.$langs->trans(
"AddCustomerPrice").
'</a></div>';
1130 if (!empty($conf->global->PRODUIT_MULTIPRICES) || !empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) {
1131 if ($user->rights->produit->creer || $user->rights->service->creer) {
1132 print
'<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER[
'PHP_SELF'].
'?action=edit_vat&id='.$object->id.
'">'.$langs->trans(
"UpdateVAT").
'</a></div>';
1135 if ($user->rights->produit->creer || $user->rights->service->creer) {
1136 print
'<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER[
'PHP_SELF'].
'?action=edit_price&id='.$object->id.
'">'.$langs->trans(
"UpdateLevelPrices").
'</a></div>';
1150 if ($action ==
'edit_vat' && ($user->rights->produit->creer || $user->rights->service->creer))
1154 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'" method="POST">';
1155 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1156 print
'<input type="hidden" name="action" value="update_vat">';
1157 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
1161 print
'<table class="border centpercent">';
1164 print
'<tr><td>'.$langs->trans(
"DefaultTaxRate").
'</td><td>';
1165 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);
1172 print
'<div class="center">';
1173 print
'<input type="submit" class="button button-save" value="'.$langs->trans(
"Save").
'">';
1174 print
' ';
1175 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.$langs->trans(
"Cancel").
'">';
1178 print
'<br></form><br>';
1181 if ($action ==
'edit_price' && $object->getRights()->creer)
1185 if (empty($conf->global->PRODUIT_MULTIPRICES) && empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES))
1187 print
'<!-- Edit price -->'.
"\n";
1188 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'" method="POST">';
1189 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1190 print
'<input type="hidden" name="action" value="update_price">';
1191 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
1195 print
'<div class="div-table-responsive-no-min">';
1196 print
'<table class="border centpercent">';
1199 print
'<tr><td class="titlefield">'.$langs->trans(
"DefaultTaxRate").
'</td><td>';
1200 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);
1205 print $langs->trans(
'PriceBase');
1208 print $form->selectPriceBaseType($object->price_base_type,
"price_base_type");
1213 if (!empty($conf->dynamicprices->enabled)) {
1215 print
'<tr><td>'.$langs->trans(
"PriceMode").
'</td><td>';
1217 $price_expression_list = array(0 => $langs->trans(
"PriceNumeric"));
1218 foreach ($price_expression->list_price_expression() as $entry) {
1219 $price_expression_list[$entry->id] = $entry->title;
1221 $price_expression_preselection =
GETPOST(
'eid') ?
GETPOST(
'eid') : ($object->fk_price_expression ? $object->fk_price_expression :
'0');
1222 print $form->selectarray(
'eid', $price_expression_list, $price_expression_preselection);
1223 print
' <div id="expression_editor" class="button">'.$langs->trans(
"PriceExpressionEditor").
'</div>';
1229 <script
type=
"text/javascript">
1230 jQuery(document).ready(
function() {
1231 jQuery(
"#expression_editor").click(
function() {
1232 window.location =
"<?php echo DOL_URL_ROOT ?>/product/dynamic_price/editor.php?id=<?php echo $id ?>&tab=price&eid=" + $(
"#eid").val();
1234 jQuery(
"#eid").change(on_change);
1237 function on_change() {
1238 if ($(
"#eid").val() == 0) {
1239 jQuery(
"#price_numeric").show();
1241 jQuery(
"#price_numeric").hide();
1250 $product->fetch($id, $ref,
'', 1);
1251 print
'<tr id="price_numeric"><td>';
1252 $text = $langs->trans(
'SellingPrice');
1253 print $form->textwithpicto($text, $langs->trans(
"PrecisionUnitIsLimitedToXDecimals", $conf->global->MAIN_MAX_DECIMALS_UNIT), 1, 1);
1255 if ($object->price_base_type ==
'TTC') {
1256 print
'<input name="price" size="10" value="'.price($product->price_ttc).
'">';
1258 print
'<input name="price" size="10" value="'.price($product->price).
'">';
1264 $text = $langs->trans(
'MinPrice');
1265 print $form->textwithpicto($text, $langs->trans(
"PrecisionUnitIsLimitedToXDecimals", $conf->global->MAIN_MAX_DECIMALS_UNIT), 1, 1);
1267 if ($object->price_base_type ==
'TTC') {
1268 print
'<input name="price_min" size="10" value="'.price($object->price_min_ttc).
'">';
1270 print
'<input name="price_min" size="10" value="'.price($object->price_min).
'">';
1272 if (!empty($conf->global->PRODUCT_MINIMUM_RECOMMENDED_PRICE))
1274 print
' '.$langs->trans(
"MinimumRecommendedPrice",
price($maxpricesupplier, 0,
'', 1, -1, -1,
'auto')).
' '.
img_warning().
'</td>';
1279 $parameters = array();
1280 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters, $object, $action);
1287 print
'<div class="center">';
1288 print
'<input type="submit" class="button button-save" value="'.$langs->trans(
"Save").
'">';
1289 print
' ';
1290 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.$langs->trans(
"Cancel").
'">';
1293 print
'<br></form>';
1295 print
'<!-- Edit price per level -->'.
"\n";
1299 var showHidePriceRules =
function () {
1300 var otherPrices = $(
'div.fiche form table tbody tr:not(:first)');
1301 var minPrice1 = $(
'div.fiche form input[name="price_min[1]"]');
1303 if (jQuery(
'input#usePriceRules').prop(
'checked')) {
1312 jQuery(document).ready(
function () {
1313 showHidePriceRules();
1315 jQuery(
'input#usePriceRules').click(showHidePriceRules);
1320 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'" method="POST">';
1321 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1322 print
'<input type="hidden" name="action" value="update_price">';
1323 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
1327 if ((!empty($conf->global->PRODUIT_MULTIPRICES) || !empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) && !empty($conf->global->PRODUIT_MULTIPRICES_ALLOW_AUTOCALC_PRICELEVEL)) {
1328 print $langs->trans(
'UseMultipriceRules').
' <input type="checkbox" id="usePriceRules" name="usePriceRules" '.($object->price_autogen ?
'checked' :
'').
'><br><br>';
1331 print
'<div class="div-table-responsive-no-min">';
1332 print
'<table class="noborder">';
1333 print
'<thead><tr class="liste_titre">';
1335 print
'<td>'.$langs->trans(
"PriceLevel").
'</td>';
1337 if (!empty($conf->global->PRODUIT_MULTIPRICES_USE_VAT_PER_LEVEL)) print
'<td style="text-align: center">'.$langs->trans(
"DefaultTaxRate").
'</td>';
1338 else print
'<td></td>';
1340 print
'<td class="center">'.$langs->trans(
"SellingPrice").
'</td>';
1342 print
'<td class="center">'.$langs->trans(
"MinPrice").
'</td>';
1344 if (!empty($conf->global->PRODUCT_MINIMUM_RECOMMENDED_PRICE)) {
1347 print
'</tr></thead>';
1351 for ($i = 1; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i++)
1353 print
'<tr class="oddeven">';
1355 $text = $langs->trans(
'SellingPrice').
' '.$i;
1356 print $form->textwithpicto($text, $langs->trans(
"PrecisionUnitIsLimitedToXDecimals", $conf->global->MAIN_MAX_DECIMALS_UNIT), 1, 1);
1360 if (empty($conf->global->PRODUIT_MULTIPRICES_USE_VAT_PER_LEVEL)) {
1362 print
'<input type="hidden" name="tva_tx['.$i.
']" value="'.($object->default_vat_code ? $object->tva_tx.
' ('.$object->default_vat_code.
')' : $object->tva_tx).
'">';
1363 print
'<input type="hidden" name="tva_npr['.$i.
']" value="'.$object->tva_npr.
'">';
1364 print
'<input type="hidden" name="localtax1_tx['.$i.
']" value="'.$object->localtax1_tx.
'">';
1365 print
'<input type="hidden" name="localtax1_type['.$i.
']" value="'.$object->localtax1_type.
'">';
1366 print
'<input type="hidden" name="localtax2_tx['.$i.
']" value="'.$object->localtax2_tx.
'">';
1367 print
'<input type="hidden" name="localtax2_type['.$i.
']" value="'.$object->localtax2_type.
'">';
1371 print
'<td style="text-align: center">';
1372 print $form->load_tva(
"tva_tx[".$i.
']', $object->multiprices_tva_tx[$i], $mysoc,
'', $object->id,
false, $object->type,
false, 1);
1377 print
'<td style="text-align: center">';
1378 if ($object->multiprices_base_type [$i] ==
'TTC') {
1379 print
'<input name="price['.$i.
']" size="10" value="'.
price($object->multiprices_ttc [$i]).
'">';
1381 print
'<input name="price['.$i.
']" size="10" value="'.
price($object->multiprices [$i]).
'">';
1383 print
' '.$form->selectPriceBaseType($object->multiprices_base_type [$i],
"multiprices_base_type[".$i.
"]");
1387 print
'<td style="text-align: center">';
1388 if ($object->multiprices_base_type [$i] ==
'TTC') {
1389 print
'<input name="price_min['.$i.
']" size="10" value="'.
price($object->multiprices_min_ttc [$i]).
'">';
1391 print
'<input name="price_min['.$i.
']" size="10" value="'.
price($object->multiprices_min [$i]).
'">';
1393 if (!empty($conf->global->PRODUCT_MINIMUM_RECOMMENDED_PRICE))
1395 print
'<td class="left">'.$langs->trans(
"MinimumRecommendedPrice",
price($maxpricesupplier, 0,
'', 1, -1, -1,
'auto')).
' '.
img_warning().
'</td>';
1409 print
'<div style="text-align: center">';
1410 print
'<input type="submit" class="button button-save" value="'.$langs->trans(
"Save").
'">';
1411 print
' ';
1412 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.$langs->trans(
"Cancel").
'"></div>';
1420 if ((empty($conf->global->PRODUIT_CUSTOMER_PRICES) || $action ==
'showlog_default_price') && !in_array($action, array(
'edit_price',
'edit_vat')))
1422 $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,";
1423 $sql .=
" p.price_level, p.price_min, p.price_min_ttc,p.price_by_qty,";
1424 $sql .=
" p.date_price as dp, p.fk_price_expression, u.rowid as user_id, u.login";
1425 $sql .=
" FROM ".MAIN_DB_PREFIX.
"product_price as p,";
1426 $sql .=
" ".MAIN_DB_PREFIX.
"user as u";
1427 $sql .=
" WHERE fk_product = ".$object->id;
1428 $sql .=
" AND p.entity IN (".getEntity(
'productprice').
")";
1429 $sql .=
" AND p.fk_user_author = u.rowid";
1430 if (!empty($socid) && !empty($conf->global->PRODUIT_MULTIPRICES)) $sql .=
" AND p.price_level = ".$soc->price_level;
1431 $sql .=
" ORDER BY p.date_price DESC, p.rowid DESC, p.price_level ASC";
1434 $result = $db->query($sql);
1437 print
'<div class="divlogofpreviouscustomerprice">';
1439 $num = $db->num_rows($result);
1448 if (!empty($conf->global->PRODUIT_MULTIPRICES)) {
1449 $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);
1451 $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));
1454 $result = $db->query($sql);
1455 $num = $db->num_rows($result);
1461 $backbutton =
'<a class="justalink" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'">'.$langs->trans(
"Back").
'</a>';
1463 if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES))
print_barre_liste($langs->trans(
"DefaultPriceLog"), 0,
$_SERVER[
"PHP_SELF"],
'',
'',
'', $backbutton, 0, $num,
'title_accountancy.png');
1464 else print_barre_liste($langs->trans(
"PriceByCustomerLog"), 0,
$_SERVER[
"PHP_SELF"],
'',
'',
'',
'', 0, $num,
'title_accountancy.png');
1466 print
'<div class="div-table-responsive">';
1467 print
'<table class="liste centpercent">';
1469 print
'<tr class="liste_titre">';
1470 print
'<td>'.$langs->trans(
"AppliedPricesFrom").
'</td>';
1472 if (!empty($conf->global->PRODUIT_MULTIPRICES) || !empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) {
1473 print
'<td class="center">'.$langs->trans(
"PriceLevel").
'</td>';
1475 if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY) || !empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) {
1476 print
'<td class="center">'.$langs->trans(
"Type").
'</td>';
1479 print
'<td class="center">'.$langs->trans(
"PriceBase").
'</td>';
1480 print $conf->global->PRODUIT_MULTIPRICES_USE_VAT_PER_LEVEL;
1481 if (empty($conf->global->PRODUIT_MULTIPRICES) && empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) print
'<td class="right">'.$langs->trans(
"DefaultTaxRate").
'</td>';
1482 print
'<td class="right">'.$langs->trans(
"HT").
'</td>';
1483 print
'<td class="right">'.$langs->trans(
"TTC").
'</td>';
1484 if (!empty($conf->dynamicprices->enabled)) {
1485 print
'<td class="right">'.$langs->trans(
"PriceExpressionSelected").
'</td>';
1487 print
'<td class="right">'.$langs->trans(
"MinPrice").
' '.$langs->trans(
"HT").
'</td>';
1488 print
'<td class="right">'.$langs->trans(
"MinPrice").
' '.$langs->trans(
"TTC").
'</td>';
1489 print
'<td class="right">'.$langs->trans(
"ChangedBy").
'</td>';
1490 if ($user->rights->produit->supprimer)
1491 print
'<td class="right"> </td>';
1494 $notfirstlineforlevel = array();
1499 $objp = $db->fetch_object($result);
1501 print
'<tr class="oddeven">';
1503 print
"<td>".dol_print_date($db->jdate($objp->dp),
"dayhour",
'tzuserrel').
"</td>";
1506 if (!empty($conf->global->PRODUIT_MULTIPRICES) || !empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) {
1507 print
'<td class="center">'.$objp->price_level.
"</td>";
1510 if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY) || !empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES))
1512 $type = ($objp->price_by_qty == 1) ?
'PriceByQuantity' :
'Standard';
1513 print
'<td class="center">'.$langs->trans($type).
"</td>";
1516 print
'<td class="center">';
1517 if (empty($objp->price_by_qty)) {
1518 print $langs->trans($objp->price_base_type);
1522 if (empty($conf->global->PRODUIT_MULTIPRICES) && empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES))
1524 print
'<td class="right">';
1526 if (empty($objp->price_by_qty)) {
1527 $positiverates =
'';
1528 if (
price2num($objp->tva_tx)) $positiverates .= ($positiverates ?
'/' :
'').
price2num($objp->tva_tx);
1529 if (
price2num($objp->localtax1_type)) $positiverates .= ($positiverates ?
'/' :
'').price2num($objp->localtax1_tx);
1530 if (
price2num($objp->localtax2_type)) $positiverates .= ($positiverates ?
'/' :
'').
price2num($objp->localtax2_tx);
1531 if (empty($positiverates)) $positiverates =
'0';
1532 echo
vatrate($positiverates.($objp->default_vat_code ?
' ('.$objp->default_vat_code.
')' :
''),
'%', $objp->tva_npr);
1545 if (!empty($objp->fk_price_expression) && !empty($conf->dynamicprices->enabled))
1548 $res = $price_expression->fetch($objp->fk_price_expression);
1549 $title = $price_expression->title;
1550 print
'<td class="right"></td>';
1551 print
'<td class="right"></td>';
1552 print
'<td class="right">'.$title.
"</td>";
1554 print
'<td class="right">';
1555 if (empty($objp->price_by_qty)) {
1556 print
price($objp->price);
1559 print
'<td class="right">';
1560 if (empty($objp->price_by_qty)) {
1561 print
price($objp->price_ttc);
1564 if (!empty($conf->dynamicprices->enabled)) {
1565 print
'<td class="right"></td>';
1569 print
'<td class="right">';
1570 if (empty($objp->price_by_qty)) {
1571 print
price($objp->price_min);
1575 print
'<td class="right">';
1576 if (empty($objp->price_by_qty)) {
1577 print
price($objp->price_min_ttc);
1582 print
'<td class="right">';
1583 if ($objp->user_id > 0) {
1584 $userstatic =
new User($db);
1585 $userstatic->fetch($objp->user_id);
1586 print $userstatic->getNomUrl(1,
'', 0, 0, 24, 0,
'login');
1591 if ($user->rights->produit->supprimer)
1594 if (!empty($conf->global->PRODUIT_MULTIPRICES) || !empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES))
1596 if (empty($notfirstlineforlevel[$objp->price_level])) $notfirstlineforlevel[$objp->price_level] = 1;
1597 else $candelete = 1;
1598 } elseif ($i > 0) $candelete = 1;
1600 print '<td class="right">';
1603 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=delete&token='.
newToken().
'&id='.$object->id.
'&lineid='.$objp->rowid.
'">';
1606 }
else print
' ';
1628 if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES))
1632 $limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
1633 $sortfield =
GETPOST(
"sortfield",
'alpha');
1634 $sortorder =
GETPOST(
"sortorder",
'alpha');
1636 if (empty($page) || $page == -1) { $page = 0; }
1637 $offset = $limit * $page;
1638 $pageprev = $page - 1;
1639 $pagenext = $page + 1;
1643 $sortfield =
"soc.nom";
1646 $filter = array(
't.fk_product' => $object->id);
1648 if (!empty($search_soc)) {
1649 $filter[
'soc.nom'] = $search_soc;
1652 if ($action ==
'add_customer_price') {
1654 $maxpricesupplier = $object->min_recommended_price();
1658 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'" method="POST">';
1659 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1660 print
'<input type="hidden" name="action" value="add_customer_price_confirm">';
1661 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
1663 print
'<table class="liste centpercent">';
1665 print
'<td class="fieldrequired">'.$langs->trans(
'ThirdParty').
'</td>';
1667 print
img_picto(
'',
'company').$form->select_company(
'',
'socid',
's.client IN (1,2,3)',
'SelectThirdParty', 0, 0, array(), 0,
'minwidth300');
1672 print
'<tr><td class="fieldrequired">'.$langs->trans(
"DefaultTaxRate").
'</td><td>';
1673 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);
1677 print
'<tr><td class="fieldrequired">';
1678 print $langs->trans(
'PriceBase');
1681 print $form->selectPriceBaseType($object->price_base_type,
"price_base_type");
1686 print
'<tr><td class="fieldrequired">';
1687 $text = $langs->trans(
'SellingPrice');
1688 print $form->textwithpicto($text, $langs->trans(
"PrecisionUnitIsLimitedToXDecimals", $conf->global->MAIN_MAX_DECIMALS_UNIT), 1, 1);
1690 if ($object->price_base_type ==
'TTC') {
1691 print
'<input name="price" size="10" value="'.price($object->price_ttc).
'">';
1693 print
'<input name="price" size="10" value="'.price($object->price).
'">';
1699 $text = $langs->trans(
'MinPrice');
1700 print $form->textwithpicto($text, $langs->trans(
"PrecisionUnitIsLimitedToXDecimals", $conf->global->MAIN_MAX_DECIMALS_UNIT), 1, 1);
1701 if ($object->price_base_type ==
'TTC') {
1702 print
'<td><input name="price_min" size="10" value="'.price($object->price_min_ttc).
'">';
1704 print
'<td><input name="price_min" size="10" value="'.price($object->price_min).
'">';
1706 if (!empty($conf->global->PRODUCT_MINIMUM_RECOMMENDED_PRICE))
1708 print
'<td class="left">'.$langs->trans(
"MinimumRecommendedPrice",
price($maxpricesupplier, 0,
'', 1, -1, -1,
'auto')).
' '.
img_warning().
'</td>';
1715 print
'<div class="center">';
1718 print
'<div class="marginbottomonly">';
1719 print
'<input type="checkbox" name="updatechildprice" id="updatechildprice" value="1"> ';
1720 print
'<label for="updatechildprice">'.$langs->trans(
'ForceUpdateChildPriceSoc').
'</label>';
1723 print
'<input type="submit" class="button button-save" value="'.$langs->trans(
"Save").
'">';
1724 print
' ';
1725 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.$langs->trans(
"Cancel").
'">';
1729 } elseif ($action ==
'edit_customer_price')
1732 $maxpricesupplier = $object->min_recommended_price();
1736 $result = $prodcustprice->fetch(
GETPOST(
'lineid',
'int'));
1741 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'" method="POST">';
1742 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1743 print
'<input type="hidden" name="action" value="update_customer_price_confirm">';
1744 print
'<input type="hidden" name="lineid" value="'.$prodcustprice->id.
'">';
1746 print
'<table class="liste centpercent">';
1748 print
'<td class="titlefield fieldrequired">'.$langs->trans(
'ThirdParty').
'</td>';
1749 $staticsoc =
new Societe($db);
1750 $staticsoc->fetch($prodcustprice->fk_soc);
1751 print
"<td>".$staticsoc->getNomUrl(1).
"</td>";
1755 print
'<tr><td class="fieldrequired">'.$langs->trans(
"DefaultTaxRate").
'</td><td>';
1756 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);
1760 print
'<tr><td class="fieldrequired">';
1761 print $langs->trans(
'PriceBase');
1764 print $form->selectPriceBaseType($prodcustprice->price_base_type,
"price_base_type");
1769 print
'<tr><td class="fieldrequired">';
1770 $text = $langs->trans(
'SellingPrice');
1771 print $form->textwithpicto($text, $langs->trans(
"PrecisionUnitIsLimitedToXDecimals", $conf->global->MAIN_MAX_DECIMALS_UNIT), 1, 1);
1773 if ($prodcustprice->price_base_type ==
'TTC') {
1774 print
'<input name="price" size="10" value="'.price($prodcustprice->price_ttc).
'">';
1776 print
'<input name="price" size="10" value="'.price($prodcustprice->price).
'">';
1782 $text = $langs->trans(
'MinPrice');
1783 print $form->textwithpicto($text, $langs->trans(
"PrecisionUnitIsLimitedToXDecimals", $conf->global->MAIN_MAX_DECIMALS_UNIT), 1, 1);
1785 if ($prodcustprice->price_base_type ==
'TTC') {
1786 print
'<input name="price_min" size="10" value="'.price($prodcustprice->price_min_ttc).
'">';
1788 print
'<input name="price_min" size="10" value="'.price($prodcustprice->price_min).
'">';
1791 if (!empty($conf->global->PRODUCT_MINIMUM_RECOMMENDED_PRICE))
1793 print
'<td class="left">'.$langs->trans(
"MinimumRecommendedPrice",
price($maxpricesupplier, 0,
'', 1, -1, -1,
'auto')).
' '.
img_warning().
'</td>';
1800 print
'<div class="center">';
1801 print
'<div class="marginbottomonly">';
1802 print
'<input type="checkbox" name="updatechildprice" id="updatechildprice" value="1"> ';
1803 print
'<label for="updatechildprice">'.$langs->trans(
'ForceUpdateChildPriceSoc').
'</label>';
1806 print
'<input type="submit" class="button button-save" value="'.$langs->trans(
"Save").
'">';
1807 print
' ';
1808 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.$langs->trans(
"Cancel").
'">';
1811 print
'<br></form>';
1812 } elseif ($action ==
'showlog_customer_price')
1815 print
'<!-- list of all log of prices per customer -->'.
"\n";
1817 $filter = array(
't.fk_product' => $object->id,
't.fk_soc' =>
GETPOST(
'socid',
'int'));
1820 $nbtotalofrecords =
'';
1821 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
1822 $nbtotalofrecords = $prodcustprice->fetch_all_log($sortorder, $sortfield, $conf->liste_limit, $offset, $filter);
1825 $result = $prodcustprice->fetch_all_log($sortorder, $sortfield, $conf->liste_limit, $offset, $filter);
1830 $option =
'&socid='.GETPOST(
'socid',
'int').
'&id='.$object->id;
1832 $staticsoc =
new Societe($db);
1833 $staticsoc->fetch(
GETPOST(
'socid',
'int'));
1835 $title = $langs->trans(
'PriceByCustomerLog');
1836 $title .=
' - '.$staticsoc->getNomUrl(1);
1838 $backbutton =
'<a class="justalink" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'">'.$langs->trans(
"Back").
'</a>';
1840 print_barre_liste($title, $page,
$_SERVER[
'PHP_SELF'], $option, $sortfield, $sortorder, $backbutton, count($prodcustprice->lines), $nbtotalofrecords,
'title_accountancy.png');
1842 if (count($prodcustprice->lines) > 0)
1844 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'" method="POST">';
1845 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1846 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
1848 print
'<div class="div-table-responsive-no-min">';
1849 print
'<table class="liste centpercent">';
1851 print
'<tr class="liste_titre">';
1852 print
'<td>'.$langs->trans(
"ThirdParty").
'</td>';
1853 print
'<td>'.$langs->trans(
"AppliedPricesFrom").
'</td>';
1854 print
'<td class="center">'.$langs->trans(
"PriceBase").
'</td>';
1855 print
'<td class="right">'.$langs->trans(
"DefaultTaxRate").
'</td>';
1856 print
'<td class="right">'.$langs->trans(
"HT").
'</td>';
1857 if ($mysoc->localtax1_assuj ==
"1" || $mysoc->localtax2_assuj ==
"1")
1860 print
'<td class="right">'.$langs->trans(
"INCT").
'</td>';
1862 print
'<td class="right">'.$langs->trans(
"TTC").
'</td>';
1864 print
'<td class="right">'.$langs->trans(
"MinPrice").
' '.$langs->trans(
"HT").
'</td>';
1865 print
'<td class="right">'.$langs->trans(
"MinPrice").
' '.$langs->trans(
"TTC").
'</td>';
1866 print
'<td class="right">'.$langs->trans(
"ChangedBy").
'</td>';
1867 print
'<td> </td>';
1870 foreach ($prodcustprice->lines as $line)
1873 $staticsoc =
new Societe($db);
1874 $staticsoc->fetch($line->fk_soc);
1876 $tva_tx = $line->default_vat_code ? $line->tva_tx.
' ('.$line->default_vat_code.
')' : $line->tva_tx;
1879 if ($line->price_base_type ==
'HT')
1883 $pu = $line->price_ttc;
1887 $localtaxarray =
getLocalTaxesFromRate($line->tva_tx.($line->default_vat_code ?
' ('.$line->default_vat_code.
')' :
''), 0, $staticsoc, $mysoc);
1889 $resultarray =
calcul_price_total(1, $pu, 0, $line->tva_tx, 1, 1, 0, $line->price_base_type, $line->recuperableonly, $object->type, $mysoc, $localtaxarray);
1891 $total_ht = $resultarray[0];
1892 $total_vat = $resultarray[1];
1893 $total_localtax1 = $resultarray[9];
1894 $total_localtax2 = $resultarray[10];
1895 $total_ttc = $resultarray[2];
1897 print
'<tr class="oddeven">';
1899 print
"<td>".$staticsoc->getNomUrl(1).
"</td>";
1900 print
"<td>".dol_print_date($line->datec,
"dayhour",
'tzuserrel').
"</td>";
1901 print
'<td class="center">'.$langs->trans($line->price_base_type).
"</td>";
1902 print
'<td class="right">';
1904 $positiverates =
'';
1905 if (
price2num($line->tva_tx)) $positiverates .= ($positiverates ?
'/' :
'').
price2num($line->tva_tx);
1906 if (
price2num($line->localtax1_type)) $positiverates .= ($positiverates ?
'/' :
'').price2num($line->localtax1_tx);
1907 if (
price2num($line->localtax2_type)) $positiverates .= ($positiverates ?
'/' :
'').
price2num($line->localtax2_tx);
1908 if (empty($positiverates)) $positiverates =
'0';
1910 echo
vatrate($positiverates.($line->default_vat_code ?
' ('.$line->default_vat_code.
')' :
''),
'%', ($line->tva_npr ? $line->tva_npr : $line->recuperableonly));
1914 print
'<td class="right">'.price($line->price).
"</td>";
1916 if ($mysoc->localtax1_assuj ==
"1" || $mysoc->localtax2_assuj ==
"1")
1919 print
'<td class="right">'.price($resultarray[2]).
'</td>';
1921 print
'<td class="right">'.price($line->price_ttc).
"</td>";
1924 print
'<td class="right">'.price($line->price_min).
'</td>';
1925 print
'<td class="right">'.price($line->price_min_ttc).
'</td>';
1928 $userstatic =
new User($db);
1929 $userstatic->fetch($line->fk_user);
1930 print
'<td class="right">';
1931 print $userstatic->getNomUrl(1,
'', 0, 0, 24, 0,
'login');
1939 print $langs->trans(
'None');
1941 } elseif ($action !=
'showlog_default_price' && $action !=
'edit_price')
1944 print
'<!-- list of all prices per customer -->'.
"\n";
1947 $nbtotalofrecords =
'';
1948 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
1949 $nbtotalofrecords = $prodcustprice->fetch_all($sortorder, $sortfield, 0, 0, $filter);
1952 $result = $prodcustprice->fetch_all($sortorder, $sortfield, $conf->liste_limit, $offset, $filter);
1957 $option =
'&search_soc='.$search_soc.
'&id='.$object->id;
1959 print_barre_liste($langs->trans(
'PriceByCustomer'), $page,
$_SERVER [
'PHP_SELF'], $option, $sortfield, $sortorder,
'', count($prodcustprice->lines), $nbtotalofrecords,
'title_accountancy.png');
1961 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'" method="POST">';
1962 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1963 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
1965 print
'<div class="div-table-responsive-no-min">';
1966 print
'<table class="liste centpercent">';
1968 if (count($prodcustprice->lines) > 0 || $search_soc)
1973 print
'<tr class="liste_titre">';
1974 print
'<td class="liste_titre"><input type="text" class="flat" name="search_soc" value="'.$search_soc.
'" size="20"></td>';
1975 print
'<td class="liste_titre" colspan="'.$colspan.
'"> </td>';
1977 print
'<td class="liste_titre maxwidthsearch">';
1978 $searchpicto = $form->showFilterAndCheckAddButtons(0);
1984 print
'<tr class="liste_titre">';
1985 print
'<td>'.$langs->trans(
"ThirdParty").
'</td>';
1986 print
'<td>'.$langs->trans(
"AppliedPricesFrom").
'</td>';
1987 print
'<td class="center">'.$langs->trans(
"PriceBase").
'</td>';
1988 print
'<td class="right">'.$langs->trans(
"DefaultTaxRate").
'</td>';
1989 print
'<td class="right">'.$langs->trans(
"HT").
'</td>';
1990 if ($mysoc->localtax1_assuj ==
"1" || $mysoc->localtax2_assuj ==
"1")
1993 print
'<td class="right">'.$langs->trans(
"INCT").
'</td>';
1995 print
'<td class="right">'.$langs->trans(
"TTC").
'</td>';
1998 print
'<td class="right">'.$langs->trans(
"MinPrice").
' '.$langs->trans(
"HT").
'</td>';
1999 print
'<td class="right">'.$langs->trans(
"MinPrice").
' '.$langs->trans(
"TTC").
'</td>';
2000 print
'<td class="right">'.$langs->trans(
"ChangedBy").
'</td>';
2005 if ($object->price_base_type ==
'HT')
2007 $pu = $object->price;
2009 $pu = $object->price_ttc;
2013 $localtaxarray =
getLocalTaxesFromRate($object->tva_tx.($object->default_vat_code ?
' ('.$object->default_vat_code.
')' :
''), 0, $mysoc, $mysoc);
2015 $resultarray =
calcul_price_total(1, $pu, 0, $object->tva_tx, 1, 1, 0, $object->price_base_type, $object->recuperableonly, $object->type, $mysoc, $localtaxarray);
2017 $total_ht = $resultarray[0];
2018 $total_vat = $resultarray[1];
2019 $total_localtax1 = $resultarray[9];
2020 $total_localtax2 = $resultarray[10];
2021 $total_ttc = $resultarray[2];
2023 print
'<tr class="oddeven">';
2024 print
"<td>".$langs->trans(
"Default").
"</td>";
2027 print
'<td class="center">'.$langs->trans($object->price_base_type).
"</td>";
2028 print
'<td class="right">';
2030 $positiverates =
'';
2031 if (
price2num($object->tva_tx)) $positiverates .= ($positiverates ?
'/' :
'').
price2num($object->tva_tx);
2032 if (
price2num($object->localtax1_type)) $positiverates .= ($positiverates ?
'/' :
'').price2num($object->localtax1_tx);
2033 if (
price2num($object->localtax2_type)) $positiverates .= ($positiverates ?
'/' :
'').
price2num($object->localtax2_tx);
2034 if (empty($positiverates)) $positiverates =
'0';
2035 echo
vatrate($positiverates.($object->default_vat_code ?
' ('.$object->default_vat_code.
')' :
''),
'%', $object->tva_npr);
2041 print
'<td class="right">'.price($object->price).
"</td>";
2043 if ($mysoc->localtax1_assuj ==
"1" || $mysoc->localtax2_assuj ==
"1")
2046 print
'<td class="right">'.price($resultarray[2]).
'</td>';
2048 print
'<td class="right">'.price($object->price_ttc).
"</td>";
2052 print
'<td class="right">'.price($object->price_min).
'</td>';
2053 print
'<td class="right">'.price($object->price_min_ttc).
'</td>';
2054 print
'<td class="right">';
2056 if ($user->rights->produit->supprimer || $user->rights->service->supprimer)
2058 print
'<td class="nowraponall">';
2059 print
'<a class="marginleftonly marginrightonly" href="'.$_SERVER[
"PHP_SELF"].
'?action=showlog_default_price&id='.$object->id.
'">';
2060 print
img_info($langs->trans(
'PriceByCustomerLog'));
2063 print
'<a class="marginleftonly marginrightonly editfielda" href="'.$_SERVER[
"PHP_SELF"].
'?action=edit_price&id='.$object->id.
'">';
2064 print
img_edit(
'default', 0,
'style="vertical-align: middle;"');
2070 if (count($prodcustprice->lines) > 0)
2072 foreach ($prodcustprice->lines as $line)
2075 $staticsoc =
new Societe($db);
2076 $staticsoc->fetch($line->fk_soc);
2078 $tva_tx = $line->default_vat_code ? $line->tva_tx.
' ('.$line->default_vat_code.
')' : $line->tva_tx;
2081 if ($line->price_base_type ==
'HT')
2085 $pu = $line->price_ttc;
2089 $localtaxarray =
getLocalTaxesFromRate($line->tva_tx.($line->default_vat_code ?
' ('.$line->default_vat_code.
')' :
''), 0, $staticsoc, $mysoc);
2091 $resultarray =
calcul_price_total(1, $pu, 0, $line->tva_tx, 1, 1, 0, $line->price_base_type, $line->recuperableonly, $object->type, $mysoc, $localtaxarray);
2093 $total_ht = $resultarray[0];
2094 $total_vat = $resultarray[1];
2095 $total_localtax1 = $resultarray[9];
2096 $total_localtax2 = $resultarray[10];
2097 $total_ttc = $resultarray[2];
2099 print
'<tr class="oddeven">';
2101 print
"<td>".$staticsoc->getNomUrl(1).
"</td>";
2102 print
"<td>".dol_print_date($line->datec,
"dayhour",
'tzuserrel').
"</td>";
2103 print
'<td class="center">'.$langs->trans($line->price_base_type).
"</td>";
2104 print
'<td class="right">';
2106 $positiverates =
'';
2107 if (
price2num($line->tva_tx)) $positiverates .= ($positiverates ?
'/' :
'').
price2num($line->tva_tx);
2108 if (
price2num($line->localtax1_type)) $positiverates .= ($positiverates ?
'/' :
'').price2num($line->localtax1_tx);
2109 if (
price2num($line->localtax2_type)) $positiverates .= ($positiverates ?
'/' :
'').
price2num($line->localtax2_tx);
2110 if (empty($positiverates)) $positiverates =
'0';
2112 echo
vatrate($positiverates.($line->default_vat_code ?
' ('.$line->default_vat_code.
')' :
''),
'%', ($line->tva_npr ? $line->tva_npr : $line->recuperableonly));
2115 print
'<td class="right">'.price($line->price).
"</td>";
2117 if ($mysoc->localtax1_assuj ==
"1" || $mysoc->localtax2_assuj ==
"1") {
2119 print
'<td class="right">'.price($resultarray[2]).
'</td>';
2121 print
'<td class="right">'.price($line->price_ttc).
"</td>";
2124 print
'<td class="right">'.price($line->price_min).
'</td>';
2125 print
'<td class="right">'.price($line->price_min_ttc).
'</td>';
2128 $userstatic =
new User($db);
2129 $userstatic->fetch($line->fk_user);
2130 print
'<td class="right">';
2131 print $userstatic->getNomUrl(1,
'', 0, 0, 24, 0,
'login');
2136 if ($user->rights->produit->supprimer || $user->rights->service->supprimer)
2138 print
'<td class="right nowraponall">';
2139 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=showlog_customer_price&id='.$object->id.
'&socid='.$line->fk_soc.
'">';
2140 print
img_info($langs->trans(
'PriceByCustomerLog'));
2143 print
'<a class="marginleftonly editfielda" href="'.$_SERVER[
"PHP_SELF"].
'?action=edit_customer_price&id='.$object->id.
'&lineid='.$line->id.
'">';
2144 print
img_edit(
'default', 0,
'style="vertical-align: middle;"');
2147 print
'<a class="marginleftonly" href="'.$_SERVER[
"PHP_SELF"].
'?action=delete_customer_price&token='.
newToken().
'&id='.$object->id.
'&lineid='.$line->id.
'">';
2148 print
img_delete(
'default',
'style="vertical-align: middle;"');
File of class to manage predefined price products or services by customer.
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
img_edit($titlealt= 'default', $float=0, $other= '')
Show logo editer/modifier fiche.
Class to parse product price expressions.
Class to manage products or services.
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).
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.
Class to manage Dolibarr users.
const TYPE_SERVICE
Service.
const TYPE_PRODUCT
Regular product.
get_localtax($vatrate, $local, $thirdparty_buyer="", $thirdparty_seller="", $vatnpr=0)
Return localtax rate for a particular vat, when selling a product with vat $vatrate, from a $thirdparty_buyer to a $thirdparty_seller Note: This function applies same rules than get_default_tva.
img_warning($titlealt= 'default', $moreatt= '', $morecss= 'pictowarning')
Show warning logo.
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...
setEventMessages($mesg, $mesgs, $style= 'mesgs', $messagekey= '')
Set event messages in dol_events session object.
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.
Class to manage third parties objects (customers, suppliers, prospects...)
load_fiche_titre($titre, $morehtmlright= '', $picto= 'generic', $pictoisfullpath=0, $id= '', $morecssontable= '', $morehtmlcenter= '')
Load a title with picto.
price2num($amount, $rounding= '', $option=0)
Function that return a number with universal decimal format (decimal separator is '...
Class for accesing price expression table.
img_picto($titlealt, $picto, $moreatt= '', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt= '', $morecss= '', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
restrictedArea($user, $features, $objectid=0, $tableandshare= '', $feature2= '', $dbt_keyfield= 'fk_soc', $dbt_select= 'rowid', $isdraft=0)
Check permissions of a user to show a page and an object.
vatrate($rate, $addpercent=false, $info_bits=0, $usestarfornpr=0)
Return a string with VAT rate label formated for view output Used into pdf and HTML pages...
print $_SERVER["PHP_SELF"]
Edit parameters.
dol_get_fiche_head($links=array(), $active= '', $title= '', $notab=0, $picto= '', $pictoisfullpath=0, $morehtmlright= '', $morecss= '', $limittoshow=0, $moretabssuffix= '')
Show tabs of a record.
print
Draft customers invoices.
if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) if(!empty($conf->don->enabled)&&$user->rights->don->lire) if(!empty($conf->tax->enabled)&&$user->rights->tax->charges->lire) if(!empty($conf->facture->enabled)&&!empty($conf->commande->enabled)&&$user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
dol_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
img_info($titlealt= 'default')
Show info logo.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
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.
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.
getLocalTaxesFromRate($vatrate, $local, $buyer, $seller, $firstparamisid=0)
Get type and rate of localtaxes for a particular vat rate/country of a thirdparty.
img_delete($titlealt= 'default', $other= 'class="pictodelete"', $morecss= '')
Show delete logo.
if(!defined('CSRFCHECK_WITH_TOKEN')) define('CSRFCHECK_WITH_TOKEN'
Draft customers invoices.
if(preg_match('/crypted:/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
product_prepare_head($object)
Prepare array with list of tabs.