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';
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);
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;
139 $localtax1_type =
'0';
140 $localtax2_type =
'0';
143 if (preg_match(
'/\((.*)\)/', $tva_tx_txt, $reg)) {
145 $vatratecode = $reg[1];
147 $sql =
"SELECT t.rowid, t.code, t.recuperableonly, t.localtax1, t.localtax2, t.localtax1_type, t.localtax2_type";
148 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_tva as t, ".MAIN_DB_PREFIX.
"c_country as c";
149 $sql .=
" WHERE t.fk_pays = c.rowid AND c.code = '".$db->escape($mysoc->country_code).
"'";
150 $sql .=
" AND t.taux = ".((float) $tva_tx).
" AND t.active = 1";
151 $sql .=
" AND t.code = '".$db->escape($vatratecode).
"'";
152 $sql .=
" AND t.entity IN (".getEntity(
'c_tva').
")";
153 $resql = $db->query($sql);
155 $obj = $db->fetch_object($resql);
157 $npr = $obj->recuperableonly;
158 $localtax1 = $obj->localtax1;
159 $localtax2 = $obj->localtax2;
160 $localtax1_type = $obj->localtax1_type;
161 $localtax2_type = $obj->localtax2_type;
166 $sql =
"SELECT t.rowid, t.code, t.recuperableonly, t.localtax1, t.localtax2, t.localtax1_type, t.localtax2_type";
167 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_tva as t, ".MAIN_DB_PREFIX.
"c_country as c";
168 $sql .=
" WHERE t.fk_pays = c.rowid AND c.code = '".$db->escape($mysoc->country_code).
"'";
169 $sql .=
" AND t.taux = ".((float) $tva_tx).
" AND t.active = 1";
170 $sql .=
" AND t.code = ''";
171 $sql .=
" AND t.entity IN (".getEntity(
'c_tva').
")";
172 $resql = $db->query($sql);
174 $obj = $db->fetch_object($resql);
176 $npr = $obj->recuperableonly;
177 $localtax1 = $obj->localtax1;
178 $localtax2 = $obj->localtax2;
179 $localtax1_type = $obj->localtax1_type;
180 $localtax2_type = $obj->localtax2_type;
185 $object->default_vat_code = $vatratecode;
186 $object->tva_tx = $tva_tx;
187 $object->tva_npr = $npr;
188 $object->localtax1_tx = $localtax1;
189 $object->localtax2_tx = $localtax2;
190 $object->localtax1_type = $localtax1_type;
191 $object->localtax2_type = $localtax2_type;
195 $resql = $object->update($object->id, $user);
203 for ($i = 1; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i++) {
205 if ($object->multiprices_base_type[$i] ==
'HT') {
206 $oldprice = $object->multiprices[$i];
207 $oldminprice = $object->multiprices_min[$i];
209 $oldprice = $object->multiprices_ttc[$i];
210 $oldminprice = $object->multiprices_min_ttc[$i];
212 $oldpricebasetype = $object->multiprices_base_type[$i];
213 $oldnpr = $object->multiprices_recuperableonly[$i];
216 $localtaxarray = array();
218 $ret = $object->updatePrice($oldprice, $oldpricebasetype, $user, $tva_tx, $oldminprice, $level, $oldnpr, 0, 0, $localtaxarray, $vatratecode);
227 if ($object->price_base_type ==
'HT') {
228 $oldprice = $object->price;
229 $oldminprice = $object->price_min;
231 $oldprice = $object->price_ttc;
232 $oldminprice = $object->price_min_ttc;
234 $oldpricebasetype = $object->price_base_type;
235 $oldnpr = $object->tva_npr;
238 $localtaxarray = array();
240 $ret = $object->updatePrice($oldprice, $oldpricebasetype, $user, $tva_tx, $oldminprice, $level, $oldnpr, 0, 0, $localtaxarray, $vatratecode);
258 if (($action ==
'update_price') && !$cancel && $object->getRights()->creer) {
260 $pricestoupdate = array();
263 $psq = empty($newpsq) ? 0 : $newpsq;
264 $maxpricesupplier = $object->min_recommended_price();
266 if (isModEnabled(
'dynamicprices')) {
267 $object->fk_price_expression = empty($eid) ? 0 : $eid;
269 if ($object->fk_price_expression != 0) {
271 require_once DOL_DOCUMENT_ROOT.
'/product/dynamic_price/class/price_parser.class.php';
274 if ($priceparser->parseProduct($object) < 0) {
283 $newprice =
GETPOST(
'price',
'array');
284 $newprice_min =
GETPOST(
'price_min',
'array');
285 $newpricebase =
GETPOST(
'multiprices_base_type',
'array');
286 $newvattx =
GETPOST(
'tva_tx',
'array');
287 $newvatnpr =
GETPOST(
'tva_npr',
'array');
288 $newlocaltax1_tx =
GETPOST(
'localtax1_tx',
'array');
289 $newlocaltax1_type =
GETPOST(
'localtax1_type',
'array');
290 $newlocaltax2_tx =
GETPOST(
'localtax2_tx',
'array');
291 $newlocaltax2_type =
GETPOST(
'localtax2_type',
'array');
294 $object->price_autogen =
GETPOST(
'usePriceRules') ==
'on';
296 for ($i = 1; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i++) {
297 if (!isset($newprice[$i])) {
301 $tva_tx_txt = $newvattx[$i];
303 $tva_tx = $tva_tx_txt;
306 if (preg_match(
'/\((.*)\)/', $tva_tx_txt, $reg)) {
307 $vat_src_code = $reg[1];
308 $tva_tx = preg_replace(
'/\s*\(.*\)/',
'', $tva_tx_txt);
310 $tva_tx =
price2num(preg_replace(
'/\*/',
'', $tva_tx));
312 $npr = preg_match(
'/\*/', $tva_tx_txt) ? 1 : 0;
313 $localtax1 = $newlocaltax1_tx[$i];
314 $localtax1_type = $newlocaltax1_type[$i];
315 $localtax2 = $newlocaltax2_tx[$i];
316 $localtax2_type = $newlocaltax2_type[$i];
317 if (preg_match(
'/\((.*)\)/', $tva_tx_txt, $reg)) {
319 $vatratecode = $reg[1];
321 $sql =
"SELECT t.rowid, t.code, t.recuperableonly, t.localtax1, t.localtax2, t.localtax1_type, t.localtax2_type";
322 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_tva as t, ".MAIN_DB_PREFIX.
"c_country as c";
323 $sql .=
" WHERE t.fk_pays = c.rowid AND c.code = '".$db->escape($mysoc->country_code).
"'";
324 $sql .=
" AND t.taux = ".((float) $tva_tx).
" AND t.active = 1";
325 $sql .=
" AND t.code ='".$db->escape($vatratecode).
"'";
326 $sql .=
" AND t.entity IN (".getEntity(
'c_tva').
")";
327 $resql = $db->query($sql);
329 $obj = $db->fetch_object($resql);
331 $npr = $obj->recuperableonly;
332 $localtax1 = $obj->localtax1;
333 $localtax2 = $obj->localtax2;
334 $localtax1_type = $obj->localtax1_type;
335 $localtax2_type = $obj->localtax2_type;
339 if (in_array($mysoc->country_code, array(
'ES'))) {
346 $sql =
"SELECT t.rowid, t.code, t.recuperableonly, t.localtax1, t.localtax2, t.localtax1_type, t.localtax2_type";
347 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_tva as t, ".MAIN_DB_PREFIX.
"c_country as c";
348 $sql .=
" WHERE t.fk_pays = c.rowid AND c.code = '".$db->escape($mysoc->country_code).
"'";
349 $sql .=
" AND t.taux = ".((float) $tva_tx).
" AND t.active = 1";
350 $sql .=
" AND t.code = ''";
351 $resql = $db->query($sql);
353 $obj = $db->fetch_object($resql);
355 $npr = $obj->recuperableonly;
356 $localtax1 = $obj->localtax1;
357 $localtax2 = $obj->localtax2;
358 $localtax1_type = $obj->localtax1_type;
359 $localtax2_type = $obj->localtax2_type;
364 $pricestoupdate[$i] = array(
365 'price' =>
price2num($newprice[$i],
'', 2),
366 'price_min' =>
price2num($newprice_min[$i],
'', 2),
367 'price_base_type' => $newpricebase[$i],
368 'default_vat_code' => $vatratecode,
371 'localtaxes_array' => array(
'0'=>$localtax1_type,
'1'=>$localtax1,
'2'=>$localtax2_type,
'3'=>$localtax2)
375 if ($object->price_autogen) {
382 $newpricebase =
GETPOST(
'price_base_type',
'alpha');
383 $tva_tx_txt =
GETPOST(
'tva_tx',
'alpha');
385 $tva_tx = $tva_tx_txt;
388 if (preg_match(
'/\((.*)\)/', $tva_tx_txt, $reg)) {
389 $vat_src_code = $reg[1];
390 $tva_tx = preg_replace(
'/\s*\(.*\)/',
'', $tva_tx_txt);
392 $tva_tx =
price2num(preg_replace(
'/\*/',
'', $tva_tx));
394 $npr = preg_match(
'/\*/', $tva_tx_txt) ? 1 : 0;
397 $localtax1_type =
'0';
398 $localtax2_type =
'0';
400 if (preg_match(
'/\((.*)\)/', $tva_tx_txt, $reg)) {
402 $vatratecode = $reg[1];
404 $sql =
"SELECT t.rowid, t.code, t.recuperableonly, t.localtax1, t.localtax2, t.localtax1_type, t.localtax2_type";
405 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_tva as t, ".MAIN_DB_PREFIX.
"c_country as c";
406 $sql .=
" WHERE t.fk_pays = c.rowid AND c.code = '".$db->escape($mysoc->country_code).
"'";
407 $sql .=
" AND t.taux = ".((float) $tva_tx).
" AND t.active = 1";
408 $sql .=
" AND t.code ='".$db->escape($vatratecode).
"'";
409 $sql .=
" AND t.entity IN (".getEntity(
'c_tva').
")";
410 $resql = $db->query($sql);
412 $obj = $db->fetch_object($resql);
414 $npr = $obj->recuperableonly;
415 $localtax1 = $obj->localtax1;
416 $localtax2 = $obj->localtax2;
417 $localtax1_type = $obj->localtax1_type;
418 $localtax2_type = $obj->localtax2_type;
422 if (in_array($mysoc->country_code, array(
'ES'))) {
429 $sql =
"SELECT t.rowid, t.code, t.recuperableonly, t.localtax1, t.localtax2, t.localtax1_type, t.localtax2_type";
430 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_tva as t, ".MAIN_DB_PREFIX.
"c_country as c";
431 $sql .=
" WHERE t.fk_pays = c.rowid AND c.code = '".$db->escape($mysoc->country_code).
"'";
432 $sql .=
" AND t.taux = ".((float) $tva_tx).
" AND t.active = 1";
433 $sql .=
" AND t.code = ''";
434 $resql = $db->query($sql);
436 $obj = $db->fetch_object($resql);
438 $npr = $obj->recuperableonly;
439 $localtax1 = $obj->localtax1;
440 $localtax2 = $obj->localtax2;
441 $localtax1_type = $obj->localtax1_type;
442 $localtax2_type = $obj->localtax2_type;
447 $pricestoupdate[0] = array(
448 'price' => $newprice,
449 'price_min' => $newprice_min,
450 'price_base_type' => $newpricebase,
451 'default_vat_code' => $vatratecode,
454 'localtaxes_array' => array(
'0'=>$localtax1_type,
'1'=>$localtax1,
'2'=>$localtax2_type,
'3'=>$localtax2)
461 foreach ($pricestoupdate as $key => $val) {
462 $newprice = $val[
'price'];
464 if ($val[
'price'] < $val[
'price_min'] && !empty($object->fk_price_expression)) {
465 $newprice = $val[
'price_min'];
469 $newprice_min =
price2num($val[
'price_min'],
'MU');
472 if (
getDolGlobalString(
'PRODUCT_MINIMUM_RECOMMENDED_PRICE') && $newprice_min < $maxpricesupplier) {
473 setEventMessages($langs->trans(
"MinimumPriceLimit",
price($maxpricesupplier, 0,
'', 1, - 1, - 1,
'auto')),
null,
'errors');
479 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) {
480 $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']);
493 if (!$error && $object->update($object->id, $user) < 0) {
503 $action =
'edit_price';
509 if ($action ==
'delete' && $user->hasRight(
'produit',
'supprimer')) {
510 $result = $object->log_price_delete($user,
GETPOST(
'lineid',
'int'));
517 if ($action ==
'activate_price_by_qty') {
519 $level =
GETPOST(
'level',
'int');
520 $basePrice = ($object->price_base_type ==
'HT') ? $object->price : $object->price_ttc;
521 $basePriceMin = ($object->price_base_type ==
'HT') ? $object->price_min : $object->price_min_ttc;
522 $ret = $object->updatePrice($basePrice, $object->price_base_type, $user, $object->tva_tx, $basePriceMin, $level, $object->tva_npr, 1);
529 if ($action ==
'disable_price_by_qty') {
531 $level =
GETPOST(
'level',
'int');
532 $basePrice = ($object->price_base_type ==
'HT') ? $object->price : $object->price_ttc;
533 $basePriceMin = ($object->price_base_type ==
'HT') ? $object->price_min : $object->price_min_ttc;
534 $ret = $object->updatePrice($basePrice, $object->price_base_type, $user, $object->tva_tx, $basePriceMin, $level, $object->tva_npr, 0);
541 if ($action ==
'edit_price_by_qty') {
542 $rowid =
GETPOST(
'rowid',
'int');
546 if ($action ==
'update_price_by_qty') {
548 $rowid =
GETPOST(
'rowid',
'int');
549 $priceid =
GETPOST(
'priceid',
'int');
556 if (empty($quantity)) {
558 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Qty")),
null,
'errors');
560 if (empty($newprice)) {
562 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Price")),
null,
'errors');
566 if ($object->price_base_type ==
'TTC') {
567 $price =
price2num($newprice) / (1 + ($object->tva_tx / 100));
571 $unitPrice =
price2num($price / $quantity,
'MU');
575 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"product_price_by_qty SET";
576 $sql .=
" price=".((float) $price).
",";
577 $sql .=
" unitprice=".((float) $unitPrice).
",";
578 $sql .=
" quantity=".((float) $quantity).
",";
579 $sql .=
" remise_percent=".((float) $remise_percent).
",";
580 $sql .=
" remise=".((float) $remise);
581 $sql .=
" WHERE rowid = ".((int) $rowid);
583 $result = $db->query($sql);
588 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"product_price_by_qty (fk_product_price,price,unitprice,quantity,remise_percent,remise) values (";
589 $sql .= ((int) $priceid).
','.((float) $price).
','.((float) $unitPrice).
','.((float) $quantity).
','.((float) $remise_percent).
','.((float) $remise).
')';
591 $result = $db->query($sql);
593 if ($db->lasterrno() ==
'DB_ERROR_RECORD_ALREADY_EXISTS') {
603 if ($action ==
'delete_price_by_qty') {
604 $rowid =
GETPOST(
'rowid',
'int');
605 if (!empty($rowid)) {
606 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"product_price_by_qty";
607 $sql .=
" WHERE rowid = ".((int) $rowid);
609 $result = $db->query($sql);
611 setEventMessages((
'delete_price_by_qty'.$langs->transnoentities(
'MissingIds')),
null,
'errors');
615 if ($action ==
'delete_all_price_by_qty') {
616 $priceid =
GETPOST(
'priceid',
'int');
617 if (!empty($rowid)) {
618 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"product_price_by_qty";
619 $sql .=
" WHERE fk_product_price = ".((int) $priceid);
621 $result = $db->query($sql);
623 setEventMessages((
'delete_price_by_qty'.$langs->transnoentities(
'MissingIds')),
null,
'errors');
632 if ($action ==
'add_customer_price_confirm' && !$cancel && ($user->hasRight(
'produit',
'creer') || $user->hasRight(
'service',
'creer'))) {
633 $maxpricesupplier = $object->min_recommended_price();
635 $update_child_soc =
GETPOST(
'updatechildprice',
'int');
638 $prodcustprice->fk_soc =
GETPOST(
'socid',
'int');
639 $prodcustprice->ref_customer =
GETPOST(
'ref_customer',
'alpha');
640 $prodcustprice->fk_product = $object->id;
643 $prodcustprice->price_base_type =
GETPOST(
"price_base_type",
'alpha');
645 $tva_tx_txt =
GETPOST(
"tva_tx",
'alpha');
647 $tva_tx = $tva_tx_txt;
649 if (preg_match(
'/\((.*)\)/', $tva_tx_txt, $reg)) {
650 $vat_src_code = $reg[1];
651 $tva_tx = preg_replace(
'/\s*\(.*\)/',
'', $tva_tx_txt);
653 $tva_tx =
price2num(preg_replace(
'/\*/',
'', $tva_tx));
655 $npr = preg_match(
'/\*/', $tva_tx_txt) ? 1 : 0;
658 $localtax1_type =
'0';
659 $localtax2_type =
'0';
661 if (preg_match(
'/\((.*)\)/', $tva_tx_txt, $reg)) {
663 $vatratecode = $reg[1];
665 $sql =
"SELECT t.rowid, t.code, t.recuperableonly, t.localtax1, t.localtax2, t.localtax1_type, t.localtax2_type";
666 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_tva as t, ".MAIN_DB_PREFIX.
"c_country as c";
667 $sql .=
" WHERE t.fk_pays = c.rowid AND c.code = '".$db->escape($mysoc->country_code).
"'";
668 $sql .=
" AND t.taux = ".((float) $tva_tx).
" AND t.active = 1";
669 $sql .=
" AND t.code ='".$db->escape($vatratecode).
"'";
670 $sql .=
" AND t.entity IN (".getEntity(
'c_tva').
")";
671 $resql = $db->query($sql);
673 $obj = $db->fetch_object($resql);
675 $npr = $obj->recuperableonly;
676 $localtax1 = $obj->localtax1;
677 $localtax2 = $obj->localtax2;
678 $localtax1_type = $obj->localtax1_type;
679 $localtax2_type = $obj->localtax2_type;
683 if (in_array($mysoc->country_code, array(
'ES'))) {
690 $sql =
"SELECT t.rowid, t.code, t.recuperableonly, t.localtax1, t.localtax2, t.localtax1_type, t.localtax2_type";
691 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_tva as t, ".MAIN_DB_PREFIX.
"c_country as c";
692 $sql .=
" WHERE t.fk_pays = c.rowid AND c.code = '".$db->escape($mysoc->country_code).
"'";
693 $sql .=
" AND t.taux = ".((float) $tva_tx).
" AND t.active = 1";
694 $sql .=
" AND t.code = ''";
695 $resql = $db->query($sql);
697 $obj = $db->fetch_object($resql);
699 $npr = $obj->recuperableonly;
700 $localtax1 = $obj->localtax1;
701 $localtax2 = $obj->localtax2;
702 $localtax1_type = $obj->localtax1_type;
703 $localtax2_type = $obj->localtax2_type;
708 $prodcustprice->default_vat_code = $vatratecode;
709 $prodcustprice->tva_tx = $tva_tx;
710 $prodcustprice->recuperableonly = $npr;
711 $prodcustprice->localtax1_tx = $localtax1;
712 $prodcustprice->localtax2_tx = $localtax2;
713 $prodcustprice->localtax1_type = $localtax1_type;
714 $prodcustprice->localtax2_type = $localtax2_type;
716 if (!($prodcustprice->fk_soc > 0)) {
717 $langs->load(
"errors");
718 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"ThirdParty")),
null,
'errors');
720 $action =
'add_customer_price';
722 if (
getDolGlobalString(
'PRODUCT_MINIMUM_RECOMMENDED_PRICE') && $prodcustprice->price_min < $maxpricesupplier) {
723 $langs->load(
"errors");
724 setEventMessages($langs->trans(
"MinimumPriceLimit",
price($maxpricesupplier, 0,
'', 1, -1, -1,
'auto')),
null,
'errors');
726 $action =
'add_customer_price';
730 $result = $prodcustprice->create($user, 0, $update_child_soc);
742 if ($action ==
'delete_customer_price' && ($user->hasRight(
'produit',
'supprimer') || $user->hasRight(
'service',
'supprimer'))) {
744 $prodcustprice->id =
GETPOST(
'lineid',
'int');
745 $result = $prodcustprice->delete($user);
755 if ($action ==
'update_customer_price_confirm' && !$cancel && ($user->hasRight(
'produit',
'creer') || $user->hasRight(
'service',
'creer'))) {
756 $maxpricesupplier = $object->min_recommended_price();
758 $update_child_soc =
GETPOST(
'updatechildprice',
'int');
760 $prodcustprice->fetch(
GETPOST(
'lineid',
'int'));
763 $prodcustprice->ref_customer =
GETPOST(
'ref_customer',
'alpha');
766 $prodcustprice->price_base_type =
GETPOST(
"price_base_type",
'alpha');
768 $tva_tx_txt =
GETPOST(
"tva_tx");
770 $tva_tx = $tva_tx_txt;
772 if (preg_match(
'/\((.*)\)/', $tva_tx_txt, $reg)) {
773 $vat_src_code = $reg[1];
774 $tva_tx = preg_replace(
'/\s*\(.*\)/',
'', $tva_tx_txt);
776 $tva_tx =
price2num(preg_replace(
'/\*/',
'', $tva_tx));
778 $npr = preg_match(
'/\*/', $tva_tx_txt) ? 1 : 0;
781 $localtax1_type =
'0';
782 $localtax2_type =
'0';
784 if (preg_match(
'/\((.*)\)/', $tva_tx_txt, $reg)) {
786 $vatratecode = $reg[1];
788 $sql =
"SELECT t.rowid, t.code, t.recuperableonly, t.localtax1, t.localtax2, t.localtax1_type, t.localtax2_type";
789 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_tva as t, ".MAIN_DB_PREFIX.
"c_country as c";
790 $sql .=
" WHERE t.fk_pays = c.rowid AND c.code = '".$db->escape($mysoc->country_code).
"'";
791 $sql .=
" AND t.taux = ".((float) $tva_tx).
" AND t.active = 1";
792 $sql .=
" AND t.code ='".$db->escape($vatratecode).
"'";
793 $sql .=
" AND t.entity IN (".getEntity(
'c_tva').
")";
794 $resql = $db->query($sql);
796 $obj = $db->fetch_object($resql);
798 $npr = $obj->recuperableonly;
799 $localtax1 = $obj->localtax1;
800 $localtax2 = $obj->localtax2;
801 $localtax1_type = $obj->localtax1_type;
802 $localtax2_type = $obj->localtax2_type;
806 if (in_array($mysoc->country_code, array(
'ES'))) {
813 $sql =
"SELECT t.rowid, t.code, t.recuperableonly, t.localtax1, t.localtax2, t.localtax1_type, t.localtax2_type";
814 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_tva as t, ".MAIN_DB_PREFIX.
"c_country as c";
815 $sql .=
" WHERE t.fk_pays = c.rowid AND c.code = '".$db->escape($mysoc->country_code).
"'";
816 $sql .=
" AND t.taux = ".((float) $tva_tx).
" AND t.active = 1";
817 $sql .=
" AND t.code = ''";
818 $resql = $db->query($sql);
820 $obj = $db->fetch_object($resql);
822 $npr = $obj->recuperableonly;
823 $localtax1 = $obj->localtax1;
824 $localtax2 = $obj->localtax2;
825 $localtax1_type = $obj->localtax1_type;
826 $localtax2_type = $obj->localtax2_type;
831 $prodcustprice->default_vat_code = $vatratecode;
832 $prodcustprice->tva_tx = $tva_tx;
833 $prodcustprice->recuperableonly = $npr;
834 $prodcustprice->localtax1_tx = $localtax1;
835 $prodcustprice->localtax2_tx = $localtax2;
836 $prodcustprice->localtax1_type = $localtax1_type;
837 $prodcustprice->localtax2_type = $localtax2_type;
839 if ($prodcustprice->price_min < $maxpricesupplier &&
getDolGlobalString(
'PRODUCT_MINIMUM_RECOMMENDED_PRICE')) {
840 setEventMessages($langs->trans(
"MinimumPriceLimit",
price($maxpricesupplier, 0,
'', 1, -1, -1,
'auto')),
null,
'errors');
842 $action =
'update_customer_price';
846 $result = $prodcustprice->update($user, 0, $update_child_soc);
864$form =
new Form($db);
866if (!empty($id) || !empty($ref)) {
868 $object->fetch($id, $ref);
871$title = $langs->trans(
'ProductServiceCard');
873$shortlabel =
dol_trunc($object->label, 16);
875 $title = $langs->trans(
'Product').
" ".$shortlabel.
" - ".$langs->trans(
'SellingPrices');
876 $helpurl =
'EN:Module_Products|FR:Module_Produits|ES:Módulo_Productos';
879 $title = $langs->trans(
'Service').
" ".$shortlabel.
" - ".$langs->trans(
'SellingPrices');
880 $helpurl =
'EN:Module_Services_En|FR:Module_Services|ES:Módulo_Servicios';
883llxHeader(
'', $title, $helpurl,
'', 0, 0,
'',
'',
'',
'classforhorizontalscrolloftabs');
886$titre = $langs->trans(
"CardProduct".$object->type);
891$linkback =
'<a href="'.DOL_URL_ROOT.
'/product/list.php?restore_lastsearch_values=1&type='.$object->type.
'">'.$langs->trans(
"BackToList").
'</a>';
892$object->next_prev_filter =
"fk_product_type = ".((int) $object->type);
895if ($user->socid && !in_array(
'product', explode(
',',
getDolGlobalString(
'MAIN_MODULES_FOR_EXTERNAL')))) {
902print
'<div class="fichecenter">';
904print
'<div class="underbanner clearboth"></div>';
905print
'<table class="border tableforfield centpercent">';
910 if (!empty($socid)) {
916 if (isModEnabled(
"product") && isModEnabled(
"service")) {
917 $typeformat =
'select;0:'.$langs->trans(
"Product").
',1:'.$langs->trans(
"Service");
918 print
'<tr><td class="">';
919 print (!
getDolGlobalString(
'PRODUCT_DENY_CHANGE_PRODUCT_TYPE')) ? $form->editfieldkey(
"Type",
'fk_product_type', $object->type, $object, 0, $typeformat) : $langs->trans(
'Type');
921 print $form->editfieldval(
"Type",
'fk_product_type', $object->type, $object, 0, $typeformat);
926 print
'<tr><td class="titlefieldcreate">';
927 print $langs->trans(
"SellingPrice");
929 print
'<td colspan="2">';
930 if ($object->multiprices_base_type[$soc->price_level] ==
'TTC') {
931 print
'<span class="amount">'.price($object->multiprices_ttc[$soc->price_level]).
'</span>';
933 print
'<span class="amount">'.price($object->multiprices[$soc->price_level]).
'</span>';
935 if ($object->multiprices_base_type[$soc->price_level]) {
936 print
' '.$langs->trans($object->multiprices_base_type[$soc->price_level]);
938 print
' '.$langs->trans($object->price_base_type);
943 print
'<tr><td>'.$langs->trans(
"MinPrice").
'</td><td colspan="2">';
944 if ($object->multiprices_base_type[$soc->price_level] ==
'TTC') {
945 print
price($object->multiprices_min_ttc[$soc->price_level]).
' '.$langs->trans($object->multiprices_base_type[$soc->price_level]);
947 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]);
953 print
'<tr><td>'.$langs->trans(
"DefaultTaxRate").
'</td><td colspan="2">';
956 if (
price2num($object->multiprices_tva_tx[$soc->price_level])) {
957 $positiverates .= ($positiverates ?
'/' :
'').
price2num($object->multiprices_tva_tx[$soc->price_level]);
959 if (
price2num($object->multiprices_localtax1_type[$soc->price_level])) {
960 $positiverates .= ($positiverates ?
'/' :
'').
price2num($object->multiprices_localtax1_tx[$soc->price_level]);
962 if (
price2num($object->multiprices_localtax2_type[$soc->price_level])) {
963 $positiverates .= ($positiverates ?
'/' :
'').
price2num($object->multiprices_localtax2_tx[$soc->price_level]);
965 if (empty($positiverates)) {
966 $positiverates =
'0';
968 echo
vatrate($positiverates.($object->default_vat_code ?
' ('.$object->default_vat_code.
')' :
''),
'%', $object->tva_npr);
973 print
'<tr><td>'.$langs->trans(
"DefaultTaxRate").
'</td><td>';
977 $positiverates .= ($positiverates ?
'/' :
'').
price2num($object->tva_tx);
979 if (
price2num($object->localtax1_type)) {
980 $positiverates .= ($positiverates ?
'/' :
'').
price2num($object->localtax1_tx);
982 if (
price2num($object->localtax2_type)) {
983 $positiverates .= ($positiverates ?
'/' :
'').
price2num($object->localtax2_tx);
985 if (empty($positiverates)) {
986 $positiverates =
'0';
988 echo
vatrate($positiverates.($object->default_vat_code ?
' ('.$object->default_vat_code.
')' :
''),
'%', $object->tva_npr);
1000 if (isModEnabled(
"product") && isModEnabled(
"service")) {
1001 $typeformat =
'select;0:'.$langs->trans(
"Product").
',1:'.$langs->trans(
"Service");
1002 print
'<tr><td class="">';
1003 print (!
getDolGlobalString(
'PRODUCT_DENY_CHANGE_PRODUCT_TYPE')) ? $form->editfieldkey(
"Type",
'fk_product_type', $object->type, $object, 0, $typeformat) : $langs->trans(
'Type');
1005 print $form->editfieldval(
"Type",
'fk_product_type', $object->type, $object, 0, $typeformat);
1010 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"DefaultTaxRate").
'</td>';
1011 print
'<td colspan="2">'.vatrate($object->multiprices_tva_tx[1],
true).
'</td>';
1015 if (isModEnabled(
"product") && isModEnabled(
"service")) {
1016 $typeformat =
'select;0:'.$langs->trans(
"Product").
',1:'.$langs->trans(
"Service");
1017 print
'<tr><td class="">';
1018 print (!
getDolGlobalString(
'PRODUCT_DENY_CHANGE_PRODUCT_TYPE')) ? $form->editfieldkey(
"Type",
'fk_product_type', $object->type, $object, 0, $typeformat) : $langs->trans(
'Type');
1020 print $form->editfieldval(
"Type",
'fk_product_type', $object->type, $object, 0, $typeformat);
1025 print
'<!-- Default VAT Rate -->';
1026 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"DefaultTaxRate").
'</td><td>';
1029 $positiverates =
'';
1031 $positiverates .= ($positiverates ?
'<span class="opacitymedium">/</span>' :
'').
price2num($object->tva_tx);
1033 if (
price2num($object->localtax1_type)) {
1034 $positiverates .= ($positiverates ?
'<span class="opacitymedium">/</span>' :
'').
price2num($object->localtax1_tx);
1036 if (
price2num($object->localtax2_type)) {
1037 $positiverates .= ($positiverates ?
'<span class="opacitymedium">/</span>' :
'').
price2num($object->localtax2_tx);
1039 if (empty($positiverates)) {
1040 $positiverates =
'0';
1043 print
vatrate($positiverates.($object->default_vat_code ?
' ('.$object->default_vat_code.
')' :
''), true, $object->tva_npr, 1);
1056 print
'<table class="noborder tableforfield centpercent">';
1057 print
'<tr class="liste_titre"><td>';
1058 print $langs->trans(
"PriceLevel");
1060 print
' <a class="editfielda" href="'.$_SERVER[
"PHP_SELF"].
'?action=editlabelsellingprice&token='.newToken().
'&pricelevel='.$i.
'&id='.$object->id.
'">'.
img_edit($langs->trans(
'EditSellingPriceLabel'), 0).
'</a>';
1063 print
'<td style="text-align: right">'.$langs->trans(
"SellingPrice").
'</td>';
1064 print
'<td style="text-align: right">'.$langs->trans(
"MinPrice").
'</td>';
1067 for ($i = 1; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i++) {
1068 print
'<tr class="oddeven">';
1072 $keyforlabel =
'PRODUIT_MULTIPRICES_LABEL'.$i;
1073 if (preg_match(
'/editlabelsellingprice/', $action)) {
1074 print
'<form method="post" action="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'">';
1075 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1076 print
'<input type="hidden" name="action" value="setlabelsellingprice">';
1077 print
'<input type="hidden" name="pricelevel" value="'.$i.
'">';
1078 print $langs->trans(
"SellingPrice").
' '.$i.
' - ';
1079 print
'<input class="maxwidthonsmartphone" type="text" name="labelsellingprice" value="' .
getDolGlobalString($keyforlabel).
'">';
1080 print
' <input type="submit" class="button smallpaddingimp" value="'.$langs->trans(
"Modify").
'">';
1083 print $langs->trans(
"SellingPrice").
' '.$i;
1084 if (!empty($conf->global->$keyforlabel)) {
1085 print
' - '.$langs->trans($conf->global->$keyforlabel);
1090 if ($object->multiprices_base_type [$i] ==
'TTC') {
1091 print
'<td class="right"><span class="amount">'.price($object->multiprices_ttc[$i]);
1093 print
'<td class="right"><span class="amount">'.price($object->multiprices[$i]);
1096 if ($object->multiprices_base_type[$i]) {
1097 print
' '.$langs->trans($object->multiprices_base_type [$i]).
'</span></td>';
1099 print
' '.$langs->trans($object->price_base_type).
'</span></td>';
1103 print
'<td style="text-align: right">';
1104 if (empty($object->multiprices_base_type[$i])) {
1105 $object->multiprices_base_type[$i] =
"HT";
1107 if ($object->multiprices_base_type[$i] ==
'TTC') {
1108 print
price($object->multiprices_min_ttc[$i]).
' '.$langs->trans($object->multiprices_base_type[$i]);
1110 print
price($object->multiprices_min[$i]).
' '.$langs->trans($object->multiprices_base_type[$i]);
1116 print
'<tr><td>'.$langs->trans(
"PriceByQuantity").
' '.$i;
1117 if (!empty($conf->global->$keyforlabel)) {
1118 print
' - '.$langs->trans($conf->global->$keyforlabel);
1120 print
'</td><td colspan="2">';
1122 if ($object->prices_by_qty[$i] == 1) {
1123 print
'<table width="50%" class="border" summary="List of quantities">';
1125 print
'<tr class="liste_titre">';
1126 print
'<td>'.$langs->trans(
"PriceByQuantityRange").
' '.$i.
'</td>';
1127 print
'<td class="right">'.$langs->trans(
"HT").
'</td>';
1128 print
'<td class="right">'.$langs->trans(
"UnitPrice").
'</td>';
1129 print
'<td class="right">'.$langs->trans(
"Discount").
'</td>';
1130 print
'<td> </td>';
1132 foreach ($object->prices_by_qty_list[$i] as $ii => $prices) {
1133 if ($action ==
'edit_price_by_qty' && $rowid == $prices[
'rowid'] && ($user->hasRight(
'produit',
'creer') || $user->hasRight(
'service',
'creer'))) {
1134 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'" method="POST">';
1135 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1136 print
'<input type="hidden" name="action" value="update_price_by_qty">';
1137 print
'<input type="hidden" name="priceid" value="'.$object->prices_by_qty_id[$i].
'">';
1138 print
'<input type="hidden" value="'.$prices[
'rowid'].
'" name="rowid">';
1139 print
'<tr class="'.($ii % 2 == 0 ?
'pair' :
'impair').
'">';
1140 print
'<td><input size="5" type="text" value="'.$prices[
'quantity'].
'" name="quantity"></td>';
1141 print
'<td class="right" colspan="2"><input size="10" type="text" value="'.price2num($prices[
'price'],
'MU').
'" name="price"> '.$object->price_base_type.
'</td>';
1142 print
'<td class="right nowraponall"><input size="5" type="text" value="'.$prices[
'remise_percent'].
'" name="remise_percent"> %</td>';
1143 print
'<td class="center"><input type="submit" value="'.$langs->trans(
"Modify").
'" class="button"></td>';
1147 print
'<tr class="'.($ii % 2 == 0 ?
'pair' :
'impair').
'">';
1148 print
'<td>'.$prices[
'quantity'].
'</td>';
1149 print
'<td class="right">'.price($prices[
'price']).
'</td>';
1150 print
'<td class="right">'.price($prices[
'unitprice']).
'</td>';
1151 print
'<td class="right">'.price($prices[
'remise_percent']).
' %</td>';
1152 print
'<td class="center">';
1153 if (($user->hasRight(
'produit',
'creer') || $user->hasRight(
'service',
'creer'))) {
1154 print
'<a class="editfielda marginleftonly marginrightonly" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=edit_price_by_qty&token='.newToken().
'&rowid='.$prices[
"rowid"].
'">';
1156 print
'<a class="marginleftonly marginrightonly" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=delete_price_by_qty&token='.newToken().
'&rowid='.$prices[
"rowid"].
'">';
1165 if ($action !=
'edit_price_by_qty' && ($user->hasRight(
'produit',
'creer') || $user->hasRight(
'service',
'creer'))) {
1166 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'" method="POST">';
1167 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1168 print
'<input type="hidden" name="action" value="update_price_by_qty">';
1169 print
'<input type="hidden" name="priceid" value="'.$object->prices_by_qty_id[$i].
'">';
1170 print
'<input type="hidden" value="0" name="rowid">';
1171 print
'<tr class="'.($ii % 2 == 0 ?
'pair' :
'impair').
'">';
1172 print
'<td><input size="5" type="text" value="1" name="quantity"></td>';
1173 print
'<td class="right" class="nowrap"><input size="10" type="text" value="0" name="price"> '.$object->price_base_type.
'</td>';
1174 print
'<td class="right"> </td>';
1175 print
'<td class="right" class="nowraponall"><input size="5" type="text" value="0" name="remise_percent"> %</td>';
1176 print
'<td class="center"><input type="submit" value="'.$langs->trans(
"Add").
'" class="button"></td>';
1182 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>';
1184 print $langs->trans(
"No");
1185 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>';
1193 print
'<tr><td class="titlefield">'.$langs->trans(
"DefaultTaxRate").
'</td><td>';
1195 $positiverates =
'';
1197 $positiverates .= ($positiverates ?
'/' :
'').
price2num($object->tva_tx);
1199 if (
price2num($object->localtax1_type)) {
1200 $positiverates .= ($positiverates ?
'/' :
'').
price2num($object->localtax1_tx);
1202 if (
price2num($object->localtax2_type)) {
1203 $positiverates .= ($positiverates ?
'/' :
'').
price2num($object->localtax2_tx);
1205 if (empty($positiverates)) {
1206 $positiverates =
'0';
1208 echo
vatrate($positiverates.($object->default_vat_code ?
' ('.$object->default_vat_code.
')' :
''),
'%', $object->tva_npr, 0, 1);
1218 print
'<tr class="field_selling_price"><td>'.$langs->trans(
"SellingPrice").
'</td><td>';
1219 if ($object->price_base_type ==
'TTC') {
1220 print
price($object->price_ttc).
' '.$langs->trans($object->price_base_type);
1222 print
price($object->price).
' '.$langs->trans($object->price_base_type);
1223 if (
getDolGlobalString(
'PRODUCT_DISPLAY_VAT_INCL_PRICES') && !empty($object->price_ttc)) {
1224 print
'<i class="opacitymedium"> - ' .
price($object->price_ttc).
' '.$langs->trans(
'TTC') .
'</i>';
1231 print
'<tr class="field_min_price"><td>'.$langs->trans(
"MinPrice").
'</td><td>';
1232 if ($object->price_base_type ==
'TTC') {
1233 print
price($object->price_min_ttc).
' '.$langs->trans($object->price_base_type);
1235 print
price($object->price_min).
' '.$langs->trans($object->price_base_type);
1236 if (
getDolGlobalString(
'PRODUCT_DISPLAY_VAT_INCL_PRICES') && !empty($object->price_min_ttc)) {
1237 print
'<i class="opacitymedium"> - ' .
price($object->price_min_ttc).
' '.$langs->trans(
'TTC') .
'</i>';
1245 print
'<tr><td>'.$langs->trans(
"PriceByQuantity");
1246 if ($object->prices_by_qty[0] == 0) {
1247 print
' <a href="'.$_SERVER[
'PHP_SELF'].
'?id='.$object->id.
'&action=activate_price_by_qty&level=1&token='.newToken().
'">('.$langs->trans(
"Activate").
')';
1249 print
' <a href="'.$_SERVER[
'PHP_SELF'].
'?id='.$object->id.
'&action=disable_price_by_qty&level=1&token='.newToken().
'">('.$langs->trans(
"DisablePriceByQty").
')';
1253 if ($object->prices_by_qty[0] == 1) {
1254 print
'<table width="50%" class="border" summary="List of quantities">';
1255 print
'<tr class="liste_titre">';
1257 print
'<td>'.$langs->trans(
"Quantity").
'</td>';
1258 print
'<td class="right">'.$langs->trans(
"Price").
'</td>';
1259 print
'<td class="right"></td>';
1260 print
'<td class="right">'.$langs->trans(
"UnitPrice").
'</td>';
1261 print
'<td class="right">'.$langs->trans(
"Discount").
'</td>';
1262 print
'<td> </td>';
1264 if ($action !=
'edit_price_by_qty') {
1265 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'" method="POST">';
1266 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1267 print
'<input type="hidden" name="action" value="update_price_by_qty">';
1268 print
'<input type="hidden" name="priceid" value="'.$object->prices_by_qty_id[0].
'">';
1269 print
'<input type="hidden" value="0" name="rowid">';
1271 print
'<tr class="'.($ii % 2 == 0 ?
'pair' :
'impair').
'">';
1272 print
'<td><input size="5" type="text" value="1" name="quantity"></td>';
1273 print
'<td class="right"><input class="width50 right" type="text" value="0" name="price"></td>';
1277 print
'<td class="right"> </td>';
1278 print
'<td class="right nowraponall"><input type="text" class="width50 right" value="0" name="remise_percent"> %</td>';
1279 print
'<td class="center"><input type="submit" value="'.$langs->trans(
"Add").
'" class="button"></td>';
1284 foreach ($object->prices_by_qty_list[0] as $ii => $prices) {
1285 if ($action ==
'edit_price_by_qty' && $rowid == $prices[
'rowid'] && ($user->hasRight(
'produit',
'creer') || $user->hasRight(
'service',
'creer'))) {
1286 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'" method="POST">';
1287 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1288 print
'<input type="hidden" name="action" value="update_price_by_qty">';
1289 print
'<input type="hidden" name="priceid" value="'.$object->prices_by_qty_id[0].
'">';
1290 print
'<input type="hidden" value="'.$prices[
'rowid'].
'" name="rowid">';
1291 print
'<tr class="'.($ii % 2 == 0 ?
'pair' :
'impair').
'">';
1292 print
'<td><input size="5" type="text" value="'.$prices[
'quantity'].
'" name="quantity"></td>';
1293 print
'<td class="right"><input class="width50 right" type="text" value="'.price2num($prices[
'price'],
'MU').
'" name="price"></td>';
1294 print
'<td class="right">';
1296 print $prices[
'price_base_type'];
1298 print
'<td class="right"> </td>';
1299 print
'<td class="right nowraponall"><input class="width50 right" type="text" value="'.$prices[
'remise_percent'].
'" name="remise_percent"> %</td>';
1300 print
'<td class="center"><input type="submit" value="'.$langs->trans(
"Modify").
'" class="button"></td>';
1304 print
'<tr class="'.($ii % 2 == 0 ?
'pair' :
'impair').
'">';
1305 print
'<td>'.$prices[
'quantity'].
'</td>';
1306 print
'<td class="right">'.price($prices[
'price']).
'</td>';
1307 print
'<td class="right">';
1309 print $prices[
'price_base_type'];
1311 print
'<td class="right">'.price($prices[
'unitprice']).
'</td>';
1312 print
'<td class="right">'.price($prices[
'remise_percent']).
' %</td>';
1313 print
'<td class="center">';
1314 if (($user->hasRight(
'produit',
'creer') || $user->hasRight(
'service',
'creer'))) {
1315 print
'<a class="editfielda marginleftonly marginrightonly" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=edit_price_by_qty&token='.newToken().
'&rowid='.$prices[
"rowid"].
'">';
1317 print
'<a class="marginleftonly marginrightonly" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=delete_price_by_qty&token='.newToken().
'&rowid='.$prices[
"rowid"].
'">';
1328 print $langs->trans(
"No");
1337print
'<div class="clearboth"></div>';
1349if (!$action || $action ==
'delete' || $action ==
'showlog_customer_price' || $action ==
'showlog_default_price' || $action ==
'add_customer_price'
1350 || $action ==
'activate_price_by_qty' || $action ==
'disable_price_by_qty') {
1351 print
"\n".
'<div class="tabsAction">'.
"\n";
1354 $parameters = array();
1355 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters, $object, $action);
1356 if (empty($reshook)) {
1357 if ($object->isVariant()) {
1358 if ($user->hasRight(
'produit',
'creer') || $user->hasRight(
'service',
'creer')) {
1359 print
'<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="' .
dol_escape_htmltag($langs->trans(
"NoEditVariants")) .
'">' . $langs->trans(
"UpdateDefaultPrice") .
'</a></div>';
1363 if ($user->hasRight(
'produit',
'creer') || $user->hasRight(
'service',
'creer')) {
1364 print
'<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER[
'PHP_SELF'] .
'?action=edit_price&token='.newToken().
'&id=' . $object->id .
'">' . $langs->trans(
"UpdateDefaultPrice") .
'</a></div>';
1366 print
'<div class="inline-block divButAction"><span class="butActionRefused" title="'.dol_escape_htmltag($langs->trans(
"NotEnoughPermissions")).
'">' . $langs->trans(
"UpdateDefaultPrice") .
'</span></div>';
1371 if ($user->hasRight(
'produit',
'creer') || $user->hasRight(
'service',
'creer')) {
1372 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>';
1374 print
'<div class="inline-block divButAction"><span class="butActionRefused" title="'.dol_escape_htmltag($langs->trans(
"NotEnoughPermissions")).
'">' . $langs->trans(
"AddCustomerPrice") .
'</span></div>';
1379 if ($user->hasRight(
'produit',
'creer') || $user->hasRight(
'service',
'creer')) {
1380 print
'<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER[
'PHP_SELF'] .
'?action=edit_vat&token='.newToken().
'&id=' . $object->id .
'">' . $langs->trans(
"UpdateVAT") .
'</a></div>';
1382 print
'<div class="inline-block divButAction"><span class="butActionRefused" title="'.dol_escape_htmltag($langs->trans(
"NotEnoughPermissions")).
'">' . $langs->trans(
"UpdateVAT") .
'</span></div>';
1385 if ($user->hasRight(
'produit',
'creer') || $user->hasRight(
'service',
'creer')) {
1386 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>';
1388 print
'<div class="inline-block divButAction"><span class="butActionRefused" title="'.dol_escape_htmltag($langs->trans(
"NotEnoughPermissions")).
'">' . $langs->trans(
"UpdateLevelPrices") .
'</span></div>';
1403if ($action ==
'edit_vat' && ($user->hasRight(
'produit',
'creer') || $user->hasRight(
'service',
'creer'))) {
1406 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'" method="POST">';
1407 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1408 print
'<input type="hidden" name="action" value="update_vat">';
1409 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
1413 print
'<table class="border centpercent">';
1416 print
'<tr><td>'.$langs->trans(
"DefaultTaxRate").
'</td><td>';
1417 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);
1424 print $form->buttonsSaveCancel();
1426 print
'<br></form><br>';
1429if ($action ==
'edit_price' && $object->getRights()->creer) {
1434 print
'<!-- Edit price -->'.
"\n";
1435 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'" method="POST">';
1436 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1437 print
'<input type="hidden" name="action" value="update_price">';
1438 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
1442 print
'<div class="div-table-responsive-no-min">';
1443 print
'<table class="border centpercent">';
1446 print
'<tr><td class="titlefield">'.$langs->trans(
"DefaultTaxRate").
'</td><td>';
1447 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);
1452 print $langs->trans(
'PriceBase');
1455 print $form->selectPriceBaseType($object->price_base_type,
"price_base_type");
1460 if (!empty($conf->dynamicprices->enabled)) {
1462 print
'<!-- Show price mode of dynamicprices editor -->'.
"\n";
1463 print
'<tr><td>'.$langs->trans(
"PriceMode").
'</td><td>';
1464 print
img_picto(
'',
'dynamicprice',
'class="pictofixedwidth"');
1466 $price_expression_list = array(0 => $langs->trans(
"Numeric").
' <span class="opacitymedium">('.$langs->trans(
"NoDynamicPrice").
')</span>');
1467 foreach ($price_expression->list_price_expression() as $entry) {
1468 $price_expression_list[$entry->id] = $entry->title;
1470 $price_expression_preselection =
GETPOST(
'eid') ?
GETPOST(
'eid') : ($object->fk_price_expression ? $object->fk_price_expression :
'0');
1471 print $form->selectarray(
'eid', $price_expression_list, $price_expression_preselection);
1472 print
' <a id="expression_editor" class="classlink">'.$langs->trans(
"PriceExpressionEditor").
'</a>';
1478 <script
type=
"text/javascript">
1479 jQuery(document).ready(
function() {
1480 jQuery(
"#expression_editor").click(
function() {
1481 window.location =
"<?php echo DOL_URL_ROOT ?>/product/dynamic_price/editor.php?id=<?php echo $id ?>&tab=price&eid=" + $(
"#eid").val();
1483 jQuery(
"#eid").change(on_change);
1486 function on_change() {
1487 if ($(
"#eid").val() == 0) {
1488 jQuery(
"#price_numeric").show();
1490 jQuery(
"#price_numeric").hide();
1499 $product->fetch($id, $ref,
'', 1);
1500 print
'<tr id="price_numeric"><td>';
1501 $text = $langs->trans(
'SellingPrice');
1502 print $form->textwithpicto($text, $langs->trans(
"PrecisionUnitIsLimitedToXDecimals", $conf->global->MAIN_MAX_DECIMALS_UNIT), 1, 1);
1504 if ($object->price_base_type ==
'TTC') {
1505 print
'<input name="price" size="10" value="'.price($product->price_ttc).
'">';
1507 print
'<input name="price" size="10" value="'.price($product->price).
'">';
1513 $text = $langs->trans(
'MinPrice');
1514 print $form->textwithpicto($text, $langs->trans(
"PrecisionUnitIsLimitedToXDecimals", $conf->global->MAIN_MAX_DECIMALS_UNIT), 1, 1);
1516 if ($object->price_base_type ==
'TTC') {
1517 print
'<input name="price_min" size="10" value="'.price($object->price_min_ttc).
'">';
1519 print
'<input name="price_min" size="10" value="'.price($object->price_min).
'">';
1522 print
' '.$langs->trans(
"MinimumRecommendedPrice",
price($maxpricesupplier, 0,
'', 1, -1, -1,
'auto')).
' '.
img_warning().
'</td>';
1527 $parameters = array();
1528 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters, $object, $action);
1535 print $form->buttonsSaveCancel();
1539 print
'<!-- Edit price per level -->'.
"\n"; ?>
1542 var showHidePriceRules =
function () {
1543 var otherPrices = $(
'div.fiche form table tbody tr:not(:first)');
1544 var minPrice1 = $(
'div.fiche form input[name="price_min[1]"]');
1546 if (jQuery(
'input#usePriceRules').prop(
'checked')) {
1555 jQuery(document).ready(
function () {
1556 showHidePriceRules();
1558 jQuery(
'input#usePriceRules').click(showHidePriceRules);
1563 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'" method="POST">';
1564 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1565 print
'<input type="hidden" name="action" value="update_price">';
1566 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
1571 print $langs->trans(
'UseMultipriceRules').
' <input type="checkbox" id="usePriceRules" name="usePriceRules" '.($object->price_autogen ?
'checked' :
'').
'><br><br>';
1574 print
'<div class="div-table-responsive-no-min">';
1575 print
'<table class="noborder">';
1576 print
'<thead><tr class="liste_titre">';
1578 print
'<td>'.$langs->trans(
"PriceLevel").
'</td>';
1581 print
'<td style="text-align: center">'.$langs->trans(
"DefaultTaxRate").
'</td>';
1586 print
'<td class="center">'.$langs->trans(
"SellingPrice").
'</td>';
1588 print
'<td class="center">'.$langs->trans(
"MinPrice").
'</td>';
1593 print
'</tr></thead>';
1597 for ($i = 1; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i++) {
1598 print
'<tr class="oddeven">';
1600 $keyforlabel =
'PRODUIT_MULTIPRICES_LABEL'.$i;
1602 print $form->textwithpicto($text, $langs->trans(
"PrecisionUnitIsLimitedToXDecimals", $conf->global->MAIN_MAX_DECIMALS_UNIT), 1, 1);
1608 print
'<input type="hidden" name="tva_tx['.$i.
']" value="'.($object->default_vat_code ? $object->tva_tx.
' ('.$object->default_vat_code.
')' : $object->tva_tx).
'">';
1609 print
'<input type="hidden" name="tva_npr['.$i.
']" value="'.$object->tva_npr.
'">';
1610 print
'<input type="hidden" name="localtax1_tx['.$i.
']" value="'.$object->localtax1_tx.
'">';
1611 print
'<input type="hidden" name="localtax1_type['.$i.
']" value="'.$object->localtax1_type.
'">';
1612 print
'<input type="hidden" name="localtax2_tx['.$i.
']" value="'.$object->localtax2_tx.
'">';
1613 print
'<input type="hidden" name="localtax2_type['.$i.
']" value="'.$object->localtax2_type.
'">';
1617 print
'<td style="text-align: center">';
1618 print $form->load_tva(
"tva_tx[".$i.
']', $object->multiprices_tva_tx[$i], $mysoc,
'', $object->id,
false, $object->type,
false, 1);
1623 print
'<td style="text-align: center">';
1624 if ($object->multiprices_base_type [$i] ==
'TTC') {
1625 print
'<input name="price['.$i.
']" size="10" value="'.
price($object->multiprices_ttc [$i]).
'">';
1627 print
'<input name="price['.$i.
']" size="10" value="'.
price($object->multiprices [$i]).
'">';
1629 print
' '.$form->selectPriceBaseType($object->multiprices_base_type [$i],
"multiprices_base_type[".$i.
"]");
1633 print
'<td style="text-align: center">';
1634 if ($object->multiprices_base_type [$i] ==
'TTC') {
1635 print
'<input name="price_min['.$i.
']" size="10" value="'.
price($object->multiprices_min_ttc [$i]).
'">';
1637 print
'<input name="price_min['.$i.
']" size="10" value="'.
price($object->multiprices_min [$i]).
'">';
1640 print
'<td class="left">'.$langs->trans(
"MinimumRecommendedPrice",
price($maxpricesupplier, 0,
'', 1, -1, -1,
'auto')).
' '.
img_warning().
'</td>';
1654 print $form->buttonsSaveCancel();
1663if ((!
getDolGlobalString(
'PRODUIT_CUSTOMER_PRICES') || $action ==
'showlog_default_price') && !in_array($action, array(
'edit_price',
'edit_vat'))) {
1664 $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,";
1665 $sql .=
" p.price_level, p.price_min, p.price_min_ttc,p.price_by_qty,";
1666 $sql .=
" p.date_price as dp, p.fk_price_expression, u.rowid as user_id, u.login";
1667 $sql .=
" FROM ".MAIN_DB_PREFIX.
"product_price as p,";
1668 $sql .=
" ".MAIN_DB_PREFIX.
"user as u";
1669 $sql .=
" WHERE fk_product = ".((int) $object->id);
1670 $sql .=
" AND p.entity IN (".getEntity(
'productprice').
")";
1671 $sql .=
" AND p.fk_user_author = u.rowid";
1673 $sql .=
" AND p.price_level = ".((int) $soc->price_level);
1675 $sql .=
" ORDER BY p.date_price DESC, p.rowid DESC, p.price_level ASC";
1679 $result = $db->query($sql);
1681 print
'<div class="divlogofpreviouscustomerprice">';
1683 $num = $db->num_rows($result);
1692 $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);
1694 $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));
1700 $result = $db->query($sql);
1701 $num = $db->num_rows($result);
1708 $backbutton =
'<a class="justalink" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'">'.$langs->trans(
"Back").
'</a>';
1711 print_barre_liste($langs->trans(
"DefaultPriceLog"), 0, $_SERVER[
"PHP_SELF"],
'',
'',
'', $backbutton, 0, $num,
'title_accountancy.png');
1713 print_barre_liste($langs->trans(
"PriceByCustomerLog"), 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', 0, $num,
'title_accountancy.png');
1716 print
'<!-- List of log prices -->'.
"\n";
1717 print
'<div class="div-table-responsive">'.
"\n";
1718 print
'<table class="liste centpercent">'.
"\n";
1720 print
'<tr class="liste_titre">';
1721 print
'<td>'.$langs->trans(
"AppliedPricesFrom").
'</td>';
1724 print
'<td class="center">'.$langs->trans(
"PriceLevel").
'</td>';
1727 print
'<td class="center">'.$langs->trans(
"Type").
'</td>';
1730 print
'<td class="center">'.$langs->trans(
"PriceBase").
'</td>';
1732 print
'<td class="right">'.$langs->trans(
"DefaultTaxRate").
'</td>';
1734 print
'<td class="right">'.$langs->trans(
"HT").
'</td>';
1735 print
'<td class="right">'.$langs->trans(
"TTC").
'</td>';
1736 if ($mysoc->localtax1_assuj ==
"1" || $mysoc->localtax2_assuj ==
"1") {
1737 print
'<td class="right">'.$langs->trans(
"INCT").
'</td>';
1739 if (!empty($conf->dynamicprices->enabled)) {
1740 print
'<td class="right">'.$langs->trans(
"PriceExpressionSelected").
'</td>';
1742 print
'<td class="right">'.$langs->trans(
"MinPrice").
' '.$langs->trans(
"HT").
'</td>';
1743 print
'<td class="right">'.$langs->trans(
"MinPrice").
' '.$langs->trans(
"TTC").
'</td>';
1744 print
'<td class="right">'.$langs->trans(
"ChangedBy").
'</td>';
1745 if ($user->hasRight(
'produit',
'supprimer')) {
1746 print
'<td class="right"> </td>';
1750 $notfirstlineforlevel = array();
1754 $objp = $db->fetch_object($result);
1756 print
'<tr class="oddeven">';
1758 print
"<td>".dol_print_date($db->jdate($objp->dp),
"dayhour",
'tzuserrel').
"</td>";
1762 print
'<td class="center">'.$objp->price_level.
"</td>";
1766 $type = ($objp->price_by_qty == 1) ?
'PriceByQuantity' :
'Standard';
1767 print
'<td class="center">'.$langs->trans($type).
"</td>";
1770 print
'<td class="center">';
1771 if (empty($objp->price_by_qty)) {
1772 print $langs->trans($objp->price_base_type);
1777 print
'<td class="right">';
1779 if (empty($objp->price_by_qty)) {
1780 $positiverates =
'';
1782 $positiverates .= ($positiverates ?
'/' :
'').
price2num($objp->tva_tx);
1785 $positiverates .= ($positiverates ?
'/' :
'').
price2num($objp->localtax1_tx);
1788 $positiverates .= ($positiverates ?
'/' :
'').
price2num($objp->localtax2_tx);
1790 if (empty($positiverates)) {
1791 $positiverates =
'0';
1793 echo
vatrate($positiverates.($objp->default_vat_code ?
' ('.$objp->default_vat_code.
')' :
''),
'%', !empty($objp->tva_npr) ? $objp->tva_npr : 0);
1806 if ($objp->price_base_type ==
'HT') {
1809 $pu = $objp->price_ttc;
1813 $localtaxarray =
getLocalTaxesFromRate($objp->tva_tx.($object->default_vat_code ?
' ('.$object->default_vat_code.
')' :
''), 0, $mysoc, $mysoc);
1815 $resultarray =
calcul_price_total(1, $pu, 0, $objp->tva_tx, 1, 1, 0, $objp->price_base_type, $objp->recuperableonly, $object->type, $mysoc, $localtaxarray);
1817 $total_ht = $resultarray[0];
1818 $total_vat = $resultarray[1];
1819 $total_localtax1 = $resultarray[9];
1820 $total_localtax2 = $resultarray[10];
1821 $total_ttc = $resultarray[2];
1824 if (!empty($objp->fk_price_expression) && !empty($conf->dynamicprices->enabled)) {
1826 $res = $price_expression->fetch($objp->fk_price_expression);
1827 $title = $price_expression->title;
1828 print
'<td class="right"></td>';
1829 print
'<td class="right"></td>';
1830 if ($mysoc->localtax1_assuj ==
"1" || $mysoc->localtax2_assuj ==
"1") {
1831 print
'<td class="right"></td>';
1833 print
'<td class="right">'.$title.
"</td>";
1836 print
'<td class="right">';
1837 if (empty($objp->price_by_qty)) {
1838 print
'<span class="amount">'.price($objp->price).
'</span>';
1842 print
'<td class="right">';
1843 if (empty($objp->price_by_qty)) {
1844 $price_ttc = $objp->price_ttc;
1845 print
'<span class="amount">'.price($price_ttc).
'<span>';
1848 if ($mysoc->localtax1_assuj ==
"1" || $mysoc->localtax2_assuj ==
"1") {
1849 print
'<td class="right">';
1850 print $resultarray[2];
1853 if (!empty($conf->dynamicprices->enabled)) {
1854 print
'<td class="right"></td>';
1859 print
'<td class="right">';
1860 if (empty($objp->price_by_qty)) {
1861 print
price($objp->price_min);
1866 print
'<td class="right">';
1867 if (empty($objp->price_by_qty)) {
1868 $price_min_ttc = $objp->price_min_ttc;
1869 print
price($price_min_ttc);
1874 print
'<td class="right">';
1875 if ($objp->user_id > 0) {
1876 $userstatic =
new User($db);
1877 $userstatic->fetch($objp->user_id);
1878 print $userstatic->getNomUrl(1,
'', 0, 0, 24, 0,
'login');
1883 if ($user->hasRight(
'produit',
'supprimer')) {
1886 if (empty($notfirstlineforlevel[$objp->price_level])) {
1887 $notfirstlineforlevel[$objp->price_level] = 1;
1895 print
'<td class="right">';
1896 if ($candelete || ($db->jdate($objp->dp) >=
dol_now())) {
1897 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=delete&token='.newToken().
'&id='.$object->id.
'&lineid='.$objp->rowid.
'">';
1927 $limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
1928 $sortfield =
GETPOST(
'sortfield',
'aZ09comma');
1929 $sortorder =
GETPOST(
'sortorder',
'aZ09comma');
1931 if (empty($page) || $page == -1) {
1934 $offset = $limit * $page;
1935 $pageprev = $page - 1;
1936 $pagenext = $page + 1;
1941 $sortfield =
"soc.nom";
1945 $filter = array(
't.fk_product' => $object->id);
1947 if (!empty($search_soc)) {
1948 $filter[
'soc.nom'] = $search_soc;
1951 if ($action ==
'add_customer_price') {
1953 $maxpricesupplier = $object->min_recommended_price();
1955 print
'<!-- add_customer_price -->';
1958 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'" method="POST">';
1959 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1960 print
'<input type="hidden" name="action" value="add_customer_price_confirm">';
1961 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
1963 print
'<div class="tabBar tabBarWithBottom">';
1965 print
'<table class="border centpercent">';
1967 print
'<td class="fieldrequired">'.$langs->trans(
'ThirdParty').
'</td>';
1969 $filter =
'(s.client:IN:1,2,3)';
1970 print
img_picto(
'',
'company').$form->select_company(
'',
'socid', $filter,
'SelectThirdParty', 0, 0, array(), 0,
'minwidth300');
1975 print
'<tr><td>' . $langs->trans(
'RefCustomer') .
'</td>';
1976 print
'<td><input name="ref_customer" size="12"></td></tr>';
1979 print
'<tr><td class="fieldrequired">'.$langs->trans(
"DefaultTaxRate").
'</td><td>';
1980 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);
1984 print
'<tr><td class="fieldrequired">';
1985 print $langs->trans(
'PriceBase');
1988 print $form->selectPriceBaseType($object->price_base_type,
"price_base_type");
1993 print
'<tr><td class="fieldrequired">';
1994 $text = $langs->trans(
'SellingPrice');
1995 print $form->textwithpicto($text, $langs->trans(
"PrecisionUnitIsLimitedToXDecimals", $conf->global->MAIN_MAX_DECIMALS_UNIT), 1, 1);
1997 if ($object->price_base_type ==
'TTC') {
1998 print
'<input name="price" size="10" value="'.price($object->price_ttc).
'">';
2000 print
'<input name="price" size="10" value="'.price($object->price).
'">';
2006 $text = $langs->trans(
'MinPrice');
2007 print $form->textwithpicto($text, $langs->trans(
"PrecisionUnitIsLimitedToXDecimals", $conf->global->MAIN_MAX_DECIMALS_UNIT), 1, 1);
2008 if ($object->price_base_type ==
'TTC') {
2009 print
'<td><input name="price_min" size="10" value="'.price($object->price_min_ttc).
'">';
2011 print
'<td><input name="price_min" size="10" value="'.price($object->price_min).
'">';
2014 print
'<td class="left">'.$langs->trans(
"MinimumRecommendedPrice",
price($maxpricesupplier, 0,
'', 1, -1, -1,
'auto')).
' '.
img_warning().
'</td>';
2023 print
'<div class="center">';
2026 print
'<div class="marginbottomonly">';
2027 print
'<input type="checkbox" name="updatechildprice" id="updatechildprice" value="1"> ';
2028 print
'<label for="updatechildprice">'.$langs->trans(
'ForceUpdateChildPriceSoc').
'</label>';
2031 print $form->buttonsSaveCancel();
2034 } elseif ($action ==
'edit_customer_price') {
2036 $maxpricesupplier = $object->min_recommended_price();
2038 print
'<!-- edit_customer_price -->';
2041 $result = $prodcustprice->fetch(
GETPOST(
'lineid',
'int'));
2046 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'" method="POST">';
2047 print
'<input type="hidden" name="token" value="'.newToken().
'">';
2048 print
'<input type="hidden" name="action" value="update_customer_price_confirm">';
2049 print
'<input type="hidden" name="lineid" value="'.$prodcustprice->id.
'">';
2051 print
'<table class="liste centpercent">';
2053 print
'<td class="titlefield fieldrequired">'.$langs->trans(
'ThirdParty').
'</td>';
2054 $staticsoc =
new Societe($db);
2055 $staticsoc->fetch($prodcustprice->fk_soc);
2056 print
"<td>".$staticsoc->getNomUrl(1).
"</td>";
2060 print
'<tr><td>' . $langs->trans(
'RefCustomer') .
'</td>';
2061 print
'<td><input name="ref_customer" size="12" value="' .
dol_escape_htmltag($prodcustprice->ref_customer) .
'"></td></tr>';
2064 print
'<tr><td class="fieldrequired">'.$langs->trans(
"DefaultTaxRate").
'</td><td>';
2065 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);
2069 print
'<tr><td class="fieldrequired">';
2070 print $langs->trans(
'PriceBase');
2073 print $form->selectPriceBaseType($prodcustprice->price_base_type,
"price_base_type");
2078 print
'<tr><td class="fieldrequired">';
2079 $text = $langs->trans(
'SellingPrice');
2080 print $form->textwithpicto($text, $langs->trans(
"PrecisionUnitIsLimitedToXDecimals", $conf->global->MAIN_MAX_DECIMALS_UNIT), 1, 1);
2082 if ($prodcustprice->price_base_type ==
'TTC') {
2083 print
'<input name="price" size="10" value="'.price($prodcustprice->price_ttc).
'">';
2085 print
'<input name="price" size="10" value="'.price($prodcustprice->price).
'">';
2091 $text = $langs->trans(
'MinPrice');
2092 print $form->textwithpicto($text, $langs->trans(
"PrecisionUnitIsLimitedToXDecimals", $conf->global->MAIN_MAX_DECIMALS_UNIT), 1, 1);
2094 if ($prodcustprice->price_base_type ==
'TTC') {
2095 print
'<input name="price_min" size="10" value="'.price($prodcustprice->price_min_ttc).
'">';
2097 print
'<input name="price_min" size="10" value="'.price($prodcustprice->price_min).
'">';
2101 print
'<td class="left">'.$langs->trans(
"MinimumRecommendedPrice",
price($maxpricesupplier, 0,
'', 1, -1, -1,
'auto')).
' '.
img_warning().
'</td>';
2108 print
'<div class="center">';
2109 print
'<div class="marginbottomonly">';
2110 print
'<input type="checkbox" name="updatechildprice" id="updatechildprice" value="1"> ';
2111 print
'<label for="updatechildprice">'.$langs->trans(
'ForceUpdateChildPriceSoc').
'</label>';
2114 print $form->buttonsSaveCancel();
2116 print
'<br></form>';
2117 } elseif ($action ==
'showlog_customer_price') {
2119 print
'<!-- list of all log of prices per customer -->'.
"\n";
2121 $filter = array(
't.fk_product' => $object->id,
't.fk_soc' =>
GETPOST(
'socid',
'int'));
2124 $nbtotalofrecords =
'';
2126 $nbtotalofrecords = $prodcustprice->fetchAllLog($sortorder, $sortfield, $conf->liste_limit, $offset, $filter);
2129 $result = $prodcustprice->fetchAllLog($sortorder, $sortfield, $conf->liste_limit, $offset, $filter);
2134 $option =
'&socid='.GETPOST(
'socid',
'int').
'&id='.$object->id;
2136 $staticsoc =
new Societe($db);
2137 $staticsoc->fetch(
GETPOST(
'socid',
'int'));
2139 $title = $langs->trans(
'PriceByCustomerLog');
2140 $title .=
' - '.$staticsoc->getNomUrl(1);
2142 $backbutton =
'<a class="justalink" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'">'.$langs->trans(
"Back").
'</a>';
2144 print_barre_liste($title, $page, $_SERVER[
'PHP_SELF'], $option, $sortfield, $sortorder, $backbutton, count($prodcustprice->lines), $nbtotalofrecords,
'title_accountancy.png');
2146 if (count($prodcustprice->lines) > 0) {
2147 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'" method="POST">';
2148 print
'<input type="hidden" name="token" value="'.newToken().
'">';
2149 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
2151 print
'<div class="div-table-responsive-no-min">';
2152 print
'<table class="liste centpercent">';
2154 print
'<tr class="liste_titre">';
2155 print
'<td>'.$langs->trans(
"ThirdParty").
'</td>';
2156 print
'<td>'.$langs->trans(
'RefCustomer').
'</td>';
2157 print
'<td>'.$langs->trans(
"AppliedPricesFrom").
'</td>';
2158 print
'<td class="center">'.$langs->trans(
"PriceBase").
'</td>';
2159 print
'<td class="right">'.$langs->trans(
"DefaultTaxRate").
'</td>';
2160 print
'<td class="right">'.$langs->trans(
"HT").
'</td>';
2161 print
'<td class="right">'.$langs->trans(
"TTC").
'</td>';
2162 if ($mysoc->localtax1_assuj ==
"1" || $mysoc->localtax2_assuj ==
"1") {
2163 print
'<td class="right">'.$langs->trans(
"INCT").
'</td>';
2165 print
'<td class="right">'.$langs->trans(
"MinPrice").
' '.$langs->trans(
"HT").
'</td>';
2166 print
'<td class="right">'.$langs->trans(
"MinPrice").
' '.$langs->trans(
"TTC").
'</td>';
2167 print
'<td class="right">'.$langs->trans(
"ChangedBy").
'</td>';
2168 print
'<td> </td>';
2171 foreach ($prodcustprice->lines as $line) {
2173 $staticsoc =
new Societe($db);
2174 $staticsoc->fetch($line->fk_soc);
2176 $tva_tx = $line->default_vat_code ? $line->tva_tx.
' ('.$line->default_vat_code.
')' : $line->tva_tx;
2179 if ($line->price_base_type ==
'HT') {
2182 $pu = $line->price_ttc;
2186 $localtaxarray =
getLocalTaxesFromRate($line->tva_tx.($line->default_vat_code ?
' ('.$line->default_vat_code.
')' :
''), 0, $staticsoc, $mysoc);
2188 $resultarray =
calcul_price_total(1, $pu, 0, $line->tva_tx, 1, 1, 0, $line->price_base_type, $line->recuperableonly, $object->type, $mysoc, $localtaxarray);
2190 $total_ht = $resultarray[0];
2191 $total_vat = $resultarray[1];
2192 $total_localtax1 = $resultarray[9];
2193 $total_localtax2 = $resultarray[10];
2194 $total_ttc = $resultarray[2];
2196 print
'<tr class="oddeven">';
2198 print
'<td class="tdoverflowmax125">'.$staticsoc->getNomUrl(1).
"</td>";
2199 print
'<td>'.$line->ref_customer.
'</td>';
2200 print
"<td>".dol_print_date($line->datec,
"dayhour",
'tzuserrel').
"</td>";
2201 print
'<td class="center">'.$langs->trans($line->price_base_type).
"</td>";
2202 print
'<td class="right">';
2204 $positiverates =
'';
2206 $positiverates .= ($positiverates ?
'/' :
'').
price2num($line->tva_tx);
2209 $positiverates .= ($positiverates ?
'/' :
'').
price2num($line->localtax1_tx);
2212 $positiverates .= ($positiverates ?
'/' :
'').
price2num($line->localtax2_tx);
2214 if (empty($positiverates)) {
2215 $positiverates =
'0';
2218 echo
vatrate($positiverates.($line->default_vat_code ?
' ('.$line->default_vat_code.
')' :
''),
'%', ($line->tva_npr ? $line->tva_npr : $line->recuperableonly));
2222 print
'<td class="right"><span class="amount">'.price($line->price).
"</span></td>";
2224 print
'<td class="right"><span class="amount">'.price($line->price_ttc).
"</span></td>";
2225 if ($mysoc->localtax1_assuj ==
"1" || $mysoc->localtax2_assuj ==
"1") {
2226 print
'<td class="right">'.price($resultarray[2]).
'</td>';
2229 print
'<td class="right">'.price($line->price_min).
'</td>';
2230 print
'<td class="right">'.price($line->price_min_ttc).
'</td>';
2233 $userstatic =
new User($db);
2234 $userstatic->fetch($line->fk_user);
2235 print
'<td class="right">';
2236 print $userstatic->getNomUrl(1,
'', 0, 0, 24, 0,
'login');
2244 print $langs->trans(
'None');
2246 } elseif ($action !=
'showlog_default_price' && $action !=
'edit_price') {
2248 print
'<!-- list of all prices per customer -->'.
"\n";
2251 $nbtotalofrecords =
'';
2253 $nbtotalofrecords = $prodcustprice->fetchAll($sortorder, $sortfield, 0, 0, $filter);
2256 $result = $prodcustprice->fetchAll($sortorder, $sortfield, $conf->liste_limit, $offset, $filter);
2261 $option =
'&search_soc='.$search_soc.
'&id='.$object->id;
2263 print_barre_liste($langs->trans(
'PriceByCustomer'), $page, $_SERVER [
'PHP_SELF'], $option, $sortfield, $sortorder,
'', count($prodcustprice->lines), $nbtotalofrecords,
'title_accountancy.png');
2265 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'" method="POST">';
2266 print
'<input type="hidden" name="token" value="'.newToken().
'">';
2267 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
2269 print
'<!-- List of prices per customer -->'.
"\n";
2270 print
'<div class="div-table-responsive-no-min">'.
"\n";
2271 print
'<table class="liste centpercent">'.
"\n";
2273 if (count($prodcustprice->lines) > 0 || $search_soc) {
2275 if ($mysoc->localtax1_assuj ==
"1" || $mysoc->localtax2_assuj ==
"1") {
2279 print
'<tr class="liste_titre">';
2280 print
'<td class="liste_titre"><input type="text" class="flat maxwidth125" name="search_soc" value="'.$search_soc.
'"></td>';
2281 print
'<td class="liste_titre" colspan="'.$colspan.
'"> </td>';
2283 print
'<td class="liste_titre maxwidthsearch">';
2284 $searchpicto = $form->showFilterAndCheckAddButtons(0);
2290 print
'<tr class="liste_titre">';
2291 print
'<td>'.$langs->trans(
"ThirdParty").
'</td>';
2292 print
'<td>'.$langs->trans(
'RefCustomer').
'</td>';
2293 print
'<td>'.$langs->trans(
"AppliedPricesFrom").
'</td>';
2294 print
'<td class="center">'.$langs->trans(
"PriceBase").
'</td>';
2295 print
'<td class="right">'.$langs->trans(
"DefaultTaxRate").
'</td>';
2296 print
'<td class="right">'.$langs->trans(
"HT").
'</td>';
2297 print
'<td class="right">'.$langs->trans(
"TTC").
'</td>';
2298 if ($mysoc->localtax1_assuj ==
"1" || $mysoc->localtax2_assuj ==
"1") {
2299 print
'<td class="right">'.$langs->trans(
"INCT").
'</td>';
2301 print
'<td class="right">'.$langs->trans(
"MinPrice").
' '.$langs->trans(
"HT").
'</td>';
2302 print
'<td class="right">'.$langs->trans(
"MinPrice").
' '.$langs->trans(
"TTC").
'</td>';
2303 print
'<td class="right">'.$langs->trans(
"ChangedBy").
'</td>';
2308 if ($object->price_base_type ==
'HT') {
2309 $pu = $object->price;
2311 $pu = $object->price_ttc;
2315 $localtaxarray =
getLocalTaxesFromRate($object->tva_tx.($object->default_vat_code ?
' ('.$object->default_vat_code.
')' :
''), 0, $mysoc, $mysoc);
2317 $resultarray =
calcul_price_total(1, $pu, 0, $object->tva_tx, 1, 1, 0, $object->price_base_type, 0, $object->type, $mysoc, $localtaxarray);
2319 $total_ht = $resultarray[0];
2320 $total_vat = $resultarray[1];
2321 $total_localtax1 = $resultarray[9];
2322 $total_localtax2 = $resultarray[10];
2323 $total_ttc = $resultarray[2];
2325 print
'<tr class="oddeven">';
2326 print
'<td colspan="3">' . $langs->trans(
'Default') .
'</td>';
2328 print
'<td class="center">'.$langs->trans($object->price_base_type).
"</td>";
2331 print
'<td class="right">';
2333 $positiverates =
'';
2335 $positiverates .= ($positiverates ?
'/' :
'').
price2num($object->tva_tx);
2337 if (
price2num($object->localtax1_type)) {
2338 $positiverates .= ($positiverates ?
'/' :
'').
price2num($object->localtax1_tx);
2340 if (
price2num($object->localtax2_type)) {
2341 $positiverates .= ($positiverates ?
'/' :
'').
price2num($object->localtax2_tx);
2343 if (empty($positiverates)) {
2344 $positiverates =
'0';
2346 echo
vatrate($positiverates.($object->default_vat_code ?
' ('.$object->default_vat_code.
')' :
''),
'%', $object->tva_npr);
2352 print
'<td class="right"><span class="amount">'.price($object->price).
"</span></td>";
2354 print
'<td class="right"><span class="amount">'.price($object->price_ttc).
"</span></td>";
2355 if ($mysoc->localtax1_assuj ==
"1" || $mysoc->localtax2_assuj ==
"1") {
2357 print
'<td class="right"><span class="amount">'.price($resultarray[2]).
'</span></td>';
2360 print
'<td class="right">'.price($object->price_min).
'</td>';
2361 print
'<td class="right">'.price($object->price_min_ttc).
'</td>';
2362 print
'<td class="right">';
2364 if ($user->hasRight(
'produit',
'supprimer') || $user->hasRight(
'service',
'supprimer')) {
2365 print
'<td class="nowraponall">';
2366 print
'<a class="marginleftonly marginrightonly" href="'.$_SERVER[
"PHP_SELF"].
'?action=showlog_default_price&token='.newToken().
'&id='.$object->id.
'">';
2367 print
img_info($langs->trans(
'PriceByCustomerLog'));
2370 print
'<a class="marginleftonly marginrightonly editfielda" href="'.$_SERVER[
"PHP_SELF"].
'?action=edit_price&token='.newToken().
'&id='.$object->id.
'">';
2371 print
img_edit(
'default', 0,
'style="vertical-align: middle;"');
2377 if (count($prodcustprice->lines) > 0) {
2378 foreach ($prodcustprice->lines as $line) {
2380 $staticsoc =
new Societe($db);
2381 $staticsoc->fetch($line->fk_soc);
2383 $tva_tx = $line->default_vat_code ? $line->tva_tx.
' ('.$line->default_vat_code.
')' : $line->tva_tx;
2386 if ($line->price_base_type ==
'HT') {
2389 $pu = $line->price_ttc;
2393 $localtaxarray =
getLocalTaxesFromRate($line->tva_tx.($line->default_vat_code ?
' ('.$line->default_vat_code.
')' :
''), 0, $staticsoc, $mysoc);
2395 $resultarray =
calcul_price_total(1, $pu, 0, $line->tva_tx, 1, 1, 0, $line->price_base_type, $line->recuperableonly, $object->type, $mysoc, $localtaxarray);
2397 $total_ht = $resultarray[0];
2398 $total_vat = $resultarray[1];
2399 $total_localtax1 = $resultarray[9];
2400 $total_localtax2 = $resultarray[10];
2401 $total_ttc = $resultarray[2];
2403 print
'<tr class="oddeven">';
2405 print
'<td class="tdoverflowmax125">'.$staticsoc->getNomUrl(1).
"</td>";
2406 print
'<td>'.dol_escape_htmltag($line->ref_customer).
'</td>';
2407 print
"<td>".dol_print_date($line->datec,
"dayhour",
'tzuserrel').
"</td>";
2408 print
'<td class="center">'.$langs->trans($line->price_base_type).
"</td>";
2410 print
'<td class="right">';
2412 $positiverates =
'';
2414 $positiverates .= ($positiverates ?
'/' :
'').
price2num($line->tva_tx);
2417 $positiverates .= ($positiverates ?
'/' :
'').
price2num($line->localtax1_tx);
2420 $positiverates .= ($positiverates ?
'/' :
'').
price2num($line->localtax2_tx);
2422 if (empty($positiverates)) {
2423 $positiverates =
'0';
2426 echo
vatrate($positiverates.($line->default_vat_code ?
' ('.$line->default_vat_code.
')' :
''),
'%', ($line->tva_npr ? $line->tva_npr : $line->recuperableonly));
2430 print
'<td class="right"><span class="amount">'.price($line->price).
"</span></td>";
2432 print
'<td class="right"><span class="amount">'.price($line->price_ttc).
"</span></td>";
2433 if ($mysoc->localtax1_assuj ==
"1" || $mysoc->localtax2_assuj ==
"1") {
2435 print
'<td class="right"><span class="amount">'.price($resultarray[2]).
'</span></td>';
2438 print
'<td class="right">'.price($line->price_min).
'</td>';
2439 print
'<td class="right">'.price($line->price_min_ttc).
'</td>';
2442 $userstatic =
new User($db);
2443 $userstatic->fetch($line->fk_user);
2445 print
'<td class="right">';
2446 print $userstatic->getNomUrl(-1,
'', 0, 0, 24, 0,
'login');
2451 if ($user->hasRight(
'produit',
'supprimer') || $user->hasRight(
'service',
'supprimer')) {
2452 print
'<td class="right nowraponall">';
2453 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=showlog_customer_price&token='.newToken().
'&id='.$object->id.
'&socid='.$line->fk_soc.
'">';
2454 print
img_info($langs->trans(
'PriceByCustomerLog'));
2457 print
'<a class="marginleftonly editfielda" href="'.$_SERVER[
"PHP_SELF"].
'?action=edit_customer_price&token='.newToken().
'&id='.$object->id.
'&lineid='.$line->id.
'">';
2458 print
img_edit(
'default', 0,
'style="vertical-align: middle;"');
2461 print
'<a class="marginleftonly" href="'.$_SERVER[
"PHP_SELF"].
'?action=delete_customer_price&token='.newToken().
'&id='.$object->id.
'&lineid='.$line->id.
'">';
2462 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.
File of class to manage predefined price products or services by customer.
Class to manage products or services.
const TYPE_PRODUCT
Regular product.
const TYPE_SERVICE
Service.
Class to manage third parties objects (customers, suppliers, prospects...)
Class to manage Dolibarr users.
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 a 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.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
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.