price.php 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617
  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 <http://www.gnu.org/licenses/>.
  21. */
  22. /**
  23. * \file htdocs/societe/price.php
  24. * \ingroup product
  25. * \brief Page to show product prices by customer
  26. */
  27. require '../main.inc.php';
  28. require_once DOL_DOCUMENT_ROOT . '/core/lib/product.lib.php';
  29. require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php';
  30. require_once DOL_DOCUMENT_ROOT . '/core/lib/company.lib.php';
  31. require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php';
  32. if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) {
  33. require_once DOL_DOCUMENT_ROOT . '/product/class/productcustomerprice.class.php';
  34. $prodcustprice = new Productcustomerprice($db);
  35. }
  36. $langs->loadLangs(array("products", "companies", "bills"));
  37. $action = GETPOST('action', 'alpha');
  38. $search_prod = GETPOST('search_prod','alpha');
  39. $cancel = GETPOST('cancel','alpha');
  40. // Security check
  41. $socid = GETPOST('socid', 'int')?GETPOST('socid', 'int'):GETPOST('id', 'int');
  42. if ($user->societe_id)
  43. $socid = $user->societe_id;
  44. $result = restrictedArea($user, 'societe', $socid, '&societe');
  45. $object = new Societe($db);
  46. // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
  47. $hookmanager->initHooks(array('thirdpartycustomerprice','globalcard'));
  48. /*
  49. * Actions
  50. */
  51. $parameters=array('id'=>$socid);
  52. $reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
  53. if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
  54. if (empty($reshook))
  55. {
  56. 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
  57. {
  58. $search_prod = '';
  59. }
  60. if ($action == 'add_customer_price_confirm' && ! $cancel && ($user->rights->produit->creer || $user->rights->service->creer)) {
  61. $update_child_soc = GETPOST('updatechildprice');
  62. // add price by customer
  63. $prodcustprice->fk_soc = $socid;
  64. $prodcustprice->fk_product = GETPOST('prodid', 'int');
  65. $prodcustprice->price = price2num(GETPOST("price"), 'MU');
  66. $prodcustprice->price_min = price2num(GETPOST("price_min"), 'MU');
  67. $prodcustprice->price_base_type = GETPOST("price_base_type", 'alpha');
  68. $tva_tx_txt = GETPOST('tva_tx', 'alpha'); // tva_tx can be '8.5' or '8.5*' or '8.5 (XXX)' or '8.5* (XXX)'
  69. // We must define tva_tx, npr and local taxes
  70. $vatratecode = '';
  71. $tva_tx = preg_replace('/[^0-9\.].*$/', '', $tva_tx_txt); // keep remove all after the numbers and dot
  72. $npr = preg_match('/\*/', $tva_tx_txt) ? 1 : 0;
  73. $localtax1 = 0; $localtax2 = 0; $localtax1_type = '0'; $localtax2_type = '0';
  74. // If value contains the unique code of vat line (new recommanded method), we use it to find npr and local taxes
  75. if (preg_match('/\((.*)\)/', $tva_tx_txt, $reg))
  76. {
  77. // 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.
  78. $vatratecode=$reg[1];
  79. // Get record from code
  80. $sql = "SELECT t.rowid, t.code, t.recuperableonly, t.localtax1, t.localtax2, t.localtax1_type, t.localtax2_type";
  81. $sql.= " FROM ".MAIN_DB_PREFIX."c_tva as t, ".MAIN_DB_PREFIX."c_country as c";
  82. $sql.= " WHERE t.fk_pays = c.rowid AND c.code = '".$mysoc->country_code."'";
  83. $sql.= " AND t.taux = ".((float) $tva_tx)." AND t.active = 1";
  84. $sql.= " AND t.code ='".$vatratecode."'";
  85. $resql=$db->query($sql);
  86. if ($resql)
  87. {
  88. $obj = $db->fetch_object($resql);
  89. $npr = $obj->recuperableonly;
  90. $localtax1 = $obj->localtax1;
  91. $localtax2 = $obj->localtax2;
  92. $localtax1_type = $obj->localtax1_type;
  93. $localtax2_type = $obj->localtax2_type;
  94. }
  95. }
  96. $prodcustprice->default_vat_code = $vatratecode;
  97. $prodcustprice->tva_tx = $tva_tx;
  98. $prodcustprice->recuperableonly = $npr;
  99. $prodcustprice->localtax1_tx = $localtax1;
  100. $prodcustprice->localtax2_tx = $localtax2;
  101. $prodcustprice->localtax1_type = $localtax1_type;
  102. $prodcustprice->localtax2_type = $localtax2_type;
  103. $result = $prodcustprice->create($user, 0, $update_child_soc);
  104. if ($result < 0) {
  105. setEventMessages($prodcustprice->error, $prodcustprice->errors, 'errors');
  106. } else {
  107. setEventMessages($langs->trans('Save'), null, 'mesgs');
  108. }
  109. $action = '';
  110. }
  111. if ($action == 'delete_customer_price' && ($user->rights->produit->creer || $user->rights->service->creer)) {
  112. // Delete price by customer
  113. $prodcustprice->id = GETPOST('lineid');
  114. $result = $prodcustprice->delete($user);
  115. if ($result < 0) {
  116. setEventMessages($prodcustprice->error, $prodcustprice->errors, 'mesgs');
  117. } else {
  118. setEventMessages($langs->trans('Delete'), null, 'errors');
  119. }
  120. $action = '';
  121. }
  122. if ($action == 'update_customer_price_confirm' && ! $_POST ["cancel"] && ($user->rights->produit->creer || $user->rights->service->creer)) {
  123. $prodcustprice->fetch(GETPOST('lineid', 'int'));
  124. $update_child_soc = GETPOST('updatechildprice');
  125. // update price by customer
  126. $prodcustprice->price = price2num(GETPOST("price"), 'MU');
  127. $prodcustprice->price_min = price2num(GETPOST("price_min"), 'MU');
  128. $prodcustprice->price_base_type = GETPOST("price_base_type", 'alpha');
  129. $prodcustprice->tva_tx = str_replace('*', '', GETPOST("tva_tx"));
  130. $prodcustprice->recuperableonly = (preg_match('/\*/', GETPOST("tva_tx")) ? 1 : 0);
  131. $result = $prodcustprice->update($user, 0, $update_child_soc);
  132. if ($result < 0) {
  133. setEventMessages($prodcustprice->error, $prodcustprice->errors, 'errors');
  134. } else {
  135. setEventMessages($langs->trans('Save'), null, 'mesgs');
  136. }
  137. $action = '';
  138. }
  139. }
  140. /*
  141. * View
  142. */
  143. $form = new Form($db);
  144. $object = new Societe($db);
  145. $result = $object->fetch($socid);
  146. llxHeader("", $langs->trans("ThirdParty") . '-' . $langs->trans('PriceByCustomer'));
  147. if (! empty($conf->notification->enabled))
  148. $langs->load("mails");
  149. $head = societe_prepare_head($object);
  150. dol_fiche_head($head, 'price', $langs->trans("ThirdParty"), -1, 'company');
  151. $linkback = '<a href="'.DOL_URL_ROOT.'/societe/list.php">'.$langs->trans("BackToList").'</a>';
  152. dol_banner_tab($object, 'socid', $linkback, ($user->societe_id?0:1), 'rowid', 'nom');
  153. print '<div class="fichecenter">';
  154. print '<div class="underbanner clearboth"></div>';
  155. print '<table class="border centpercent">';
  156. if (! empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field
  157. {
  158. print '<tr><td class="titlefield">' . $langs->trans('Prefix') . '</td><td colspan="3">' . $object->prefix_comm . '</td></tr>';
  159. }
  160. if ($object->client) {
  161. print '<tr><td class="titlefield">';
  162. print $langs->trans('CustomerCode') . '</td><td colspan="3">';
  163. print $object->code_client;
  164. if ($object->check_codeclient() != 0)
  165. print ' <font class="error">(' . $langs->trans("WrongCustomerCode") . ')</font>';
  166. print '</td></tr>';
  167. }
  168. if ($object->fournisseur) {
  169. print '<tr><td class="titlefield">';
  170. print $langs->trans('SupplierCode') . '</td><td colspan="3">';
  171. print $object->code_fournisseur;
  172. if ($object->check_codefournisseur() != 0)
  173. print ' <font class="error">(' . $langs->trans("WrongSupplierCode") . ')</font>';
  174. print '</td></tr>';
  175. }
  176. print '</table>';
  177. print '</div>';
  178. dol_fiche_end();
  179. if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) {
  180. $prodcustprice = new Productcustomerprice($db);
  181. $sortfield = GETPOST("sortfield", 'alpha');
  182. $sortorder = GETPOST("sortorder", 'alpha');
  183. $limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit;
  184. $page = GETPOST("page", 'int');
  185. if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
  186. $offset = $limit * $page;
  187. $pageprev = $page - 1;
  188. $pagenext = $page + 1;
  189. if (! $sortorder)
  190. $sortorder = "ASC";
  191. if (! $sortfield)
  192. $sortfield = "soc.nom";
  193. // Build filter to diplay only concerned lines
  194. $filter = array (
  195. 't.fk_soc' => $object->id
  196. );
  197. if (! empty($search_prod)) {
  198. $filter ['prod.ref'] = $search_prod;
  199. }
  200. if ($action == 'add_customer_price') {
  201. // Create mode
  202. print load_fiche_titre($langs->trans('PriceByCustomer'));
  203. print '<form action="' . $_SERVER["PHP_SELF"] . '?socid=' . $object->id . '" method="POST">';
  204. print '<input type="hidden" name="token" value="' . $_SESSION ['newtoken'] . '">';
  205. print '<input type="hidden" name="action" value="add_customer_price_confirm">';
  206. print '<input type="hidden" name="socid" value="' . $object->id . '">';
  207. print '<table class="border" width="100%">';
  208. print '<tr>';
  209. print '<td>' . $langs->trans('Product') . '</td>';
  210. print '<td>';
  211. print $form->select_produits('', 'prodid', '', 0);
  212. print '</td>';
  213. print '</tr>';
  214. // VAT
  215. print '<tr><td>' . $langs->trans("VATRate") . '</td><td>';
  216. print $form->load_tva("tva_tx", $object->tva_tx, $mysoc, '', $object->id, $object->tva_npr, '', false, 1);
  217. print '</td></tr>';
  218. // Price base
  219. print '<tr><td width="15%">';
  220. print $langs->trans('PriceBase');
  221. print '</td>';
  222. print '<td>';
  223. print $form->selectPriceBaseType($object->price_base_type, "price_base_type");
  224. print '</td>';
  225. print '</tr>';
  226. // Price
  227. print '<tr><td width="20%">';
  228. $text = $langs->trans('SellingPrice');
  229. print $form->textwithpicto($text, $langs->trans("PrecisionUnitIsLimitedToXDecimals", $conf->global->MAIN_MAX_DECIMALS_UNIT), 1, 1);
  230. print '</td><td>';
  231. if ($object->price_base_type == 'TTC') {
  232. print '<input name="price" size="10" value="' . price($object->price_ttc) . '">';
  233. } else {
  234. print '<input name="price" size="10" value="' . price($object->price) . '">';
  235. }
  236. print '</td></tr>';
  237. // Price minimum
  238. print '<tr><td>';
  239. $text = $langs->trans('MinPrice');
  240. print $form->textwithpicto($text, $langs->trans("PrecisionUnitIsLimitedToXDecimals", $conf->global->MAIN_MAX_DECIMALS_UNIT), 1, 1);
  241. if ($object->price_base_type == 'TTC') {
  242. print '<td><input name="price_min" size="10" value="' . price($object->price_min_ttc) . '">';
  243. } else {
  244. print '<td><input name="price_min" size="10" value="' . price($object->price_min) . '">';
  245. }
  246. print '</td></tr>';
  247. // Update all child soc
  248. print '<tr><td width="15%">';
  249. print $langs->trans('ForceUpdateChildPriceSoc');
  250. print '</td>';
  251. print '<td>';
  252. print '<input type="checkbox" name="updatechildprice" value="1"/>';
  253. print '</td>';
  254. print '</tr>';
  255. print '</table>';
  256. print '<br><div align="center">';
  257. print '<input type="submit" class="button" value="' . $langs->trans("Save") . '">';
  258. print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
  259. print '<input type="submit" class="button" name="cancel" value="' . $langs->trans("Cancel") . '">';
  260. print '</div>';
  261. print '<br></form>';
  262. } elseif ($action == 'edit_customer_price') {
  263. // Edit mode
  264. print load_fiche_titre($langs->trans('PriceByCustomer'));
  265. $result = $prodcustprice->fetch(GETPOST('lineid', 'int'));
  266. if ($result < 0)
  267. {
  268. setEventMessages($prodcustprice->error, $prodcustprice->errors, 'errors');
  269. }
  270. print '<form action="' . $_SERVER["PHP_SELF"] . '?socid=' . $object->id . '" method="POST">';
  271. print '<input type="hidden" name="token" value="' . $_SESSION ['newtoken'] . '">';
  272. print '<input type="hidden" name="action" value="update_customer_price_confirm">';
  273. print '<input type="hidden" name="lineid" value="' . $prodcustprice->id . '">';
  274. print '<table class="border" width="100%">';
  275. print '<tr>';
  276. print '<td>' . $langs->trans('Product') . '</td>';
  277. $staticprod = new Product($db);
  278. $staticprod->fetch($prodcustprice->fk_product);
  279. print "<td>" . $staticprod->getNomUrl(1) . "</td>";
  280. print '</tr>';
  281. // VAT
  282. print '<tr><td>' . $langs->trans("VATRate") . '</td><td>';
  283. print $form->load_tva("tva_tx", $prodcustprice->tva_tx, $mysoc, '', $staticprod->id, $prodcustprice->recuperableonly);
  284. print '</td></tr>';
  285. // Price base
  286. print '<tr><td width="15%">';
  287. print $langs->trans('PriceBase');
  288. print '</td>';
  289. print '<td>';
  290. print $form->selectPriceBaseType($prodcustprice->price_base_type, "price_base_type");
  291. print '</td>';
  292. print '</tr>';
  293. // Price
  294. print '<tr><td width="20%">';
  295. $text = $langs->trans('SellingPrice');
  296. print $form->textwithpicto($text, $langs->trans("PrecisionUnitIsLimitedToXDecimals", $conf->global->MAIN_MAX_DECIMALS_UNIT), 1, 1);
  297. print '</td><td>';
  298. if ($prodcustprice->price_base_type == 'TTC') {
  299. print '<input name="price" size="10" value="' . price($prodcustprice->price_ttc) . '">';
  300. } else {
  301. print '<input name="price" size="10" value="' . price($prodcustprice->price) . '">';
  302. }
  303. print '</td></tr>';
  304. // Price minimum
  305. print '<tr><td>';
  306. $text = $langs->trans('MinPrice');
  307. print $form->textwithpicto($text, $langs->trans("PrecisionUnitIsLimitedToXDecimals", $conf->global->MAIN_MAX_DECIMALS_UNIT), 1, 1);
  308. print '</td><td>';
  309. if ($prodcustprice->price_base_type == 'TTC') {
  310. print '<input name="price_min" size="10" value="' . price($prodcustprice->price_min_ttc) . '">';
  311. } else {
  312. print '<input name="price_min" size="10" value="' . price($prodcustprice->price_min) . '">';
  313. }
  314. print '</td></tr>';
  315. // Update all child soc
  316. print '<tr><td width="15%">';
  317. print $langs->trans('ForceUpdateChildPriceSoc');
  318. print '</td>';
  319. print '<td>';
  320. print '<input type="checkbox" name="updatechildprice" value="1">';
  321. print '</td>';
  322. print '</tr>';
  323. print '</table>';
  324. print '<br><div class="center">';
  325. print '<input type="submit" class="button" value="' . $langs->trans("Save") . '">';
  326. print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
  327. print '<input type="submit" class="button" name="cancel" value="' . $langs->trans("Cancel") . '">';
  328. print '</div>';
  329. print '<br></form>';
  330. } elseif ($action == 'showlog_customer_price') {
  331. print '<!-- showlog_customer_price -->'."\n";
  332. $filter = array (
  333. 't.fk_product' => GETPOST('prodid', 'int'),'t.fk_soc' => $socid
  334. );
  335. // Count total nb of records
  336. $nbtotalofrecords = '';
  337. if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
  338. $nbtotalofrecords = $prodcustprice->fetch_all_log($sortorder, $sortfield, $conf->liste_limit, $offset, $filter);
  339. }
  340. $result = $prodcustprice->fetch_all_log($sortorder, $sortfield, $conf->liste_limit, $offset, $filter);
  341. if ($result < 0)
  342. {
  343. setEventMessages($prodcustprice->error, $prodcustprice->errors, 'errors');
  344. }
  345. $option = '&socid=' . GETPOST('socid', 'int') . '&prodid=' . GETPOST('prodid', 'int');
  346. print_barre_liste($langs->trans('PriceByCustomerLog'), $page, $_SERVEUR ['PHP_SELF'], $option, $sortfield, $sortorder, '', count($prodcustprice->lines), $nbtotalofrecords);
  347. if (count($prodcustprice->lines) > 0) {
  348. print '<form action="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '" method="POST">';
  349. print '<input type="hidden" name="id" value="' . $object->id . '">';
  350. print '<table class="noborder" width="100%">';
  351. print '<tr class="liste_titre">';
  352. print '<td>' . $langs->trans("Product") . '</td>';
  353. print '<td>' . $langs->trans("AppliedPricesFrom") . '</td>';
  354. print '<td align="center">' . $langs->trans("PriceBase") . '</td>';
  355. print '<td align="right">' . $langs->trans("VAT") . '</td>';
  356. print '<td align="right">' . $langs->trans("HT") . '</td>';
  357. print '<td align="right">' . $langs->trans("TTC") . '</td>';
  358. print '<td align="right">' . $langs->trans("MinPrice") . ' ' . $langs->trans("HT") . '</td>';
  359. print '<td align="right">' . $langs->trans("MinPrice") . ' ' . $langs->trans("TTC") . '</td>';
  360. print '<td align="right">' . $langs->trans("ChangedBy") . '</td>';
  361. print '<td>&nbsp;</td>';
  362. print '</tr>';
  363. foreach ( $prodcustprice->lines as $line ) {
  364. print '<tr class="oddeven">';
  365. $staticprod = new Product($db);
  366. $staticprod->fetch($line->fk_product);
  367. print "<td>" . $staticprod->getNomUrl(1) . "</td>";
  368. print "<td>" . dol_print_date($line->datec, "dayhour") . "</td>";
  369. print '<td align="center">' . $langs->trans($line->price_base_type) . "</td>";
  370. print '<td align="right">' . vatrate($line->tva_tx, true, $line->recuperableonly) . "</td>";
  371. print '<td align="right">' . price($line->price) . "</td>";
  372. print '<td align="right">' . price($line->price_ttc) . "</td>";
  373. print '<td align="right">' . price($line->price_min) . '</td>';
  374. print '<td align="right">' . price($line->price_min_ttc) . '</td>';
  375. // User
  376. $userstatic = new User($db);
  377. $userstatic->fetch($line->fk_user);
  378. print '<td align="right">';
  379. print $userstatic->getLoginUrl(1);
  380. print '</td>';
  381. }
  382. print "</table>";
  383. }
  384. else
  385. {
  386. print $langs->trans('None');
  387. }
  388. print "\n" . '<div class="tabsAction">' . "\n";
  389. print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?socid=' . $object->id . '">' . $langs->trans("Ok") . '</a></div>';
  390. print "\n</div><br>\n";
  391. }
  392. else
  393. {
  394. // View mode
  395. /* ************************************************************************** */
  396. /* */
  397. /* Barre d'action */
  398. /* */
  399. /* ************************************************************************** */
  400. print "\n" . '<div class="tabsAction">' . "\n";
  401. if ($user->rights->produit->creer || $user->rights->service->creer) {
  402. 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>';
  403. }
  404. print "\n</div>\n";
  405. // Count total nb of records
  406. $nbtotalofrecords = '';
  407. if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
  408. {
  409. $nbtotalofrecords = $prodcustprice->fetch_all('', '', 0, 0, $filter);
  410. }
  411. $result = $prodcustprice->fetch_all($sortorder, $sortfield, $conf->liste_limit, $offset, $filter);
  412. if ($result < 0)
  413. {
  414. setEventMessages($prodcustprice->error, $prodcustprice->errors, 'errors');
  415. }
  416. $option = '&search_prod=' . $search_prod . '&id=' . $object->id;
  417. print '<!-- view specific price for each product -->'."\n";
  418. print_barre_liste($langs->trans('PriceForEachProduct'), $page, $_SERVEUR['PHP_SELF'], $option, $sortfield, $sortorder, '', count($prodcustprice->lines), $nbtotalofrecords, '');
  419. print '<form action="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '" method="POST">';
  420. print '<input type="hidden" name="id" value="' . $object->id . '">';
  421. print '<table class="noborder" width="100%">';
  422. print '<tr class="liste_titre">';
  423. print '<td>' . $langs->trans("Product") . '</td>';
  424. print '<td>' . $langs->trans("AppliedPricesFrom") . '</td>';
  425. print '<td align="center">' . $langs->trans("PriceBase") . '</td>';
  426. print '<td align="right">' . $langs->trans("VAT") . '</td>';
  427. print '<td align="right">' . $langs->trans("HT") . '</td>';
  428. print '<td align="right">' . $langs->trans("TTC") . '</td>';
  429. print '<td align="right">' . $langs->trans("MinPrice") . ' ' . $langs->trans("HT") . '</td>';
  430. print '<td align="right">' . $langs->trans("MinPrice") . ' ' . $langs->trans("TTC") . '</td>';
  431. print '<td align="right">' . $langs->trans("ChangedBy") . '</td>';
  432. print '<td>&nbsp;</td>';
  433. print '</tr>';
  434. if (count($prodcustprice->lines) > 0 || $search_prod)
  435. {
  436. print '<tr class="liste_titre">';
  437. print '<td class="liste_titre"><input type="text" class="flat" name="search_prod" value="' . $search_prod . '" size="20"></td>';
  438. print '<td class="liste_titre" colspan="8">&nbsp;</td>';
  439. // Print the search button
  440. print '<td class="liste_titre" align="right">';
  441. $searchpicto=$form->showFilterAndCheckAddButtons(0);
  442. print $searchpicto;
  443. print '</td>';
  444. print '</tr>';
  445. }
  446. if (count($prodcustprice->lines) > 0)
  447. {
  448. foreach ($prodcustprice->lines as $line)
  449. {
  450. print '<tr class="oddeven">';
  451. $staticprod = new Product($db);
  452. $staticprod->fetch($line->fk_product);
  453. print "<td>" . $staticprod->getNomUrl(1) . "</td>";
  454. print "<td>" . dol_print_date($line->datec, "dayhour") . "</td>";
  455. print '<td align="center">' . $langs->trans($line->price_base_type) . "</td>";
  456. print '<td align="right">' . vatrate($line->tva_tx.($line->default_vat_code?' ('.$line->default_vat_code.')':''), true, $line->recuperableonly) . "</td>";
  457. print '<td align="right">' . price($line->price) . "</td>";
  458. print '<td align="right">' . price($line->price_ttc) . "</td>";
  459. print '<td align="right">' . price($line->price_min) . '</td>';
  460. print '<td align="right">' . price($line->price_min_ttc) . '</td>';
  461. // User
  462. $userstatic = new User($db);
  463. $userstatic->fetch($line->fk_user);
  464. print '<td align="right">';
  465. print $userstatic->getLoginUrl(1);
  466. print '</td>';
  467. // Action
  468. if ($user->rights->produit->creer || $user->rights->service->creer)
  469. {
  470. print '<td align="right">';
  471. print '<a href="' . $_SERVER["PHP_SELF"] . '?action=showlog_customer_price&amp;socid=' . $object->id . '&amp;prodid=' . $line->fk_product . '">';
  472. print img_info();
  473. print '</a>';
  474. print ' ';
  475. print '<a href="' . $_SERVER["PHP_SELF"] . '?action=edit_customer_price&amp;socid=' . $object->id . '&amp;lineid=' . $line->id . '">';
  476. print img_edit('default', 0, 'style="vertical-align: middle;"');
  477. print '</a>';
  478. print ' ';
  479. print '<a href="' . $_SERVER["PHP_SELF"] . '?action=delete_customer_price&amp;socid=' . $object->id . '&amp;lineid=' . $line->id . '">';
  480. print img_delete('default', 'style="vertical-align: middle;"');
  481. print '</a>';
  482. print '</td>';
  483. }
  484. print "</tr>\n";
  485. }
  486. }
  487. else
  488. {
  489. $colspan=9;
  490. if ($user->rights->produit->supprimer || $user->rights->service->supprimer) $colspan+=1;
  491. print '<tr ' . $bc[false] . '><td colspan="'.$colspan.'">' . $langs->trans('None') . '</td></tr>';
  492. }
  493. print "</table>";
  494. print "</form>";
  495. }
  496. }
  497. // End of page
  498. llxFooter();
  499. $db->close();