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';
51 require_once DOL_DOCUMENT_ROOT.
'/product/class/productcustomerprice.class.php';
57$langs->loadLangs(array(
"products",
"companies",
"bills"));
61$action =
GETPOST(
'action',
'aZ09');
62$search_prod =
GETPOST(
'search_prod',
'alpha');
63$cancel =
GETPOST(
'cancel',
'alpha');
64$search_label =
GETPOST(
'search_label',
'alpha');
65$search_price =
GETPOST(
'search_price');
66$search_price_ttc =
GETPOST(
'search_price_ttc');
71 $socid = $user->socid;
75$hookmanager->initHooks(array(
'thirdpartycustomerprice',
'globalcard'));
89$parameters = array(
'id' => $socid);
90$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
96 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
97 $search_prod = $search_label = $search_price = $search_price_ttc =
'';
100 if ($action ==
'add_customer_price_confirm' && !$cancel && ($user->hasRight(
'produit',
'creer') || $user->hasRight(
'service',
'creer'))) {
103 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->trans(
"Product")),
null,
'errors');
104 $action =
'add_customer_price';
108 $update_child_soc =
GETPOST(
'updatechildprice');
111 $prodcustprice->fk_soc = $socid;
112 $prodcustprice->ref_customer =
GETPOST(
'ref_customer',
'alpha');
113 $prodcustprice->fk_product =
GETPOSTINT(
'prodid');
116 $prodcustprice->price_base_type =
GETPOST(
"price_base_type",
'alpha');
118 $tva_tx_txt =
GETPOST(
'tva_tx',
'alpha');
122 $tva_tx = preg_replace(
'/[^0-9\.].*$/',
'', $tva_tx_txt);
123 $npr = preg_match(
'/\*/', $tva_tx_txt) ? 1 : 0;
126 $localtax1_type =
'0';
127 $localtax2_type =
'0';
129 if (preg_match(
'/\((.*)\)/', $tva_tx_txt, $reg)) {
131 $vatratecode = $reg[1];
133 $sql =
"SELECT t.rowid, t.code, t.recuperableonly, t.localtax1, t.localtax2, t.localtax1_type, t.localtax2_type";
134 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_tva as t, ".MAIN_DB_PREFIX.
"c_country as c";
135 $sql .=
" WHERE t.fk_pays = c.rowid AND c.code = '".$db->escape($mysoc->country_code).
"'";
136 $sql .=
" AND t.taux = ".((float) $tva_tx).
" AND t.active = 1";
137 $sql .=
" AND t.code = '".$db->escape($vatratecode).
"'";
138 $sql .=
" AND t.entity IN (".getEntity(
'c_tva').
")";
139 $resql = $db->query($sql);
141 $obj = $db->fetch_object($resql);
142 $npr = $obj->recuperableonly;
143 $localtax1 = $obj->localtax1;
144 $localtax2 = $obj->localtax2;
145 $localtax1_type = $obj->localtax1_type;
146 $localtax2_type = $obj->localtax2_type;
150 $prodcustprice->default_vat_code = $vatratecode;
151 $prodcustprice->tva_tx = $tva_tx;
152 $prodcustprice->recuperableonly = $npr;
153 $prodcustprice->localtax1_tx = $localtax1;
154 $prodcustprice->localtax2_tx = $localtax2;
155 $prodcustprice->localtax1_type = $localtax1_type;
156 $prodcustprice->localtax2_type = $localtax2_type;
158 $result = $prodcustprice->create($user, 0, $update_child_soc);
160 $extrafields->fetch_name_optionals_label(
"product_customer_price");
161 $extralabels = !empty($extrafields->attributes[
"product_customer_price"][
'label']) ? $extrafields->attributes[
"product_customer_price"][
'label'] :
'';
162 $extrafield_values = $extrafields->getOptionalsFromPost(
"product_customer_price");
163 if (!empty($extralabels) && is_array($extralabels)) {
165 $res = $productcustomerprice->fetch($prodcustprice->id);
167 foreach ($extrafield_values as $key => $value) {
168 $productcustomerprice->array_options[$key] = $value;
170 $result2 = $productcustomerprice->insertExtraFields();
172 $prodcustprice->error = $productcustomerprice->error;
173 $prodcustprice->errors = $productcustomerprice->errors;
190 if ($action ==
'delete_customer_price' && ($user->hasRight(
'produit',
'creer') || $user->hasRight(
'service',
'creer'))) {
193 $result = $prodcustprice->delete($user);
203 if ($action ==
'update_customer_price_confirm' && !$cancel && ($user->hasRight(
'produit',
'creer') || $user->hasRight(
'service',
'creer'))) {
206 $update_child_soc =
GETPOST(
'updatechildprice');
209 $prodcustprice->ref_customer =
GETPOST(
'ref_customer',
'alpha');
212 $prodcustprice->price_base_type =
GETPOST(
"price_base_type",
'alpha');
213 $prodcustprice->tva_tx = str_replace(
'*',
'',
GETPOST(
"tva_tx"));
214 $prodcustprice->recuperableonly = (preg_match(
'/\*/',
GETPOST(
"tva_tx")) ? 1 : 0);
216 $result = $prodcustprice->update($user, 0, $update_child_soc);
218 $extrafields->fetch_name_optionals_label(
"product_customer_price");
219 $extralabels = !empty($extrafields->attributes[
"product_customer_price"][
'label']) ? $extrafields->attributes[
"product_customer_price"][
'label'] :
'';
220 $extrafield_values = $extrafields->getOptionalsFromPost(
"product_customer_price");
221 if (!empty($extralabels) && is_array($extralabels)) {
223 $res = $productcustomerprice->fetch($prodcustprice->id);
225 foreach ($extrafield_values as $key => $value) {
226 $productcustomerprice->array_options[$key] = $value;
228 $result2 = $productcustomerprice->insertExtraFields();
230 $prodcustprice->error = $productcustomerprice->error;
231 $prodcustprice->errors = $productcustomerprice->errors;
252$form =
new Form($db);
256$result =
$object->fetch($socid);
257llxHeader(
"", $langs->trans(
"ThirdParty").
'-'.$langs->trans(
'PriceByCustomer'));
263$linkback =
'<a href="'.DOL_URL_ROOT.
'/societe/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
265dol_banner_tab($object,
'socid', $linkback, ($user->socid ? 0 : 1),
'rowid',
'nom');
267print
'<div class="fichecenter">';
269print
'<div class="underbanner clearboth"></div>';
270print
'<table class="border centpercent tableforfield">';
273print
'<tr><td class="titlefield">'.$langs->trans(
'NatureOfThirdParty').
'</td><td>';
278 print
'<tr><td class="titlefield">'.$langs->trans(
'Prefix').
'</td><td colspan="3">'.
$object->prefix_comm.
'</td></tr>';
282 print
'<tr><td class="titlefield">';
283 print $langs->trans(
'CustomerCode').
'</td><td colspan="3">';
285 $tmpcheck =
$object->check_codeclient();
286 if ($tmpcheck != 0 && $tmpcheck != -5) {
287 print
' <span class="error">('.$langs->trans(
"WrongCustomerCode").
')</span>';
293 print
'<tr><td class="titlefield">';
294 print $langs->trans(
'SupplierCode').
'</td><td colspan="3">';
295 print
$object->code_fournisseur;
296 $tmpcheck =
$object->check_codefournisseur();
297 if ($tmpcheck != 0 && $tmpcheck != -5) {
298 print
' <span class="error">('.$langs->trans(
"WrongSupplierCode").
')</span>';
314 $sortfield =
GETPOST(
'sortfield',
'aZ09comma');
315 $sortorder =
GETPOST(
'sortorder',
'aZ09comma');
318 if (empty($page) || $page == -1) {
321 $offset = $limit * $page;
322 $pageprev = $page - 1;
323 $pagenext = $page + 1;
328 $sortfield =
"soc.nom";
336 if (!empty($search_prod)) {
337 $filter [
'prod.ref'] = $search_prod;
340 if (!empty($search_label)) {
341 $filter [
'prod.label'] = $search_label;
344 if (!empty($search_price)) {
345 $filter [
't.price'] = $search_price;
348 if (!empty($search_price_ttc)) {
349 $filter [
't.price_ttc'] = $search_price_ttc;
352 if ($action ==
'add_customer_price') {
356 print
'<!-- Price by customer -->'.
"\n";
360 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'?socid='.
$object->id.
'" method="POST">';
361 print
'<input type="hidden" name="token" value="'.newToken().
'">';
362 print
'<input type="hidden" name="action" value="add_customer_price_confirm">';
363 print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
364 print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
365 print
'<input type="hidden" name="socid" value="'.$object->id.
'">';
366 print
'<table class="border centpercent">';
368 print
'<td>'.$langs->trans(
'Product').
'</td>';
370 $form->select_produits(
'',
'prodid',
'', 0);
375 print
'<tr><td>'.$langs->trans(
'RefCustomer').
'</td>';
376 print
'<td><input name="ref_customer" size="12"></td></tr>';
379 print
'<tr><td>'.$langs->trans(
"VATRate").
'</td><td>';
380 print $form->load_tva(
"tva_tx",
GETPOST(
"tva_tx",
"alpha"), $mysoc,
'',
$object->id, 0,
'',
false, 1);
384 print
'<tr><td width="15%">';
385 print $langs->trans(
'PriceBase');
388 print $form->selectPriceBaseType(
GETPOST(
"price_base_type",
"aZ09"),
"price_base_type");
393 print
'<tr><td width="20%">';
394 $text = $langs->trans(
'SellingPrice');
395 print $form->textwithpicto($text, $langs->trans(
"PrecisionUnitIsLimitedToXDecimals",
getDolGlobalString(
'MAIN_MAX_DECIMALS_UNIT')), 1, 1);
397 print
'<input name="price" size="10" value="'.GETPOSTINT(
'price').
'">';
402 $text = $langs->trans(
'MinPrice');
403 print $form->textwithpicto($text, $langs->trans(
"PrecisionUnitIsLimitedToXDecimals",
getDolGlobalString(
'MAIN_MAX_DECIMALS_UNIT')), 1, 1);
404 print
'<td><input name="price_min" size="10" value="'.GETPOSTINT(
'price_min').
'">';
408 print
'<tr><td width="15%">';
409 print $langs->trans(
'ForceUpdateChildPriceSoc');
412 print
'<input type="checkbox" name="updatechildprice" value="1"/>';
417 $extrafields->fetch_name_optionals_label(
"product_customer_price");
418 $extralabels = !empty($extrafields->attributes[
"product_customer_price"][
'label']) ? $extrafields->attributes[
"product_customer_price"][
'label'] :
'';
419 $extrafield_values = $extrafields->getOptionalsFromPost(
"product_customer_price");
420 if (!empty($extralabels)) {
421 if (empty($prodcustprice->id)) {
422 foreach ($extralabels as $key => $value) {
423 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))) {
424 if (!empty($extrafields->attributes[
"product_customer_price"][
'langfile'][$key])) {
425 $langs->load($extrafields->attributes[
"product_customer_price"][
'langfile'][$key]);
428 print
'<tr><td'.($extrafields->attributes[
"product_customer_price"][
'required'][$key] ?
' class="fieldrequired"' :
'').
'>';
429 if (!empty($extrafields->attributes[
"product_customer_price"][
'help'][$key])) {
430 print $form->textwithpicto($langs->trans($value), $langs->trans($extrafields->attributes[
"product_customer_price"][
'help'][$key]));
432 print $langs->trans($value);
434 print
'</td><td>'.$extrafields->showInputField($key, GETPOSTISSET(
'options_'.$key) ? $extrafield_values[
'options_'.$key] :
'',
'',
'',
'',
'', 0,
'product_customer_price').
'</td></tr>';
442 print $form->buttonsSaveCancel();
445 } elseif ($action ==
'edit_customer_price') {
450 $result = $prodcustprice->fetch(
GETPOSTINT(
'lineid'));
455 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'?socid='.
$object->id.
'" method="POST">';
456 print
'<input type="hidden" name="token" value="'.newToken().
'">';
457 print
'<input type="hidden" name="action" value="update_customer_price_confirm">';
458 print
'<input type="hidden" name="lineid" value="'.$prodcustprice->id.
'">';
459 print
'<table class="border centpercent">';
461 print
'<td>'.$langs->trans(
'Product').
'</td>';
462 $staticprod =
new Product($db);
463 $staticprod->fetch($prodcustprice->fk_product);
464 print
"<td>".$staticprod->getNomUrl(1).
"</td>";
468 print
'<tr><td>'.$langs->trans(
'RefCustomer').
'</td>';
469 print
'<td><input name="ref_customer" size="12" value="'.dol_escape_htmltag($prodcustprice->ref_customer).
'"></td></tr>';
472 print
'<tr><td>'.$langs->trans(
"VATRate").
'</td><td>';
473 print $form->load_tva(
"tva_tx", $prodcustprice->tva_tx, $mysoc,
'', $staticprod->id, $prodcustprice->recuperableonly);
477 print
'<tr><td width="15%">';
478 print $langs->trans(
'PriceBase');
481 print $form->selectPriceBaseType($prodcustprice->price_base_type,
"price_base_type");
487 $text = $langs->trans(
'SellingPrice');
488 print $form->textwithpicto($text, $langs->trans(
"PrecisionUnitIsLimitedToXDecimals",
getDolGlobalString(
'MAIN_MAX_DECIMALS_UNIT')), 1, 1);
490 if ($prodcustprice->price_base_type ==
'TTC') {
491 print
'<input name="price" size="10" value="'.price($prodcustprice->price_ttc).
'">';
493 print
'<input name="price" size="10" value="'.price($prodcustprice->price).
'">';
499 $text = $langs->trans(
'MinPrice');
500 print $form->textwithpicto($text, $langs->trans(
"PrecisionUnitIsLimitedToXDecimals",
getDolGlobalString(
'MAIN_MAX_DECIMALS_UNIT')), 1, 1);
502 if ($prodcustprice->price_base_type ==
'TTC') {
503 print
'<input name="price_min" size="10" value="'.price($prodcustprice->price_min_ttc).
'">';
505 print
'<input name="price_min" size="10" value="'.price($prodcustprice->price_min).
'">';
511 print $langs->trans(
'ForceUpdateChildPriceSoc');
514 print
'<input type="checkbox" name="updatechildprice" value="1">';
519 $extrafields->fetch_name_optionals_label(
"product_customer_price");
520 $extralabels = !empty($extrafields->attributes[
"product_customer_price"][
'label']) ? $extrafields->attributes[
"product_customer_price"][
'label'] :
'';
521 $extrafield_values = $extrafields->getOptionalsFromPost(
"product_customer_price");
522 if (!empty($extralabels)) {
524 foreach ($extralabels as $key => $value) {
525 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))) {
526 if (!empty($extrafields->attributes[
"product_customer_price"][
'langfile'][$key])) {
527 $langs->load($extrafields->attributes[
"product_customer_price"][
'langfile'][$key]);
530 print
'<tr><td'.($extrafields->attributes[
"product_customer_price"][
'required'][$key] ?
' class="fieldrequired"' :
'').
'>';
531 if (!empty($extrafields->attributes[
"product_customer_price"][
'help'][$key])) {
532 print $form->textwithpicto($langs->trans($value), $langs->trans($extrafields->attributes[
"product_customer_price"][
'help'][$key]));
534 print $langs->trans($value);
536 print
'</td><td>'.$extrafields->showInputField($key, GETPOSTISSET(
'options_'.$key) ? $extrafield_values[
'options_'.$key] :
'',
'',
'',
'',
'', 0,
'product_customer_price').
'</td></tr>';
541 $sql .=
" fk_object";
542 foreach ($extralabels as $key => $value) {
545 $sql .=
" FROM ".MAIN_DB_PREFIX.
"product_customer_price_extrafields";
546 $sql .=
" WHERE fk_object = ".((int) $prodcustprice->id);
547 $resql = $db->query($sql);
549 $obj = $db->fetch_object($resql);
550 foreach ($extralabels as $key => $value) {
551 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))) {
552 if (!empty($extrafields->attributes[
"product_customer_price"][
'langfile'][$key])) {
553 $langs->load($extrafields->attributes[
"product_customer_price"][
'langfile'][$key]);
556 print
'<tr><td'.($extrafields->attributes[
"product_customer_price"][
'required'][$key] ?
' class="fieldrequired"' :
'').
'>';
557 if (!empty($extrafields->attributes[
"product_customer_price"][
'help'][$key])) {
558 print $form->textwithpicto($langs->trans($value), $langs->trans($extrafields->attributes[
"product_customer_price"][
'help'][$key]));
560 print $langs->trans($value);
562 print
'</td><td>'.$extrafields->showInputField($key, GETPOSTISSET(
'options_'.$key) ? $extrafield_values[
'options_'.$key] : $obj->{$key},
'',
'',
'',
'', 0,
'product_customer_price');
574 print $form->buttonsSaveCancel();
578 } elseif ($action ==
'showlog_customer_price') {
580 print
'<!-- showlog_customer_price -->'.
"\n";
588 $nbtotalofrecords =
'';
589 $result = $prodcustprice->fetchAllLog($sortorder, $sortfield,
$conf->liste_limit, $offset, $filter);
594 $nbtotalofrecords = $result;
598 $option =
'&socid='.GETPOSTINT(
'socid').
'&prodid='.
GETPOSTINT(
'prodid');
601 print_barre_liste($langs->trans(
'PriceByCustomerLog'), $page, $_SERVER [
'PHP_SELF'], $option, $sortfield, $sortorder,
'', count($prodcustprice->lines), $nbtotalofrecords);
603 if (count($prodcustprice->lines) > 0) {
604 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'" method="POST">';
605 print
'<input type="hidden" name="token" value="'.newToken().
'">';
606 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
608 print
'<table class="noborder centpercent">';
610 print
'<tr class="liste_titre">';
611 print
'<td>'.$langs->trans(
"Product").
'</td>';
612 print
'<td>'.$langs->trans(
'RefCustomer').
'</td>';
613 print
'<td>'.$langs->trans(
"AppliedPricesFrom").
'</td>';
614 print
'<td class="center">'.$langs->trans(
"PriceBase").
'</td>';
615 print
'<td class="right">'.$langs->trans(
"VAT").
'</td>';
616 print
'<td class="right">'.$langs->trans(
"HT").
'</td>';
617 print
'<td class="right">'.$langs->trans(
"TTC").
'</td>';
618 print
'<td class="right">'.$langs->trans(
"MinPrice").
' '.$langs->trans(
"HT").
'</td>';
619 print
'<td class="right">'.$langs->trans(
"MinPrice").
' '.$langs->trans(
"TTC").
'</td>';
620 print
'<td class="right">'.$langs->trans(
"ChangedBy").
'</td>';
624 foreach ($prodcustprice->lines as $line) {
625 $staticprod =
new Product($db);
626 $staticprod->fetch($line->fk_product);
628 $userstatic =
new User($db);
629 $userstatic->fetch($line->fk_user);
631 print
'<tr class="oddeven">';
633 print
"<td>".$staticprod->getNomUrl(1).
"</td>";
634 print
'<td>'.$line->ref_customer.
'</td>';
635 print
"<td>".dol_print_date($line->datec,
"dayhour").
"</td>";
637 print
'<td class="center">'.$langs->trans($line->price_base_type).
"</td>";
638 print
'<td class="right">'.vatrate($line->tva_tx,
true, $line->recuperableonly).
"</td>";
639 print
'<td class="right">'.price($line->price).
"</td>";
640 print
'<td class="right">'.price($line->price_ttc).
"</td>";
641 print
'<td class="right">'.price($line->price_min).
'</td>';
642 print
'<td class="right">'.price($line->price_min_ttc).
'</td>';
645 print
'<td class="right">';
646 print $userstatic->getNomUrl(-1);
652 print $langs->trans(
'None');
655 print
"\n".
'<div class="tabsAction">'.
"\n";
656 print
'<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?socid='.
$object->id.
'">'.$langs->trans(
"Ok").
'</a></div>';
657 print
"\n</div><br>\n";
664 print
"\n".
'<div class="tabsAction">'.
"\n";
666 if ($user->hasRight(
'produit',
'creer') || $user->hasRight(
'service',
'creer')) {
667 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>';
672 $arrayfields = array();
673 foreach ($prodcustprice->fields as $key => $val) {
675 if (!empty($val[
'visible'])) {
676 $visible = (int)
dol_eval((
string) $val[
'visible'], 1, 1,
'1');
677 $arrayfields[
't.'.$key] = array(
678 'label' => $val[
'label'],
679 'checked' => (($visible < 0) ? 0 : 1),
680 'enabled' => (abs($visible) != 3 && (bool)
dol_eval($val[
'enabled'], 1)),
681 'position' => $val[
'position'],
682 'help' => isset($val[
'help']) ? $val[
'help'] :
''
687 $extrafields->fetch_name_optionals_label(
"product_customer_price");
688 if ($extrafields->attributes[
"product_customer_price"] && array_key_exists(
'label', $extrafields->attributes[
"product_customer_price"])) {
689 $extralabels = $extrafields->attributes[
"product_customer_price"][
'label'];
691 if (!empty($extralabels)) {
692 foreach ($extralabels as $key => $value) {
694 if (!empty($extrafields->attributes[
"product_customer_price"][
'list'][$key]) && $extrafields->attributes[
"product_customer_price"][
'list'][$key] != 3) {
695 $extratitle = $langs->trans($value);
696 if (!empty($val[
'visible'])) {
697 $visible = (int)
dol_eval((
string) $val[
'visible'], 1, 1,
'1');
698 $arrayfields[
'ef.' . $key] = array(
699 'label' => $extratitle,
700 'checked' => (($visible < 0) ? 0 : 1),
701 'position' => (int) $extrafields->attributes[
'product_customer_price'][
'pos'][$key],
702 'langfile' => $extrafields->attributes[
"product_customer_price"][
'langfile'][$key],
703 'help' => $extrafields->attributes[
"product_customer_price"][
'help'][$key]
714 $nbtotalofrecords =
'';
716 $nbtotalofrecords = $prodcustprice->fetchAll(
'',
'', 0, 0, $filter);
719 $result = $prodcustprice->fetchAll($sortorder, $sortfield,
$conf->liste_limit, $offset, $filter);
724 $option =
'&search_prod='.$search_prod.
'&id='.
$object->id.
'&label='.$search_label.
'&price='.$search_price.
'&price_ttc='.$search_price_ttc;
726 print
'<!-- view specific price for each product -->'.
"\n";
729 print_barre_liste($langs->trans(
'PriceForEachProduct'), $page, $_SERVER[
'PHP_SELF'], $option, $sortfield, $sortorder,
'', count($prodcustprice->lines), $nbtotalofrecords,
'');
731 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'" method="POST">';
732 print
'<input type="hidden" name="token" value="'.newToken().
'">';
733 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
734 if (!empty($sortfield)) {
735 print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'"/>';
737 if (!empty($sortorder)) {
738 print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'"/>';
740 print
'<div class="div-table-responsive-no-min">';
741 print
'<table class="noborder centpercent liste">';
743 $param =
'socid='.$object->id.
'&';
745 $param .=
'&search_prod='.urlencode($search_prod);
748 $param .=
'&search_label='.urlencode($search_label);
751 $param .=
'&search_price='.urlencode($search_price);
754 $param .=
'&search_price='.urlencode($search_price);
756 if ($search_price_ttc) {
757 $param .=
'&search_price_ttc='.urlencode($search_price_ttc);
760 print
'<tr class="liste_titre">';
761 foreach ($prodcustprice->fields as $key => $val) {
762 if (!empty($arrayfields[
't.'.$key][
'checked'])) {
763 print
getTitleFieldOfList($arrayfields[
't.'.$key][
'label'], 0, $_SERVER[
'PHP_SELF'], $key,
'', $param,
'', $sortfield, $sortorder).
"\n";
766 if (!empty($extralabels) && is_array($extralabels)) {
767 foreach ($extralabels as $key => $val) {
768 if (!empty($arrayfields[
'ef.'.$key][
'checked'])) {
769 print
getTitleFieldOfList($arrayfields[
'ef.'.$key][
'label'], 0, $_SERVER[
'PHP_SELF'], $key,
'', $param,
'', $sortfield, $sortorder).
"\n";
776 if (count($prodcustprice->lines) > 0 || $search_prod) {
777 print
'<tr class="liste_titre">';
778 print
'<td class="liste_titre"><input type="text" class="flat width75" name="search_prod" value="'.$search_prod.
'"></td>';
779 print
'<td class="liste_titre" ><input type="text" class="flat width75" name="search_label" value="'.$search_label.
'"></td>';
780 print
'<td class="liste_titre"></td>';
781 print
'<td class="liste_titre"></td>';
782 print
'<td class="liste_titre"></td>';
783 print
'<td class="liste_titre"></td>';
784 print
'<td class="liste_titre left"><input type="text" class="flat width75" name="search_price" value="'.$search_price.
'"></td>';
785 print
'<td class="liste_titre left"><input type="text" class="flat width75" name="search_price_ttc" value="'.$search_price_ttc.
'"></td>';
786 print
'<td class="liste_titre"></td>';
787 print
'<td class="liste_titre"></td>';
788 print
'<td class="liste_titre"></td>';
789 print
'<td class="liste_titre"></td>';
790 if (!empty($extralabels)) {
791 foreach ($extralabels as $key) {
792 print
'<td class="right"></td>';
796 print
'<td class="liste_titre maxwidthsearch">';
797 $searchpicto = $form->showFilterAndCheckAddButtons(0);
803 if (count($prodcustprice->lines) > 0) {
804 foreach ($prodcustprice->lines as $line) {
805 $staticprod =
new Product($db);
806 $staticprod->fetch($line->fk_product);
808 $userstatic =
new User($db);
809 $userstatic->fetch($line->fk_user);
811 print
'<tr class="oddeven">';
813 print
'<td class="left">'.$staticprod->getNomUrl(1).
"</td>";
814 print
'<td class="left">'.$staticprod->label.
"</td>";
815 print
'<td class="left">'.$line->ref_customer.
'</td>';
816 print
'<td class="left">'.dol_print_date($line->datec,
"dayhour").
"</td>";
817 print
'<td class="left">'.$langs->trans($line->price_base_type).
"</td>";
818 print
'<td class="left">'.vatrate($line->tva_tx.($line->default_vat_code ?
' ('.$line->default_vat_code.
')' :
''), true, $line->recuperableonly).
"</td>";
819 print
'<td class="left">'.price($line->price).
"</td>";
820 print
'<td class="left">'.price($line->price_ttc).
"</td>";
821 print
'<td class="left">'.price($line->price_min).
'</td>';
822 print
'<td class="left">'.price($line->price_min_ttc).
'</td>';
823 print
'<td class="left">'.$line->price_label.
'</td>';
825 print
'<td class="left">';
826 print $userstatic->getNomUrl(-1);
829 $extrafields->fetch_name_optionals_label(
"product_customer_price");
830 $extralabels = $extrafields->attributes[
"product_customer_price"][
'label'];
831 if (!empty($extralabels)) {
833 $sql .=
" fk_object";
834 foreach ($extralabels as $key => $value) {
837 $sql .=
" FROM ".MAIN_DB_PREFIX.
"product_customer_price_extrafields";
838 $sql .=
" WHERE fk_object = ".((int) $line->id);
839 $resql = $db->query($sql);
841 if ($db->num_rows($resql) != 1) {
842 foreach ($extralabels as $key => $value) {
843 if (!empty($extrafields->attributes[
"product_customer_price"][
'list'][$key]) && $extrafields->attributes[
"product_customer_price"][
'list'][$key] != 3) {
848 $obj = $db->fetch_object($resql);
849 foreach ($extralabels as $key => $value) {
850 if (!empty($extrafields->attributes[
"product_customer_price"][
'list'][$key]) && $extrafields->attributes[
"product_customer_price"][
'list'][$key] != 3) {
851 print
'<td align="right">'.$extrafields->showOutputField($key, $obj->{$key},
'',
'product_customer_price').
"</td>";
859 if ($user->hasRight(
'produit',
'creer') || $user->hasRight(
'service',
'creer')) {
860 print
'<td class="right nowraponall">';
861 print
'<a class="paddingleftonly paddingrightonly" href="'.$_SERVER[
"PHP_SELF"].
'?action=showlog_customer_price&token='.
newToken().
'&socid='.
$object->id.
'&prodid='.$line->fk_product.
'">';
865 print
'<a class="editfielda paddingleftonly paddingrightonly" href="'.$_SERVER[
"PHP_SELF"].
'?action=edit_customer_price&token='.
newToken().
'&socid='.
$object->id.
'&lineid='.$line->id.
'">';
866 print
img_edit(
'default', 0,
'style="vertical-align: middle;"');
869 print
'<a class="paddingleftonly paddingrightonly" href="'.$_SERVER[
"PHP_SELF"].
'?action=delete_customer_price&token='.
newToken().
'&socid='.
$object->id.
'&lineid='.$line->id.
'">';
870 print
img_delete(
'default',
'style="vertical-align: middle;"');
879 if ($user->hasRight(
'produit',
'supprimer') || $user->hasRight(
'service',
'supprimer')) {
882 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.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
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.