38require
'../main.inc.php';
39require_once DOL_DOCUMENT_ROOT.
'/core/lib/product.lib.php';
40require_once DOL_DOCUMENT_ROOT.
'/core/lib/price.lib.php';
41require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
42require_once DOL_DOCUMENT_ROOT.
'/product/dynamic_price/class/price_expression.class.php';
43require_once DOL_DOCUMENT_ROOT.
'/product/dynamic_price/class/price_parser.class.php';
45if (!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;
73if ($id > 0 || !empty($ref)) {
74 $object->fetch($id, $ref);
78if ((!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'));
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);
111if (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->hasRight(
'produit',
'creer') || $user->hasRight(
'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();
261 if (isModEnabled(
'dynamicprices')) {
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 $basePrice = ($object->price_base_type ==
'HT') ? $object->price : $object->price_ttc;
511 $basePriceMin = ($object->price_base_type ==
'HT') ? $object->price_min : $object->price_min_ttc;
512 $ret = $object->updatePrice($basePrice, $object->price_base_type, $user, $object->tva_tx, $basePriceMin, $level, $object->tva_npr, 1);
519 if ($action ==
'disable_price_by_qty') {
521 $level =
GETPOST(
'level',
'int');
522 $basePrice = ($object->price_base_type ==
'HT') ? $object->price : $object->price_ttc;
523 $basePriceMin = ($object->price_base_type ==
'HT') ? $object->price_min : $object->price_min_ttc;
524 $ret = $object->updatePrice($basePrice, $object->price_base_type, $user, $object->tva_tx, $basePriceMin, $level, $object->tva_npr, 0);
531 if ($action ==
'edit_price_by_qty') {
532 $rowid =
GETPOST(
'rowid',
'int');
536 if ($action ==
'update_price_by_qty') {
538 $rowid =
GETPOST(
'rowid',
'int');
539 $priceid =
GETPOST(
'priceid',
'int');
546 if (empty($quantity)) {
548 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Qty")),
null,
'errors');
550 if (empty($newprice)) {
552 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Price")),
null,
'errors');
556 if ($object->price_base_type ==
'TTC') {
557 $price =
price2num($newprice) / (1 + ($object->tva_tx / 100));
561 $unitPrice =
price2num($price / $quantity,
'MU');
565 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"product_price_by_qty SET";
566 $sql .=
" price=".((float) $price).
",";
567 $sql .=
" unitprice=".((float) $unitPrice).
",";
568 $sql .=
" quantity=".((float) $quantity).
",";
569 $sql .=
" remise_percent=".((float) $remise_percent).
",";
570 $sql .=
" remise=".((float) $remise);
571 $sql .=
" WHERE rowid = ".((int) $rowid);
573 $result = $db->query($sql);
578 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"product_price_by_qty (fk_product_price,price,unitprice,quantity,remise_percent,remise) values (";
579 $sql .= ((int) $priceid).
','.((float) $price).
','.((float) $unitPrice).
','.((float) $quantity).
','.((float) $remise_percent).
','.((float) $remise).
')';
581 $result = $db->query($sql);
583 if ($db->lasterrno() ==
'DB_ERROR_RECORD_ALREADY_EXISTS') {
593 if ($action ==
'delete_price_by_qty') {
594 $rowid =
GETPOST(
'rowid',
'int');
595 if (!empty($rowid)) {
596 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"product_price_by_qty";
597 $sql .=
" WHERE rowid = ".((int) $rowid);
599 $result = $db->query($sql);
601 setEventMessages((
'delete_price_by_qty'.$langs->transnoentities(
'MissingIds')),
null,
'errors');
605 if ($action ==
'delete_all_price_by_qty') {
606 $priceid =
GETPOST(
'priceid',
'int');
607 if (!empty($rowid)) {
608 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"product_price_by_qty";
609 $sql .=
" WHERE fk_product_price = ".((int) $priceid);
611 $result = $db->query($sql);
613 setEventMessages((
'delete_price_by_qty'.$langs->transnoentities(
'MissingIds')),
null,
'errors');
622 if ($action ==
'add_customer_price_confirm' && !$cancel && ($user->hasRight(
'produit',
'creer') || $user->hasRight(
'service',
'creer'))) {
623 $maxpricesupplier = $object->min_recommended_price();
625 $update_child_soc =
GETPOST(
'updatechildprice',
'int');
628 $prodcustprice->fk_soc =
GETPOST(
'socid',
'int');
629 $prodcustprice->ref_customer =
GETPOST(
'ref_customer',
'alpha');
630 $prodcustprice->fk_product = $object->id;
633 $prodcustprice->price_base_type =
GETPOST(
"price_base_type",
'alpha');
635 $tva_tx_txt =
GETPOST(
"tva_tx",
'alpha');
637 $tva_tx = $tva_tx_txt;
639 if (preg_match(
'/\((.*)\)/', $tva_tx_txt, $reg)) {
640 $vat_src_code = $reg[1];
641 $tva_tx = preg_replace(
'/\s*\(.*\)/',
'', $tva_tx_txt);
643 $tva_tx =
price2num(preg_replace(
'/\*/',
'', $tva_tx));
645 $npr = preg_match(
'/\*/', $tva_tx_txt) ? 1 : 0;
646 $localtax1 = 0; $localtax2 = 0; $localtax1_type =
'0'; $localtax2_type =
'0';
648 if (preg_match(
'/\((.*)\)/', $tva_tx_txt, $reg)) {
650 $vatratecode = $reg[1];
652 $sql =
"SELECT t.rowid, t.code, t.recuperableonly, t.localtax1, t.localtax2, t.localtax1_type, t.localtax2_type";
653 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_tva as t, ".MAIN_DB_PREFIX.
"c_country as c";
654 $sql .=
" WHERE t.fk_pays = c.rowid AND c.code = '".$db->escape($mysoc->country_code).
"'";
655 $sql .=
" AND t.taux = ".((float) $tva_tx).
" AND t.active = 1";
656 $sql .=
" AND t.code ='".$db->escape($vatratecode).
"'";
657 $resql = $db->query($sql);
659 $obj = $db->fetch_object($resql);
661 $npr = $obj->recuperableonly;
662 $localtax1 = $obj->localtax1;
663 $localtax2 = $obj->localtax2;
664 $localtax1_type = $obj->localtax1_type;
665 $localtax2_type = $obj->localtax2_type;
669 if (in_array($mysoc->country_code, array(
'ES'))) {
676 $sql =
"SELECT t.rowid, t.code, t.recuperableonly, t.localtax1, t.localtax2, t.localtax1_type, t.localtax2_type";
677 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_tva as t, ".MAIN_DB_PREFIX.
"c_country as c";
678 $sql .=
" WHERE t.fk_pays = c.rowid AND c.code = '".$db->escape($mysoc->country_code).
"'";
679 $sql .=
" AND t.taux = ".((float) $tva_tx).
" AND t.active = 1";
680 $sql .=
" AND t.code = ''";
681 $resql = $db->query($sql);
683 $obj = $db->fetch_object($resql);
685 $npr = $obj->recuperableonly;
686 $localtax1 = $obj->localtax1;
687 $localtax2 = $obj->localtax2;
688 $localtax1_type = $obj->localtax1_type;
689 $localtax2_type = $obj->localtax2_type;
694 $prodcustprice->default_vat_code = $vatratecode;
695 $prodcustprice->tva_tx = $tva_tx;
696 $prodcustprice->recuperableonly = $npr;
697 $prodcustprice->localtax1_tx = $localtax1;
698 $prodcustprice->localtax2_tx = $localtax2;
699 $prodcustprice->localtax1_type = $localtax1_type;
700 $prodcustprice->localtax2_type = $localtax2_type;
702 if (!($prodcustprice->fk_soc > 0)) {
703 $langs->load(
"errors");
704 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"ThirdParty")),
null,
'errors');
706 $action =
'add_customer_price';
708 if (!empty($conf->global->PRODUCT_MINIMUM_RECOMMENDED_PRICE) && $prodcustprice->price_min < $maxpricesupplier) {
709 $langs->load(
"errors");
710 setEventMessages($langs->trans(
"MinimumPriceLimit",
price($maxpricesupplier, 0,
'', 1, -1, -1,
'auto')),
null,
'errors');
712 $action =
'add_customer_price';
716 $result = $prodcustprice->create($user, 0, $update_child_soc);
728 if ($action ==
'delete_customer_price' && ($user->rights->produit->supprimer || $user->rights->service->supprimer)) {
730 $prodcustprice->id =
GETPOST(
'lineid',
'int');
731 $result = $prodcustprice->delete($user);
741 if ($action ==
'update_customer_price_confirm' && !$cancel && ($user->hasRight(
'produit',
'creer') || $user->hasRight(
'service',
'creer'))) {
742 $maxpricesupplier = $object->min_recommended_price();
744 $update_child_soc =
GETPOST(
'updatechildprice',
'int');
746 $prodcustprice->fetch(
GETPOST(
'lineid',
'int'));
749 $prodcustprice->ref_customer =
GETPOST(
'ref_customer',
'alpha');
752 $prodcustprice->price_base_type =
GETPOST(
"price_base_type",
'alpha');
754 $tva_tx_txt =
GETPOST(
"tva_tx");
756 $tva_tx = $tva_tx_txt;
758 if (preg_match(
'/\((.*)\)/', $tva_tx_txt, $reg)) {
759 $vat_src_code = $reg[1];
760 $tva_tx = preg_replace(
'/\s*\(.*\)/',
'', $tva_tx_txt);
762 $tva_tx =
price2num(preg_replace(
'/\*/',
'', $tva_tx));
764 $npr = preg_match(
'/\*/', $tva_tx_txt) ? 1 : 0;
765 $localtax1 = 0; $localtax2 = 0; $localtax1_type =
'0'; $localtax2_type =
'0';
767 if (preg_match(
'/\((.*)\)/', $tva_tx_txt, $reg)) {
769 $vatratecode = $reg[1];
771 $sql =
"SELECT t.rowid, t.code, t.recuperableonly, t.localtax1, t.localtax2, t.localtax1_type, t.localtax2_type";
772 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_tva as t, ".MAIN_DB_PREFIX.
"c_country as c";
773 $sql .=
" WHERE t.fk_pays = c.rowid AND c.code = '".$db->escape($mysoc->country_code).
"'";
774 $sql .=
" AND t.taux = ".((float) $tva_tx).
" AND t.active = 1";
775 $sql .=
" AND t.code ='".$db->escape($vatratecode).
"'";
776 $resql = $db->query($sql);
778 $obj = $db->fetch_object($resql);
780 $npr = $obj->recuperableonly;
781 $localtax1 = $obj->localtax1;
782 $localtax2 = $obj->localtax2;
783 $localtax1_type = $obj->localtax1_type;
784 $localtax2_type = $obj->localtax2_type;
788 if (in_array($mysoc->country_code, array(
'ES'))) {
795 $sql =
"SELECT t.rowid, t.code, t.recuperableonly, t.localtax1, t.localtax2, t.localtax1_type, t.localtax2_type";
796 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_tva as t, ".MAIN_DB_PREFIX.
"c_country as c";
797 $sql .=
" WHERE t.fk_pays = c.rowid AND c.code = '".$db->escape($mysoc->country_code).
"'";
798 $sql .=
" AND t.taux = ".((float) $tva_tx).
" AND t.active = 1";
799 $sql .=
" AND t.code = ''";
800 $resql = $db->query($sql);
802 $obj = $db->fetch_object($resql);
804 $npr = $obj->recuperableonly;
805 $localtax1 = $obj->localtax1;
806 $localtax2 = $obj->localtax2;
807 $localtax1_type = $obj->localtax1_type;
808 $localtax2_type = $obj->localtax2_type;
813 $prodcustprice->default_vat_code = $vatratecode;
814 $prodcustprice->tva_tx = $tva_tx;
815 $prodcustprice->recuperableonly = $npr;
816 $prodcustprice->localtax1_tx = $localtax1;
817 $prodcustprice->localtax2_tx = $localtax2;
818 $prodcustprice->localtax1_type = $localtax1_type;
819 $prodcustprice->localtax2_type = $localtax2_type;
821 if ($prodcustprice->price_min < $maxpricesupplier && !empty($conf->global->PRODUCT_MINIMUM_RECOMMENDED_PRICE)) {
822 setEventMessages($langs->trans(
"MinimumPriceLimit",
price($maxpricesupplier, 0,
'', 1, -1, -1,
'auto')),
null,
'errors');
824 $action =
'update_customer_price';
828 $result = $prodcustprice->update($user, 0, $update_child_soc);
846$form =
new Form($db);
848if (!empty($id) || !empty($ref)) {
850 $object->fetch($id, $ref);
853$title = $langs->trans(
'ProductServiceCard');
855$shortlabel =
dol_trunc($object->label, 16);
857 $title = $langs->trans(
'Product').
" ".$shortlabel.
" - ".$langs->trans(
'SellingPrices');
858 $helpurl =
'EN:Module_Products|FR:Module_Produits|ES:Módulo_Productos';
861 $title = $langs->trans(
'Service').
" ".$shortlabel.
" - ".$langs->trans(
'SellingPrices');
862 $helpurl =
'EN:Module_Services_En|FR:Module_Services|ES:Módulo_Servicios';
865llxHeader(
'', $title, $helpurl,
'', 0, 0,
'',
'',
'',
'classforhorizontalscrolloftabs');
868$titre = $langs->trans(
"CardProduct".$object->type);
873$linkback =
'<a href="'.DOL_URL_ROOT.
'/product/list.php?restore_lastsearch_values=1&type='.$object->type.
'">'.$langs->trans(
"BackToList").
'</a>';
874$object->next_prev_filter =
"fk_product_type = ".((int) $object->type);
877if ($user->socid && !in_array(
'product', explode(
',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) {
884print
'<div class="fichecenter">';
886print
'<div class="underbanner clearboth"></div>';
887print
'<table class="border tableforfield centpercent">';
890if (!empty($conf->global->PRODUIT_MULTIPRICES) || !empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) {
892 if (!empty($socid)) {
898 if (isModEnabled(
"product") && isModEnabled(
"service")) {
899 $typeformat =
'select;0:'.$langs->trans(
"Product").
',1:'.$langs->trans(
"Service");
900 print
'<tr><td class="">';
901 print (empty($conf->global->PRODUCT_DENY_CHANGE_PRODUCT_TYPE)) ? $form->editfieldkey(
"Type",
'fk_product_type', $object->type, $object, 0, $typeformat) : $langs->trans(
'Type');
903 print $form->editfieldval(
"Type",
'fk_product_type', $object->type, $object, 0, $typeformat);
908 print
'<tr><td class="titlefieldcreate">';
909 print $langs->trans(
"SellingPrice");
911 print
'<td colspan="2">';
912 if ($object->multiprices_base_type[$soc->price_level] ==
'TTC') {
913 print
'<span class="amount">'.price($object->multiprices_ttc[$soc->price_level]).
'</span>';
915 print
'<span class="amount">'.price($object->multiprices[$soc->price_level]).
'</span>';
917 if ($object->multiprices_base_type[$soc->price_level]) {
918 print
' '.$langs->trans($object->multiprices_base_type[$soc->price_level]);
920 print
' '.$langs->trans($object->price_base_type);
925 print
'<tr><td>'.$langs->trans(
"MinPrice").
'</td><td colspan="2">';
926 if ($object->multiprices_base_type[$soc->price_level] ==
'TTC') {
927 print
price($object->multiprices_min_ttc[$soc->price_level]).
' '.$langs->trans($object->multiprices_base_type[$soc->price_level]);
929 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]);
933 if (!empty($conf->global->PRODUIT_MULTIPRICES_USE_VAT_PER_LEVEL)) {
935 print
'<tr><td>'.$langs->trans(
"DefaultTaxRate").
'</td><td colspan="2">';
938 if (
price2num($object->multiprices_tva_tx[$soc->price_level])) {
939 $positiverates .= ($positiverates ?
'/' :
'').
price2num($object->multiprices_tva_tx[$soc->price_level]);
941 if (
price2num($object->multiprices_localtax1_type[$soc->price_level])) {
942 $positiverates .= ($positiverates ?
'/' :
'').
price2num($object->multiprices_localtax1_tx[$soc->price_level]);
944 if (
price2num($object->multiprices_localtax2_type[$soc->price_level])) {
945 $positiverates .= ($positiverates ?
'/' :
'').
price2num($object->multiprices_localtax2_tx[$soc->price_level]);
947 if (empty($positiverates)) {
948 $positiverates =
'0';
950 echo
vatrate($positiverates.($object->default_vat_code ?
' ('.$object->default_vat_code.
')' :
''),
'%', $object->tva_npr);
955 print
'<tr><td>'.$langs->trans(
"DefaultTaxRate").
'</td><td>';
959 $positiverates .= ($positiverates ?
'/' :
'').
price2num($object->tva_tx);
961 if (
price2num($object->localtax1_type)) {
962 $positiverates .= ($positiverates ?
'/' :
'').
price2num($object->localtax1_tx);
964 if (
price2num($object->localtax2_type)) {
965 $positiverates .= ($positiverates ?
'/' :
'').
price2num($object->localtax2_tx);
967 if (empty($positiverates)) {
968 $positiverates =
'0';
970 echo
vatrate($positiverates.($object->default_vat_code ?
' ('.$object->default_vat_code.
')' :
''),
'%', $object->tva_npr);
980 if (!empty($conf->global->PRODUIT_MULTIPRICES_USE_VAT_PER_LEVEL)) {
982 if (isModEnabled(
"product") && isModEnabled(
"service")) {
983 $typeformat =
'select;0:'.$langs->trans(
"Product").
',1:'.$langs->trans(
"Service");
984 print
'<tr><td class="">';
985 print (empty($conf->global->PRODUCT_DENY_CHANGE_PRODUCT_TYPE)) ? $form->editfieldkey(
"Type",
'fk_product_type', $object->type, $object, 0, $typeformat) : $langs->trans(
'Type');
987 print $form->editfieldval(
"Type",
'fk_product_type', $object->type, $object, 0, $typeformat);
992 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"DefaultTaxRate").
'</td>';
993 print
'<td colspan="2">'.vatrate($object->multiprices_tva_tx[1],
true).
'</td>';
997 if (isModEnabled(
"product") && isModEnabled(
"service")) {
998 $typeformat =
'select;0:'.$langs->trans(
"Product").
',1:'.$langs->trans(
"Service");
999 print
'<tr><td class="">';
1000 print (empty($conf->global->PRODUCT_DENY_CHANGE_PRODUCT_TYPE)) ? $form->editfieldkey(
"Type",
'fk_product_type', $object->type, $object, 0, $typeformat) : $langs->trans(
'Type');
1002 print $form->editfieldval(
"Type",
'fk_product_type', $object->type, $object, 0, $typeformat);
1007 print
'<!-- Default VAT Rate -->';
1008 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"DefaultTaxRate").
'</td><td>';
1011 $positiverates =
'';
1013 $positiverates .= ($positiverates ?
'<span class="opacitymedium">/</span>' :
'').
price2num($object->tva_tx);
1015 if (
price2num($object->localtax1_type)) {
1016 $positiverates .= ($positiverates ?
'<span class="opacitymedium">/</span>' :
'').
price2num($object->localtax1_tx);
1018 if (
price2num($object->localtax2_type)) {
1019 $positiverates .= ($positiverates ?
'<span class="opacitymedium">/</span>' :
'').
price2num($object->localtax2_tx);
1021 if (empty($positiverates)) {
1022 $positiverates =
'0';
1025 print
vatrate($positiverates.($object->default_vat_code ?
' ('.$object->default_vat_code.
')' :
''), true, $object->tva_npr, 1);
1038 print
'<table class="noborder tableforfield centpercent">';
1039 print
'<tr class="liste_titre"><td>';
1040 print $langs->trans(
"PriceLevel");
1042 print
' <a class="editfielda" href="'.$_SERVER[
"PHP_SELF"].
'?action=editlabelsellingprice&token='.newToken().
'&pricelevel='.$i.
'&id='.$object->id.
'">'.
img_edit($langs->trans(
'EditSellingPriceLabel'), 0).
'</a>';
1045 print
'<td style="text-align: right">'.$langs->trans(
"SellingPrice").
'</td>';
1046 print
'<td style="text-align: right">'.$langs->trans(
"MinPrice").
'</td>';
1049 for ($i = 1; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i++) {
1050 print
'<tr class="oddeven">';
1054 $keyforlabel =
'PRODUIT_MULTIPRICES_LABEL'.$i;
1055 if (preg_match(
'/editlabelsellingprice/', $action)) {
1056 print
'<form method="post" action="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'">';
1057 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1058 print
'<input type="hidden" name="action" value="setlabelsellingprice">';
1059 print
'<input type="hidden" name="pricelevel" value="'.$i.
'">';
1060 print $langs->trans(
"SellingPrice").
' '.$i.
' - ';
1061 print
'<input class="maxwidthonsmartphone" type="text" name="labelsellingprice" value="'.$conf->global->$keyforlabel.
'">';
1062 print
' <input type="submit" class="button smallpaddingimp" value="'.$langs->trans(
"Modify").
'">';
1065 print $langs->trans(
"SellingPrice").
' '.$i;
1066 if (!empty($conf->global->$keyforlabel)) {
1067 print
' - '.$langs->trans($conf->global->$keyforlabel);
1072 if ($object->multiprices_base_type [$i] ==
'TTC') {
1073 print
'<td class="right"><span class="amount">'.price($object->multiprices_ttc[$i]);
1075 print
'<td class="right"><span class="amount">'.price($object->multiprices[$i]);
1078 if ($object->multiprices_base_type[$i]) {
1079 print
' '.$langs->trans($object->multiprices_base_type [$i]).
'</span></td>';
1081 print
' '.$langs->trans($object->price_base_type).
'</span></td>';
1085 print
'<td style="text-align: right">';
1086 if (empty($object->multiprices_base_type[$i])) {
1087 $object->multiprices_base_type[$i] =
"HT";
1089 if ($object->multiprices_base_type[$i] ==
'TTC') {
1090 print
price($object->multiprices_min_ttc[$i]).
' '.$langs->trans($object->multiprices_base_type[$i]);
1092 print
price($object->multiprices_min[$i]).
' '.$langs->trans($object->multiprices_base_type[$i]);
1097 if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY) || !empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) {
1098 print
'<tr><td>'.$langs->trans(
"PriceByQuantity").
' '.$i;
1099 if (!empty($conf->global->$keyforlabel)) {
1100 print
' - '.$langs->trans($conf->global->$keyforlabel);
1102 print
'</td><td colspan="2">';
1104 if ($object->prices_by_qty[$i] == 1) {
1105 print
'<table width="50%" class="border" summary="List of quantities">';
1107 print
'<tr class="liste_titre">';
1108 print
'<td>'.$langs->trans(
"PriceByQuantityRange").
' '.$i.
'</td>';
1109 print
'<td class="right">'.$langs->trans(
"HT").
'</td>';
1110 print
'<td class="right">'.$langs->trans(
"UnitPrice").
'</td>';
1111 print
'<td class="right">'.$langs->trans(
"Discount").
'</td>';
1112 print
'<td> </td>';
1114 foreach ($object->prices_by_qty_list[$i] as $ii => $prices) {
1115 if ($action ==
'edit_price_by_qty' && $rowid == $prices[
'rowid'] && ($user->hasRight(
'produit',
'creer') || $user->hasRight(
'service',
'creer'))) {
1116 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'" method="POST">';
1117 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1118 print
'<input type="hidden" name="action" value="update_price_by_qty">';
1119 print
'<input type="hidden" name="priceid" value="'.$object->prices_by_qty_id[$i].
'">';
1120 print
'<input type="hidden" value="'.$prices[
'rowid'].
'" name="rowid">';
1121 print
'<tr class="'.($ii % 2 == 0 ?
'pair' :
'impair').
'">';
1122 print
'<td><input size="5" type="text" value="'.$prices[
'quantity'].
'" name="quantity"></td>';
1123 print
'<td class="right" colspan="2"><input size="10" type="text" value="'.price2num($prices[
'price'],
'MU').
'" name="price"> '.$object->price_base_type.
'</td>';
1124 print
'<td class="right nowraponall"><input size="5" type="text" value="'.$prices[
'remise_percent'].
'" name="remise_percent"> %</td>';
1125 print
'<td class="center"><input type="submit" value="'.$langs->trans(
"Modify").
'" class="button"></td>';
1129 print
'<tr class="'.($ii % 2 == 0 ?
'pair' :
'impair').
'">';
1130 print
'<td>'.$prices[
'quantity'].
'</td>';
1131 print
'<td class="right">'.price($prices[
'price']).
'</td>';
1132 print
'<td class="right">'.price($prices[
'unitprice']).
'</td>';
1133 print
'<td class="right">'.price($prices[
'remise_percent']).
' %</td>';
1134 print
'<td class="center">';
1135 if (($user->rights->produit->creer || $user->hasRight(
'service',
'creer'))) {
1136 print
'<a class="editfielda marginleftonly marginrightonly" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=edit_price_by_qty&token='.newToken().
'&rowid='.$prices[
"rowid"].
'">';
1138 print
'<a class="marginleftonly marginrightonly" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=delete_price_by_qty&token='.newToken().
'&rowid='.$prices[
"rowid"].
'">';
1147 if ($action !=
'edit_price_by_qty' && ($user->hasRight(
'produit',
'creer') || $user->hasRight(
'service',
'creer'))) {
1148 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'" method="POST">';
1149 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1150 print
'<input type="hidden" name="action" value="update_price_by_qty">';
1151 print
'<input type="hidden" name="priceid" value="'.$object->prices_by_qty_id[$i].
'">';
1152 print
'<input type="hidden" value="0" name="rowid">';
1153 print
'<tr class="'.($ii % 2 == 0 ?
'pair' :
'impair').
'">';
1154 print
'<td><input size="5" type="text" value="1" name="quantity"></td>';
1155 print
'<td class="right" class="nowrap"><input size="10" type="text" value="0" name="price"> '.$object->price_base_type.
'</td>';
1156 print
'<td class="right"> </td>';
1157 print
'<td class="right" class="nowraponall"><input size="5" type="text" value="0" name="remise_percent"> %</td>';
1158 print
'<td class="center"><input type="submit" value="'.$langs->trans(
"Add").
'" class="button"></td>';
1164 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>';
1166 print $langs->trans(
"No");
1167 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>';
1175 print
'<tr><td class="titlefield">'.$langs->trans(
"DefaultTaxRate").
'</td><td>';
1177 $positiverates =
'';
1179 $positiverates .= ($positiverates ?
'/' :
'').
price2num($object->tva_tx);
1181 if (
price2num($object->localtax1_type)) {
1182 $positiverates .= ($positiverates ?
'/' :
'').
price2num($object->localtax1_tx);
1184 if (
price2num($object->localtax2_type)) {
1185 $positiverates .= ($positiverates ?
'/' :
'').
price2num($object->localtax2_tx);
1187 if (empty($positiverates)) {
1188 $positiverates =
'0';
1190 echo
vatrate($positiverates.($object->default_vat_code ?
' ('.$object->default_vat_code.
')' :
''),
'%', $object->tva_npr, 0, 1);
1200 print
'<tr class="field_selling_price"><td>'.$langs->trans(
"SellingPrice").
'</td><td>';
1201 if ($object->price_base_type ==
'TTC') {
1202 print
price($object->price_ttc).
' '.$langs->trans($object->price_base_type);
1204 print
price($object->price).
' '.$langs->trans($object->price_base_type);
1205 if (!empty($conf->global->PRODUCT_DISPLAY_VAT_INCL_PRICES) && !empty($object->price_ttc)) {
1206 print
'<i class="opacitymedium"> - ' .
price($object->price_ttc).
' '.$langs->trans(
'TTC') .
'</i>';
1213 print
'<tr class="field_min_price"><td>'.$langs->trans(
"MinPrice").
'</td><td>';
1214 if ($object->price_base_type ==
'TTC') {
1215 print
price($object->price_min_ttc).
' '.$langs->trans($object->price_base_type);
1217 print
price($object->price_min).
' '.$langs->trans($object->price_base_type);
1218 if (!empty($conf->global->PRODUCT_DISPLAY_VAT_INCL_PRICES) && !empty($object->price_min_ttc)) {
1219 print
'<i class="opacitymedium"> - ' .
price($object->price_min_ttc).
' '.$langs->trans(
'TTC') .
'</i>';
1226 if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY) || !empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) {
1227 print
'<tr><td>'.$langs->trans(
"PriceByQuantity");
1228 if ($object->prices_by_qty[0] == 0) {
1229 print
' <a href="'.$_SERVER[
'PHP_SELF'].
'?id='.$object->id.
'&action=activate_price_by_qty&level=1&token='.newToken().
'">('.$langs->trans(
"Activate").
')';
1231 print
' <a href="'.$_SERVER[
'PHP_SELF'].
'?id='.$object->id.
'&action=disable_price_by_qty&level=1&token='.newToken().
'">('.$langs->trans(
"DisablePriceByQty").
')';
1235 if ($object->prices_by_qty[0] == 1) {
1236 print
'<table width="50%" class="border" summary="List of quantities">';
1237 print
'<tr class="liste_titre">';
1239 print
'<td>'.$langs->trans(
"Quantity").
'</td>';
1240 print
'<td class="right">'.$langs->trans(
"Price").
'</td>';
1241 print
'<td class="right"></td>';
1242 print
'<td class="right">'.$langs->trans(
"UnitPrice").
'</td>';
1243 print
'<td class="right">'.$langs->trans(
"Discount").
'</td>';
1244 print
'<td> </td>';
1246 if ($action !=
'edit_price_by_qty') {
1247 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'" method="POST">';
1248 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1249 print
'<input type="hidden" name="action" value="update_price_by_qty">';
1250 print
'<input type="hidden" name="priceid" value="'.$object->prices_by_qty_id[0].
'">';
1251 print
'<input type="hidden" value="0" name="rowid">';
1253 print
'<tr class="'.($ii % 2 == 0 ?
'pair' :
'impair').
'">';
1254 print
'<td><input size="5" type="text" value="1" name="quantity"></td>';
1255 print
'<td class="right"><input class="width50 right" type="text" value="0" name="price"></td>';
1259 print
'<td class="right"> </td>';
1260 print
'<td class="right nowraponall"><input type="text" class="width50 right" value="0" name="remise_percent"> %</td>';
1261 print
'<td class="center"><input type="submit" value="'.$langs->trans(
"Add").
'" class="button"></td>';
1266 foreach ($object->prices_by_qty_list[0] as $ii => $prices) {
1267 if ($action ==
'edit_price_by_qty' && $rowid == $prices[
'rowid'] && ($user->hasRight(
'produit',
'creer') || $user->hasRight(
'service',
'creer'))) {
1268 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'" method="POST">';
1269 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1270 print
'<input type="hidden" name="action" value="update_price_by_qty">';
1271 print
'<input type="hidden" name="priceid" value="'.$object->prices_by_qty_id[0].
'">';
1272 print
'<input type="hidden" value="'.$prices[
'rowid'].
'" name="rowid">';
1273 print
'<tr class="'.($ii % 2 == 0 ?
'pair' :
'impair').
'">';
1274 print
'<td><input size="5" type="text" value="'.$prices[
'quantity'].
'" name="quantity"></td>';
1275 print
'<td class="right"><input class="width50 right" type="text" value="'.price2num($prices[
'price'],
'MU').
'" name="price"></td>';
1276 print
'<td class="right">';
1278 print $prices[
'price_base_type'];
1280 print
'<td class="right"> </td>';
1281 print
'<td class="right nowraponall"><input class="width50 right" type="text" value="'.$prices[
'remise_percent'].
'" name="remise_percent"> %</td>';
1282 print
'<td class="center"><input type="submit" value="'.$langs->trans(
"Modify").
'" class="button"></td>';
1286 print
'<tr class="'.($ii % 2 == 0 ?
'pair' :
'impair').
'">';
1287 print
'<td>'.$prices[
'quantity'].
'</td>';
1288 print
'<td class="right">'.price($prices[
'price']).
'</td>';
1289 print
'<td class="right">';
1291 print $prices[
'price_base_type'];
1293 print
'<td class="right">'.price($prices[
'unitprice']).
'</td>';
1294 print
'<td class="right">'.price($prices[
'remise_percent']).
' %</td>';
1295 print
'<td class="center">';
1296 if (($user->rights->produit->creer || $user->hasRight(
'service',
'creer'))) {
1297 print
'<a class="editfielda marginleftonly marginrightonly" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=edit_price_by_qty&token='.newToken().
'&rowid='.$prices[
"rowid"].
'">';
1299 print
'<a class="marginleftonly marginrightonly" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=delete_price_by_qty&token='.newToken().
'&rowid='.$prices[
"rowid"].
'">';
1310 print $langs->trans(
"No");
1319print
'<div class="clearboth"></div>';
1331if (!$action || $action ==
'delete' || $action ==
'showlog_customer_price' || $action ==
'showlog_default_price' || $action ==
'add_customer_price'
1332 || $action ==
'activate_price_by_qty' || $action ==
'disable_price_by_qty') {
1333 print
"\n".
'<div class="tabsAction">'.
"\n";
1336 $parameters = array();
1337 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters, $object, $action);
1338 if (empty($reshook)) {
1339 if ($object->isVariant()) {
1340 if ($user->hasRight(
'produit',
'creer') || $user->hasRight(
'service',
'creer')) {
1341 print
'<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="' .
dol_escape_htmltag($langs->trans(
"NoEditVariants")) .
'">' . $langs->trans(
"UpdateDefaultPrice") .
'</a></div>';
1344 if (empty($conf->global->PRODUIT_MULTIPRICES) && empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) {
1345 if ($user->hasRight(
'produit',
'creer') || $user->hasRight(
'service',
'creer')) {
1346 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>';
1348 print
'<div class="inline-block divButAction"><span class="butActionRefused" title="'.dol_escape_htmltag($langs->trans(
"NotEnoughPermissions")).
'">' . $langs->trans(
"UpdateDefaultPrice") .
'</span></div>';
1352 if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) {
1353 if ($user->hasRight(
'produit',
'creer') || $user->hasRight(
'service',
'creer')) {
1354 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>';
1356 print
'<div class="inline-block divButAction"><span class="butActionRefused" title="'.dol_escape_htmltag($langs->trans(
"NotEnoughPermissions")).
'">' . $langs->trans(
"AddCustomerPrice") .
'</span></div>';
1360 if (!empty($conf->global->PRODUIT_MULTIPRICES) || !empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) {
1361 if ($user->hasRight(
'produit',
'creer') || $user->hasRight(
'service',
'creer')) {
1362 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>';
1364 print
'<div class="inline-block divButAction"><span class="butActionRefused" title="'.dol_escape_htmltag($langs->trans(
"NotEnoughPermissions")).
'">' . $langs->trans(
"UpdateVAT") .
'</span></div>';
1367 if ($user->hasRight(
'produit',
'creer') || $user->hasRight(
'service',
'creer')) {
1368 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>';
1370 print
'<div class="inline-block divButAction"><span class="butActionRefused" title="'.dol_escape_htmltag($langs->trans(
"NotEnoughPermissions")).
'">' . $langs->trans(
"UpdateLevelPrices") .
'</span></div>';
1385if ($action ==
'edit_vat' && ($user->hasRight(
'produit',
'creer') || $user->hasRight(
'service',
'creer'))) {
1388 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'" method="POST">';
1389 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1390 print
'<input type="hidden" name="action" value="update_vat">';
1391 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
1395 print
'<table class="border centpercent">';
1398 print
'<tr><td>'.$langs->trans(
"DefaultTaxRate").
'</td><td>';
1399 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);
1406 print $form->buttonsSaveCancel();
1408 print
'<br></form><br>';
1411if ($action ==
'edit_price' && $object->getRights()->creer) {
1415 if (empty($conf->global->PRODUIT_MULTIPRICES) && empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) {
1416 print
'<!-- Edit price -->'.
"\n";
1417 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'" method="POST">';
1418 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1419 print
'<input type="hidden" name="action" value="update_price">';
1420 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
1424 print
'<div class="div-table-responsive-no-min">';
1425 print
'<table class="border centpercent">';
1428 print
'<tr><td class="titlefield">'.$langs->trans(
"DefaultTaxRate").
'</td><td>';
1429 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);
1434 print $langs->trans(
'PriceBase');
1437 print $form->selectPriceBaseType($object->price_base_type,
"price_base_type");
1442 if (!empty($conf->dynamicprices->enabled)) {
1444 print
'<!-- Show price mode of dynamicprices editor -->'.
"\n";
1445 print
'<tr><td>'.$langs->trans(
"PriceMode").
'</td><td>';
1446 print
img_picto(
'',
'dynamicprice',
'class="pictofixedwidth"');
1448 $price_expression_list = array(0 => $langs->trans(
"Numeric").
' <span class="opacitymedium">('.$langs->trans(
"NoDynamicPrice").
')</span>');
1449 foreach ($price_expression->list_price_expression() as $entry) {
1450 $price_expression_list[$entry->id] = $entry->title;
1452 $price_expression_preselection =
GETPOST(
'eid') ?
GETPOST(
'eid') : ($object->fk_price_expression ? $object->fk_price_expression :
'0');
1453 print $form->selectarray(
'eid', $price_expression_list, $price_expression_preselection);
1454 print
' <a id="expression_editor" class="classlink">'.$langs->trans(
"PriceExpressionEditor").
'</a>';
1460 <script
type=
"text/javascript">
1461 jQuery(document).ready(
function() {
1462 jQuery(
"#expression_editor").click(
function() {
1463 window.location =
"<?php echo DOL_URL_ROOT ?>/product/dynamic_price/editor.php?id=<?php echo $id ?>&tab=price&eid=" + $(
"#eid").val();
1465 jQuery(
"#eid").change(on_change);
1468 function on_change() {
1469 if ($(
"#eid").val() == 0) {
1470 jQuery(
"#price_numeric").show();
1472 jQuery(
"#price_numeric").hide();
1481 $product->fetch($id, $ref,
'', 1);
1482 print
'<tr id="price_numeric"><td>';
1483 $text = $langs->trans(
'SellingPrice');
1484 print $form->textwithpicto($text, $langs->trans(
"PrecisionUnitIsLimitedToXDecimals", $conf->global->MAIN_MAX_DECIMALS_UNIT), 1, 1);
1486 if ($object->price_base_type ==
'TTC') {
1487 print
'<input name="price" size="10" value="'.price($product->price_ttc).
'">';
1489 print
'<input name="price" size="10" value="'.price($product->price).
'">';
1495 $text = $langs->trans(
'MinPrice');
1496 print $form->textwithpicto($text, $langs->trans(
"PrecisionUnitIsLimitedToXDecimals", $conf->global->MAIN_MAX_DECIMALS_UNIT), 1, 1);
1498 if ($object->price_base_type ==
'TTC') {
1499 print
'<input name="price_min" size="10" value="'.price($object->price_min_ttc).
'">';
1501 print
'<input name="price_min" size="10" value="'.price($object->price_min).
'">';
1503 if (!empty($conf->global->PRODUCT_MINIMUM_RECOMMENDED_PRICE)) {
1504 print
' '.$langs->trans(
"MinimumRecommendedPrice",
price($maxpricesupplier, 0,
'', 1, -1, -1,
'auto')).
' '.
img_warning().
'</td>';
1509 $parameters = array();
1510 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters, $object, $action);
1517 print $form->buttonsSaveCancel();
1521 print
'<!-- Edit price per level -->'.
"\n";
1525 var showHidePriceRules =
function () {
1526 var otherPrices = $(
'div.fiche form table tbody tr:not(:first)');
1527 var minPrice1 = $(
'div.fiche form input[name="price_min[1]"]');
1529 if (jQuery(
'input#usePriceRules').prop(
'checked')) {
1538 jQuery(document).ready(
function () {
1539 showHidePriceRules();
1541 jQuery(
'input#usePriceRules').click(showHidePriceRules);
1546 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'" method="POST">';
1547 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1548 print
'<input type="hidden" name="action" value="update_price">';
1549 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
1553 if ((!empty($conf->global->PRODUIT_MULTIPRICES) || !empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) && !empty($conf->global->PRODUIT_MULTIPRICES_ALLOW_AUTOCALC_PRICELEVEL)) {
1554 print $langs->trans(
'UseMultipriceRules').
' <input type="checkbox" id="usePriceRules" name="usePriceRules" '.($object->price_autogen ?
'checked' :
'').
'><br><br>';
1557 print
'<div class="div-table-responsive-no-min">';
1558 print
'<table class="noborder">';
1559 print
'<thead><tr class="liste_titre">';
1561 print
'<td>'.$langs->trans(
"PriceLevel").
'</td>';
1563 if (!empty($conf->global->PRODUIT_MULTIPRICES_USE_VAT_PER_LEVEL)) {
1564 print
'<td style="text-align: center">'.$langs->trans(
"DefaultTaxRate").
'</td>';
1569 print
'<td class="center">'.$langs->trans(
"SellingPrice").
'</td>';
1571 print
'<td class="center">'.$langs->trans(
"MinPrice").
'</td>';
1573 if (!empty($conf->global->PRODUCT_MINIMUM_RECOMMENDED_PRICE)) {
1576 print
'</tr></thead>';
1580 for ($i = 1; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i++) {
1581 print
'<tr class="oddeven">';
1583 $text = $langs->trans(
'SellingPrice').
' '.$i;
1584 print $form->textwithpicto($text, $langs->trans(
"PrecisionUnitIsLimitedToXDecimals", $conf->global->MAIN_MAX_DECIMALS_UNIT), 1, 1);
1588 if (empty($conf->global->PRODUIT_MULTIPRICES_USE_VAT_PER_LEVEL)) {
1590 print
'<input type="hidden" name="tva_tx['.$i.
']" value="'.($object->default_vat_code ? $object->tva_tx.
' ('.$object->default_vat_code.
')' : $object->tva_tx).
'">';
1591 print
'<input type="hidden" name="tva_npr['.$i.
']" value="'.$object->tva_npr.
'">';
1592 print
'<input type="hidden" name="localtax1_tx['.$i.
']" value="'.$object->localtax1_tx.
'">';
1593 print
'<input type="hidden" name="localtax1_type['.$i.
']" value="'.$object->localtax1_type.
'">';
1594 print
'<input type="hidden" name="localtax2_tx['.$i.
']" value="'.$object->localtax2_tx.
'">';
1595 print
'<input type="hidden" name="localtax2_type['.$i.
']" value="'.$object->localtax2_type.
'">';
1599 print
'<td style="text-align: center">';
1600 print $form->load_tva(
"tva_tx[".$i.
']', $object->multiprices_tva_tx[$i], $mysoc,
'', $object->id,
false, $object->type,
false, 1);
1605 print
'<td style="text-align: center">';
1606 if ($object->multiprices_base_type [$i] ==
'TTC') {
1607 print
'<input name="price['.$i.
']" size="10" value="'.
price($object->multiprices_ttc [$i]).
'">';
1609 print
'<input name="price['.$i.
']" size="10" value="'.
price($object->multiprices [$i]).
'">';
1611 print
' '.$form->selectPriceBaseType($object->multiprices_base_type [$i],
"multiprices_base_type[".$i.
"]");
1615 print
'<td style="text-align: center">';
1616 if ($object->multiprices_base_type [$i] ==
'TTC') {
1617 print
'<input name="price_min['.$i.
']" size="10" value="'.
price($object->multiprices_min_ttc [$i]).
'">';
1619 print
'<input name="price_min['.$i.
']" size="10" value="'.
price($object->multiprices_min [$i]).
'">';
1621 if (!empty($conf->global->PRODUCT_MINIMUM_RECOMMENDED_PRICE)) {
1622 print
'<td class="left">'.$langs->trans(
"MinimumRecommendedPrice",
price($maxpricesupplier, 0,
'', 1, -1, -1,
'auto')).
' '.
img_warning().
'</td>';
1636 print $form->buttonsSaveCancel();
1645if ((empty($conf->global->PRODUIT_CUSTOMER_PRICES) || $action ==
'showlog_default_price') && !in_array($action, array(
'edit_price',
'edit_vat'))) {
1646 $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,";
1647 $sql .=
" p.price_level, p.price_min, p.price_min_ttc,p.price_by_qty,";
1648 $sql .=
" p.date_price as dp, p.fk_price_expression, u.rowid as user_id, u.login";
1649 $sql .=
" FROM ".MAIN_DB_PREFIX.
"product_price as p,";
1650 $sql .=
" ".MAIN_DB_PREFIX.
"user as u";
1651 $sql .=
" WHERE fk_product = ".((int) $object->id);
1652 $sql .=
" AND p.entity IN (".getEntity(
'productprice').
")";
1653 $sql .=
" AND p.fk_user_author = u.rowid";
1654 if (!empty($socid) && !empty($conf->global->PRODUIT_MULTIPRICES)) {
1655 $sql .=
" AND p.price_level = ".((int) $soc->price_level);
1657 $sql .=
" ORDER BY p.date_price DESC, p.rowid DESC, p.price_level ASC";
1661 $result = $db->query($sql);
1663 print
'<div class="divlogofpreviouscustomerprice">';
1665 $num = $db->num_rows($result);
1673 if (!empty($conf->global->PRODUIT_MULTIPRICES)) {
1674 $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);
1676 $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));
1682 $result = $db->query($sql);
1683 $num = $db->num_rows($result);
1690 $backbutton =
'<a class="justalink" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'">'.$langs->trans(
"Back").
'</a>';
1692 if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) {
1693 print_barre_liste($langs->trans(
"DefaultPriceLog"), 0, $_SERVER[
"PHP_SELF"],
'',
'',
'', $backbutton, 0, $num,
'title_accountancy.png');
1695 print_barre_liste($langs->trans(
"PriceByCustomerLog"), 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', 0, $num,
'title_accountancy.png');
1698 print
'<!-- List of log prices -->'.
"\n";
1699 print
'<div class="div-table-responsive">'.
"\n";
1700 print
'<table class="liste centpercent">'.
"\n";
1702 print
'<tr class="liste_titre">';
1703 print
'<td>'.$langs->trans(
"AppliedPricesFrom").
'</td>';
1705 if (!empty($conf->global->PRODUIT_MULTIPRICES) || !empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) {
1706 print
'<td class="center">'.$langs->trans(
"PriceLevel").
'</td>';
1708 if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY) || !empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) {
1709 print
'<td class="center">'.$langs->trans(
"Type").
'</td>';
1712 print
'<td class="center">'.$langs->trans(
"PriceBase").
'</td>';
1713 if (empty($conf->global->PRODUIT_MULTIPRICES) && empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) {
1714 print
'<td class="right">'.$langs->trans(
"DefaultTaxRate").
'</td>';
1716 print
'<td class="right">'.$langs->trans(
"HT").
'</td>';
1717 print
'<td class="right">'.$langs->trans(
"TTC").
'</td>';
1718 if ($mysoc->localtax1_assuj ==
"1" || $mysoc->localtax2_assuj ==
"1") {
1719 print
'<td class="right">'.$langs->trans(
"INCT").
'</td>';
1721 if (!empty($conf->dynamicprices->enabled)) {
1722 print
'<td class="right">'.$langs->trans(
"PriceExpressionSelected").
'</td>';
1724 print
'<td class="right">'.$langs->trans(
"MinPrice").
' '.$langs->trans(
"HT").
'</td>';
1725 print
'<td class="right">'.$langs->trans(
"MinPrice").
' '.$langs->trans(
"TTC").
'</td>';
1726 print
'<td class="right">'.$langs->trans(
"ChangedBy").
'</td>';
1727 if ($user->rights->produit->supprimer) {
1728 print
'<td class="right"> </td>';
1732 $notfirstlineforlevel = array();
1736 $objp = $db->fetch_object($result);
1738 print
'<tr class="oddeven">';
1740 print
"<td>".dol_print_date($db->jdate($objp->dp),
"dayhour",
'tzuserrel').
"</td>";
1743 if (!empty($conf->global->PRODUIT_MULTIPRICES) || !empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) {
1744 print
'<td class="center">'.$objp->price_level.
"</td>";
1747 if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY) || !empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) {
1748 $type = ($objp->price_by_qty == 1) ?
'PriceByQuantity' :
'Standard';
1749 print
'<td class="center">'.$langs->trans($type).
"</td>";
1752 print
'<td class="center">';
1753 if (empty($objp->price_by_qty)) {
1754 print $langs->trans($objp->price_base_type);
1758 if (empty($conf->global->PRODUIT_MULTIPRICES) && empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) {
1759 print
'<td class="right">';
1761 if (empty($objp->price_by_qty)) {
1762 $positiverates =
'';
1764 $positiverates .= ($positiverates ?
'/' :
'').
price2num($objp->tva_tx);
1767 $positiverates .= ($positiverates ?
'/' :
'').
price2num($objp->localtax1_tx);
1770 $positiverates .= ($positiverates ?
'/' :
'').
price2num($objp->localtax2_tx);
1772 if (empty($positiverates)) {
1773 $positiverates =
'0';
1775 echo
vatrate($positiverates.($objp->default_vat_code ?
' ('.$objp->default_vat_code.
')' :
''),
'%', !empty($objp->tva_npr) ? $objp->tva_npr : 0);
1788 if ($objp->price_base_type ==
'HT') {
1791 $pu = $objp->price_ttc;
1795 $localtaxarray =
getLocalTaxesFromRate($objp->tva_tx.($object->default_vat_code ?
' ('.$object->default_vat_code.
')' :
''), 0, $mysoc, $mysoc);
1797 $resultarray =
calcul_price_total(1, $pu, 0, $objp->tva_tx, 1, 1, 0, $objp->price_base_type, $objp->recuperableonly, $object->type, $mysoc, $localtaxarray);
1799 $total_ht = $resultarray[0];
1800 $total_vat = $resultarray[1];
1801 $total_localtax1 = $resultarray[9];
1802 $total_localtax2 = $resultarray[10];
1803 $total_ttc = $resultarray[2];
1806 if (!empty($objp->fk_price_expression) && !empty($conf->dynamicprices->enabled)) {
1808 $res = $price_expression->fetch($objp->fk_price_expression);
1809 $title = $price_expression->title;
1810 print
'<td class="right"></td>';
1811 print
'<td class="right"></td>';
1812 if ($mysoc->localtax1_assuj ==
"1" || $mysoc->localtax2_assuj ==
"1") {
1813 print
'<td class="right"></td>';
1815 print
'<td class="right">'.$title.
"</td>";
1818 print
'<td class="right">';
1819 if (empty($objp->price_by_qty)) {
1820 print
'<span class="amount">'.price($objp->price).
'</span>';
1824 print
'<td class="right">';
1825 if (empty($objp->price_by_qty)) {
1826 $price_ttc = $objp->price_ttc;
1827 print
'<span class="amount">'.price($price_ttc).
'<span>';
1830 if ($mysoc->localtax1_assuj ==
"1" || $mysoc->localtax2_assuj ==
"1") {
1831 print
'<td class="right">';
1832 print $resultarray[2];
1835 if (!empty($conf->dynamicprices->enabled)) {
1836 print
'<td class="right"></td>';
1841 print
'<td class="right">';
1842 if (empty($objp->price_by_qty)) {
1843 print
price($objp->price_min);
1848 print
'<td class="right">';
1849 if (empty($objp->price_by_qty)) {
1850 $price_min_ttc = $objp->price_min_ttc;
1851 print
price($price_min_ttc);
1856 print
'<td class="right">';
1857 if ($objp->user_id > 0) {
1858 $userstatic =
new User($db);
1859 $userstatic->fetch($objp->user_id);
1860 print $userstatic->getNomUrl(1,
'', 0, 0, 24, 0,
'login');
1865 if ($user->rights->produit->supprimer) {
1867 if (!empty($conf->global->PRODUIT_MULTIPRICES) || !empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) {
1868 if (empty($notfirstlineforlevel[$objp->price_level])) {
1869 $notfirstlineforlevel[$objp->price_level] = 1;
1877 print
'<td class="right">';
1878 if ($candelete || ($db->jdate($objp->dp) >=
dol_now())) {
1879 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=delete&token='.newToken().
'&id='.$object->id.
'&lineid='.$objp->rowid.
'">';
1906if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) {
1909 $limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
1910 $sortfield =
GETPOST(
'sortfield',
'aZ09comma');
1911 $sortorder =
GETPOST(
'sortorder',
'aZ09comma');
1913 if (empty($page) || $page == -1) {
1916 $offset = $limit * $page;
1917 $pageprev = $page - 1;
1918 $pagenext = $page + 1;
1923 $sortfield =
"soc.nom";
1927 $filter = array(
't.fk_product' => $object->id);
1929 if (!empty($search_soc)) {
1930 $filter[
'soc.nom'] = $search_soc;
1933 if ($action ==
'add_customer_price') {
1935 $maxpricesupplier = $object->min_recommended_price();
1937 print
'<!-- add_customer_price -->';
1940 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'" method="POST">';
1941 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1942 print
'<input type="hidden" name="action" value="add_customer_price_confirm">';
1943 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
1945 print
'<div class="tabBar tabBarWithBottom">';
1947 print
'<table class="border centpercent">';
1949 print
'<td class="fieldrequired">'.$langs->trans(
'ThirdParty').
'</td>';
1951 $filter =
'(s.client:IN:1,2,3)';
1952 print
img_picto(
'',
'company').$form->select_company(
'',
'socid', $filter,
'SelectThirdParty', 0, 0, array(), 0,
'minwidth300');
1957 print
'<tr><td>' . $langs->trans(
'RefCustomer') .
'</td>';
1958 print
'<td><input name="ref_customer" size="12"></td></tr>';
1961 print
'<tr><td class="fieldrequired">'.$langs->trans(
"DefaultTaxRate").
'</td><td>';
1962 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);
1966 print
'<tr><td class="fieldrequired">';
1967 print $langs->trans(
'PriceBase');
1970 print $form->selectPriceBaseType($object->price_base_type,
"price_base_type");
1975 print
'<tr><td class="fieldrequired">';
1976 $text = $langs->trans(
'SellingPrice');
1977 print $form->textwithpicto($text, $langs->trans(
"PrecisionUnitIsLimitedToXDecimals", $conf->global->MAIN_MAX_DECIMALS_UNIT), 1, 1);
1979 if ($object->price_base_type ==
'TTC') {
1980 print
'<input name="price" size="10" value="'.price($object->price_ttc).
'">';
1982 print
'<input name="price" size="10" value="'.price($object->price).
'">';
1988 $text = $langs->trans(
'MinPrice');
1989 print $form->textwithpicto($text, $langs->trans(
"PrecisionUnitIsLimitedToXDecimals", $conf->global->MAIN_MAX_DECIMALS_UNIT), 1, 1);
1990 if ($object->price_base_type ==
'TTC') {
1991 print
'<td><input name="price_min" size="10" value="'.price($object->price_min_ttc).
'">';
1993 print
'<td><input name="price_min" size="10" value="'.price($object->price_min).
'">';
1995 if (!empty($conf->global->PRODUCT_MINIMUM_RECOMMENDED_PRICE)) {
1996 print
'<td class="left">'.$langs->trans(
"MinimumRecommendedPrice",
price($maxpricesupplier, 0,
'', 1, -1, -1,
'auto')).
' '.
img_warning().
'</td>';
2005 print
'<div class="center">';
2008 print
'<div class="marginbottomonly">';
2009 print
'<input type="checkbox" name="updatechildprice" id="updatechildprice" value="1"> ';
2010 print
'<label for="updatechildprice">'.$langs->trans(
'ForceUpdateChildPriceSoc').
'</label>';
2013 print $form->buttonsSaveCancel();
2016 } elseif ($action ==
'edit_customer_price') {
2018 $maxpricesupplier = $object->min_recommended_price();
2020 print
'<!-- edit_customer_price -->';
2023 $result = $prodcustprice->fetch(
GETPOST(
'lineid',
'int'));
2028 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'" method="POST">';
2029 print
'<input type="hidden" name="token" value="'.newToken().
'">';
2030 print
'<input type="hidden" name="action" value="update_customer_price_confirm">';
2031 print
'<input type="hidden" name="lineid" value="'.$prodcustprice->id.
'">';
2033 print
'<table class="liste centpercent">';
2035 print
'<td class="titlefield fieldrequired">'.$langs->trans(
'ThirdParty').
'</td>';
2036 $staticsoc =
new Societe($db);
2037 $staticsoc->fetch($prodcustprice->fk_soc);
2038 print
"<td>".$staticsoc->getNomUrl(1).
"</td>";
2042 print
'<tr><td>' . $langs->trans(
'RefCustomer') .
'</td>';
2043 print
'<td><input name="ref_customer" size="12" value="' .
dol_escape_htmltag($prodcustprice->ref_customer) .
'"></td></tr>';
2046 print
'<tr><td class="fieldrequired">'.$langs->trans(
"DefaultTaxRate").
'</td><td>';
2047 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);
2051 print
'<tr><td class="fieldrequired">';
2052 print $langs->trans(
'PriceBase');
2055 print $form->selectPriceBaseType($prodcustprice->price_base_type,
"price_base_type");
2060 print
'<tr><td class="fieldrequired">';
2061 $text = $langs->trans(
'SellingPrice');
2062 print $form->textwithpicto($text, $langs->trans(
"PrecisionUnitIsLimitedToXDecimals", $conf->global->MAIN_MAX_DECIMALS_UNIT), 1, 1);
2064 if ($prodcustprice->price_base_type ==
'TTC') {
2065 print
'<input name="price" size="10" value="'.price($prodcustprice->price_ttc).
'">';
2067 print
'<input name="price" size="10" value="'.price($prodcustprice->price).
'">';
2073 $text = $langs->trans(
'MinPrice');
2074 print $form->textwithpicto($text, $langs->trans(
"PrecisionUnitIsLimitedToXDecimals", $conf->global->MAIN_MAX_DECIMALS_UNIT), 1, 1);
2076 if ($prodcustprice->price_base_type ==
'TTC') {
2077 print
'<input name="price_min" size="10" value="'.price($prodcustprice->price_min_ttc).
'">';
2079 print
'<input name="price_min" size="10" value="'.price($prodcustprice->price_min).
'">';
2082 if (!empty($conf->global->PRODUCT_MINIMUM_RECOMMENDED_PRICE)) {
2083 print
'<td class="left">'.$langs->trans(
"MinimumRecommendedPrice",
price($maxpricesupplier, 0,
'', 1, -1, -1,
'auto')).
' '.
img_warning().
'</td>';
2090 print
'<div class="center">';
2091 print
'<div class="marginbottomonly">';
2092 print
'<input type="checkbox" name="updatechildprice" id="updatechildprice" value="1"> ';
2093 print
'<label for="updatechildprice">'.$langs->trans(
'ForceUpdateChildPriceSoc').
'</label>';
2096 print $form->buttonsSaveCancel();
2098 print
'<br></form>';
2099 } elseif ($action ==
'showlog_customer_price') {
2101 print
'<!-- list of all log of prices per customer -->'.
"\n";
2103 $filter = array(
't.fk_product' => $object->id,
't.fk_soc' =>
GETPOST(
'socid',
'int'));
2106 $nbtotalofrecords =
'';
2108 $nbtotalofrecords = $prodcustprice->fetch_all_log($sortorder, $sortfield, $conf->liste_limit, $offset, $filter);
2111 $result = $prodcustprice->fetch_all_log($sortorder, $sortfield, $conf->liste_limit, $offset, $filter);
2116 $option =
'&socid='.GETPOST(
'socid',
'int').
'&id='.$object->id;
2118 $staticsoc =
new Societe($db);
2119 $staticsoc->fetch(
GETPOST(
'socid',
'int'));
2121 $title = $langs->trans(
'PriceByCustomerLog');
2122 $title .=
' - '.$staticsoc->getNomUrl(1);
2124 $backbutton =
'<a class="justalink" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'">'.$langs->trans(
"Back").
'</a>';
2126 print_barre_liste($title, $page, $_SERVER[
'PHP_SELF'], $option, $sortfield, $sortorder, $backbutton, count($prodcustprice->lines), $nbtotalofrecords,
'title_accountancy.png');
2128 if (count($prodcustprice->lines) > 0) {
2129 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'" method="POST">';
2130 print
'<input type="hidden" name="token" value="'.newToken().
'">';
2131 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
2133 print
'<div class="div-table-responsive-no-min">';
2134 print
'<table class="liste centpercent">';
2136 print
'<tr class="liste_titre">';
2137 print
'<td>'.$langs->trans(
"ThirdParty").
'</td>';
2138 print
'<td>'.$langs->trans(
'RefCustomer').
'</td>';
2139 print
'<td>'.$langs->trans(
"AppliedPricesFrom").
'</td>';
2140 print
'<td class="center">'.$langs->trans(
"PriceBase").
'</td>';
2141 print
'<td class="right">'.$langs->trans(
"DefaultTaxRate").
'</td>';
2142 print
'<td class="right">'.$langs->trans(
"HT").
'</td>';
2143 print
'<td class="right">'.$langs->trans(
"TTC").
'</td>';
2144 if ($mysoc->localtax1_assuj ==
"1" || $mysoc->localtax2_assuj ==
"1") {
2145 print
'<td class="right">'.$langs->trans(
"INCT").
'</td>';
2147 print
'<td class="right">'.$langs->trans(
"MinPrice").
' '.$langs->trans(
"HT").
'</td>';
2148 print
'<td class="right">'.$langs->trans(
"MinPrice").
' '.$langs->trans(
"TTC").
'</td>';
2149 print
'<td class="right">'.$langs->trans(
"ChangedBy").
'</td>';
2150 print
'<td> </td>';
2153 foreach ($prodcustprice->lines as $line) {
2155 $staticsoc =
new Societe($db);
2156 $staticsoc->fetch($line->fk_soc);
2158 $tva_tx = $line->default_vat_code ? $line->tva_tx.
' ('.$line->default_vat_code.
')' : $line->tva_tx;
2161 if ($line->price_base_type ==
'HT') {
2164 $pu = $line->price_ttc;
2168 $localtaxarray =
getLocalTaxesFromRate($line->tva_tx.($line->default_vat_code ?
' ('.$line->default_vat_code.
')' :
''), 0, $staticsoc, $mysoc);
2170 $resultarray =
calcul_price_total(1, $pu, 0, $line->tva_tx, 1, 1, 0, $line->price_base_type, $line->recuperableonly, $object->type, $mysoc, $localtaxarray);
2172 $total_ht = $resultarray[0];
2173 $total_vat = $resultarray[1];
2174 $total_localtax1 = $resultarray[9];
2175 $total_localtax2 = $resultarray[10];
2176 $total_ttc = $resultarray[2];
2178 print
'<tr class="oddeven">';
2180 print
"<td>".$staticsoc->getNomUrl(1).
"</td>";
2181 print
'<td>'.$line->ref_customer.
'</td>';
2182 print
"<td>".dol_print_date($line->datec,
"dayhour",
'tzuserrel').
"</td>";
2183 print
'<td class="center">'.$langs->trans($line->price_base_type).
"</td>";
2184 print
'<td class="right">';
2186 $positiverates =
'';
2188 $positiverates .= ($positiverates ?
'/' :
'').
price2num($line->tva_tx);
2191 $positiverates .= ($positiverates ?
'/' :
'').
price2num($line->localtax1_tx);
2194 $positiverates .= ($positiverates ?
'/' :
'').
price2num($line->localtax2_tx);
2196 if (empty($positiverates)) {
2197 $positiverates =
'0';
2200 echo
vatrate($positiverates.($line->default_vat_code ?
' ('.$line->default_vat_code.
')' :
''),
'%', ($line->tva_npr ? $line->tva_npr : $line->recuperableonly));
2204 print
'<td class="right"><span class="amount">'.price($line->price).
"</span></td>";
2206 print
'<td class="right"><span class="amount">'.price($line->price_ttc).
"</span></td>";
2207 if ($mysoc->localtax1_assuj ==
"1" || $mysoc->localtax2_assuj ==
"1") {
2208 print
'<td class="right">'.price($resultarray[2]).
'</td>';
2211 print
'<td class="right">'.price($line->price_min).
'</td>';
2212 print
'<td class="right">'.price($line->price_min_ttc).
'</td>';
2215 $userstatic =
new User($db);
2216 $userstatic->fetch($line->fk_user);
2217 print
'<td class="right">';
2218 print $userstatic->getNomUrl(1,
'', 0, 0, 24, 0,
'login');
2226 print $langs->trans(
'None');
2228 } elseif ($action !=
'showlog_default_price' && $action !=
'edit_price') {
2230 print
'<!-- list of all prices per customer -->'.
"\n";
2233 $nbtotalofrecords =
'';
2235 $nbtotalofrecords = $prodcustprice->fetchAll($sortorder, $sortfield, 0, 0, $filter);
2238 $result = $prodcustprice->fetchAll($sortorder, $sortfield, $conf->liste_limit, $offset, $filter);
2243 $option =
'&search_soc='.$search_soc.
'&id='.$object->id;
2245 print_barre_liste($langs->trans(
'PriceByCustomer'), $page, $_SERVER [
'PHP_SELF'], $option, $sortfield, $sortorder,
'', count($prodcustprice->lines), $nbtotalofrecords,
'title_accountancy.png');
2247 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'" method="POST">';
2248 print
'<input type="hidden" name="token" value="'.newToken().
'">';
2249 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
2251 print
'<!-- List of prices per customer -->'.
"\n";
2252 print
'<div class="div-table-responsive-no-min">'.
"\n";
2253 print
'<table class="liste centpercent">'.
"\n";
2255 if (count($prodcustprice->lines) > 0 || $search_soc) {
2257 if ($mysoc->localtax1_assuj ==
"1" || $mysoc->localtax2_assuj ==
"1") {
2261 print
'<tr class="liste_titre">';
2262 print
'<td class="liste_titre"><input type="text" class="flat maxwidth125" name="search_soc" value="'.$search_soc.
'"></td>';
2263 print
'<td class="liste_titre" colspan="'.$colspan.
'"> </td>';
2265 print
'<td class="liste_titre maxwidthsearch">';
2266 $searchpicto = $form->showFilterAndCheckAddButtons(0);
2272 print
'<tr class="liste_titre">';
2273 print
'<td>'.$langs->trans(
"ThirdParty").
'</td>';
2274 print
'<td>'.$langs->trans(
'RefCustomer').
'</td>';
2275 print
'<td>'.$langs->trans(
"AppliedPricesFrom").
'</td>';
2276 print
'<td class="center">'.$langs->trans(
"PriceBase").
'</td>';
2277 print
'<td class="right">'.$langs->trans(
"DefaultTaxRate").
'</td>';
2278 print
'<td class="right">'.$langs->trans(
"HT").
'</td>';
2279 print
'<td class="right">'.$langs->trans(
"TTC").
'</td>';
2280 if ($mysoc->localtax1_assuj ==
"1" || $mysoc->localtax2_assuj ==
"1") {
2281 print
'<td class="right">'.$langs->trans(
"INCT").
'</td>';
2283 print
'<td class="right">'.$langs->trans(
"MinPrice").
' '.$langs->trans(
"HT").
'</td>';
2284 print
'<td class="right">'.$langs->trans(
"MinPrice").
' '.$langs->trans(
"TTC").
'</td>';
2285 print
'<td class="right">'.$langs->trans(
"ChangedBy").
'</td>';
2290 if ($object->price_base_type ==
'HT') {
2291 $pu = $object->price;
2293 $pu = $object->price_ttc;
2297 $localtaxarray =
getLocalTaxesFromRate($object->tva_tx.($object->default_vat_code ?
' ('.$object->default_vat_code.
')' :
''), 0, $mysoc, $mysoc);
2299 $resultarray =
calcul_price_total(1, $pu, 0, $object->tva_tx, 1, 1, 0, $object->price_base_type, $object->recuperableonly, $object->type, $mysoc, $localtaxarray);
2301 $total_ht = $resultarray[0];
2302 $total_vat = $resultarray[1];
2303 $total_localtax1 = $resultarray[9];
2304 $total_localtax2 = $resultarray[10];
2305 $total_ttc = $resultarray[2];
2307 print
'<tr class="oddeven">';
2308 print
'<td colspan="3">' . $langs->trans(
'Default') .
'</td>';
2310 print
'<td class="center">'.$langs->trans($object->price_base_type).
"</td>";
2313 print
'<td class="right">';
2315 $positiverates =
'';
2317 $positiverates .= ($positiverates ?
'/' :
'').
price2num($object->tva_tx);
2319 if (
price2num($object->localtax1_type)) {
2320 $positiverates .= ($positiverates ?
'/' :
'').
price2num($object->localtax1_tx);
2322 if (
price2num($object->localtax2_type)) {
2323 $positiverates .= ($positiverates ?
'/' :
'').
price2num($object->localtax2_tx);
2325 if (empty($positiverates)) {
2326 $positiverates =
'0';
2328 echo
vatrate($positiverates.($object->default_vat_code ?
' ('.$object->default_vat_code.
')' :
''),
'%', $object->tva_npr);
2334 print
'<td class="right"><span class="amount">'.price($object->price).
"</span></td>";
2336 print
'<td class="right"><span class="amount">'.price($object->price_ttc).
"</span></td>";
2337 if ($mysoc->localtax1_assuj ==
"1" || $mysoc->localtax2_assuj ==
"1") {
2339 print
'<td class="right"><span class="amount">'.price($resultarray[2]).
'</span></td>';
2342 print
'<td class="right">'.price($object->price_min).
'</td>';
2343 print
'<td class="right">'.price($object->price_min_ttc).
'</td>';
2344 print
'<td class="right">';
2346 if ($user->hasRight(
'produit',
'supprimer') || $user->hasRight(
'service',
'supprimer')) {
2347 print
'<td class="nowraponall">';
2348 print
'<a class="marginleftonly marginrightonly" href="'.$_SERVER[
"PHP_SELF"].
'?action=showlog_default_price&token='.newToken().
'&id='.$object->id.
'">';
2349 print
img_info($langs->trans(
'PriceByCustomerLog'));
2352 print
'<a class="marginleftonly marginrightonly editfielda" href="'.$_SERVER[
"PHP_SELF"].
'?action=edit_price&token='.newToken().
'&id='.$object->id.
'">';
2353 print
img_edit(
'default', 0,
'style="vertical-align: middle;"');
2359 if (count($prodcustprice->lines) > 0) {
2360 foreach ($prodcustprice->lines as $line) {
2362 $staticsoc =
new Societe($db);
2363 $staticsoc->fetch($line->fk_soc);
2365 $tva_tx = $line->default_vat_code ? $line->tva_tx.
' ('.$line->default_vat_code.
')' : $line->tva_tx;
2368 if ($line->price_base_type ==
'HT') {
2371 $pu = $line->price_ttc;
2375 $localtaxarray =
getLocalTaxesFromRate($line->tva_tx.($line->default_vat_code ?
' ('.$line->default_vat_code.
')' :
''), 0, $staticsoc, $mysoc);
2377 $resultarray =
calcul_price_total(1, $pu, 0, $line->tva_tx, 1, 1, 0, $line->price_base_type, $line->recuperableonly, $object->type, $mysoc, $localtaxarray);
2379 $total_ht = $resultarray[0];
2380 $total_vat = $resultarray[1];
2381 $total_localtax1 = $resultarray[9];
2382 $total_localtax2 = $resultarray[10];
2383 $total_ttc = $resultarray[2];
2385 print
'<tr class="oddeven">';
2387 print
"<td>".$staticsoc->getNomUrl(1).
"</td>";
2388 print
'<td>'.dol_escape_htmltag($line->ref_customer).
'</td>';
2389 print
"<td>".dol_print_date($line->datec,
"dayhour",
'tzuserrel').
"</td>";
2390 print
'<td class="center">'.$langs->trans($line->price_base_type).
"</td>";
2392 print
'<td class="right">';
2394 $positiverates =
'';
2396 $positiverates .= ($positiverates ?
'/' :
'').
price2num($line->tva_tx);
2399 $positiverates .= ($positiverates ?
'/' :
'').
price2num($line->localtax1_tx);
2402 $positiverates .= ($positiverates ?
'/' :
'').
price2num($line->localtax2_tx);
2404 if (empty($positiverates)) {
2405 $positiverates =
'0';
2408 echo
vatrate($positiverates.($line->default_vat_code ?
' ('.$line->default_vat_code.
')' :
''),
'%', ($line->tva_npr ? $line->tva_npr : $line->recuperableonly));
2412 print
'<td class="right"><span class="amount">'.price($line->price).
"</span></td>";
2414 print
'<td class="right"><span class="amount">'.price($line->price_ttc).
"</span></td>";
2415 if ($mysoc->localtax1_assuj ==
"1" || $mysoc->localtax2_assuj ==
"1") {
2417 print
'<td class="right"><span class="amount">'.price($resultarray[2]).
'</span></td>';
2420 print
'<td class="right">'.price($line->price_min).
'</td>';
2421 print
'<td class="right">'.price($line->price_min_ttc).
'</td>';
2424 $userstatic =
new User($db);
2425 $userstatic->fetch($line->fk_user);
2426 print
'<td class="right">';
2427 print $userstatic->getNomUrl(1,
'', 0, 0, 24, 0,
'login');
2432 if ($user->rights->produit->supprimer || $user->rights->service->supprimer) {
2433 print
'<td class="right nowraponall">';
2434 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=showlog_customer_price&token='.newToken().
'&id='.$object->id.
'&socid='.$line->fk_soc.
'">';
2435 print
img_info($langs->trans(
'PriceByCustomerLog'));
2438 print
'<a class="marginleftonly editfielda" href="'.$_SERVER[
"PHP_SELF"].
'?action=edit_customer_price&token='.newToken().
'&id='.$object->id.
'&lineid='.$line->id.
'">';
2439 print
img_edit(
'default', 0,
'style="vertical-align: middle;"');
2442 print
'<a class="marginleftonly" href="'.$_SERVER[
"PHP_SELF"].
'?action=delete_customer_price&token='.newToken().
'&id='.$object->id.
'&lineid='.$line->id.
'">';
2443 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.
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.
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
img_delete($titlealt='default', $other='class="pictodelete"', $morecss='')
Show delete logo.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0)
Show tabs of a record.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
dol_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.
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages.
dol_now($mode='auto')
Return date for now.
getDolGlobalInt($key, $default=0)
Return dolibarr global constant int value.
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.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
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.
img_edit($titlealt='default', $float=0, $other='')
Show logo editer/modifier fiche.
img_info($titlealt='default')
Show info logo.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
calcul_price_total($qty, $pu, $remise_percent_ligne, $txtva, $uselocaltax1_rate, $uselocaltax2_rate, $remise_percent_global, $price_base_type, $info_bits, $type, $seller='', $localtaxes_array='', $progress=100, $multicurrency_tx=1, $pu_devise=0, $multicurrency_code='')
Calculate totals (net, vat, ...) of a line.
product_prepare_head($object)
Prepare array with list of tabs.
if(preg_match('/crypted:/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.