34require
'../main.inc.php';
35require_once DOL_DOCUMENT_ROOT.
'/core/lib/product.lib.php';
36require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
37require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
38require_once DOL_DOCUMENT_ROOT.
'/societe/class/societe.class.php';
41 require_once DOL_DOCUMENT_ROOT.
'/product/class/productcustomerprice.class.php';
48$langs->loadLangs(array(
"products",
"companies",
"bills"));
52$action =
GETPOST(
'action',
'aZ09');
53$search_prod =
GETPOST(
'search_prod',
'alpha');
54$cancel =
GETPOST(
'cancel',
'alpha');
55$search_label =
GETPOST(
'search_label',
'alpha');
56$search_price =
GETPOST(
'search_price');
57$search_price_ttc =
GETPOST(
'search_price_ttc');
62 $socid = $user->socid;
66$hookmanager->initHooks(array(
'thirdpartycustomerprice',
'globalcard'));
80$parameters = array(
'id' => $socid);
81$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
87 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
88 $search_prod = $search_label = $search_price = $search_price_ttc =
'';
91 if ($action ==
'add_customer_price_confirm' && !$cancel && ($user->hasRight(
'produit',
'creer') || $user->hasRight(
'service',
'creer'))) {
94 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->trans(
"Product")),
null,
'errors');
95 $action =
'add_customer_price';
99 $update_child_soc =
GETPOST(
'updatechildprice');
102 $prodcustprice->fk_soc = $socid;
103 $prodcustprice->ref_customer =
GETPOST(
'ref_customer',
'alpha');
104 $prodcustprice->fk_product =
GETPOSTINT(
'prodid');
107 $prodcustprice->price_base_type =
GETPOST(
"price_base_type",
'alpha');
109 $tva_tx_txt =
GETPOST(
'tva_tx',
'alpha');
113 $tva_tx = preg_replace(
'/[^0-9\.].*$/',
'', $tva_tx_txt);
114 $npr = preg_match(
'/\*/', $tva_tx_txt) ? 1 : 0;
117 $localtax1_type =
'0';
118 $localtax2_type =
'0';
120 if (preg_match(
'/\((.*)\)/', $tva_tx_txt, $reg)) {
122 $vatratecode = $reg[1];
124 $sql =
"SELECT t.rowid, t.code, t.recuperableonly, t.localtax1, t.localtax2, t.localtax1_type, t.localtax2_type";
125 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_tva as t, ".MAIN_DB_PREFIX.
"c_country as c";
126 $sql .=
" WHERE t.fk_pays = c.rowid AND c.code = '".$db->escape($mysoc->country_code).
"'";
127 $sql .=
" AND t.taux = ".((float) $tva_tx).
" AND t.active = 1";
128 $sql .=
" AND t.code = '".$db->escape($vatratecode).
"'";
129 $sql .=
" AND t.entity IN (".getEntity(
'c_tva').
")";
130 $resql = $db->query($sql);
132 $obj = $db->fetch_object($resql);
133 $npr = $obj->recuperableonly;
134 $localtax1 = $obj->localtax1;
135 $localtax2 = $obj->localtax2;
136 $localtax1_type = $obj->localtax1_type;
137 $localtax2_type = $obj->localtax2_type;
141 $prodcustprice->default_vat_code = $vatratecode;
142 $prodcustprice->tva_tx = $tva_tx;
143 $prodcustprice->recuperableonly = $npr;
144 $prodcustprice->localtax1_tx = $localtax1;
145 $prodcustprice->localtax2_tx = $localtax2;
146 $prodcustprice->localtax1_type = $localtax1_type;
147 $prodcustprice->localtax2_type = $localtax2_type;
149 $result = $prodcustprice->create($user, 0, $update_child_soc);
151 $extrafields->fetch_name_optionals_label(
"product_customer_price");
152 $extralabels = !empty($extrafields->attributes[
"product_customer_price"][
'label']) ? $extrafields->attributes[
"product_customer_price"][
'label'] :
'';
153 $extrafield_values = $extrafields->getOptionalsFromPost(
"product_customer_price");
154 if (!empty($extralabels) && is_array($extralabels)) {
156 $res = $productcustomerprice->fetch($prodcustprice->id);
158 foreach ($extrafield_values as $key => $value) {
159 $productcustomerprice->array_options[$key] = $value;
161 $result2 = $productcustomerprice->insertExtraFields();
163 $prodcustprice->error = $productcustomerprice->error;
164 $prodcustprice->errors = $productcustomerprice->errors;
181 if ($action ==
'delete_customer_price' && ($user->hasRight(
'produit',
'creer') || $user->hasRight(
'service',
'creer'))) {
184 $result = $prodcustprice->delete($user);
194 if ($action ==
'update_customer_price_confirm' && !$cancel && ($user->hasRight(
'produit',
'creer') || $user->hasRight(
'service',
'creer'))) {
197 $update_child_soc =
GETPOST(
'updatechildprice');
200 $prodcustprice->ref_customer =
GETPOST(
'ref_customer',
'alpha');
203 $prodcustprice->price_base_type =
GETPOST(
"price_base_type",
'alpha');
204 $prodcustprice->tva_tx = str_replace(
'*',
'',
GETPOST(
"tva_tx"));
205 $prodcustprice->recuperableonly = (preg_match(
'/\*/',
GETPOST(
"tva_tx")) ? 1 : 0);
207 $result = $prodcustprice->update($user, 0, $update_child_soc);
209 $extrafields->fetch_name_optionals_label(
"product_customer_price");
210 $extralabels = !empty($extrafields->attributes[
"product_customer_price"][
'label']) ? $extrafields->attributes[
"product_customer_price"][
'label'] :
'';
211 $extrafield_values = $extrafields->getOptionalsFromPost(
"product_customer_price");
212 if (!empty($extralabels) && is_array($extralabels)) {
214 $res = $productcustomerprice->fetch($prodcustprice->id);
216 foreach ($extrafield_values as $key => $value) {
217 $productcustomerprice->array_options[$key] = $value;
219 $result2 = $productcustomerprice->insertExtraFields();
221 $prodcustprice->error = $productcustomerprice->error;
222 $prodcustprice->errors = $productcustomerprice->errors;
243$form =
new Form($db);
247$result =
$object->fetch($socid);
248llxHeader(
"", $langs->trans(
"ThirdParty").
'-'.$langs->trans(
'PriceByCustomer'));
254$linkback =
'<a href="'.DOL_URL_ROOT.
'/societe/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
256dol_banner_tab($object,
'socid', $linkback, ($user->socid ? 0 : 1),
'rowid',
'nom');
258print
'<div class="fichecenter">';
260print
'<div class="underbanner clearboth"></div>';
261print
'<table class="border centpercent tableforfield">';
264print
'<tr><td class="titlefield">'.$langs->trans(
'NatureOfThirdParty').
'</td><td>';
269 print
'<tr><td class="titlefield">'.$langs->trans(
'Prefix').
'</td><td colspan="3">'.
$object->prefix_comm.
'</td></tr>';
273 print
'<tr><td class="titlefield">';
274 print $langs->trans(
'CustomerCode').
'</td><td colspan="3">';
276 $tmpcheck =
$object->check_codeclient();
277 if ($tmpcheck != 0 && $tmpcheck != -5) {
278 print
' <span class="error">('.$langs->trans(
"WrongCustomerCode").
')</span>';
284 print
'<tr><td class="titlefield">';
285 print $langs->trans(
'SupplierCode').
'</td><td colspan="3">';
286 print
$object->code_fournisseur;
287 $tmpcheck =
$object->check_codefournisseur();
288 if ($tmpcheck != 0 && $tmpcheck != -5) {
289 print
' <span class="error">('.$langs->trans(
"WrongSupplierCode").
')</span>';
305 $sortfield =
GETPOST(
'sortfield',
'aZ09comma');
306 $sortorder =
GETPOST(
'sortorder',
'aZ09comma');
309 if (empty($page) || $page == -1) {
312 $offset = $limit * $page;
313 $pageprev = $page - 1;
314 $pagenext = $page + 1;
319 $sortfield =
"soc.nom";
327 if (!empty($search_prod)) {
328 $filter [
'prod.ref'] = $search_prod;
331 if (!empty($search_label)) {
332 $filter [
'prod.label'] = $search_label;
335 if (!empty($search_price)) {
336 $filter [
't.price'] = $search_price;
339 if (!empty($search_price_ttc)) {
340 $filter [
't.price_ttc'] = $search_price_ttc;
343 if ($action ==
'add_customer_price') {
347 print
'<!-- Price by customer -->'.
"\n";
351 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'?socid='.
$object->id.
'" method="POST">';
352 print
'<input type="hidden" name="token" value="'.newToken().
'">';
353 print
'<input type="hidden" name="action" value="add_customer_price_confirm">';
354 print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
355 print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
356 print
'<input type="hidden" name="socid" value="'.$object->id.
'">';
357 print
'<table class="border centpercent">';
359 print
'<td>'.$langs->trans(
'Product').
'</td>';
361 $form->select_produits(
'',
'prodid',
'', 0);
366 print
'<tr><td>'.$langs->trans(
'RefCustomer').
'</td>';
367 print
'<td><input name="ref_customer" size="12"></td></tr>';
370 print
'<tr><td>'.$langs->trans(
"VATRate").
'</td><td>';
371 print $form->load_tva(
"tva_tx",
GETPOST(
"tva_tx",
"alpha"), $mysoc,
'',
$object->id, 0,
'',
false, 1);
375 print
'<tr><td width="15%">';
376 print $langs->trans(
'PriceBase');
379 print $form->selectPriceBaseType(
GETPOST(
"price_base_type",
"aZ09"),
"price_base_type");
384 print
'<tr><td width="20%">';
385 $text = $langs->trans(
'SellingPrice');
386 print $form->textwithpicto($text, $langs->trans(
"PrecisionUnitIsLimitedToXDecimals",
getDolGlobalString(
'MAIN_MAX_DECIMALS_UNIT')), 1, 1);
388 print
'<input name="price" size="10" value="'.GETPOSTINT(
'price').
'">';
393 $text = $langs->trans(
'MinPrice');
394 print $form->textwithpicto($text, $langs->trans(
"PrecisionUnitIsLimitedToXDecimals",
getDolGlobalString(
'MAIN_MAX_DECIMALS_UNIT')), 1, 1);
395 print
'<td><input name="price_min" size="10" value="'.GETPOSTINT(
'price_min').
'">';
399 print
'<tr><td width="15%">';
400 print $langs->trans(
'ForceUpdateChildPriceSoc');
403 print
'<input type="checkbox" name="updatechildprice" value="1"/>';
408 $extrafields->fetch_name_optionals_label(
"product_customer_price");
409 $extralabels = !empty($extrafields->attributes[
"product_customer_price"][
'label']) ? $extrafields->attributes[
"product_customer_price"][
'label'] :
'';
410 $extrafield_values = $extrafields->getOptionalsFromPost(
"product_customer_price");
411 if (!empty($extralabels)) {
412 if (empty($prodcustprice->id)) {
413 foreach ($extralabels as $key => $value) {
414 if (!empty($extrafields->attributes[
"product_customer_price"][
'list'][$key]) && ($extrafields->attributes[
"product_customer_price"][
'list'][$key] == 1 || $extrafields->attributes[
"product_customer_price"][
'list'][$key] == 3 || ($action ==
"add_customer_price" && $extrafields->attributes[
"product_customer_price"][
'list'][$key] == 4))) {
415 if (!empty($extrafields->attributes[
"product_customer_price"][
'langfile'][$key])) {
416 $langs->load($extrafields->attributes[
"product_customer_price"][
'langfile'][$key]);
419 print
'<tr><td'.($extrafields->attributes[
"product_customer_price"][
'required'][$key] ?
' class="fieldrequired"' :
'').
'>';
420 if (!empty($extrafields->attributes[
"product_customer_price"][
'help'][$key])) {
421 print $form->textwithpicto($langs->trans($value), $langs->trans($extrafields->attributes[
"product_customer_price"][
'help'][$key]));
423 print $langs->trans($value);
425 print
'</td><td>'.$extrafields->showInputField($key, GETPOSTISSET(
'options_'.$key) ? $extrafield_values[
'options_'.$key] :
'',
'',
'',
'',
'', 0,
'product_customer_price').
'</td></tr>';
433 print $form->buttonsSaveCancel();
436 } elseif ($action ==
'edit_customer_price') {
441 $result = $prodcustprice->fetch(
GETPOSTINT(
'lineid'));
446 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'?socid='.
$object->id.
'" method="POST">';
447 print
'<input type="hidden" name="token" value="'.newToken().
'">';
448 print
'<input type="hidden" name="action" value="update_customer_price_confirm">';
449 print
'<input type="hidden" name="lineid" value="'.$prodcustprice->id.
'">';
450 print
'<table class="border centpercent">';
452 print
'<td>'.$langs->trans(
'Product').
'</td>';
453 $staticprod =
new Product($db);
454 $staticprod->fetch($prodcustprice->fk_product);
455 print
"<td>".$staticprod->getNomUrl(1).
"</td>";
459 print
'<tr><td>'.$langs->trans(
'RefCustomer').
'</td>';
460 print
'<td><input name="ref_customer" size="12" value="'.dol_escape_htmltag($prodcustprice->ref_customer).
'"></td></tr>';
463 print
'<tr><td>'.$langs->trans(
"VATRate").
'</td><td>';
464 print $form->load_tva(
"tva_tx", $prodcustprice->tva_tx, $mysoc,
'', $staticprod->id, $prodcustprice->recuperableonly);
468 print
'<tr><td width="15%">';
469 print $langs->trans(
'PriceBase');
472 print $form->selectPriceBaseType($prodcustprice->price_base_type,
"price_base_type");
478 $text = $langs->trans(
'SellingPrice');
479 print $form->textwithpicto($text, $langs->trans(
"PrecisionUnitIsLimitedToXDecimals",
getDolGlobalString(
'MAIN_MAX_DECIMALS_UNIT')), 1, 1);
481 if ($prodcustprice->price_base_type ==
'TTC') {
482 print
'<input name="price" size="10" value="'.price($prodcustprice->price_ttc).
'">';
484 print
'<input name="price" size="10" value="'.price($prodcustprice->price).
'">';
490 $text = $langs->trans(
'MinPrice');
491 print $form->textwithpicto($text, $langs->trans(
"PrecisionUnitIsLimitedToXDecimals",
getDolGlobalString(
'MAIN_MAX_DECIMALS_UNIT')), 1, 1);
493 if ($prodcustprice->price_base_type ==
'TTC') {
494 print
'<input name="price_min" size="10" value="'.price($prodcustprice->price_min_ttc).
'">';
496 print
'<input name="price_min" size="10" value="'.price($prodcustprice->price_min).
'">';
502 print $langs->trans(
'ForceUpdateChildPriceSoc');
505 print
'<input type="checkbox" name="updatechildprice" value="1">';
510 $extrafields->fetch_name_optionals_label(
"product_customer_price");
511 $extralabels = !empty($extrafields->attributes[
"product_customer_price"][
'label']) ? $extrafields->attributes[
"product_customer_price"][
'label'] :
'';
512 $extrafield_values = $extrafields->getOptionalsFromPost(
"product_customer_price");
513 if (!empty($extralabels)) {
515 foreach ($extralabels as $key => $value) {
516 if (!empty($extrafields->attributes[
"product_customer_price"][
'list'][$key]) && ($extrafields->attributes[
"product_customer_price"][
'list'][$key] == 1 || $extrafields->attributes[
"product_customer_price"][
'list'][$key] == 3 || ($action ==
"edit_price" && $extrafields->attributes[
"product_customer_price"][
'list'][$key] == 4))) {
517 if (!empty($extrafields->attributes[
"product_customer_price"][
'langfile'][$key])) {
518 $langs->load($extrafields->attributes[
"product_customer_price"][
'langfile'][$key]);
521 print
'<tr><td'.($extrafields->attributes[
"product_customer_price"][
'required'][$key] ?
' class="fieldrequired"' :
'').
'>';
522 if (!empty($extrafields->attributes[
"product_customer_price"][
'help'][$key])) {
523 print $form->textwithpicto($langs->trans($value), $langs->trans($extrafields->attributes[
"product_customer_price"][
'help'][$key]));
525 print $langs->trans($value);
527 print
'</td><td>'.$extrafields->showInputField($key, GETPOSTISSET(
'options_'.$key) ? $extrafield_values[
'options_'.$key] :
'',
'',
'',
'',
'', 0,
'product_customer_price').
'</td></tr>';
532 $sql .=
" fk_object";
533 foreach ($extralabels as $key => $value) {
536 $sql .=
" FROM ".MAIN_DB_PREFIX.
"product_customer_price_extrafields";
537 $sql .=
" WHERE fk_object = ".((int) $prodcustprice->id);
538 $resql = $db->query($sql);
540 $obj = $db->fetch_object($resql);
541 foreach ($extralabels as $key => $value) {
542 if (!empty($extrafields->attributes[
"product_customer_price"][
'list'][$key]) && ($extrafields->attributes[
"product_customer_price"][
'list'][$key] == 1 || $extrafields->attributes[
"product_customer_price"][
'list'][$key] == 3 || ($action ==
"edit_price" && $extrafields->attributes[
"product_customer_price"][
'list'][$key] == 4))) {
543 if (!empty($extrafields->attributes[
"product_customer_price"][
'langfile'][$key])) {
544 $langs->load($extrafields->attributes[
"product_customer_price"][
'langfile'][$key]);
547 print
'<tr><td'.($extrafields->attributes[
"product_customer_price"][
'required'][$key] ?
' class="fieldrequired"' :
'').
'>';
548 if (!empty($extrafields->attributes[
"product_customer_price"][
'help'][$key])) {
549 print $form->textwithpicto($langs->trans($value), $langs->trans($extrafields->attributes[
"product_customer_price"][
'help'][$key]));
551 print $langs->trans($value);
553 print
'</td><td>'.$extrafields->showInputField($key, GETPOSTISSET(
'options_'.$key) ? $extrafield_values[
'options_'.$key] : $obj->{$key},
'',
'',
'',
'', 0,
'product_customer_price');
565 print $form->buttonsSaveCancel();
569 } elseif ($action ==
'showlog_customer_price') {
571 print
'<!-- showlog_customer_price -->'.
"\n";
579 $nbtotalofrecords =
'';
580 $result = $prodcustprice->fetchAllLog($sortorder, $sortfield, $conf->liste_limit, $offset, $filter);
585 $nbtotalofrecords = $result;
589 $option =
'&socid='.GETPOSTINT(
'socid').
'&prodid='.
GETPOSTINT(
'prodid');
592 print_barre_liste($langs->trans(
'PriceByCustomerLog'), $page, $_SERVER [
'PHP_SELF'], $option, $sortfield, $sortorder,
'', count($prodcustprice->lines), $nbtotalofrecords);
594 if (count($prodcustprice->lines) > 0) {
595 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'" method="POST">';
596 print
'<input type="hidden" name="token" value="'.newToken().
'">';
597 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
599 print
'<table class="noborder centpercent">';
601 print
'<tr class="liste_titre">';
602 print
'<td>'.$langs->trans(
"Product").
'</td>';
603 print
'<td>'.$langs->trans(
'RefCustomer').
'</td>';
604 print
'<td>'.$langs->trans(
"AppliedPricesFrom").
'</td>';
605 print
'<td class="center">'.$langs->trans(
"PriceBase").
'</td>';
606 print
'<td class="right">'.$langs->trans(
"VAT").
'</td>';
607 print
'<td class="right">'.$langs->trans(
"HT").
'</td>';
608 print
'<td class="right">'.$langs->trans(
"TTC").
'</td>';
609 print
'<td class="right">'.$langs->trans(
"MinPrice").
' '.$langs->trans(
"HT").
'</td>';
610 print
'<td class="right">'.$langs->trans(
"MinPrice").
' '.$langs->trans(
"TTC").
'</td>';
611 print
'<td class="right">'.$langs->trans(
"ChangedBy").
'</td>';
615 foreach ($prodcustprice->lines as $line) {
616 $staticprod =
new Product($db);
617 $staticprod->fetch($line->fk_product);
619 $userstatic =
new User($db);
620 $userstatic->fetch($line->fk_user);
622 print
'<tr class="oddeven">';
624 print
"<td>".$staticprod->getNomUrl(1).
"</td>";
625 print
'<td>'.$line->ref_customer.
'</td>';
626 print
"<td>".dol_print_date($line->datec,
"dayhour").
"</td>";
628 print
'<td class="center">'.$langs->trans($line->price_base_type).
"</td>";
629 print
'<td class="right">'.vatrate($line->tva_tx,
true, $line->recuperableonly).
"</td>";
630 print
'<td class="right">'.price($line->price).
"</td>";
631 print
'<td class="right">'.price($line->price_ttc).
"</td>";
632 print
'<td class="right">'.price($line->price_min).
'</td>';
633 print
'<td class="right">'.price($line->price_min_ttc).
'</td>';
636 print
'<td class="right">';
637 print $userstatic->getNomUrl(-1);
643 print $langs->trans(
'None');
646 print
"\n".
'<div class="tabsAction">'.
"\n";
647 print
'<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?socid='.
$object->id.
'">'.$langs->trans(
"Ok").
'</a></div>';
648 print
"\n</div><br>\n";
655 print
"\n".
'<div class="tabsAction">'.
"\n";
657 if ($user->hasRight(
'produit',
'creer') || $user->hasRight(
'service',
'creer')) {
658 print
'<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?action=add_customer_price&token='.
newToken().
'&socid='.
$object->id.
'">'.$langs->trans(
"AddCustomerPrice").
'</a></div>';
663 $arrayfields = array();
664 foreach ($prodcustprice->fields as $key => $val) {
666 if (!empty($val[
'visible'])) {
667 $visible = (int)
dol_eval((
string) $val[
'visible'], 1, 1,
'1');
668 $arrayfields[
't.'.$key] = array(
669 'label' => $val[
'label'],
670 'checked' => (($visible < 0) ? 0 : 1),
671 'enabled' => (abs($visible) != 3 && (bool)
dol_eval($val[
'enabled'], 1)),
672 'position' => $val[
'position'],
673 'help' => isset($val[
'help']) ? $val[
'help'] :
''
678 $extrafields->fetch_name_optionals_label(
"product_customer_price");
679 if ($extrafields->attributes[
"product_customer_price"] && array_key_exists(
'label', $extrafields->attributes[
"product_customer_price"])) {
680 $extralabels = $extrafields->attributes[
"product_customer_price"][
'label'];
682 if (!empty($extralabels)) {
683 foreach ($extralabels as $key => $value) {
685 if (!empty($extrafields->attributes[
"product_customer_price"][
'list'][$key]) && $extrafields->attributes[
"product_customer_price"][
'list'][$key] != 3) {
686 $extratitle = $langs->trans($value);
687 if (!empty($val[
'visible'])) {
688 $visible = (int)
dol_eval((
string) $val[
'visible'], 1, 1,
'1');
689 $arrayfields[
'ef.' . $key] = array(
690 'label' => $extratitle,
691 'checked' => (($visible < 0) ? 0 : 1),
692 'position' => (int) $extrafields->attributes[
'product_customer_price'][
'pos'][$key],
693 'langfile' => $extrafields->attributes[
"product_customer_price"][
'langfile'][$key],
694 'help' => $extrafields->attributes[
"product_customer_price"][
'help'][$key]
705 $nbtotalofrecords =
'';
707 $nbtotalofrecords = $prodcustprice->fetchAll(
'',
'', 0, 0, $filter);
710 $result = $prodcustprice->fetchAll($sortorder, $sortfield, $conf->liste_limit, $offset, $filter);
715 $option =
'&search_prod='.$search_prod.
'&id='.
$object->id.
'&label='.$search_label.
'&price='.$search_price.
'&price_ttc='.$search_price_ttc;
717 print
'<!-- view specific price for each product -->'.
"\n";
720 print_barre_liste($langs->trans(
'PriceForEachProduct'), $page, $_SERVER[
'PHP_SELF'], $option, $sortfield, $sortorder,
'', count($prodcustprice->lines), $nbtotalofrecords,
'');
722 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'" method="POST">';
723 print
'<input type="hidden" name="token" value="'.newToken().
'">';
724 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
725 if (!empty($sortfield)) {
726 print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'"/>';
728 if (!empty($sortorder)) {
729 print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'"/>';
731 print
'<div class="div-table-responsive-no-min">';
732 print
'<table class="noborder centpercent liste">';
734 $param =
'socid='.$object->id.
'&';
736 $param .=
'&search_prod='.urlencode($search_prod);
739 $param .=
'&search_label='.urlencode($search_label);
742 $param .=
'&search_price='.urlencode($search_price);
745 $param .=
'&search_price='.urlencode($search_price);
747 if ($search_price_ttc) {
748 $param .=
'&search_price_ttc='.urlencode($search_price_ttc);
751 print
'<tr class="liste_titre">';
752 foreach ($prodcustprice->fields as $key => $val) {
753 if (!empty($arrayfields[
't.'.$key][
'checked'])) {
754 print
getTitleFieldOfList($arrayfields[
't.'.$key][
'label'], 0, $_SERVER[
'PHP_SELF'], $key,
'', $param,
'', $sortfield, $sortorder).
"\n";
757 foreach ($extralabels as $key => $val) {
758 if (!empty($arrayfields[
'ef.'.$key][
'checked'])) {
759 print
getTitleFieldOfList($arrayfields[
'ef.'.$key][
'label'], 0, $_SERVER[
'PHP_SELF'], $key,
'', $param,
'', $sortfield, $sortorder).
"\n";
765 if (count($prodcustprice->lines) > 0 || $search_prod) {
766 print
'<tr class="liste_titre">';
767 print
'<td class="liste_titre"><input type="text" class="flat width75" name="search_prod" value="'.$search_prod.
'"></td>';
768 print
'<td class="liste_titre" ><input type="text" class="flat width75" name="search_label" value="'.$search_label.
'"></td>';
769 print
'<td class="liste_titre"></td>';
770 print
'<td class="liste_titre"></td>';
771 print
'<td class="liste_titre"></td>';
772 print
'<td class="liste_titre"></td>';
773 print
'<td class="liste_titre left"><input type="text" class="flat width75" name="search_price" value="'.$search_price.
'"></td>';
774 print
'<td class="liste_titre left"><input type="text" class="flat width75" name="search_price_ttc" value="'.$search_price_ttc.
'"></td>';
775 print
'<td class="liste_titre"></td>';
776 print
'<td class="liste_titre"></td>';
777 print
'<td class="liste_titre"></td>';
778 print
'<td class="liste_titre"></td>';
779 if (!empty($extralabels)) {
780 foreach ($extralabels as $key) {
781 print
'<td class="right"></td>';
785 print
'<td class="liste_titre maxwidthsearch">';
786 $searchpicto = $form->showFilterAndCheckAddButtons(0);
792 if (count($prodcustprice->lines) > 0) {
793 foreach ($prodcustprice->lines as $line) {
794 $staticprod =
new Product($db);
795 $staticprod->fetch($line->fk_product);
797 $userstatic =
new User($db);
798 $userstatic->fetch($line->fk_user);
800 print
'<tr class="oddeven">';
802 print
'<td class="left">'.$staticprod->getNomUrl(1).
"</td>";
803 print
'<td class="left">'.$staticprod->label.
"</td>";
804 print
'<td class="left">'.$line->ref_customer.
'</td>';
805 print
'<td class="left">'.dol_print_date($line->datec,
"dayhour").
"</td>";
806 print
'<td class="left">'.$langs->trans($line->price_base_type).
"</td>";
807 print
'<td class="left">'.vatrate($line->tva_tx.($line->default_vat_code ?
' ('.$line->default_vat_code.
')' :
''), true, $line->recuperableonly).
"</td>";
808 print
'<td class="left">'.price($line->price).
"</td>";
809 print
'<td class="left">'.price($line->price_ttc).
"</td>";
810 print
'<td class="left">'.price($line->price_min).
'</td>';
811 print
'<td class="left">'.price($line->price_min_ttc).
'</td>';
812 print
'<td class="left">'.$line->price_label.
'</td>';
814 print
'<td class="left">';
815 print $userstatic->getNomUrl(-1);
818 $extrafields->fetch_name_optionals_label(
"product_customer_price");
819 $extralabels = $extrafields->attributes[
"product_customer_price"][
'label'];
820 if (!empty($extralabels)) {
822 $sql .=
" fk_object";
823 foreach ($extralabels as $key => $value) {
826 $sql .=
" FROM ".MAIN_DB_PREFIX.
"product_customer_price_extrafields";
827 $sql .=
" WHERE fk_object = ".((int) $line->id);
828 $resql = $db->query($sql);
830 if ($db->num_rows($resql) != 1) {
831 foreach ($extralabels as $key => $value) {
832 if (!empty($extrafields->attributes[
"product_customer_price"][
'list'][$key]) && $extrafields->attributes[
"product_customer_price"][
'list'][$key] != 3) {
837 $obj = $db->fetch_object($resql);
838 foreach ($extralabels as $key => $value) {
839 if (!empty($extrafields->attributes[
"product_customer_price"][
'list'][$key]) && $extrafields->attributes[
"product_customer_price"][
'list'][$key] != 3) {
840 print
'<td align="right">'.$extrafields->showOutputField($key, $obj->{$key},
'',
'product_customer_price').
"</td>";
848 if ($user->hasRight(
'produit',
'creer') || $user->hasRight(
'service',
'creer')) {
849 print
'<td class="right nowraponall">';
850 print
'<a class="paddingleftonly paddingrightonly" href="'.$_SERVER[
"PHP_SELF"].
'?action=showlog_customer_price&token='.
newToken().
'&socid='.
$object->id.
'&prodid='.$line->fk_product.
'">';
854 print
'<a class="editfielda paddingleftonly paddingrightonly" href="'.$_SERVER[
"PHP_SELF"].
'?action=edit_customer_price&token='.
newToken().
'&socid='.
$object->id.
'&lineid='.$line->id.
'">';
855 print
img_edit(
'default', 0,
'style="vertical-align: middle;"');
858 print
'<a class="paddingleftonly paddingrightonly" href="'.$_SERVER[
"PHP_SELF"].
'?action=delete_customer_price&token='.
newToken().
'&socid='.
$object->id.
'&lineid='.$line->id.
'">';
859 print
img_delete(
'default',
'style="vertical-align: middle;"');
868 if ($user->hasRight(
'produit',
'supprimer') || $user->hasRight(
'service',
'supprimer')) {
871 print
'<tr class="oddeven"><td colspan="'.$colspan.
'">'.$langs->trans(
'None').
'</td></tr>';
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
File of class to manage predefined price products or services by customer.
Class to manage products or services.
Class to manage third parties objects (customers, suppliers, prospects...)
Class to manage Dolibarr users.
societe_prepare_head(Societe $object)
Return array of tabs to used on pages for third parties cards.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
print_barre_liste($title, $page, $file, $options='', $sortfield='', $sortorder='', $morehtmlcenter='', $num=-1, $totalnboflines='', $picto='generic', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limit=-1, $selectlimitsuffix=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow='')
Print a title with navigation controls for pagination.
img_delete($titlealt='default', $other='class="pictodelete"', $morecss='')
Show delete logo.
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0)
Show tabs of a record.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
dol_eval($s, $returnvalue=1, $hideerrors=1, $onlysimplestring='1')
Replace eval function to add more security.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_sort_array(&$array, $index, $order='asc', $natsort=0, $case_sensitive=0, $keepindex=0)
Advanced sort array by the value of a given key, which produces ascending (default) or descending out...
newToken()
Return the value of token currently saved into session with name 'newtoken'.
getTitleFieldOfList($name, $thead=0, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $disablesortlink=0, $tooltip='', $forcenowrapcolumntitle=0)
Get title line of an array.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
img_edit($titlealt='default', $float=0, $other='')
Show logo edit/modify fiche.
img_info($titlealt='default')
Show info logo.
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.