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 23/** 24 * \file htdocs/societe/price.php 25 * \ingroup product 26 * \brief Page to show product prices by customer 27 */ 28 29require '../main.inc.php'; 30require_once DOL_DOCUMENT_ROOT.'/core/lib/product.lib.php'; 31require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; 32require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; 33require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; 34 35if (!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'); 52if ($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 71if ($reshook < 0) { 72 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); 73} 74 75if (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' && !$_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->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); 193llxHeader("", $langs->trans("ThirdParty").'-'.$langs->trans('PriceByCustomer')); 194 195if (!empty($conf->notification->enabled)) { 196 $langs->load("mails"); 197} 198$head = societe_prepare_head($object); 199 200print 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 204dol_banner_tab($object, 'socid', $linkback, ($user->socid ? 0 : 1), 'rowid', 'nom'); 205 206print '<div class="fichecenter">'; 207 208print '<div class="underbanner clearboth"></div>'; 209print '<table class="border centpercent tableforfield">'; 210 211if (!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 215if ($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 ' <font class="error">('.$langs->trans("WrongCustomerCode").')</font>'; 222 } 223 print '</td></tr>'; 224} 225 226if ($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 ' <font class="error">('.$langs->trans("WrongSupplierCode").')</font>'; 233 } 234 print '</td></tr>'; 235} 236 237print '</table>'; 238 239print '</div>'; 240 241print dol_get_fiche_end(); 242 243 244 245if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) { 246 $prodcustprice = new Productcustomerprice($db); 247 248 $sortfield = GETPOST("sortfield", 'alpha'); 249 $sortorder = GETPOST("sortorder", 'alpha'); 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 if ($object->price_base_type == 'TTC') { 330 print '<input name="price" size="10" value="'.price($object->price_ttc).'">'; 331 } else { 332 print '<input name="price" size="10" value="'.price($object->price).'">'; 333 } 334 print '</td></tr>'; 335 336 // Price minimum 337 print '<tr><td>'; 338 $text = $langs->trans('MinPrice'); 339 print $form->textwithpicto($text, $langs->trans("PrecisionUnitIsLimitedToXDecimals", $conf->global->MAIN_MAX_DECIMALS_UNIT), 1, 1); 340 if ($object->price_base_type == 'TTC') { 341 print '<td><input name="price_min" size="10" value="'.price($object->price_min_ttc).'">'; 342 } else { 343 print '<td><input name="price_min" size="10" value="'.price($object->price_min).'">'; 344 } 345 print '</td></tr>'; 346 347 // Update all child soc 348 print '<tr><td width="15%">'; 349 print $langs->trans('ForceUpdateChildPriceSoc'); 350 print '</td>'; 351 print '<td>'; 352 print '<input type="checkbox" name="updatechildprice" value="1"/>'; 353 print '</td>'; 354 print '</tr>'; 355 356 print '</table>'; 357 358 print '<br><div class="center">'; 359 print '<input type="submit" class="button button-save" value="'.$langs->trans("Save").'">'; 360 print ' '; 361 print '<input type="submit" class="button button-cancel" name="cancel" value="'.$langs->trans("Cancel").'">'; 362 print '</div>'; 363 364 print '<br></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 '<br><div class="center">'; 441 print '<input type="submit" class="button button-save" value="'.$langs->trans("Save").'">'; 442 print ' '; 443 print '<input type="submit" class="button button-cancel" name="cancel" value="'.$langs->trans("Cancel").'">'; 444 print '</div>'; 445 446 print '<br></form>'; 447 } 448 } elseif ($action == 'showlog_customer_price') { 449 print '<br>'; 450 print '<!-- showlog_customer_price -->'."\n"; 451 452 $filter = array( 453 't.fk_product' => GETPOST('prodid', 'int'), 454 't.fk_soc' => $socid 455 ); 456 457 // Count total nb of records 458 $nbtotalofrecords = ''; 459 $result = $prodcustprice->fetch_all_log($sortorder, $sortfield, $conf->liste_limit, $offset, $filter); 460 if ($result < 0) { 461 setEventMessages($prodcustprice->error, $prodcustprice->errors, 'errors'); 462 } else { 463 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { 464 $nbtotalofrecords = $result; 465 } 466 } 467 468 $option = '&socid='.GETPOST('socid', 'int').'&prodid='.GETPOST('prodid', 'int'); 469 470 print_barre_liste($langs->trans('PriceByCustomerLog'), $page, $_SERVER ['PHP_SELF'], $option, $sortfield, $sortorder, '', count($prodcustprice->lines), $nbtotalofrecords); 471 472 if (count($prodcustprice->lines) > 0) { 473 print '<form action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'" method="POST">'; 474 print '<input type="hidden" name="token" value="'.newToken().'">'; 475 print '<input type="hidden" name="id" value="'.$object->id.'">'; 476 477 print '<table class="noborder centpercent">'; 478 479 print '<tr class="liste_titre">'; 480 print '<td>'.$langs->trans("Product").'</td>'; 481 print '<td>'.$langs->trans('RefCustomer').'</td>'; 482 print '<td>'.$langs->trans("AppliedPricesFrom").'</td>'; 483 print '<td class="center">'.$langs->trans("PriceBase").'</td>'; 484 print '<td class="right">'.$langs->trans("VAT").'</td>'; 485 print '<td class="right">'.$langs->trans("HT").'</td>'; 486 print '<td class="right">'.$langs->trans("TTC").'</td>'; 487 print '<td class="right">'.$langs->trans("MinPrice").' '.$langs->trans("HT").'</td>'; 488 print '<td class="right">'.$langs->trans("MinPrice").' '.$langs->trans("TTC").'</td>'; 489 print '<td class="right">'.$langs->trans("ChangedBy").'</td>'; 490 print '<td></td>'; 491 print '</tr>'; 492 493 foreach ($prodcustprice->lines as $line) { 494 $staticprod = new Product($db); 495 $staticprod->fetch($line->fk_product); 496 497 $userstatic = new User($db); 498 $userstatic->fetch($line->fk_user); 499 500 print '<tr class="oddeven">'; 501 502 print "<td>".$staticprod->getNomUrl(1)."</td>"; 503 print '<td>'.$line->ref_customer.'</td>'; 504 print "<td>".dol_print_date($line->datec, "dayhour")."</td>"; 505 506 print '<td class="center">'.$langs->trans($line->price_base_type)."</td>"; 507 print '<td class="right">'.vatrate($line->tva_tx, true, $line->recuperableonly)."</td>"; 508 print '<td class="right">'.price($line->price)."</td>"; 509 print '<td class="right">'.price($line->price_ttc)."</td>"; 510 print '<td class="right">'.price($line->price_min).'</td>'; 511 print '<td class="right">'.price($line->price_min_ttc).'</td>'; 512 513 // User 514 print '<td class="right">'; 515 print $userstatic->getNomUrl(-1); 516 print '</td>'; 517 print '<td></td>'; 518 } 519 print "</table>"; 520 } else { 521 print $langs->trans('None'); 522 } 523 524 print "\n".'<div class="tabsAction">'."\n"; 525 print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?socid='.$object->id.'">'.$langs->trans("Ok").'</a></div>'; 526 print "\n</div><br>\n"; 527 } else { 528 // View mode 529 530 /* 531 * Action bar 532 */ 533 print "\n".'<div class="tabsAction">'."\n"; 534 535 if ($user->rights->produit->creer || $user->rights->service->creer) { 536 print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=add_customer_price&socid='.$object->id.'">'.$langs->trans("AddCustomerPrice").'</a></div>'; 537 } 538 print "\n</div>\n"; 539 540 541 // Count total nb of records 542 $nbtotalofrecords = ''; 543 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { 544 $nbtotalofrecords = $prodcustprice->fetch_all('', '', 0, 0, $filter); 545 } 546 547 $result = $prodcustprice->fetch_all($sortorder, $sortfield, $conf->liste_limit, $offset, $filter); 548 if ($result < 0) { 549 setEventMessages($prodcustprice->error, $prodcustprice->errors, 'errors'); 550 } 551 552 $option = '&search_prod='.$search_prod.'&id='.$object->id.'&label='.$search_label.'&price='.$search_price.'&price_ttc='.$search_price_ttc; 553 554 print '<!-- view specific price for each product -->'."\n"; 555 556 print_barre_liste($langs->trans('PriceForEachProduct'), $page, $_SERVER['PHP_SELF'], $option, $sortfield, $sortorder, '', count($prodcustprice->lines), $nbtotalofrecords, ''); 557 558 print '<form action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'" method="POST">'; 559 print '<input type="hidden" name="token" value="'.newToken().'">'; 560 print '<input type="hidden" name="id" value="'.$object->id.'">'; 561 562 print '<table class="noborder centpercent">'; 563 564 print '<tr class="liste_titre">'; 565 print '<td>'.$langs->trans("Ref").'</td>'; 566 print '<td>'.$langs->trans("Product").'</td>'; 567 print '<td>'.$langs->trans('RefCustomer').'</td>'; 568 print '<td>'.$langs->trans("AppliedPricesFrom").'</td>'; 569 print '<td class="center">'.$langs->trans("PriceBase").'</td>'; 570 print '<td class="right">'.$langs->trans("VAT").'</td>'; 571 print '<td class="right">'.$langs->trans("HT").'</td>'; 572 print '<td class="right">'.$langs->trans("TTC").'</td>'; 573 print '<td class="right">'.$langs->trans("MinPrice").' '.$langs->trans("HT").'</td>'; 574 print '<td class="right">'.$langs->trans("MinPrice").' '.$langs->trans("TTC").'</td>'; 575 print '<td class="right">'.$langs->trans("ChangedBy").'</td>'; 576 print '<td></td>'; 577 print '</tr>'; 578 579 if (count($prodcustprice->lines) > 0 || $search_prod) { 580 print '<tr class="liste_titre">'; 581 print '<td class="liste_titre"><input type="text" class="flat" name="search_prod" value="'.$search_prod.'" size="20"></td>'; 582 print '<td class="liste_titre" ><input type="text" class="flat" name="search_label" value="'.$search_label.'" size="20"></td>'; 583 print '<td class="liste_titre"></td>'; 584 print '<td class="liste_titre"></td>'; 585 print '<td class="liste_titre"></td>'; 586 print '<td class="liste_titre"></td>'; 587 print '<td class="liste_titre" class="right"><input type="text" class="flat" name="search_price" value="'.$search_price.'" size="10"></td>'; 588 print '<td class="liste_titre" class="right"><input type="text" class="flat" name="search_price_ttc" value="'.$search_price_ttc.'" size="10"></td>'; 589 print '<td class="liste_titre"></td>'; 590 print '<td class="liste_titre"></td>'; 591 print '<td class="liste_titre"></td>'; 592 // Print the search button 593 print '<td class="liste_titre maxwidthsearch">'; 594 $searchpicto = $form->showFilterAndCheckAddButtons(0); 595 print $searchpicto; 596 print '</td>'; 597 print '</tr>'; 598 } 599 600 if (count($prodcustprice->lines) > 0) { 601 foreach ($prodcustprice->lines as $line) { 602 $staticprod = new Product($db); 603 $staticprod->fetch($line->fk_product); 604 605 $userstatic = new User($db); 606 $userstatic->fetch($line->fk_user); 607 608 print '<tr class="oddeven">'; 609 610 print "<td>".$staticprod->getNomUrl(1)."</td>"; 611 print "<td>".$staticprod->label."</td>"; 612 print '<td>'.$line->ref_customer.'</td>'; 613 print "<td>".dol_print_date($line->datec, "dayhour")."</td>"; 614 print '<td class="center">'.$langs->trans($line->price_base_type)."</td>"; 615 print '<td class="right">'.vatrate($line->tva_tx.($line->default_vat_code ? ' ('.$line->default_vat_code.')' : ''), true, $line->recuperableonly)."</td>"; 616 print '<td class="right">'.price($line->price)."</td>"; 617 print '<td class="right">'.price($line->price_ttc)."</td>"; 618 print '<td class="right">'.price($line->price_min).'</td>'; 619 print '<td class="right">'.price($line->price_min_ttc).'</td>'; 620 // User 621 print '<td class="right">'; 622 print $userstatic->getNomUrl(-1); 623 print '</td>'; 624 // Action 625 if ($user->rights->produit->creer || $user->rights->service->creer) { 626 print '<td class="right nowraponall">'; 627 print '<a class="paddingleftonly paddingrightonly" href="'.$_SERVER["PHP_SELF"].'?action=showlog_customer_price&socid='.$object->id.'&prodid='.$line->fk_product.'">'; 628 print img_info(); 629 print '</a>'; 630 print ' '; 631 print '<a class="editfielda paddingleftonly paddingrightonly" href="'.$_SERVER["PHP_SELF"].'?action=edit_customer_price&socid='.$object->id.'&lineid='.$line->id.'">'; 632 print img_edit('default', 0, 'style="vertical-align: middle;"'); 633 print '</a>'; 634 print ' '; 635 print '<a class="paddingleftonly paddingrightonly" href="'.$_SERVER["PHP_SELF"].'?action=delete_customer_price&token='.newToken().'&socid='.$object->id.'&lineid='.$line->id.'">'; 636 print img_delete('default', 'style="vertical-align: middle;"'); 637 print '</a>'; 638 print '</td>'; 639 } 640 641 print "</tr>\n"; 642 } 643 } else { 644 $colspan = 10; 645 if ($user->rights->produit->supprimer || $user->rights->service->supprimer) { 646 $colspan += 1; 647 } 648 print '<tr class="oddeven"><td colspan="'.$colspan.'">'.$langs->trans('None').'</td></tr>'; 649 } 650 651 print "</table>"; 652 653 print "</form>"; 654 } 655} 656 657// End of page 658llxFooter(); 659$db->close(); 660