35require
'../main.inc.php';
45require_once DOL_DOCUMENT_ROOT.
'/core/lib/product.lib.php';
46require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
47require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
48require_once DOL_DOCUMENT_ROOT.
'/societe/class/societe.class.php';
49require_once DOL_DOCUMENT_ROOT.
'/product/class/productcustomerprice.class.php';
58$langs->loadLangs(array(
"products",
"companies",
"bills"));
62$action =
GETPOST(
'action',
'aZ09');
63$search_prod =
GETPOST(
'search_prod',
'alpha');
64$cancel =
GETPOST(
'cancel',
'alpha');
65$search_label =
GETPOST(
'search_label',
'alpha');
66$search_price =
GETPOST(
'search_price');
67$search_price_ttc =
GETPOST(
'search_price_ttc');
72 $socid = $user->socid;
76$hookmanager->initHooks(array(
'thirdpartycustomerprice',
'globalcard'));
90$parameters = array(
'id' => $socid);
91$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
97 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
98 $search_prod = $search_label = $search_price = $search_price_ttc =
'';
101 if ($action ==
'add_customer_price_confirm' && $prodcustprice !==
null && !$cancel && ($user->hasRight(
'produit',
'creer') || $user->hasRight(
'service',
'creer'))) {
104 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->trans(
"Product")),
null,
'errors');
105 $action =
'add_customer_price';
109 $update_child_soc =
GETPOSTINT(
'updatechildprice');
112 $prodcustprice->fk_soc = $socid;
113 $prodcustprice->ref_customer =
GETPOST(
'ref_customer',
'alpha');
114 $prodcustprice->fk_product =
GETPOSTINT(
'prodid');
117 $prodcustprice->price_base_type =
GETPOST(
"price_base_type",
'alpha');
122 $tva_tx_txt =
GETPOST(
'tva_tx',
'alpha');
126 $tva_tx = preg_replace(
'/[^0-9\.].*$/',
'', $tva_tx_txt);
127 $npr = preg_match(
'/\*/', $tva_tx_txt) ? 1 : 0;
130 $localtax1_type =
'0';
131 $localtax2_type =
'0';
133 if (preg_match(
'/\((.*)\)/', $tva_tx_txt, $reg)) {
135 $vatratecode = $reg[1];
137 $sql =
"SELECT t.rowid, t.code, t.recuperableonly, t.localtax1, t.localtax2, t.localtax1_type, t.localtax2_type";
138 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_tva as t, ".MAIN_DB_PREFIX.
"c_country as c";
139 $sql .=
" WHERE t.fk_pays = c.rowid AND c.code = '".$db->escape(
$mysoc->country_code).
"'";
140 $sql .=
" AND t.taux = ".((float) $tva_tx).
" AND t.active = 1";
141 $sql .=
" AND t.code = '".$db->escape($vatratecode).
"'";
142 $sql .=
" AND t.entity IN (".getEntity(
'c_tva').
")";
143 $resql =
$db->query($sql);
145 $obj =
$db->fetch_object($resql);
146 $npr = $obj->recuperableonly;
147 $localtax1 = $obj->localtax1;
148 $localtax2 = $obj->localtax2;
149 $localtax1_type = $obj->localtax1_type;
150 $localtax2_type = $obj->localtax2_type;
154 $prodcustprice->default_vat_code = $vatratecode;
155 $prodcustprice->tva_tx = $tva_tx;
156 $prodcustprice->recuperableonly = $npr;
157 $prodcustprice->localtax1_tx = $localtax1;
158 $prodcustprice->localtax2_tx = $localtax2;
159 $prodcustprice->localtax1_type = $localtax1_type;
160 $prodcustprice->localtax2_type = $localtax2_type;
162 $result = $prodcustprice->create($user, 0, $update_child_soc);
164 $extrafields->fetch_name_optionals_label(
"product_customer_price");
165 $extralabels = !empty($extrafields->attributes[
"product_customer_price"][
'label']) ? $extrafields->attributes[
"product_customer_price"][
'label'] :
'';
166 $extrafield_values = $extrafields->getOptionalsFromPost(
"product_customer_price");
167 if (!empty($extralabels) && is_array($extralabels)) {
169 $res = $productcustomerprice->fetch($prodcustprice->id);
171 foreach ($extrafield_values as $key => $value) {
172 $productcustomerprice->array_options[$key] = $value;
174 $result2 = $productcustomerprice->insertExtraFields();
176 $prodcustprice->error = $productcustomerprice->error;
177 $prodcustprice->errors = $productcustomerprice->errors;
186 $action =
'add_customer_price';
194 if ($action ==
'delete_customer_price' && $prodcustprice !==
null && ($user->hasRight(
'produit',
'creer') || $user->hasRight(
'service',
'creer'))) {
197 $result = $prodcustprice->delete($user);
207 if ($action ==
'update_customer_price_confirm' && $prodcustprice !==
null && !$cancel && ($user->hasRight(
'produit',
'creer') || $user->hasRight(
'service',
'creer'))) {
210 $update_child_soc =
GETPOSTINT(
'updatechildprice');
213 $prodcustprice->ref_customer =
GETPOST(
'ref_customer',
'alpha');
216 $prodcustprice->price_base_type =
GETPOST(
"price_base_type",
'alpha');
217 $tva_tx_txt =
GETPOST(
'tva_tx',
'alpha');
221 $tva_tx = preg_replace(
'/[^0-9\.].*$/',
'', $tva_tx_txt);
222 $npr = preg_match(
'/\*/', $tva_tx_txt) ? 1 : 0;
225 $localtax1_type =
'0';
226 $localtax2_type =
'0';
228 if (preg_match(
'/\((.*)\)/', $tva_tx_txt, $reg)) {
229 $vatratecode = $reg[1];
231 if ($tva_tx !==
'') {
232 $sql =
"SELECT t.rowid, t.code, t.recuperableonly, t.localtax1, t.localtax2, t.localtax1_type, t.localtax2_type";
233 $sql .=
" FROM ".$db->prefix().
"c_tva as t, ".
$db->prefix().
"c_country as c";
234 $sql .=
" WHERE t.fk_pays = c.rowid AND c.code = '".$db->escape(
$mysoc->country_code).
"'";
235 $sql .=
" AND t.taux = ".((float) $tva_tx).
" AND t.active = 1";
236 $sql .=
" AND t.code = '".$db->escape($vatratecode).
"'";
237 if ($vatratecode ===
'') {
238 $sql .=
" AND t.recuperableonly = ".((int) $npr);
240 $sql .=
" AND t.entity IN (".getEntity(
'c_tva').
")";
241 $resql =
$db->query($sql);
243 $obj =
$db->fetch_object($resql);
245 $npr = $obj->recuperableonly;
246 $localtax1 = $obj->localtax1;
247 $localtax2 = $obj->localtax2;
248 $localtax1_type = $obj->localtax1_type;
249 $localtax2_type = $obj->localtax2_type;
254 $prodcustprice->default_vat_code = $vatratecode;
255 $prodcustprice->tva_tx = $tva_tx;
256 $prodcustprice->recuperableonly = $npr;
257 $prodcustprice->localtax1_tx = $localtax1;
258 $prodcustprice->localtax2_tx = $localtax2;
259 $prodcustprice->localtax1_type = $localtax1_type;
260 $prodcustprice->localtax2_type = $localtax2_type;
265 $result = $prodcustprice->update($user, 0, $update_child_soc);
267 $extrafields->fetch_name_optionals_label(
"product_customer_price");
268 $extralabels = !empty($extrafields->attributes[
"product_customer_price"][
'label']) ? $extrafields->attributes[
"product_customer_price"][
'label'] :
'';
269 $extrafield_values = $extrafields->getOptionalsFromPost(
"product_customer_price");
270 if (!empty($extralabels) && is_array($extralabels)) {
272 $res = $productcustomerprice->fetch($prodcustprice->id);
274 foreach ($extrafield_values as $key => $value) {
275 $productcustomerprice->array_options[$key] = $value;
277 $result2 = $productcustomerprice->insertExtraFields();
279 $prodcustprice->error = $productcustomerprice->error;
280 $prodcustprice->errors = $productcustomerprice->errors;
288 $action =
'edit_customer_price';
305$result =
$object->fetch($socid);
306llxHeader(
"", $langs->trans(
"ThirdParty").
'-'.$langs->trans(
'PriceByCustomer'));
312$linkback =
'<a href="'.DOL_URL_ROOT.
'/societe/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
314dol_banner_tab($object,
'socid', $linkback, ($user->socid ? 0 : 1),
'rowid',
'nom');
316print
'<div class="fichecenter">';
318print
'<div class="underbanner clearboth"></div>';
319print
'<table class="border centpercent tableforfield">';
322print
'<tr><td class="titlefield">'.$langs->trans(
'NatureOfThirdParty').
'</td><td>';
327 print
'<tr><td class="titlefield">';
328 print $langs->trans(
'CustomerCode').
'</td><td colspan="3">';
330 $tmpcheck =
$object->check_codeclient();
331 if ($tmpcheck != 0 && $tmpcheck != -5) {
332 print
' <span class="error">('.$langs->trans(
"WrongCustomerCode").
')</span>';
338 print
'<tr><td class="titlefield">';
339 print $langs->trans(
'SupplierCode').
'</td><td colspan="3">';
340 print
$object->code_fournisseur;
341 $tmpcheck =
$object->check_codefournisseur();
342 if ($tmpcheck != 0 && $tmpcheck != -5) {
343 print
' <span class="error">('.$langs->trans(
"WrongSupplierCode").
')</span>';
359 $sortfield =
GETPOST(
'sortfield',
'aZ09comma');
360 $sortorder =
GETPOST(
'sortorder',
'aZ09comma');
363 if (empty($page) || $page == -1) {
366 $offset = $limit * $page;
367 $pageprev = $page - 1;
368 $pagenext = $page + 1;
370 $sortorder =
"ASC,ASC";
373 $sortfield =
"soc.nom,t.date_begin";
378 't.fk_soc' => (
string)
$object->id
381 if (!empty($search_prod)) {
382 $filter [
'prod.ref'] = (
string) $search_prod;
385 if (!empty($search_label)) {
386 $filter [
'prod.label'] = (
string) $search_label;
389 if (!empty($search_price)) {
390 $filter [
't.price'] = (
string) $search_price;
393 if (!empty($search_price_ttc)) {
394 $filter [
't.price_ttc'] = (
string) $search_price_ttc;
397 if ($action ==
'add_customer_price') {
401 print
'<!-- Price by customer -->'.
"\n";
405 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'?socid='.
$object->id.
'" method="POST">';
406 print
'<input type="hidden" name="token" value="'.newToken().
'">';
407 print
'<input type="hidden" name="action" value="add_customer_price_confirm">';
408 print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
409 print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
410 print
'<input type="hidden" name="socid" value="'.$object->id.
'">';
411 print
'<table class="border centpercent">';
413 print
'<td>'.$langs->trans(
'Product').
'</td>';
415 $form->select_produits(
GETPOSTINT(
'prodid'),
'prodid',
'', 0);
420 print
'<tr><td>'.$langs->trans(
'RefCustomer').
'</td>';
421 print
'<td><input name="ref_customer" size="12"></td></tr>';
425 print
'<tr><td>'.$langs->trans(
"AppliedPricesFrom").
'</td><td>';
426 print $form->selectDate(!empty($date_begin) ? $date_begin :
dol_now(),
"date_begin", 0, 0, 1,
"date_begin");
431 print
'<tr><td>'.$langs->trans(
"AppliedPricesTo").
'</td><td>';
432 print $form->selectDate($date_end,
"date_end", 0, 0, 1,
"date_end");
436 print
'<tr><td>'.$langs->trans(
"VATRate").
'</td><td>';
437 print $form->load_tva(
"tva_tx",
GETPOST(
"tva_tx",
"alpha"),
$mysoc, $object, 0, 0,
'',
false, 1, 1);
441 print
'<tr><td width="15%">';
442 print $langs->trans(
'PriceBase');
445 print $form->selectPriceBaseType(
GETPOST(
"price_base_type",
"aZ09"),
"price_base_type");
450 print
'<tr><td width="20%">';
451 $text = $langs->trans(
'SellingPrice');
452 print $form->textwithpicto($text, $langs->trans(
"PrecisionUnitIsLimitedToXDecimals",
getDolGlobalString(
'MAIN_MAX_DECIMALS_UNIT')), 1,
'help');
454 print
'<input name="price" size="10" value="'.GETPOSTINT(
'price').
'">';
459 $text = $langs->trans(
'MinPrice');
460 print $form->textwithpicto($text, $langs->trans(
"PrecisionUnitIsLimitedToXDecimals",
getDolGlobalString(
'MAIN_MAX_DECIMALS_UNIT')), 1,
'help');
461 print
'<td><input name="price_min" size="10" value="'.GETPOSTINT(
'price_min').
'">';
466 print
'<tr><td>'.$langs->trans(
"Discount").
'</td><td>';
467 print
'<input name="discount_percent" size="10" value="'.price($discount_percent).
'">';
471 print
'<tr><td width="15%">';
472 print $langs->trans(
'ForceUpdateChildPriceSoc');
475 print
'<input type="checkbox" name="updatechildprice" value="1"/>';
480 $extrafields->fetch_name_optionals_label(
"product_customer_price");
481 $extralabels = !empty($extrafields->attributes[
"product_customer_price"][
'label']) ? $extrafields->attributes[
"product_customer_price"][
'label'] :
'';
482 $extrafield_values = $extrafields->getOptionalsFromPost(
"product_customer_price");
483 if (!empty($extralabels)) {
484 if (empty($prodcustprice->id)) {
485 foreach ($extralabels as $key => $value) {
486 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))) {
487 if (!empty($extrafields->attributes[
"product_customer_price"][
'langfile'][$key])) {
488 $langs->load($extrafields->attributes[
"product_customer_price"][
'langfile'][$key]);
491 print
'<tr><td'.($extrafields->attributes[
"product_customer_price"][
'required'][$key] ?
' class="fieldrequired"' :
'').
'>';
492 if (!empty($extrafields->attributes[
"product_customer_price"][
'help'][$key])) {
493 print $form->textwithpicto($langs->trans($value), $langs->trans($extrafields->attributes[
"product_customer_price"][
'help'][$key]));
495 print $langs->trans($value);
497 print
'</td><td>'.$extrafields->showInputField($key,
GETPOSTISSET(
'options_'.$key) ? $extrafield_values[
'options_'.$key] :
'',
'',
'',
'',
'', 0,
'product_customer_price').
'</td></tr>';
505 print $form->buttonsSaveCancel();
508 } elseif ($action ==
'edit_customer_price') {
513 $result = $prodcustprice->fetch(
GETPOSTINT(
'lineid'));
518 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'?socid='.
$object->id.
'" method="POST">';
519 print
'<input type="hidden" name="token" value="'.newToken().
'">';
520 print
'<input type="hidden" name="action" value="update_customer_price_confirm">';
521 print
'<input type="hidden" name="lineid" value="'.$prodcustprice->id.
'">';
522 print
'<table class="border centpercent">';
524 print
'<td>'.$langs->trans(
'Product').
'</td>';
526 $staticprod->fetch($prodcustprice->fk_product);
527 print
"<td>".$staticprod->getNomUrl(1).
"</td>";
531 print
'<tr><td>'.$langs->trans(
'RefCustomer').
'</td>';
532 print
'<td><input name="ref_customer" size="12" value="'.dol_escape_htmltag($prodcustprice->ref_customer).
'"></td></tr>';
535 print
'<tr><td>'.$langs->trans(
"AppliedPricesFrom").
'</td><td>';
536 print $form->selectDate($prodcustprice->date_begin,
"date_begin", 0, 0, 1,
"date_begin");
540 print
'<tr><td>'.$langs->trans(
"AppliedPricesTo").
'</td><td>';
541 print $form->selectDate($prodcustprice->date_end,
"date_end", 0, 0, 1,
"date_end");
545 print
'<tr><td>'.$langs->trans(
"VATRate").
'</td><td>';
546 print $form->load_tva(
"tva_tx", $prodcustprice->default_vat_code ? $prodcustprice->tva_tx.
' ('.$prodcustprice->default_vat_code.
')' : $prodcustprice->tva_tx,
$mysoc, null, $staticprod->id, $prodcustprice->recuperableonly,
'', false, 1, 1);
550 print
'<tr><td width="15%">';
551 print $langs->trans(
'PriceBase');
554 print $form->selectPriceBaseType($prodcustprice->price_base_type,
"price_base_type");
560 $text = $langs->trans(
'SellingPrice');
561 print $form->textwithpicto($text, $langs->trans(
"PrecisionUnitIsLimitedToXDecimals",
getDolGlobalString(
'MAIN_MAX_DECIMALS_UNIT')), 1,
'help');
563 if ($prodcustprice->price_base_type ==
'TTC') {
564 print
'<input name="price" size="10" value="'.price($prodcustprice->price_ttc).
'">';
566 print
'<input name="price" size="10" value="'.price($prodcustprice->price).
'">';
572 $text = $langs->trans(
'MinPrice');
573 print $form->textwithpicto($text, $langs->trans(
"PrecisionUnitIsLimitedToXDecimals",
getDolGlobalString(
'MAIN_MAX_DECIMALS_UNIT')), 1,
'help');
575 if ($prodcustprice->price_base_type ==
'TTC') {
576 print
'<input name="price_min" size="10" value="'.price($prodcustprice->price_min_ttc).
'">';
578 print
'<input name="price_min" size="10" value="'.price($prodcustprice->price_min).
'">';
583 print
'<tr><td>'.$langs->trans(
"Discount").
'</td><td>';
584 print
'<input name="discount_percent" size="10" value="'.price($prodcustprice->discount_percent).
'">';
588 $extrafields->fetch_name_optionals_label(
"product_customer_price");
589 $extralabels = !empty($extrafields->attributes[
"product_customer_price"][
'label']) ? $extrafields->attributes[
"product_customer_price"][
'label'] :
'';
590 $extrafield_values = $extrafields->getOptionalsFromPost(
"product_customer_price");
591 if (!empty($extralabels)) {
593 foreach ($extralabels as $key => $value) {
594 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_customer_price" && $extrafields->attributes[
"product_customer_price"][
'list'][$key] == 4))) {
595 if (!empty($extrafields->attributes[
"product_customer_price"][
'langfile'][$key])) {
596 $langs->load($extrafields->attributes[
"product_customer_price"][
'langfile'][$key]);
599 print
'<tr><td'.($extrafields->attributes[
"product_customer_price"][
'required'][$key] ?
' class="fieldrequired"' :
'').
'>';
600 if (!empty($extrafields->attributes[
"product_customer_price"][
'help'][$key])) {
601 print $form->textwithpicto($langs->trans($value), $langs->trans($extrafields->attributes[
"product_customer_price"][
'help'][$key]));
603 print $langs->trans($value);
605 print
'</td><td>'.$extrafields->showInputField($key,
GETPOSTISSET(
'options_'.$key) ? $extrafield_values[
'options_'.$key] :
'',
'',
'',
'',
'', 0,
'product_customer_price').
'</td></tr>';
610 $sql .=
" fk_object";
611 foreach ($extralabels as $key => $value) {
612 $sql .=
", ".$db->sanitize($key);
614 $sql .=
" FROM ".MAIN_DB_PREFIX.
"product_customer_price_extrafields";
615 $sql .=
" WHERE fk_object = ".((int) $prodcustprice->id);
616 $resql =
$db->query($sql);
618 $obj =
$db->fetch_object($resql);
619 foreach ($extralabels as $key => $value) {
620 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_customer_price" && $extrafields->attributes[
"product_customer_price"][
'list'][$key] == 4))) {
621 if (!empty($extrafields->attributes[
"product_customer_price"][
'langfile'][$key])) {
622 $langs->load($extrafields->attributes[
"product_customer_price"][
'langfile'][$key]);
625 print
'<tr><td'.($extrafields->attributes[
"product_customer_price"][
'required'][$key] ?
' class="fieldrequired"' :
'').
'>';
626 if (!empty($extrafields->attributes[
"product_customer_price"][
'help'][$key])) {
627 print $form->textwithpicto($langs->trans($value), $langs->trans($extrafields->attributes[
"product_customer_price"][
'help'][$key]));
629 print $langs->trans($value);
631 print
'</td><td>'.$extrafields->showInputField($key,
GETPOSTISSET(
'options_'.$key) ? $extrafield_values[
'options_'.$key] : $obj->{$key},
'',
'',
'',
'', 0,
'product_customer_price');
645 print
'<input type="checkbox" name="updatechildprice" id="updatechildprice" value="1"> ';
646 print
'<label for="updatechildprice">'.$langs->trans(
'ForceUpdateChildPriceSoc').
'</label>';
649 print $form->buttonsSaveCancel();
653 } elseif ($action ==
'showlog_customer_price') {
655 print
'<!-- showlog_customer_price -->'.
"\n";
657 $sortfield =
't.datec';
659 't.fk_product' => (
string)
GETPOSTINT(
'prodid'),
660 't.fk_soc' => (
string) $socid
664 $nbtotalofrecords =
'';
665 $result = $prodcustprice->fetchAllLog($sortorder, $sortfield,
$conf->liste_limit, $offset, $filter);
670 $nbtotalofrecords = $result;
674 $option =
'&socid='.GETPOSTINT(
'socid').
'&prodid='.
GETPOSTINT(
'prodid');
677 print_barre_liste($langs->trans(
'PriceByCustomerLog'), $page, $_SERVER [
'PHP_SELF'], $option, $sortfield, $sortorder,
'', count($prodcustprice->lines), $nbtotalofrecords);
679 if (count($prodcustprice->lines) > 0) {
680 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'" method="POST">';
681 print
'<input type="hidden" name="token" value="'.newToken().
'">';
682 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
684 print
'<table class="noborder centpercent">';
686 print
'<tr class="liste_titre">';
687 print
'<td>'.$langs->trans(
"Product").
'</td>';
688 print
'<td>'.$langs->trans(
'RefCustomer').
'</td>';
689 print
'<td>'.$langs->trans(
"AppliedPricesFrom").
'</td>';
690 print
'<td>'.$langs->trans(
"AppliedPricesTo").
'</td>';
691 print
'<td class="center">'.$langs->trans(
"PriceBase").
'</td>';
692 print
'<td class="right">'.$langs->trans(
"VAT").
'</td>';
693 print
'<td class="right">'.$langs->trans(
"HT").
'</td>';
694 print
'<td class="right">'.$langs->trans(
"TTC").
'</td>';
695 print
'<td class="right">'.$langs->trans(
"MinPrice").
' '.$langs->trans(
"HT").
'</td>';
696 print
'<td class="right">'.$langs->trans(
"MinPrice").
' '.$langs->trans(
"TTC").
'</td>';
697 print
'<td class="right">'.$langs->trans(
"Discount").
'</td>';
698 print
'<td class="right">'.$langs->trans(
"ChangedBy").
'</td>';
699 print
'<td>'.$langs->trans(
"DateCreation").
'</td>';
702 foreach ($prodcustprice->lines as $line) {
704 $staticprod->fetch($line->fk_product);
707 $userstatic->fetch($line->fk_user);
709 print
'<tr class="oddeven">';
711 print
"<td>".$staticprod->getNomUrl(1).
"</td>";
712 print
'<td>'.$line->ref_customer.
'</td>';
713 print
"<td>".dol_print_date($line->date_begin,
"day",
'tzuserrel').
"</td>";
714 print
"<td>".dol_print_date($line->date_end,
"day",
'tzuserrel').
"</td>";
716 print
'<td class="center">'.$langs->trans($line->price_base_type).
"</td>";
717 print
'<td class="right">'.vatrate($line->tva_tx,
true, $line->recuperableonly).
"</td>";
718 print
'<td class="right">'.price($line->price).
"</td>";
719 print
'<td class="right">'.price($line->price_ttc).
"</td>";
720 print
'<td class="right">'.price($line->price_min).
'</td>';
721 print
'<td class="right">'.price($line->price_min_ttc).
'</td>';
722 print
'<td class="right">'.price($line->discount_percent).
'</td>';
725 print
'<td class="right">';
726 print $userstatic->getNomUrl(-1);
728 print
"<td>".dol_print_date($line->datec,
"dayhour",
'tzuserrel').
"</td>";
732 print $langs->trans(
'None');
735 print
"\n".
'<div class="tabsAction">'.
"\n";
736 print
'<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?socid='.
$object->id.
'">'.$langs->trans(
"Ok").
'</a></div>';
737 print
"\n</div><br>\n";
744 print
"\n".
'<div class="tabsAction">'.
"\n";
746 if ($user->hasRight(
'produit',
'creer') || $user->hasRight(
'service',
'creer')) {
747 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>';
752 $arrayfields = array();
753 foreach ($prodcustprice->fields as $key => $val) {
755 if (!empty($val[
'visible'])) {
756 $visible = (int)
dol_eval((
string) $val[
'visible'], 1, 1,
'1');
757 $arrayfields[
't.'.$key] = array(
758 'label' => $val[
'label'],
759 'checked' => (($visible < 0) ? 0 : 1),
760 'enabled' => (abs($visible) != 3 && (bool)
dol_eval((
string) $val[
'enabled'], 1)),
761 'position' => $val[
'position'],
762 'help' => isset($val[
'help']) ? $val[
'help'] :
''
767 $extrafields->fetch_name_optionals_label(
"product_customer_price");
768 if ($extrafields->attributes[
"product_customer_price"] && array_key_exists(
'label', $extrafields->attributes[
"product_customer_price"])) {
769 $extralabels = $extrafields->attributes[
"product_customer_price"][
'label'];
771 if (!empty($extralabels)) {
772 foreach ($extralabels as $key => $value) {
774 if (!empty($extrafields->attributes[
"product_customer_price"][
'list'][$key]) && $extrafields->attributes[
"product_customer_price"][
'list'][$key] != 3) {
775 $extratitle = $langs->trans($value);
776 if (!empty($val[
'visible'])) {
777 $visible = (int)
dol_eval((
string) $val[
'visible'], 1, 1,
'1');
778 $arrayfields[
'ef.' . $key] = array(
779 'label' => $extratitle,
780 'checked' => (($visible < 0) ? 0 : 1),
781 'position' => (int) $extrafields->attributes[
'product_customer_price'][
'pos'][$key],
782 'langfile' => $extrafields->attributes[
"product_customer_price"][
'langfile'][$key],
783 'help' => $extrafields->attributes[
"product_customer_price"][
'help'][$key]
794 $nbtotalofrecords =
'';
796 $nbtotalofrecords = $prodcustprice->fetchAll(
'',
'', 0, 0, $filter);
799 $result = $prodcustprice->fetchAll($sortorder, $sortfield, $limit, $offset, $filter);
804 $option =
'&search_prod='.urlencode($search_prod).
'&id='.
$object->id.
'&search_label='.urlencode($search_label).
'&search_price='.urlencode($search_price).
'&search_price_ttc='.urlencode($search_price_ttc);
806 print
'<!-- view specific price for each product -->'.
"\n";
809 print_barre_liste($langs->trans(
'PriceForEachProduct'), $page, $_SERVER[
'PHP_SELF'], $option, $sortfield, $sortorder,
'', count($prodcustprice->lines), $nbtotalofrecords,
'product');
811 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'" method="POST">';
812 print
'<input type="hidden" name="token" value="'.newToken().
'">';
813 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
814 if (!empty($sortfield)) {
815 print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'"/>';
817 if (!empty($sortorder)) {
818 print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'"/>';
820 print
'<div class="div-table-responsive-no-min">';
821 print
'<table class="noborder centpercent liste">';
823 $param =
'socid='.$object->id.
'&';
825 $param .=
'&search_prod='.urlencode($search_prod);
828 $param .=
'&search_label='.urlencode($search_label);
831 $param .=
'&search_price='.urlencode($search_price);
834 $param .=
'&search_price='.urlencode($search_price);
836 if ($search_price_ttc) {
837 $param .=
'&search_price_ttc='.urlencode($search_price_ttc);
840 print
'<tr class="liste_titre">';
844 foreach ($prodcustprice->fields as $key => $val) {
845 if (!empty($arrayfields[
't.'.$key][
'checked'])) {
846 print
getTitleFieldOfList($arrayfields[
't.'.$key][
'label'], 0, $_SERVER[
'PHP_SELF'], $key,
'', $param,
'', $sortfield, $sortorder).
"\n";
850 if (!empty($extralabels) && is_array($extralabels)) {
851 foreach ($extralabels as $key => $val) {
852 if (!empty($arrayfields[
'ef.'.$key][
'checked'])) {
853 print
getTitleFieldOfList($arrayfields[
'ef.'.$key][
'label'], 0, $_SERVER[
'PHP_SELF'], $key,
'', $param,
'', $sortfield, $sortorder).
"\n";
863 if (count($prodcustprice->lines) > 0 || $search_prod) {
864 print
'<tr class="liste_titre">';
865 print
'<td class="liste_titre"><input type="text" class="flat width75" name="search_prod" value="'.$search_prod.
'"></td>';
866 print
'<td class="liste_titre" ><input type="text" class="flat width75" name="search_label" value="'.$search_label.
'"></td>';
867 print
'<td class="liste_titre"></td>';
868 print
'<td class="liste_titre"></td>';
869 print
'<td class="liste_titre"></td>';
870 print
'<td class="liste_titre"></td>';
871 print
'<td class="liste_titre"></td>';
872 print
'<td class="liste_titre left"><input type="text" class="flat width75" name="search_price" value="'.$search_price.
'"></td>';
873 print
'<td class="liste_titre left"><input type="text" class="flat width75" name="search_price_ttc" value="'.$search_price_ttc.
'"></td>';
874 print
'<td class="liste_titre"></td>';
875 print
'<td class="liste_titre"></td>';
876 print
'<td class="liste_titre"></td>';
877 print
'<td class="liste_titre"></td>';
878 print
'<td class="liste_titre"></td>';
879 if (!empty($extralabels)) {
880 foreach ($extralabels as $key) {
881 print
'<td class="right"></td>';
885 print
'<td class="liste_titre maxwidthsearch">';
886 $searchpicto = $form->showFilterAndCheckAddButtons(0);
892 if (count($prodcustprice->lines) > 0) {
893 foreach ($prodcustprice->lines as $line) {
895 $staticprod->fetch($line->fk_product);
898 $userstatic->fetch($line->fk_user);
900 print
'<tr class="oddeven">';
902 print
'<td class="left">'.$staticprod->getNomUrl(1).
"</td>";
903 print
'<td class="left">'.$staticprod->label.
"</td>";
904 print
'<td class="left">'.$line->ref_customer.
'</td>';
905 print
'<td class="left">'.dol_print_date($line->date_begin,
"day",
'tzuserrel').
"</td>";
906 print
'<td class="left">'.dol_print_date($line->date_end,
"day",
'tzuserrel').
"</td>";
907 print
'<td class="left">'.$langs->trans($line->price_base_type).
"</td>";
908 print
'<td class="left">'.vatrate($line->tva_tx.($line->default_vat_code ?
' ('.$line->default_vat_code.
')' :
''), true, $line->recuperableonly).
"</td>";
909 print
'<td class="left">'.price($line->price).
"</td>";
910 print
'<td class="left">'.price($line->price_ttc).
"</td>";
911 print
'<td class="left">'.price($line->price_min).
'</td>';
912 print
'<td class="left">'.price($line->price_min_ttc).
'</td>';
913 print
'<td class="left">'.$line->price_label.
'</td>';
914 print
'<td class="left">'.price($line->discount_percent).
'</td>';
916 print
'<td class="left">';
917 print $userstatic->getNomUrl(-1);
921 $extrafields->fetch_name_optionals_label(
"product_customer_price");
922 $extralabels = !empty($extrafields->attributes[
"product_customer_price"][
'label']) ? $extrafields->attributes[
"product_customer_price"][
'label'] :
'';
923 if (!empty($extralabels)) {
925 $sql .=
" fk_object";
926 foreach ($extralabels as $key => $value) {
927 $sql .=
", ".$db->sanitize($key);
929 $sql .=
" FROM ".MAIN_DB_PREFIX.
"product_customer_price_extrafields";
930 $sql .=
" WHERE fk_object = ".((int) $line->id);
931 $resql =
$db->query($sql);
933 if (
$db->num_rows($resql) != 1) {
934 foreach ($extralabels as $key => $value) {
935 if (!empty($extrafields->attributes[
"product_customer_price"][
'list'][$key]) && $extrafields->attributes[
"product_customer_price"][
'list'][$key] != 3) {
940 $obj =
$db->fetch_object($resql);
941 foreach ($extralabels as $key => $value) {
942 if (!empty($extrafields->attributes[
"product_customer_price"][
'list'][$key]) && $extrafields->attributes[
"product_customer_price"][
'list'][$key] != 3) {
943 print
'<td align="right">'.$extrafields->showOutputField($key, $obj->{$key},
'',
'product_customer_price').
"</td>";
951 if ($user->hasRight(
'produit',
'creer') || $user->hasRight(
'service',
'creer')) {
952 print
'<td class="right nowraponall">';
953 print
'<a class="paddingleftonly paddingrightonly" href="'.$_SERVER[
"PHP_SELF"].
'?action=showlog_customer_price&token='.
newToken().
'&socid='.
$object->id.
'&prodid='.$line->fk_product.
'">';
957 print
'<a class="editfielda paddingleftonly paddingrightonly" href="'.$_SERVER[
"PHP_SELF"].
'?action=edit_customer_price&token='.
newToken().
'&socid='.
$object->id.
'&lineid='.$line->id.
'">';
958 print
img_edit(
'default', 0,
'style="vertical-align: middle;"');
961 print
'<a class="paddingleftonly paddingrightonly" href="'.$_SERVER[
"PHP_SELF"].
'?action=delete_customer_price&token='.
newToken().
'&socid='.
$object->id.
'&lineid='.$line->id.
'">';
962 print
img_delete(
'default',
'style="vertical-align: middle;"');
970 if ($user->hasRight(
'produit',
'supprimer') || $user->hasRight(
'service',
'supprimer')) {
973 print
'<tr class="oddeven"><td colspan="'.$colspan.
'"><span class="opacitymedium">'.$langs->trans(
'None').
'</span></td></tr>';
if(! $sortfield) if(! $sortorder) $object
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
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, $subtabs='')
Return array of tabs to used on pages for third parties cards.
dol_now($mode='gmt')
Return date for now.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed information (by default a local PHP server timestamp) Rep...
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.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0, $morecssdiv='')
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'.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0, $nodefault=0)
Return value of a param into GET or POST supervariable.
getTitleFieldOfList($name, $thead=0, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $disablesortlink=0, $tooltip='', $forcenowrapcolumntitle=0)
Get title line of an array.
GETPOSTINT($paramname, $method=0, $nodefault=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
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.
print $langs trans("Show") . '< td style="' . $timeColor . '" align="center"> s</td > badge status0 badge status4 badge status3 Error badge status8< td align="center">< span class="badge ' . $badge . '"></span ></td >< td align="center">< a href="#" class="button button-small" onclick="openLogModal(this)" data-req="' . dol_escape_htmltag($reqSafe) . '" data-res="' . dol_escape_htmltag($resSafe) . '" data-err="' . dol_escape_htmltag($errSafe) . '">< span class="fa fa-search-plus"></span ></a ></td ></tr >< tr >< td colspan="' . $colspan . '" class="opacitymedium"></td ></tr ></table ></div ></form > logModal none logModal none s a JSON string
buildzip.php
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $nodie=0, $mode='')
Check permissions of a user to show a page and an object.