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