dolibarr  16.0.5
price.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2001-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3  * Copyright (C) 2004-2015 Laurent Destailleur <eldy@users.sourceforge.net>
4  * Copyright (C) 2005 Eric Seigne <eric.seigne@ryxeo.com>
5  * Copyright (C) 2005-2013 Regis Houssin <regis.houssin@inodbox.com>
6  * Copyright (C) 2006 Andre Cianfarani <acianfa@free.fr>
7  * Copyright (C) 2015 Marcos GarcĂ­a <marcosgdf@gmail.com>
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 3 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program. If not, see <https://www.gnu.org/licenses/>.
21  */
22 
29 require '../main.inc.php';
30 require_once DOL_DOCUMENT_ROOT.'/core/lib/product.lib.php';
31 require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
32 require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
33 require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
34 
35 if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) {
36  require_once DOL_DOCUMENT_ROOT.'/product/class/productcustomerprice.class.php';
37 
38  $prodcustprice = new Productcustomerprice($db);
39 }
40 
41 $langs->loadLangs(array("products", "companies", "bills"));
42 
43 $action = GETPOST('action', 'aZ09');
44 $search_prod = GETPOST('search_prod', 'alpha');
45 $cancel = GETPOST('cancel', 'alpha');
46 $search_label = GETPOST('search_label', 'alpha');
47 $search_price = GETPOST('search_price');
48 $search_price_ttc = GETPOST('search_price_ttc');
49 
50 // Security check
51 $socid = GETPOST('socid', 'int') ?GETPOST('socid', 'int') : GETPOST('id', 'int');
52 if ($user->socid) {
53  $socid = $user->socid;
54 }
55 $result = restrictedArea($user, 'societe', $socid, '&societe');
56 
57 $object = new Societe($db);
58 
59 // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
60 $hookmanager->initHooks(array('thirdpartycustomerprice', 'globalcard'));
61 
62 $error = 0;
63 
64 
65 /*
66  * Actions
67  */
68 
69 $parameters = array('id'=>$socid);
70 $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
71 if ($reshook < 0) {
72  setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
73 }
74 
75 if (empty($reshook)) {
76  if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // Both test are required to be compatible with all browsers
77  $search_prod = $search_label = $search_price = $search_price_ttc = '';
78  }
79 
80  if ($action == 'add_customer_price_confirm' && !$cancel && ($user->rights->produit->creer || $user->rights->service->creer)) {
81  if (!(GETPOST('prodid', 'int') > 0)) {
82  $error++;
83  setEventMessages($langs->trans("ErrorFieldRequired", $langs->trans("Product")), null, 'errors');
84  $action = 'add_customer_price';
85  }
86 
87  if (!$error) {
88  $update_child_soc = GETPOST('updatechildprice');
89 
90  // add price by customer
91  $prodcustprice->fk_soc = $socid;
92  $prodcustprice->ref_customer = GETPOST('ref_customer', 'alpha');
93  $prodcustprice->fk_product = GETPOST('prodid', 'int');
94  $prodcustprice->price = price2num(GETPOST("price"), 'MU');
95  $prodcustprice->price_min = price2num(GETPOST("price_min"), 'MU');
96  $prodcustprice->price_base_type = GETPOST("price_base_type", 'alpha');
97 
98  $tva_tx_txt = GETPOST('tva_tx', 'alpha'); // tva_tx can be '8.5' or '8.5*' or '8.5 (XXX)' or '8.5* (XXX)'
99 
100  // We must define tva_tx, npr and local taxes
101  $vatratecode = '';
102  $tva_tx = preg_replace('/[^0-9\.].*$/', '', $tva_tx_txt); // keep remove all after the numbers and dot
103  $npr = preg_match('/\*/', $tva_tx_txt) ? 1 : 0;
104  $localtax1 = 0; $localtax2 = 0; $localtax1_type = '0'; $localtax2_type = '0';
105  // If value contains the unique code of vat line (new recommended method), we use it to find npr and local taxes
106  if (preg_match('/\((.*)\)/', $tva_tx_txt, $reg)) {
107  // We look into database using code (we can't use get_localtax() because it depends on buyer that is not known). Same in update price.
108  $vatratecode = $reg[1];
109  // Get record from code
110  $sql = "SELECT t.rowid, t.code, t.recuperableonly, t.localtax1, t.localtax2, t.localtax1_type, t.localtax2_type";
111  $sql .= " FROM ".MAIN_DB_PREFIX."c_tva as t, ".MAIN_DB_PREFIX."c_country as c";
112  $sql .= " WHERE t.fk_pays = c.rowid AND c.code = '".$db->escape($mysoc->country_code)."'";
113  $sql .= " AND t.taux = ".((float) $tva_tx)." AND t.active = 1";
114  $sql .= " AND t.code ='".$db->escape($vatratecode)."'";
115  $resql = $db->query($sql);
116  if ($resql) {
117  $obj = $db->fetch_object($resql);
118  $npr = $obj->recuperableonly;
119  $localtax1 = $obj->localtax1;
120  $localtax2 = $obj->localtax2;
121  $localtax1_type = $obj->localtax1_type;
122  $localtax2_type = $obj->localtax2_type;
123  }
124  }
125 
126  $prodcustprice->default_vat_code = $vatratecode;
127  $prodcustprice->tva_tx = $tva_tx;
128  $prodcustprice->recuperableonly = $npr;
129  $prodcustprice->localtax1_tx = $localtax1;
130  $prodcustprice->localtax2_tx = $localtax2;
131  $prodcustprice->localtax1_type = $localtax1_type;
132  $prodcustprice->localtax2_type = $localtax2_type;
133 
134  $result = $prodcustprice->create($user, 0, $update_child_soc);
135 
136  if ($result < 0) {
137  setEventMessages($prodcustprice->error, $prodcustprice->errors, 'errors');
138  } else {
139  setEventMessages($langs->trans("Save"), null, 'mesgs');
140  }
141 
142  $action = '';
143  }
144  }
145 
146  if ($action == 'delete_customer_price' && ($user->rights->produit->creer || $user->rights->service->creer)) {
147  // Delete price by customer
148  $prodcustprice->id = GETPOST('lineid', 'int');
149  $result = $prodcustprice->delete($user);
150 
151  if ($result < 0) {
152  setEventMessages($prodcustprice->error, $prodcustprice->errors, 'mesgs');
153  } else {
154  setEventMessages($langs->trans('Delete'), null, 'errors');
155  }
156  $action = '';
157  }
158 
159  if ($action == 'update_customer_price_confirm' && !$cancel && ($user->rights->produit->creer || $user->rights->service->creer)) {
160  $prodcustprice->fetch(GETPOST('lineid', 'int'));
161 
162  $update_child_soc = GETPOST('updatechildprice');
163 
164  // update price by customer
165  $prodcustprice->ref_customer = GETPOST('ref_customer', 'alpha');
166  $prodcustprice->price = price2num(GETPOST("price"), 'MU');
167  $prodcustprice->price_min = price2num(GETPOST("price_min"), 'MU');
168  $prodcustprice->price_base_type = GETPOST("price_base_type", 'alpha');
169  $prodcustprice->tva_tx = str_replace('*', '', GETPOST("tva_tx"));
170  $prodcustprice->recuperableonly = (preg_match('/\*/', GETPOST("tva_tx")) ? 1 : 0);
171 
172  $result = $prodcustprice->update($user, 0, $update_child_soc);
173  if ($result < 0) {
174  setEventMessages($prodcustprice->error, $prodcustprice->errors, 'errors');
175  } else {
176  setEventMessages($langs->trans("Save"), null, 'mesgs');
177  }
178 
179  $action = '';
180  }
181 }
182 
183 
184 /*
185  * View
186  */
187 
188 $form = new Form($db);
189 
190 $object = new Societe($db);
191 
192 $result = $object->fetch($socid);
193 llxHeader("", $langs->trans("ThirdParty").'-'.$langs->trans('PriceByCustomer'));
194 
195 if (!empty($conf->notification->enabled)) {
196  $langs->load("mails");
197 }
198 $head = societe_prepare_head($object);
199 
200 print dol_get_fiche_head($head, 'price', $langs->trans("ThirdParty"), -1, 'company');
201 
202 $linkback = '<a href="'.DOL_URL_ROOT.'/societe/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
203 
204 dol_banner_tab($object, 'socid', $linkback, ($user->socid ? 0 : 1), 'rowid', 'nom');
205 
206 print '<div class="fichecenter">';
207 
208 print '<div class="underbanner clearboth"></div>';
209 print '<table class="border centpercent tableforfield">';
210 
211 if (!empty($conf->global->SOCIETE_USEPREFIX)) { // Old not used prefix field
212  print '<tr><td class="titlefield">'.$langs->trans('Prefix').'</td><td colspan="3">'.$object->prefix_comm.'</td></tr>';
213 }
214 
215 if ($object->client) {
216  print '<tr><td class="titlefield">';
217  print $langs->trans('CustomerCode').'</td><td colspan="3">';
218  print $object->code_client;
219  $tmpcheck = $object->check_codeclient();
220  if ($tmpcheck != 0 && $tmpcheck != -5) {
221  print ' <span class="error">('.$langs->trans("WrongCustomerCode").')</span>';
222  }
223  print '</td></tr>';
224 }
225 
226 if ($object->fournisseur) {
227  print '<tr><td class="titlefield">';
228  print $langs->trans('SupplierCode').'</td><td colspan="3">';
229  print $object->code_fournisseur;
230  $tmpcheck = $object->check_codefournisseur();
231  if ($tmpcheck != 0 && $tmpcheck != -5) {
232  print ' <span class="error">('.$langs->trans("WrongSupplierCode").')</span>';
233  }
234  print '</td></tr>';
235 }
236 
237 print '</table>';
238 
239 print '</div>';
240 
241 print dol_get_fiche_end();
242 
243 
244 
245 if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) {
246  $prodcustprice = new Productcustomerprice($db);
247 
248  $sortfield = GETPOST('sortfield', 'aZ09comma');
249  $sortorder = GETPOST('sortorder', 'aZ09comma');
250  $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
251  $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
252  if (empty($page) || $page == -1) {
253  $page = 0;
254  } // If $page is not defined, or '' or -1
255  $offset = $limit * $page;
256  $pageprev = $page - 1;
257  $pagenext = $page + 1;
258  if (!$sortorder) {
259  $sortorder = "ASC";
260  }
261  if (!$sortfield) {
262  $sortfield = "soc.nom";
263  }
264 
265  // Build filter to display only concerned lines
266  $filter = array(
267  't.fk_soc' => $object->id
268  );
269 
270  if (!empty($search_prod)) {
271  $filter ['prod.ref'] = $search_prod;
272  }
273 
274  if (!empty($search_label)) {
275  $filter ['prod.label'] = $search_label;
276  }
277 
278  if (!empty($search_price)) {
279  $filter ['t.price'] = $search_price;
280  }
281 
282  if (!empty($search_price_ttc)) {
283  $filter ['t.price_ttc'] = $search_price_ttc;
284  }
285 
286  if ($action == 'add_customer_price') {
287  // Create mode
288 
289  print '<br>';
290  print '<!-- Price by customer -->'."\n";
291 
292  print load_fiche_titre($langs->trans('PriceByCustomer'));
293 
294  print '<form action="'.$_SERVER["PHP_SELF"].'?socid='.$object->id.'" method="POST">';
295  print '<input type="hidden" name="token" value="'.newToken().'">';
296  print '<input type="hidden" name="action" value="add_customer_price_confirm">';
297  print '<input type="hidden" name="socid" value="'.$object->id.'">';
298  print '<table class="border centpercent">';
299  print '<tr>';
300  print '<td>'.$langs->trans('Product').'</td>';
301  print '<td>';
302  $form->select_produits('', 'prodid', '', 0);
303  print '</td>';
304  print '</tr>';
305 
306  // Ref. Customer
307  print '<tr><td>'.$langs->trans('RefCustomer').'</td>';
308  print '<td><input name="ref_customer" size="12"></td></tr>';
309 
310  // VAT
311  print '<tr><td>'.$langs->trans("VATRate").'</td><td>';
312  print $form->load_tva("tva_tx", $object->tva_tx, $mysoc, '', $object->id, $object->tva_npr, '', false, 1);
313  print '</td></tr>';
314 
315  // Price base
316  print '<tr><td width="15%">';
317  print $langs->trans('PriceBase');
318  print '</td>';
319  print '<td>';
320  print $form->selectPriceBaseType($object->price_base_type, "price_base_type");
321  print '</td>';
322  print '</tr>';
323 
324  // Price
325  print '<tr><td width="20%">';
326  $text = $langs->trans('SellingPrice');
327  print $form->textwithpicto($text, $langs->trans("PrecisionUnitIsLimitedToXDecimals", $conf->global->MAIN_MAX_DECIMALS_UNIT), 1, 1);
328  print '</td><td>';
329  print '<input name="price" size="10" value="'.GETPOST('price', 'int').'">';
330  print '</td></tr>';
331 
332  // Price minimum
333  print '<tr><td>';
334  $text = $langs->trans('MinPrice');
335  print $form->textwithpicto($text, $langs->trans("PrecisionUnitIsLimitedToXDecimals", $conf->global->MAIN_MAX_DECIMALS_UNIT), 1, 1);
336  print '<td><input name="price_min" size="10" value="'.GETPOST('price_min', 'int').'">';
337  print '</td></tr>';
338 
339  // Update all child soc
340  print '<tr><td width="15%">';
341  print $langs->trans('ForceUpdateChildPriceSoc');
342  print '</td>';
343  print '<td>';
344  print '<input type="checkbox" name="updatechildprice" value="1"/>';
345  print '</td>';
346  print '</tr>';
347 
348  print '</table>';
349 
350  print $form->buttonsSaveCancel();
351 
352  print '</form>';
353  } elseif ($action == 'edit_customer_price') {
354  // Edit mode
355 
356  print load_fiche_titre($langs->trans('PriceByCustomer'));
357 
358  $result = $prodcustprice->fetch(GETPOST('lineid', 'int'));
359 
360  if ($result <= 0) {
361  setEventMessages($prodcustprice->error, $prodcustprice->errors, 'errors');
362  } else {
363  print '<form action="'.$_SERVER["PHP_SELF"].'?socid='.$object->id.'" method="POST">';
364  print '<input type="hidden" name="token" value="'.newToken().'">';
365  print '<input type="hidden" name="action" value="update_customer_price_confirm">';
366  print '<input type="hidden" name="lineid" value="'.$prodcustprice->id.'">';
367  print '<table class="border centpercent">';
368  print '<tr>';
369  print '<td>'.$langs->trans('Product').'</td>';
370  $staticprod = new Product($db);
371  $staticprod->fetch($prodcustprice->fk_product);
372  print "<td>".$staticprod->getNomUrl(1)."</td>";
373  print '</tr>';
374 
375  // Ref. Customer
376  print '<tr><td>'.$langs->trans('RefCustomer').'</td>';
377  print '<td><input name="ref_customer" size="12" value="'.dol_escape_htmltag($prodcustprice->ref_customer).'"></td></tr>';
378 
379  // VAT
380  print '<tr><td>'.$langs->trans("VATRate").'</td><td>';
381  print $form->load_tva("tva_tx", $prodcustprice->tva_tx, $mysoc, '', $staticprod->id, $prodcustprice->recuperableonly);
382  print '</td></tr>';
383 
384  // Price base
385  print '<tr><td width="15%">';
386  print $langs->trans('PriceBase');
387  print '</td>';
388  print '<td>';
389  print $form->selectPriceBaseType($prodcustprice->price_base_type, "price_base_type");
390  print '</td>';
391  print '</tr>';
392 
393  // Price
394  print '<tr><td>';
395  $text = $langs->trans('SellingPrice');
396  print $form->textwithpicto($text, $langs->trans("PrecisionUnitIsLimitedToXDecimals", $conf->global->MAIN_MAX_DECIMALS_UNIT), 1, 1);
397  print '</td><td>';
398  if ($prodcustprice->price_base_type == 'TTC') {
399  print '<input name="price" size="10" value="'.price($prodcustprice->price_ttc).'">';
400  } else {
401  print '<input name="price" size="10" value="'.price($prodcustprice->price).'">';
402  }
403  print '</td></tr>';
404 
405  // Price minimum
406  print '<tr><td>';
407  $text = $langs->trans('MinPrice');
408  print $form->textwithpicto($text, $langs->trans("PrecisionUnitIsLimitedToXDecimals", $conf->global->MAIN_MAX_DECIMALS_UNIT), 1, 1);
409  print '</td><td>';
410  if ($prodcustprice->price_base_type == 'TTC') {
411  print '<input name="price_min" size="10" value="'.price($prodcustprice->price_min_ttc).'">';
412  } else {
413  print '<input name="price_min" size="10" value="'.price($prodcustprice->price_min).'">';
414  }
415  print '</td></tr>';
416 
417  // Update all child soc
418  print '<tr><td>';
419  print $langs->trans('ForceUpdateChildPriceSoc');
420  print '</td>';
421  print '<td>';
422  print '<input type="checkbox" name="updatechildprice" value="1">';
423  print '</td>';
424  print '</tr>';
425 
426  print '</table>';
427 
428  print $form->buttonsSaveCancel();
429 
430  print '</form>';
431  }
432  } elseif ($action == 'showlog_customer_price') {
433  print '<br>';
434  print '<!-- showlog_customer_price -->'."\n";
435 
436  $filter = array(
437  't.fk_product' => GETPOST('prodid', 'int'),
438  't.fk_soc' => $socid
439  );
440 
441  // Count total nb of records
442  $nbtotalofrecords = '';
443  $result = $prodcustprice->fetch_all_log($sortorder, $sortfield, $conf->liste_limit, $offset, $filter);
444  if ($result < 0) {
445  setEventMessages($prodcustprice->error, $prodcustprice->errors, 'errors');
446  } else {
447  if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
448  $nbtotalofrecords = $result;
449  }
450  }
451 
452  $option = '&socid='.GETPOST('socid', 'int').'&prodid='.GETPOST('prodid', 'int');
453 
454  print_barre_liste($langs->trans('PriceByCustomerLog'), $page, $_SERVER ['PHP_SELF'], $option, $sortfield, $sortorder, '', count($prodcustprice->lines), $nbtotalofrecords);
455 
456  if (count($prodcustprice->lines) > 0) {
457  print '<form action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'" method="POST">';
458  print '<input type="hidden" name="token" value="'.newToken().'">';
459  print '<input type="hidden" name="id" value="'.$object->id.'">';
460 
461  print '<table class="noborder centpercent">';
462 
463  print '<tr class="liste_titre">';
464  print '<td>'.$langs->trans("Product").'</td>';
465  print '<td>'.$langs->trans('RefCustomer').'</td>';
466  print '<td>'.$langs->trans("AppliedPricesFrom").'</td>';
467  print '<td class="center">'.$langs->trans("PriceBase").'</td>';
468  print '<td class="right">'.$langs->trans("VAT").'</td>';
469  print '<td class="right">'.$langs->trans("HT").'</td>';
470  print '<td class="right">'.$langs->trans("TTC").'</td>';
471  print '<td class="right">'.$langs->trans("MinPrice").' '.$langs->trans("HT").'</td>';
472  print '<td class="right">'.$langs->trans("MinPrice").' '.$langs->trans("TTC").'</td>';
473  print '<td class="right">'.$langs->trans("ChangedBy").'</td>';
474  print '<td></td>';
475  print '</tr>';
476 
477  foreach ($prodcustprice->lines as $line) {
478  $staticprod = new Product($db);
479  $staticprod->fetch($line->fk_product);
480 
481  $userstatic = new User($db);
482  $userstatic->fetch($line->fk_user);
483 
484  print '<tr class="oddeven">';
485 
486  print "<td>".$staticprod->getNomUrl(1)."</td>";
487  print '<td>'.$line->ref_customer.'</td>';
488  print "<td>".dol_print_date($line->datec, "dayhour")."</td>";
489 
490  print '<td class="center">'.$langs->trans($line->price_base_type)."</td>";
491  print '<td class="right">'.vatrate($line->tva_tx, true, $line->recuperableonly)."</td>";
492  print '<td class="right">'.price($line->price)."</td>";
493  print '<td class="right">'.price($line->price_ttc)."</td>";
494  print '<td class="right">'.price($line->price_min).'</td>';
495  print '<td class="right">'.price($line->price_min_ttc).'</td>';
496 
497  // User
498  print '<td class="right">';
499  print $userstatic->getNomUrl(-1);
500  print '</td>';
501  print '<td></td>';
502  }
503  print "</table>";
504  } else {
505  print $langs->trans('None');
506  }
507 
508  print "\n".'<div class="tabsAction">'."\n";
509  print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?socid='.$object->id.'">'.$langs->trans("Ok").'</a></div>';
510  print "\n</div><br>\n";
511  } else {
512  // View mode
513 
514  /*
515  * Action bar
516  */
517  print "\n".'<div class="tabsAction">'."\n";
518 
519  if ($user->rights->produit->creer || $user->rights->service->creer) {
520  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>';
521  }
522  print "\n</div>\n";
523 
524 
525  // Count total nb of records
526  $nbtotalofrecords = '';
527  if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
528  $nbtotalofrecords = $prodcustprice->fetch_all('', '', 0, 0, $filter);
529  }
530 
531  $result = $prodcustprice->fetch_all($sortorder, $sortfield, $conf->liste_limit, $offset, $filter);
532  if ($result < 0) {
533  setEventMessages($prodcustprice->error, $prodcustprice->errors, 'errors');
534  }
535 
536  $option = '&search_prod='.$search_prod.'&id='.$object->id.'&label='.$search_label.'&price='.$search_price.'&price_ttc='.$search_price_ttc;
537 
538  print '<!-- view specific price for each product -->'."\n";
539 
540  print_barre_liste($langs->trans('PriceForEachProduct'), $page, $_SERVER['PHP_SELF'], $option, $sortfield, $sortorder, '', count($prodcustprice->lines), $nbtotalofrecords, '');
541 
542  print '<form action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'" method="POST">';
543  print '<input type="hidden" name="token" value="'.newToken().'">';
544  print '<input type="hidden" name="id" value="'.$object->id.'">';
545 
546  print '<div class="div-table-responsive-no-min">';
547  print '<table class="noborder centpercent">';
548 
549  print '<tr class="liste_titre">';
550  print '<td>'.$langs->trans("Ref").'</td>';
551  print '<td>'.$langs->trans("Product").'</td>';
552  print '<td>'.$langs->trans('RefCustomer').'</td>';
553  print '<td>'.$langs->trans("AppliedPricesFrom").'</td>';
554  print '<td class="center">'.$langs->trans("PriceBase").'</td>';
555  print '<td class="right">'.$langs->trans("VAT").'</td>';
556  print '<td class="right">'.$langs->trans("HT").'</td>';
557  print '<td class="right">'.$langs->trans("TTC").'</td>';
558  print '<td class="right">'.$langs->trans("MinPrice").' '.$langs->trans("HT").'</td>';
559  print '<td class="right">'.$langs->trans("MinPrice").' '.$langs->trans("TTC").'</td>';
560  print '<td class="right">'.$langs->trans("ChangedBy").'</td>';
561  print '<td></td>';
562  print '</tr>';
563 
564  if (count($prodcustprice->lines) > 0 || $search_prod) {
565  print '<tr class="liste_titre">';
566  print '<td class="liste_titre"><input type="text" class="flat width75" name="search_prod" value="'.$search_prod.'"></td>';
567  print '<td class="liste_titre" ><input type="text" class="flat width75" name="search_label" value="'.$search_label.'"></td>';
568  print '<td class="liste_titre"></td>';
569  print '<td class="liste_titre"></td>';
570  print '<td class="liste_titre"></td>';
571  print '<td class="liste_titre"></td>';
572  print '<td class="liste_titre right"><input type="text" class="flat width75 right" name="search_price" value="'.$search_price.'"></td>';
573  print '<td class="liste_titre right"><input type="text" class="flat width75 right" name="search_price_ttc" value="'.$search_price_ttc.'"></td>';
574  print '<td class="liste_titre"></td>';
575  print '<td class="liste_titre"></td>';
576  print '<td class="liste_titre"></td>';
577  // Print the search button
578  print '<td class="liste_titre maxwidthsearch">';
579  $searchpicto = $form->showFilterAndCheckAddButtons(0);
580  print $searchpicto;
581  print '</td>';
582  print '</tr>';
583  }
584 
585  if (count($prodcustprice->lines) > 0) {
586  foreach ($prodcustprice->lines as $line) {
587  $staticprod = new Product($db);
588  $staticprod->fetch($line->fk_product);
589 
590  $userstatic = new User($db);
591  $userstatic->fetch($line->fk_user);
592 
593  print '<tr class="oddeven">';
594 
595  print "<td>".$staticprod->getNomUrl(1)."</td>";
596  print "<td>".$staticprod->label."</td>";
597  print '<td>'.$line->ref_customer.'</td>';
598  print "<td>".dol_print_date($line->datec, "dayhour")."</td>";
599  print '<td class="center">'.$langs->trans($line->price_base_type)."</td>";
600  print '<td class="right">'.vatrate($line->tva_tx.($line->default_vat_code ? ' ('.$line->default_vat_code.')' : ''), true, $line->recuperableonly)."</td>";
601  print '<td class="right">'.price($line->price)."</td>";
602  print '<td class="right">'.price($line->price_ttc)."</td>";
603  print '<td class="right">'.price($line->price_min).'</td>';
604  print '<td class="right">'.price($line->price_min_ttc).'</td>';
605  // User
606  print '<td class="right">';
607  print $userstatic->getNomUrl(-1);
608  print '</td>';
609  // Action
610  if ($user->rights->produit->creer || $user->rights->service->creer) {
611  print '<td class="right nowraponall">';
612  print '<a class="paddingleftonly paddingrightonly" href="'.$_SERVER["PHP_SELF"].'?action=showlog_customer_price&token='.newToken().'&socid='.$object->id.'&prodid='.$line->fk_product.'">';
613  print img_info();
614  print '</a>';
615  print ' ';
616  print '<a class="editfielda paddingleftonly paddingrightonly" href="'.$_SERVER["PHP_SELF"].'?action=edit_customer_price&token='.newToken().'&socid='.$object->id.'&lineid='.$line->id.'">';
617  print img_edit('default', 0, 'style="vertical-align: middle;"');
618  print '</a>';
619  print ' ';
620  print '<a class="paddingleftonly paddingrightonly" href="'.$_SERVER["PHP_SELF"].'?action=delete_customer_price&token='.newToken().'&socid='.$object->id.'&lineid='.$line->id.'">';
621  print img_delete('default', 'style="vertical-align: middle;"');
622  print '</a>';
623  print '</td>';
624  }
625 
626  print "</tr>\n";
627  }
628  } else {
629  $colspan = 10;
630  if ($user->rights->produit->supprimer || $user->rights->service->supprimer) {
631  $colspan += 1;
632  }
633  print '<tr class="oddeven"><td colspan="'.$colspan.'">'.$langs->trans('None').'</td></tr>';
634  }
635 
636  print "</table>";
637  print '</div>';
638 
639  print "</form>";
640  }
641 }
642 
643 // End of page
644 llxFooter();
645 $db->close();
Societe
Class to manage third parties objects (customers, suppliers, prospects...)
Definition: societe.class.php:48
restrictedArea
restrictedArea($user, $features, $objectid=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.
Definition: security.lib.php:234
llxFooter
llxFooter()
Empty footer.
Definition: wrapper.php:73
Productcustomerprice
File of class to manage predefined price products or services by customer.
Definition: productcustomerprice.class.php:29
load_fiche_titre
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
Definition: functions.lib.php:5204
GETPOST
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
Definition: functions.lib.php:484
img_info
img_info($titlealt='default')
Show info logo.
Definition: functions.lib.php:4502
$form
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
Definition: card.php:142
img_edit
img_edit($titlealt='default', $float=0, $other='')
Show logo editer/modifier fiche.
Definition: functions.lib.php:4389
dol_banner_tab
dol_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='rowid', $fieldref='ref', $morehtmlref='', $moreparam='', $nodbprefix=0, $morehtmlleft='', $morehtmlstatus='', $onlybanner=0, $morehtmlright='')
Show tab footer of a card.
Definition: functions.lib.php:2046
price2num
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
Definition: functions.lib.php:5661
img_delete
img_delete($titlealt='default', $other='class="pictodelete"', $morecss='')
Show delete logo.
Definition: functions.lib.php:4429
print_barre_liste
print_barre_liste($titre, $page, $file, $options='', $sortfield='', $sortorder='', $morehtmlcenter='', $num=-1, $totalnboflines='', $picto='generic', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limit=-1, $hideselectlimit=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow='')
Print a title with navigation controls for pagination.
Definition: functions.lib.php:5257
dol_get_fiche_head
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='')
Show tabs of a record.
Definition: functions.lib.php:1822
societe_prepare_head
societe_prepare_head(Societe $object)
Return array of tabs to used on pages for third parties cards.
Definition: company.lib.php:42
newToken
newToken()
Return the value of token currently saved into session with name 'newtoken'.
Definition: functions.lib.php:10878
dol_get_fiche_end
dol_get_fiche_end($notab=0)
Return tab footer of a card.
Definition: functions.lib.php:2018
User
Class to manage Dolibarr users.
Definition: user.class.php:44
GETPOSTISSET
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
Definition: functions.lib.php:386
Product
Class to manage products or services.
Definition: product.class.php:46
Form
Class to manage generation of HTML components Only common components must be here.
Definition: html.form.class.php:52
$resql
if(isModEnabled('facture') &&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->rights->fournisseur->facture->lire)||(isModEnabled('supplier_invoice') && $user->rights->supplier_invoice->lire)) if(isModEnabled('don') &&!empty($user->rights->don->lire)) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
Definition: index.php:742
setEventMessages
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
Definition: functions.lib.php:8137
llxHeader
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOCSRFCHECK')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
Definition: wrapper.php:59