reassort.php 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523
  1. <?php
  2. /* Copyright (C) 2001-2006 Rodolphe Quiedeville <rodolphe@quiedeville.org>
  3. * Copyright (C) 2004-2015 Laurent Destailleur <eldy@users.sourceforge.net>
  4. * Copyright (C) 2005-2018 Regis Houssin <regis.houssin@inodbox.com>
  5. * Copyright (C) 2013 Cédric Salvador <csalvador@gpcsolutions.fr>
  6. * Copyright (C) 2015 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
  7. * Copyright (C) 2019 Juanjo Menent <jmenent@2byte.es>
  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. * \file htdocs/product/reassort.php
  24. * \ingroup produit
  25. * \brief Page to list stocks
  26. */
  27. require '../main.inc.php';
  28. require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
  29. require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
  30. require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
  31. require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php';
  32. // Load translation files required by the page
  33. $langs->loadLangs(array('products', 'stocks'));
  34. $action = GETPOST('action', 'aZ09');
  35. $sref = GETPOST("sref", 'alpha');
  36. $snom = GETPOST("snom", 'alpha');
  37. $sall = trim((GETPOST('search_all', 'alphanohtml') != '') ?GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml'));
  38. $type = GETPOSTISSET('type') ? GETPOST('type', 'int') : Product::TYPE_PRODUCT;
  39. $search_barcode = GETPOST("search_barcode", 'alpha');
  40. $toolowstock = GETPOST('toolowstock');
  41. $tosell = GETPOST("tosell");
  42. $tobuy = GETPOST("tobuy");
  43. $fourn_id = GETPOST("fourn_id", 'int');
  44. $sbarcode = GETPOST("sbarcode", 'int');
  45. $search_stock_physique = GETPOST('search_stock_physique', 'alpha');
  46. $sortfield = GETPOST('sortfield', 'aZ09comma');
  47. $sortorder = GETPOST('sortorder', 'aZ09comma');
  48. $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
  49. if (empty($page) || $page < 0) {
  50. $page = 0;
  51. }
  52. if (!$sortfield) {
  53. $sortfield = "p.ref";
  54. }
  55. if (!$sortorder) {
  56. $sortorder = "ASC";
  57. }
  58. $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
  59. if (empty($page) || $page == -1) {
  60. $page = 0;
  61. } // If $page is not defined, or '' or -1
  62. $offset = $limit * $page;
  63. // Load sale and categ filters
  64. $search_sale = GETPOST("search_sale");
  65. if (GETPOSTISSET('catid')) {
  66. $search_categ = GETPOST('catid', 'int');
  67. } else {
  68. $search_categ = GETPOST('search_categ', 'int');
  69. }
  70. // Get object canvas (By default, this is not defined, so standard usage of dolibarr)
  71. $canvas = GETPOST("canvas");
  72. $objcanvas = null;
  73. if (!empty($canvas)) {
  74. require_once DOL_DOCUMENT_ROOT.'/core/class/canvas.class.php';
  75. $objcanvas = new Canvas($db, $action);
  76. $objcanvas->getCanvas('product', 'list', $canvas);
  77. }
  78. // Define virtualdiffersfromphysical
  79. $virtualdiffersfromphysical = 0;
  80. if (!empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT)
  81. || !empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER)
  82. || !empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT_CLOSE)
  83. || !empty($conf->global->STOCK_CALCULATE_ON_RECEPTION)
  84. || !empty($conf->global->STOCK_CALCULATE_ON_RECEPTION_CLOSE)
  85. || !empty($conf->mrp->enabled)) {
  86. $virtualdiffersfromphysical = 1; // According to increase/decrease stock options, virtual and physical stock may differs.
  87. }
  88. // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
  89. $hookmanager->initHooks(array('productreassortlist'));
  90. if ($user->socid) {
  91. $socid = $user->socid;
  92. }
  93. $result = restrictedArea($user, 'produit|service', 0, 'product&product');
  94. $object = new Product($db);
  95. /*
  96. * Actions
  97. */
  98. if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All tests are required to be compatible with all browsers
  99. $sref = "";
  100. $snom = "";
  101. $sall = "";
  102. $tosell = "";
  103. $tobuy = "";
  104. $search_sale = "";
  105. $search_categ = "";
  106. $toolowstock = '';
  107. $fourn_id = '';
  108. $sbarcode = '';
  109. $search_stock_physique = '';
  110. }
  111. /*
  112. * View
  113. */
  114. $helpurl = 'EN:Module_Stocks_En|FR:Module_Stock|ES:M&oacute;dulo_Stocks';
  115. $form = new Form($db);
  116. $htmlother = new FormOther($db);
  117. $sql = 'SELECT p.rowid, p.ref, p.label, p.barcode, p.price, p.price_ttc, p.price_base_type, p.entity,';
  118. $sql .= ' p.fk_product_type, p.tms as datem,';
  119. $sql .= ' p.duration, p.tosell as statut, p.tobuy, p.seuil_stock_alerte, p.desiredstock,';
  120. $sql .= ' SUM(s.reel) as stock_physique';
  121. if (!empty($conf->global->PRODUCT_USE_UNITS)) {
  122. $sql .= ', u.short_label as unit_short';
  123. }
  124. // Add fields from hooks
  125. $parameters = array();
  126. $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook
  127. $sql .= $hookmanager->resPrint;
  128. $sql .= ' FROM '.MAIN_DB_PREFIX.'product as p';
  129. $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_stock as s ON p.rowid = s.fk_product';
  130. $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'entrepot as e ON s.fk_entrepot = e.rowid AND e.entity IN ('.getEntity('entrepot').')';
  131. if (!empty($conf->global->PRODUCT_USE_UNITS)) {
  132. $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_units as u on p.fk_unit = u.rowid';
  133. }
  134. $sql .= " WHERE p.entity IN (".getEntity('product').")";
  135. if (!empty($search_categ) && $search_categ != '-1') {
  136. $sql .= " AND ";
  137. if ($search_categ == -2) {
  138. $sql .= " NOT EXISTS ";
  139. } else {
  140. $sql .= " EXISTS ";
  141. }
  142. $sql .= "(";
  143. $sql .= " SELECT cp.fk_categorie, cp.fk_product";
  144. $sql .= " FROM " . MAIN_DB_PREFIX . "categorie_product as cp";
  145. $sql .= " WHERE cp.fk_product = p.rowid"; // Join for the needed table to filter by categ
  146. if ($search_categ > 0) {
  147. $sql .= " AND cp.fk_categorie = " . ((int) $search_categ);
  148. }
  149. $sql .= ")";
  150. }
  151. if ($sall) {
  152. $sql .= natural_search(array('p.ref', 'p.label', 'p.description', 'p.note'), $sall);
  153. }
  154. // if the type is not 1, we show all products (type = 0,2,3)
  155. if (dol_strlen($type)) {
  156. if ($type == 1) {
  157. $sql .= " AND p.fk_product_type = '1'";
  158. } else {
  159. $sql .= " AND p.fk_product_type <> '1'";
  160. }
  161. }
  162. if ($sref) {
  163. $sql .= natural_search('p.ref', $sref);
  164. }
  165. if ($search_barcode) {
  166. $sql .= natural_search('p.barcode', $search_barcode);
  167. }
  168. if ($snom) {
  169. $sql .= natural_search('p.label', $snom);
  170. }
  171. if (!empty($tosell)) {
  172. $sql .= " AND p.tosell = ".((int) $tosell);
  173. }
  174. if (!empty($tobuy)) {
  175. $sql .= " AND p.tobuy = ".((int) $tobuy);
  176. }
  177. if (!empty($canvas)) {
  178. $sql .= " AND p.canvas = '".$db->escape($canvas)."'";
  179. }
  180. if ($fourn_id > 0) {
  181. $sql .= " AND p.rowid = pf.fk_product AND pf.fk_soc = ".((int) $fourn_id);
  182. }
  183. // Add where from hooks
  184. $parameters = array();
  185. $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object); // Note that $action and $object may have been modified by hook
  186. $sql .= $hookmanager->resPrint;
  187. $sql .= " GROUP BY p.rowid, p.ref, p.label, p.barcode, p.price, p.price_ttc, p.price_base_type, p.entity,";
  188. $sql .= " p.fk_product_type, p.tms, p.duration, p.tosell, p.tobuy, p.seuil_stock_alerte, p.desiredstock";
  189. // Add fields from hooks
  190. $parameters = array();
  191. $reshook = $hookmanager->executeHooks('printFieldSelect', $parameters, $object); // Note that $action and $object may have been modified by hook
  192. $sql .= $hookmanager->resPrint;
  193. $sql_having = '';
  194. if ($toolowstock) {
  195. $sql_having .= " HAVING SUM(".$db->ifsql('s.reel IS NULL', '0', 's.reel').") < p.seuil_stock_alerte";
  196. }
  197. if ($search_stock_physique != '') {
  198. //$natural_search_physique = natural_search('HAVING SUM(' . $db->ifsql('s.reel IS NULL', '0', 's.reel') . ')', $search_stock_physique, 1, 1);
  199. $natural_search_physique = natural_search('SUM(' . $db->ifsql('s.reel IS NULL', '0', 's.reel') . ')', $search_stock_physique, 1, 1);
  200. $natural_search_physique = " " . substr($natural_search_physique, 1, -1); // remove first "(" and last ")" characters
  201. if (!empty($sql_having)) {
  202. $sql_having .= " AND";
  203. } else {
  204. $sql_having .= " HAVING";
  205. }
  206. $sql_having .= $natural_search_physique;
  207. }
  208. if (!empty($sql_having)) {
  209. $sql .= $sql_having;
  210. }
  211. $sql .= $db->order($sortfield, $sortorder);
  212. // Count total nb of records
  213. $nbtotalofrecords = '';
  214. if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
  215. $result = $db->query($sql);
  216. $nbtotalofrecords = $db->num_rows($result);
  217. if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0
  218. $page = 0;
  219. $offset = 0;
  220. }
  221. }
  222. $sql .= $db->plimit($limit + 1, $offset);
  223. $resql = $db->query($sql);
  224. if ($resql) {
  225. $num = $db->num_rows($resql);
  226. $i = 0;
  227. if ($num == 1 && GETPOST('autojumpifoneonly') && ($sall || $snom || $sref)) {
  228. $objp = $db->fetch_object($resql);
  229. header("Location: card.php?id=$objp->rowid");
  230. exit;
  231. }
  232. if (isset($type)) {
  233. if ($type == 1) {
  234. $texte = $langs->trans("Services");
  235. } else {
  236. $texte = $langs->trans("Products");
  237. }
  238. } else {
  239. $texte = $langs->trans("ProductsAndServices");
  240. }
  241. $texte .= ' ('.$langs->trans("MenuStocks").')';
  242. $param = '';
  243. if ($limit > 0 && $limit != $conf->liste_limit) {
  244. $param .= '&limit='.urlencode($limit);
  245. }
  246. if ($sall) {
  247. $param .= "&sall=".urlencode($sall);
  248. }
  249. if ($tosell) {
  250. $param .= "&tosell=".urlencode($tosell);
  251. }
  252. if ($tobuy) {
  253. $param .= "&tobuy=".urlencode($tobuy);
  254. }
  255. if ($type != '') {
  256. $param .= "&type=".urlencode($type);
  257. }
  258. if ($fourn_id) {
  259. $param .= "&fourn_id=".urlencode($fourn_id);
  260. }
  261. if ($snom) {
  262. $param .= "&snom=".urlencode($snom);
  263. }
  264. if ($sref) {
  265. $param .= "&sref=".urlencode($sref);
  266. }
  267. if ($search_sale) {
  268. $param .= "&search_sale=".urlencode($search_sale);
  269. }
  270. if ($search_categ > 0) {
  271. $param .= "&search_categ=".urlencode($search_categ);
  272. }
  273. if ($toolowstock) {
  274. $param .= "&toolowstock=".urlencode($toolowstock);
  275. }
  276. if ($sbarcode) {
  277. $param .= "&sbarcode=".urlencode($sbarcode);
  278. }
  279. if ($search_stock_physique) {
  280. $param .= '&search_stock_physique=' . urlencode($search_stock_physique);
  281. }
  282. llxHeader("", $texte, $helpurl);
  283. print '<form action="'.$_SERVER["PHP_SELF"].'" method="post" name="formulaire">';
  284. print '<input type="hidden" name="token" value="'.newToken().'">';
  285. print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
  286. print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
  287. print '<input type="hidden" name="page" value="'.$page.'">';
  288. print '<input type="hidden" name="type" value="'.$type.'">';
  289. print_barre_liste($texte, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'product', 0, '', '', $limit);
  290. if ($search_categ > 0) {
  291. print "<div id='ways'>";
  292. $c = new Categorie($db);
  293. $c->fetch($search_categ);
  294. $ways = $c->print_all_ways(' &gt; ', 'product/reassort.php');
  295. print " &gt; ".$ways[0]."<br>\n";
  296. print "</div><br>";
  297. }
  298. // Filter on categories
  299. $moreforfilter = '';
  300. if (!empty($conf->categorie->enabled)) {
  301. $moreforfilter .= '<div class="divsearchfield">';
  302. $moreforfilter .= img_picto($langs->trans('Categories'), 'category', 'class="pictofixedwidth"');
  303. $moreforfilter .= $htmlother->select_categories(Categorie::TYPE_PRODUCT, $search_categ, 'search_categ', 1);
  304. $moreforfilter .= '</div>';
  305. }
  306. $moreforfilter .= '<div class="divsearchfield">';
  307. $moreforfilter .= $langs->trans("StockTooLow").' <input type="checkbox" name="toolowstock" value="1"'.($toolowstock ? ' checked' : '').'>';
  308. $moreforfilter .= '</div>';
  309. if (!empty($moreforfilter)) {
  310. print '<div class="liste_titre liste_titre_bydiv centpercent">';
  311. print $moreforfilter;
  312. $parameters = array();
  313. $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook
  314. print $hookmanager->resPrint;
  315. print '</div>';
  316. }
  317. $formProduct = new FormProduct($db);
  318. $formProduct->loadWarehouses();
  319. $warehouses_list = $formProduct->cache_warehouses;
  320. $nb_warehouse = count($warehouses_list);
  321. $colspan_warehouse = 1;
  322. if (!empty($conf->global->STOCK_DETAIL_ON_WAREHOUSE)) {
  323. $colspan_warehouse = $nb_warehouse > 1 ? $nb_warehouse + 1 : 1;
  324. }
  325. print '<div class="div-table-responsive">';
  326. print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">';
  327. // Fields title search
  328. print '<tr class="liste_titre_filter">';
  329. print '<td class="liste_titre">';
  330. print '<input class="flat" type="text" name="sref" size="6" value="'.$sref.'">';
  331. print '</td>';
  332. print '<td class="liste_titre">';
  333. print '<input class="flat" type="text" name="snom" size="8" value="'.$snom.'">';
  334. print '</td>';
  335. // Duration
  336. if (!empty($conf->service->enabled) && $type == 1) {
  337. print '<td class="liste_titre">';
  338. print '&nbsp;';
  339. print '</td>';
  340. }
  341. // Stock limit
  342. print '<td class="liste_titre">&nbsp;</td>';
  343. print '<td class="liste_titre right">&nbsp;</td>';
  344. // Physical stock
  345. print '<td class="liste_titre right">';
  346. print '<input class="flat" type="text" size="5" name="search_stock_physique" value="'.dol_escape_htmltag($search_stock_physique).'">';
  347. print '</td>';
  348. if ($virtualdiffersfromphysical) {
  349. print '<td class="liste_titre">&nbsp;</td>';
  350. }
  351. print '<td class="liste_titre">&nbsp;</td>';
  352. print '<td class="liste_titre" colspan="'.$colspan_warehouse.'">&nbsp;</td>';
  353. print '<td class="liste_titre"></td>';
  354. $parameters = array();
  355. $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook
  356. print $hookmanager->resPrint;
  357. print '<td class="liste_titre maxwidthsearch">';
  358. $searchpicto = $form->showFilterAndCheckAddButtons(0);
  359. print $searchpicto;
  360. print '</td>';
  361. print '</tr>';
  362. //Line for column titles
  363. print "<tr class=\"liste_titre\">";
  364. print_liste_field_titre("Ref", $_SERVER["PHP_SELF"], "p.ref", '', $param, "", $sortfield, $sortorder);
  365. print_liste_field_titre("Label", $_SERVER["PHP_SELF"], "p.label", '', $param, "", $sortfield, $sortorder);
  366. if (!empty($conf->service->enabled) && $type == 1) {
  367. print_liste_field_titre("Duration", $_SERVER["PHP_SELF"], "p.duration", '', $param, "", $sortfield, $sortorder, 'center ');
  368. }
  369. print_liste_field_titre("StockLimit", $_SERVER["PHP_SELF"], "p.seuil_stock_alerte", '', $param, "", $sortfield, $sortorder, 'right ');
  370. print_liste_field_titre("DesiredStock", $_SERVER["PHP_SELF"], "p.desiredstock", '', $param, "", $sortfield, $sortorder, 'right ');
  371. print_liste_field_titre("PhysicalStock", $_SERVER["PHP_SELF"], "stock_physique", '', $param, "", $sortfield, $sortorder, 'right ');
  372. // Details per warehouse
  373. if (!empty($conf->global->STOCK_DETAIL_ON_WAREHOUSE)) { // TODO This should be moved into the selection of fields on page product/list (page product/stock will be removed and replaced with product/list with its own context)
  374. if ($nb_warehouse > 1) {
  375. foreach ($warehouses_list as &$wh) {
  376. print_liste_field_titre($wh['label'], '', '', '', '', '', '', '', 'right ');
  377. }
  378. }
  379. }
  380. if ($virtualdiffersfromphysical) {
  381. print_liste_field_titre("VirtualStock", $_SERVER["PHP_SELF"], "", '', $param, "", $sortfield, $sortorder, 'right ', 'VirtualStockDesc');
  382. }
  383. // Units
  384. if (!empty($conf->global->PRODUCT_USE_UNITS)) {
  385. print_liste_field_titre("Unit", $_SERVER["PHP_SELF"], "unit_short", '', $param, 'align="right"', $sortfield, $sortorder);
  386. }
  387. print_liste_field_titre('');
  388. print_liste_field_titre("ProductStatusOnSell", $_SERVER["PHP_SELF"], "p.tosell", '', $param, "", $sortfield, $sortorder, 'right ');
  389. print_liste_field_titre("ProductStatusOnBuy", $_SERVER["PHP_SELF"], "p.tobuy", '', $param, "", $sortfield, $sortorder, 'right ');
  390. // Hook fields
  391. $parameters = array('param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder);
  392. $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook
  393. print $hookmanager->resPrint;
  394. print_liste_field_titre('');
  395. print "</tr>\n";
  396. while ($i < min($num, $limit)) {
  397. $objp = $db->fetch_object($resql);
  398. $product = new Product($db);
  399. $product->fetch($objp->rowid);
  400. $product->load_stock();
  401. print '<tr>';
  402. print '<td class="nowrap">';
  403. print $product->getNomUrl(1, '', 16);
  404. //if ($objp->stock_theorique < $objp->seuil_stock_alerte) print ' '.img_warning($langs->trans("StockTooLow"));
  405. print '</td>';
  406. print '<td>'.$product->label.'</td>';
  407. if (!empty($conf->service->enabled) && $type == 1) {
  408. print '<td class="center">';
  409. if (preg_match('/([0-9]+)y/i', $objp->duration, $regs)) {
  410. print $regs[1].' '.$langs->trans("DurationYear");
  411. } elseif (preg_match('/([0-9]+)m/i', $objp->duration, $regs)) {
  412. print $regs[1].' '.$langs->trans("DurationMonth");
  413. } elseif (preg_match('/([0-9]+)d/i', $objp->duration, $regs)) {
  414. print $regs[1].' '.$langs->trans("DurationDay");
  415. } else {
  416. print $objp->duration;
  417. }
  418. print '</td>';
  419. }
  420. //print '<td class="right">'.$objp->stock_theorique.'</td>';
  421. print '<td class="right">'.$objp->seuil_stock_alerte.'</td>';
  422. print '<td class="right">'.$objp->desiredstock.'</td>';
  423. // Real stock
  424. print '<td class="right">';
  425. if ($objp->seuil_stock_alerte != '' && ($objp->stock_physique < $objp->seuil_stock_alerte)) {
  426. print img_warning($langs->trans("StockTooLow")).' ';
  427. }
  428. print price2num($objp->stock_physique, 'MS');
  429. print '</td>';
  430. // Details per warehouse
  431. if (!empty($conf->global->STOCK_DETAIL_ON_WAREHOUSE)) { // TODO This should be moved into the selection of fields on page product/list (page product/stock will be removed and replaced with product/list with its own context)
  432. if ($nb_warehouse > 1) {
  433. foreach ($warehouses_list as &$wh) {
  434. print '<td class="right">';
  435. print empty($product->stock_warehouse[$wh['id']]->real) ? '0' : $product->stock_warehouse[$wh['id']]->real;
  436. print '</td>';
  437. }
  438. }
  439. }
  440. // Virtual stock
  441. if ($virtualdiffersfromphysical) {
  442. print '<td class="right">';
  443. if ($objp->seuil_stock_alerte != '' && ($product->stock_theorique < $objp->seuil_stock_alerte)) {
  444. print img_warning($langs->trans("StockTooLow")).' ';
  445. }
  446. print price2num($product->stock_theorique, 'MS');
  447. print '</td>';
  448. }
  449. // Units
  450. if (!empty($conf->global->PRODUCT_USE_UNITS)) {
  451. print '<td class="left">'.$objp->unit_short.'</td>';
  452. }
  453. print '<td class="center">';
  454. print img_picto($langs->trans("StockMovement"), 'movement', 'class="pictofixedwidth"');
  455. print '<a href="'.DOL_URL_ROOT.'/product/stock/movement_list.php?idproduct='.$product->id.'">'.$langs->trans("Movements").'</a>';
  456. print '</td>';
  457. print '<td class="right nowrap">'.$product->LibStatut($objp->statut, 5, 0).'</td>';
  458. print '<td class="right nowrap">'.$product->LibStatut($objp->tobuy, 5, 1).'</td>';
  459. // Fields from hook
  460. $parameters = array('obj'=>$objp);
  461. $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $product); // Note that $action and $object may have been modified by hook
  462. print $hookmanager->resPrint;
  463. print '<td></td>';
  464. print "</tr>\n";
  465. $i++;
  466. }
  467. print "</table>";
  468. print '</div>';
  469. print '</form>';
  470. $db->free($resql);
  471. } else {
  472. dol_print_error($db);
  473. }
  474. // End of page
  475. llxFooter();
  476. $db->close();