dolibarr  13.0.2
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 $result = restrictedArea($user, 'societe', $socid, '&societe');
55 
56 $object = new Societe($db);
57 
58 // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
59 $hookmanager->initHooks(array('thirdpartycustomerprice', 'globalcard'));
60 
61 $error = 0;
62 
63 
64 /*
65  * Actions
66  */
67 
68 $parameters = array('id'=>$socid);
69 $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
70 if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
71 
72 if (empty($reshook))
73 {
74  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
75  {
76  $search_prod = $search_label = $search_price = $search_price_ttc = '';
77  }
78 
79  if ($action == 'add_customer_price_confirm' && !$cancel && ($user->rights->produit->creer || $user->rights->service->creer)) {
80  if (!(GETPOST('prodid', 'int') > 0)) {
81  $error++;
82  setEventMessages($langs->trans("ErrorFieldRequired", $langs->trans("Product")), null, 'errors');
83  $action = 'add_customer_price';
84  }
85 
86  if (!$error) {
87  $update_child_soc = GETPOST('updatechildprice');
88 
89  // add price by customer
90  $prodcustprice->fk_soc = $socid;
91  $prodcustprice->fk_product = GETPOST('prodid', 'int');
92  $prodcustprice->price = price2num(GETPOST("price"), 'MU');
93  $prodcustprice->price_min = price2num(GETPOST("price_min"), 'MU');
94  $prodcustprice->price_base_type = GETPOST("price_base_type", 'alpha');
95 
96  $tva_tx_txt = GETPOST('tva_tx', 'alpha'); // tva_tx can be '8.5' or '8.5*' or '8.5 (XXX)' or '8.5* (XXX)'
97 
98  // We must define tva_tx, npr and local taxes
99  $vatratecode = '';
100  $tva_tx = preg_replace('/[^0-9\.].*$/', '', $tva_tx_txt); // keep remove all after the numbers and dot
101  $npr = preg_match('/\*/', $tva_tx_txt) ? 1 : 0;
102  $localtax1 = 0; $localtax2 = 0; $localtax1_type = '0'; $localtax2_type = '0';
103  // If value contains the unique code of vat line (new recommended method), we use it to find npr and local taxes
104  if (preg_match('/\((.*)\)/', $tva_tx_txt, $reg))
105  {
106  // 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.
107  $vatratecode = $reg[1];
108  // Get record from code
109  $sql = "SELECT t.rowid, t.code, t.recuperableonly, t.localtax1, t.localtax2, t.localtax1_type, t.localtax2_type";
110  $sql .= " FROM ".MAIN_DB_PREFIX."c_tva as t, ".MAIN_DB_PREFIX."c_country as c";
111  $sql .= " WHERE t.fk_pays = c.rowid AND c.code = '".$db->escape($mysoc->country_code)."'";
112  $sql .= " AND t.taux = ".((float) $tva_tx)." AND t.active = 1";
113  $sql .= " AND t.code ='".$db->escape($vatratecode)."'";
114  $resql = $db->query($sql);
115  if ($resql)
116  {
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');
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' && !$_POST ["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->price = price2num(GETPOST("price"), 'MU');
166  $prodcustprice->price_min = price2num(GETPOST("price_min"), 'MU');
167  $prodcustprice->price_base_type = GETPOST("price_base_type", 'alpha');
168  $prodcustprice->tva_tx = str_replace('*', '', GETPOST("tva_tx"));
169  $prodcustprice->recuperableonly = (preg_match('/\*/', GETPOST("tva_tx")) ? 1 : 0);
170 
171  $result = $prodcustprice->update($user, 0, $update_child_soc);
172  if ($result < 0) {
173  setEventMessages($prodcustprice->error, $prodcustprice->errors, 'errors');
174  } else {
175  setEventMessages($langs->trans("Save"), null, 'mesgs');
176  }
177 
178  $action = '';
179  }
180 }
181 
182 
183 /*
184  * View
185  */
186 
187 $form = new Form($db);
188 
189 $object = new Societe($db);
190 
191 $result = $object->fetch($socid);
192 llxHeader("", $langs->trans("ThirdParty").'-'.$langs->trans('PriceByCustomer'));
193 
194 if (!empty($conf->notification->enabled))
195  $langs->load("mails");
196 $head = societe_prepare_head($object);
197 
198 print dol_get_fiche_head($head, 'price', $langs->trans("ThirdParty"), -1, 'company');
199 
200 $linkback = '<a href="'.DOL_URL_ROOT.'/societe/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
201 
202 dol_banner_tab($object, 'socid', $linkback, ($user->socid ? 0 : 1), 'rowid', 'nom');
203 
204 print '<div class="fichecenter">';
205 
206 print '<div class="underbanner clearboth"></div>';
207 print '<table class="border centpercent">';
208 
209 if (!empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field
210 {
211  print '<tr><td class="titlefield">'.$langs->trans('Prefix').'</td><td colspan="3">'.$object->prefix_comm.'</td></tr>';
212 }
213 
214 if ($object->client) {
215  print '<tr><td class="titlefield">';
216  print $langs->trans('CustomerCode').'</td><td colspan="3">';
217  print $object->code_client;
218  $tmpcheck = $object->check_codeclient();
219  if ($tmpcheck != 0 && $tmpcheck != -5) {
220  print ' <font class="error">('.$langs->trans("WrongCustomerCode").')</font>';
221  }
222  print '</td></tr>';
223 }
224 
225 if ($object->fournisseur) {
226  print '<tr><td class="titlefield">';
227  print $langs->trans('SupplierCode').'</td><td colspan="3">';
228  print $object->code_fournisseur;
229  $tmpcheck = $object->check_codefournisseur();
230  if ($tmpcheck != 0 && $tmpcheck != -5) {
231  print ' <font class="error">('.$langs->trans("WrongSupplierCode").')</font>';
232  }
233  print '</td></tr>';
234 }
235 
236 print '</table>';
237 
238 print '</div>';
239 
241 
242 
243 
244 if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) {
245  $prodcustprice = new Productcustomerprice($db);
246 
247  $sortfield = GETPOST("sortfield", 'alpha');
248  $sortorder = GETPOST("sortorder", 'alpha');
249  $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
250  $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
251  if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
252  $offset = $limit * $page;
253  $pageprev = $page - 1;
254  $pagenext = $page + 1;
255  if (!$sortorder)
256  $sortorder = "ASC";
257  if (!$sortfield)
258  $sortfield = "soc.nom";
259 
260  // Build filter to display only concerned lines
261  $filter = array(
262  't.fk_soc' => $object->id
263  );
264 
265  if (!empty($search_prod)) {
266  $filter ['prod.ref'] = $search_prod;
267  }
268 
269  if (!empty($search_label)) {
270  $filter ['prod.label'] = $search_label;
271  }
272 
273  if (!empty($search_price)) {
274  $filter ['t.price'] = $search_price;
275  }
276 
277  if (!empty($search_price_ttc)) {
278  $filter ['t.price_ttc'] = $search_price_ttc;
279  }
280 
281  if ($action == 'add_customer_price') {
282  // Create mode
283 
284  print '<br>';
285  print '<!-- Price by customer -->'."\n";
286 
287  print load_fiche_titre($langs->trans('PriceByCustomer'));
288 
289  print '<form action="'.$_SERVER["PHP_SELF"].'?socid='.$object->id.'" method="POST">';
290  print '<input type="hidden" name="token" value="'.newToken().'">';
291  print '<input type="hidden" name="action" value="add_customer_price_confirm">';
292  print '<input type="hidden" name="socid" value="'.$object->id.'">';
293  print '<table class="border centpercent">';
294  print '<tr>';
295  print '<td>'.$langs->trans('Product').'</td>';
296  print '<td>';
297  $form->select_produits('', 'prodid', '', 0);
298  print '</td>';
299  print '</tr>';
300 
301  // VAT
302  print '<tr><td>'.$langs->trans("VATRate").'</td><td>';
303  print $form->load_tva("tva_tx", $object->tva_tx, $mysoc, '', $object->id, $object->tva_npr, '', false, 1);
304  print '</td></tr>';
305 
306  // Price base
307  print '<tr><td width="15%">';
308  print $langs->trans('PriceBase');
309  print '</td>';
310  print '<td>';
311  print $form->selectPriceBaseType($object->price_base_type, "price_base_type");
312  print '</td>';
313  print '</tr>';
314 
315  // Price
316  print '<tr><td width="20%">';
317  $text = $langs->trans('SellingPrice');
318  print $form->textwithpicto($text, $langs->trans("PrecisionUnitIsLimitedToXDecimals", $conf->global->MAIN_MAX_DECIMALS_UNIT), 1, 1);
319  print '</td><td>';
320  if ($object->price_base_type == 'TTC') {
321  print '<input name="price" size="10" value="'.price($object->price_ttc).'">';
322  } else {
323  print '<input name="price" size="10" value="'.price($object->price).'">';
324  }
325  print '</td></tr>';
326 
327  // Price minimum
328  print '<tr><td>';
329  $text = $langs->trans('MinPrice');
330  print $form->textwithpicto($text, $langs->trans("PrecisionUnitIsLimitedToXDecimals", $conf->global->MAIN_MAX_DECIMALS_UNIT), 1, 1);
331  if ($object->price_base_type == 'TTC') {
332  print '<td><input name="price_min" size="10" value="'.price($object->price_min_ttc).'">';
333  } else {
334  print '<td><input name="price_min" size="10" value="'.price($object->price_min).'">';
335  }
336  print '</td></tr>';
337 
338  // Update all child soc
339  print '<tr><td width="15%">';
340  print $langs->trans('ForceUpdateChildPriceSoc');
341  print '</td>';
342  print '<td>';
343  print '<input type="checkbox" name="updatechildprice" value="1"/>';
344  print '</td>';
345  print '</tr>';
346 
347  print '</table>';
348 
349  print '<br><div class="center">';
350  print '<input type="submit" class="button button-save" value="'.$langs->trans("Save").'">';
351  print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
352  print '<input type="submit" class="button button-cancel" name="cancel" value="'.$langs->trans("Cancel").'">';
353  print '</div>';
354 
355  print '<br></form>';
356  } elseif ($action == 'edit_customer_price') {
357  // Edit mode
358 
359  print load_fiche_titre($langs->trans('PriceByCustomer'));
360 
361  $result = $prodcustprice->fetch(GETPOST('lineid', 'int'));
362  if ($result < 0)
363  {
364  setEventMessages($prodcustprice->error, $prodcustprice->errors, 'errors');
365  }
366 
367  print '<form action="'.$_SERVER["PHP_SELF"].'?socid='.$object->id.'" method="POST">';
368  print '<input type="hidden" name="token" value="'.newToken().'">';
369  print '<input type="hidden" name="action" value="update_customer_price_confirm">';
370  print '<input type="hidden" name="lineid" value="'.$prodcustprice->id.'">';
371  print '<table class="border centpercent">';
372  print '<tr>';
373  print '<td>'.$langs->trans('Product').'</td>';
374  $staticprod = new Product($db);
375  $staticprod->fetch($prodcustprice->fk_product);
376  print "<td>".$staticprod->getNomUrl(1)."</td>";
377  print '</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 width="20%">';
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 width="15%">';
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 '<br><div class="center">';
429  print '<input type="submit" class="button button-save" value="'.$langs->trans("Save").'">';
430  print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
431  print '<input type="submit" class="button button-cancel" name="cancel" value="'.$langs->trans("Cancel").'">';
432  print '</div>';
433 
434  print '<br></form>';
435  } elseif ($action == 'showlog_customer_price') {
436  print '<br>';
437  print '<!-- showlog_customer_price -->'."\n";
438 
439  $filter = array(
440  't.fk_product' => GETPOST('prodid', 'int'), 't.fk_soc' => $socid
441  );
442 
443  // Count total nb of records
444  $nbtotalofrecords = '';
445  if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
446  $nbtotalofrecords = $prodcustprice->fetch_all_log($sortorder, $sortfield, $conf->liste_limit, $offset, $filter);
447  }
448 
449  $result = $prodcustprice->fetch_all_log($sortorder, $sortfield, $conf->liste_limit, $offset, $filter);
450  if ($result < 0)
451  {
452  setEventMessages($prodcustprice->error, $prodcustprice->errors, 'errors');
453  }
454 
455  $option = '&socid='.GETPOST('socid', 'int').'&prodid='.GETPOST('prodid', 'int');
456 
457  print_barre_liste($langs->trans('PriceByCustomerLog'), $page, $_SERVER ['PHP_SELF'], $option, $sortfield, $sortorder, '', count($prodcustprice->lines), $nbtotalofrecords);
458 
459  if (count($prodcustprice->lines) > 0) {
460  print '<form action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'" method="POST">';
461  print '<input type="hidden" name="token" value="'.newToken().'">';
462  print '<input type="hidden" name="id" value="'.$object->id.'">';
463 
464  print '<table class="noborder centpercent">';
465 
466  print '<tr class="liste_titre">';
467  print '<td>'.$langs->trans("Product").'</td>';
468  print '<td>'.$langs->trans("AppliedPricesFrom").'</td>';
469  print '<td class="center">'.$langs->trans("PriceBase").'</td>';
470  print '<td class="right">'.$langs->trans("VAT").'</td>';
471  print '<td class="right">'.$langs->trans("HT").'</td>';
472  print '<td class="right">'.$langs->trans("TTC").'</td>';
473  print '<td class="right">'.$langs->trans("MinPrice").' '.$langs->trans("HT").'</td>';
474  print '<td class="right">'.$langs->trans("MinPrice").' '.$langs->trans("TTC").'</td>';
475  print '<td class="right">'.$langs->trans("ChangedBy").'</td>';
476  print '<td>&nbsp;</td>';
477  print '</tr>';
478 
479  foreach ($prodcustprice->lines as $line) {
480  print '<tr class="oddeven">';
481  $staticprod = new Product($db);
482  $staticprod->fetch($line->fk_product);
483 
484  print "<td>".$staticprod->getNomUrl(1)."</td>";
485  print "<td>".dol_print_date($line->datec, "dayhour")."</td>";
486 
487  print '<td class="center">'.$langs->trans($line->price_base_type)."</td>";
488  print '<td class="right">'.vatrate($line->tva_tx, true, $line->recuperableonly)."</td>";
489  print '<td class="right">'.price($line->price)."</td>";
490  print '<td class="right">'.price($line->price_ttc)."</td>";
491  print '<td class="right">'.price($line->price_min).'</td>';
492  print '<td class="right">'.price($line->price_min_ttc).'</td>';
493 
494  // User
495  $userstatic = new User($db);
496  $userstatic->fetch($line->fk_user);
497  print '<td class="right">';
498  print $userstatic->getLoginUrl(1);
499  print '</td>';
500  }
501  print "</table>";
502  } else {
503  print $langs->trans('None');
504  }
505 
506  print "\n".'<div class="tabsAction">'."\n";
507  print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?socid='.$object->id.'">'.$langs->trans("Ok").'</a></div>';
508  print "\n</div><br>\n";
509  } else {
510  // View mode
511 
512  /* ************************************************************************** */
513  /* */
514  /* Barre d'action */
515  /* */
516  /* ************************************************************************** */
517 
518  print "\n".'<div class="tabsAction">'."\n";
519 
520  if ($user->rights->produit->creer || $user->rights->service->creer) {
521  print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=add_customer_price&amp;socid='.$object->id.'">'.$langs->trans("AddCustomerPrice").'</a></div>';
522  }
523  print "\n</div>\n";
524 
525 
526  // Count total nb of records
527  $nbtotalofrecords = '';
528  if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
529  {
530  $nbtotalofrecords = $prodcustprice->fetch_all('', '', 0, 0, $filter);
531  }
532 
533  $result = $prodcustprice->fetch_all($sortorder, $sortfield, $conf->liste_limit, $offset, $filter);
534  if ($result < 0)
535  {
536  setEventMessages($prodcustprice->error, $prodcustprice->errors, 'errors');
537  }
538 
539  $option = '&search_prod='.$search_prod.'&id='.$object->id.'&label='.$search_label.'&price='.$search_price.'&price_ttc='.$search_price_ttc;
540 
541  print '<!-- view specific price for each product -->'."\n";
542 
543  print_barre_liste($langs->trans('PriceForEachProduct'), $page, $_SERVER['PHP_SELF'], $option, $sortfield, $sortorder, '', count($prodcustprice->lines), $nbtotalofrecords, '');
544 
545  print '<form action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'" method="POST">';
546  print '<input type="hidden" name="token" value="'.newToken().'">';
547  print '<input type="hidden" name="id" value="'.$object->id.'">';
548 
549  print '<table class="noborder centpercent">';
550 
551  print '<tr class="liste_titre">';
552  print '<td>'.$langs->trans("Ref").'</td>';
553  print '<td>'.$langs->trans("Product").'</td>';
554  print '<td>'.$langs->trans("AppliedPricesFrom").'</td>';
555  print '<td class="center">'.$langs->trans("PriceBase").'</td>';
556  print '<td class="right">'.$langs->trans("VAT").'</td>';
557  print '<td class="right">'.$langs->trans("HT").'</td>';
558  print '<td class="right">'.$langs->trans("TTC").'</td>';
559  print '<td class="right">'.$langs->trans("MinPrice").' '.$langs->trans("HT").'</td>';
560  print '<td class="right">'.$langs->trans("MinPrice").' '.$langs->trans("TTC").'</td>';
561  print '<td class="right">'.$langs->trans("ChangedBy").'</td>';
562  print '<td>&nbsp;</td>';
563  print '</tr>';
564 
565  if (count($prodcustprice->lines) > 0 || $search_prod)
566  {
567  print '<tr class="liste_titre">';
568  print '<td class="liste_titre"><input type="text" class="flat" name="search_prod" value="'.$search_prod.'" size="20"></td>';
569  print '<td class="liste_titre" ><input type="text" class="flat" name="search_label" value="'.$search_label.'" size="20"></td>';
570  print '<td class="liste_titre" colspan="3">&nbsp;</td>';
571  print '<td class="liste_titre" align="right"><input type="text" class="flat" name="search_price" value="'.$search_price.'" size="10"></td>';
572  print '<td class="liste_titre" align="right"><input type="text" class="flat" name="search_price_ttc" value="'.$search_price_ttc.'" size="10"></td>';
573  print '<td class="liste_titre" colspan="3">&nbsp;</td>';
574  // Print the search button
575  print '<td class="liste_titre maxwidthsearch">';
576  $searchpicto = $form->showFilterAndCheckAddButtons(0);
577  print $searchpicto;
578  print '</td>';
579  print '</tr>';
580  }
581 
582  if (count($prodcustprice->lines) > 0)
583  {
584  foreach ($prodcustprice->lines as $line)
585  {
586  print '<tr class="oddeven">';
587 
588  $staticprod = new Product($db);
589  $staticprod->fetch($line->fk_product);
590 
591  print "<td>".$staticprod->getNomUrl(1)."</td>";
592  print "<td>".$staticprod->label."</td>";
593  print "<td>".dol_print_date($line->datec, "dayhour")."</td>";
594 
595  print '<td class="center">'.$langs->trans($line->price_base_type)."</td>";
596  print '<td class="right">'.vatrate($line->tva_tx.($line->default_vat_code ? ' ('.$line->default_vat_code.')' : ''), true, $line->recuperableonly)."</td>";
597  print '<td class="right">'.price($line->price)."</td>";
598  print '<td class="right">'.price($line->price_ttc)."</td>";
599  print '<td class="right">'.price($line->price_min).'</td>';
600  print '<td class="right">'.price($line->price_min_ttc).'</td>';
601 
602  // User
603  $userstatic = new User($db);
604  $userstatic->fetch($line->fk_user);
605  print '<td class="right">';
606  print $userstatic->getLoginUrl(1);
607  print '</td>';
608 
609  // Action
610  if ($user->rights->produit->creer || $user->rights->service->creer)
611  {
612  print '<td class="right nowraponall">';
613  print '<a class="paddingleftonly paddingrightonly" href="'.$_SERVER["PHP_SELF"].'?action=showlog_customer_price&amp;socid='.$object->id.'&amp;prodid='.$line->fk_product.'">';
614  print img_info();
615  print '</a>';
616  print ' ';
617  print '<a class="editfielda paddingleftonly paddingrightonly" href="'.$_SERVER["PHP_SELF"].'?action=edit_customer_price&amp;socid='.$object->id.'&amp;lineid='.$line->id.'">';
618  print img_edit('default', 0, 'style="vertical-align: middle;"');
619  print '</a>';
620  print ' ';
621  print '<a class="paddingleftonly paddingrightonly" href="'.$_SERVER["PHP_SELF"].'?action=delete_customer_price&amp;token='.newToken().'&amp;socid='.$object->id.'&amp;lineid='.$line->id.'">';
622  print img_delete('default', 'style="vertical-align: middle;"');
623  print '</a>';
624  print '</td>';
625  }
626 
627  print "</tr>\n";
628  }
629  } else {
630  $colspan = 9;
631  if ($user->rights->produit->supprimer || $user->rights->service->supprimer) $colspan += 1;
632  print '<tr class="oddeven"><td colspan="'.$colspan.'">'.$langs->trans('None').'</td></tr>';
633  }
634 
635  print "</table>";
636 
637  print "</form>";
638  }
639 }
640 
641 // End of page
642 llxFooter();
643 $db->close();
File of class to manage predefined price products or services by customer.
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
img_edit($titlealt= 'default', $float=0, $other= '')
Show logo editer/modifier fiche.
Class to manage products or services.
Class to manage Dolibarr users.
Definition: user.class.php:44
llxHeader()
Empty header.
Definition: wrapper.php:45
setEventMessages($mesg, $mesgs, $style= 'mesgs', $messagekey= '')
Set event messages in dol_events session object.
print_barre_liste($titre, $page, $file, $options= '', $sortfield= '', $sortorder= '', $morehtmlcenter= '', $num=-1, $totalnboflines= '', $picto= 'generic', $pictoisfullpath=0, $morehtmlright= '', $morecss= '', $limit=-1, $hideselectlimit=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow= '')
Print a title with navigation controls for pagination.
Class to manage generation of HTML components Only common components must be here.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname.
Class to manage third parties objects (customers, suppliers, prospects...)
load_fiche_titre($titre, $morehtmlright= '', $picto= 'generic', $pictoisfullpath=0, $id= '', $morecssontable= '', $morehtmlcenter= '')
Load a title with picto.
price2num($amount, $rounding= '', $option=0)
Function that return a number with universal decimal format (decimal separator is &#39;...
restrictedArea($user, $features, $objectid=0, $tableandshare= '', $feature2= '', $dbt_keyfield= 'fk_soc', $dbt_select= 'rowid', $isdraft=0)
Check permissions of a user to show a page and an object.
societe_prepare_head(Societe $object)
Return array of tabs to used on pages for third parties cards.
Definition: company.lib.php:42
print $_SERVER["PHP_SELF"]
Edit parameters.
dol_get_fiche_head($links=array(), $active= '', $title= '', $notab=0, $picto= '', $pictoisfullpath=0, $morehtmlright= '', $morecss= '', $limittoshow=0, $moretabssuffix= '')
Show tabs of a record.
print
Draft customers invoices.
Definition: index.php:89
if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) if(!empty($conf->don->enabled)&&$user->rights->don->lire) if(!empty($conf->tax->enabled)&&$user->rights->tax->charges->lire) if(!empty($conf->facture->enabled)&&!empty($conf->commande->enabled)&&$user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
Definition: index.php:1232
img_info($titlealt= 'default')
Show info logo.
newToken()
Return the value of token currently saved into session with name &#39;newtoken&#39;.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
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.
llxFooter()
Empty footer.
Definition: wrapper.php:59
img_delete($titlealt= 'default', $other= 'class="pictodelete"', $morecss= '')
Show delete logo.