32require
'../main.inc.php';
33require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
34require_once DOL_DOCUMENT_ROOT.
'/product/stock/class/productlot.class.php';
35require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formother.class.php';
36require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
37require_once DOL_DOCUMENT_ROOT.
'/product/stock/class/entrepot.class.php';
38require_once DOL_DOCUMENT_ROOT.
'/product/stock/class/productlot.class.php';
41$langs->loadLangs(array(
'products',
'stocks',
'productbatch',
'categories'));
43$action =
GETPOST(
'action',
'aZ09') ?
GETPOST(
'action',
'aZ09') :
'view';
44$massaction =
GETPOST(
'massaction',
'alpha');
45$contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'myobjectlist';
46$backtopage =
GETPOST(
'backtopage',
'alpha');
47$optioncss =
GETPOST(
'optioncss',
'aZ');
50$sref =
GETPOST(
"sref",
'alpha');
51$snom =
GETPOST(
"snom",
'alpha');
52$search_all = trim((
GETPOST(
'search_all',
'alphanohtml') !=
'') ?
GETPOST(
'search_all',
'alphanohtml') :
GETPOST(
'sall',
'alphanohtml'));
53$type = GETPOSTISSET(
'type') ?
GETPOST(
'type',
'int') :
Product::TYPE_PRODUCT;
54$search_barcode =
GETPOST(
"search_barcode",
'alpha');
55$search_warehouse =
GETPOST(
'search_warehouse',
'alpha');
56$search_batch =
GETPOST(
'search_batch',
'alpha');
57$search_toolowstock =
GETPOST(
'search_toolowstock');
58$search_subjecttolotserial =
GETPOST(
'search_subjecttolotserial');
61$fourn_id =
GETPOST(
"fourn_id",
'int');
62$sbarcode =
GETPOST(
"sbarcode",
'int');
63$search_stock_physique =
GETPOST(
'search_stock_physique',
'alpha');
66$limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
67$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
68$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
69$page = GETPOSTISSET(
'pageplusone') ? (
GETPOST(
'pageplusone') - 1) :
GETPOST(
"page",
'int');
70if (empty($page) || $page < 0 ||
GETPOST(
'button_search',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
74$offset = $limit * $page;
80$search_sale =
GETPOST(
"search_sale");
81if (GETPOSTISSET(
'catid')) {
82 $search_categ =
GETPOST(
'catid',
'int');
84 $search_categ =
GETPOST(
'search_categ',
'int');
86$search_warehouse_categ =
GETPOST(
'search_warehouse_categ',
'int');
89$extrafields->fetch_name_optionals_label($object->table_element);
92$search_array_options = $extrafields->getOptionalsFromPost($object->table_element,
'',
'search_');
96 reset($object->fields);
97 $sortfield =
"p.".key($object->fields);
106foreach ($object->fields as $key => $val) {
107 if (
GETPOST(
'search_'.$key,
'alpha') !==
'') {
108 $search[$key] =
GETPOST(
'search_'.$key,
'alpha');
110 if (preg_match(
'/^(date|timestamp|datetime)/', $val[
'type'])) {
111 $search[$key.
'_dtstart'] =
dol_mktime(0, 0, 0,
GETPOST(
'search_'.$key.
'_dtstartmonth',
'int'),
GETPOST(
'search_'.$key.
'_dtstartday',
'int'),
GETPOST(
'search_'.$key.
'_dtstartyear',
'int'));
112 $search[$key.
'_dtend'] =
dol_mktime(23, 59, 59,
GETPOST(
'search_'.$key.
'_dtendmonth',
'int'),
GETPOST(
'search_'.$key.
'_dtendday',
'int'),
GETPOST(
'search_'.$key.
'_dtendyear',
'int'));
116$search[$key.
'_dtstart'] =
dol_mktime(0, 0, 0,
GETPOST(
'search_'.$key.
'_dtstartmonth',
'int'),
GETPOST(
'search_'.$key.
'_dtstartday',
'int'),
GETPOST(
'search_'.$key.
'_dtstartyear',
'int'));
117$search[$key.
'_dtend'] =
dol_mktime(23, 59, 59,
GETPOST(
'search_'.$key.
'_dtendmonth',
'int'),
GETPOST(
'search_'.$key.
'_dtendday',
'int'),
GETPOST(
'search_'.$key.
'_dtendyear',
'int'));
119$search[$key.
'_dtstart'] =
dol_mktime(0, 0, 0,
GETPOST(
'search_'.$key.
'_dtstartmonth',
'int'),
GETPOST(
'search_'.$key.
'_dtstartday',
'int'),
GETPOST(
'search_'.$key.
'_dtstartyear',
'int'));
120$search[$key.
'_dtend'] =
dol_mktime(23, 59, 59,
GETPOST(
'search_'.$key.
'_dtendmonth',
'int'),
GETPOST(
'search_'.$key.
'_dtendday',
'int'),
GETPOST(
'search_'.$key.
'_dtendyear',
'int'));
125if (!empty($canvas)) {
126 require_once DOL_DOCUMENT_ROOT.
'/core/class/canvas.class.php';
127 $objcanvas =
new Canvas($db, $action);
128 $objcanvas->getCanvas(
'product',
'list', $canvas);
132$hookmanager->initHooks(array(
'reassortlotlist'));
136 $socid = $user->socid;
138$result =
restrictedArea($user,
'produit|service', 0,
'product&product');
142 array(
'type'=>
'varchar',
'label'=>
'Ref',
'checked'=>1,
'enabled'=>1,
'position'=>1),
143 array(
'type'=>
'varchar',
'label'=>
'Label',
'checked'=>1,
'enabled'=>1,
'position'=>1),
144 array(
'type'=>
'int',
'label'=>
'Warehouse',
'checked'=>1,
'enabled'=>1,
'position'=>1),
145 array(
'type'=>
'varchar',
'label'=>
'Lot',
'checked'=>1,
'enabled'=>1,
'position'=>1),
146 array(
'type'=>
'varchar',
'label'=>
'DLC',
'checked'=>1,
'enabled'=>1,
'position'=>1),
147 array(
'type'=>
'varchar',
'label'=>
'DLUO',
'checked'=>1,
'enabled'=>1,
'position'=>1),
148 array(
'type'=>
'int',
'label'=>
'Stock',
'checked'=>1,
'enabled'=>1,
'position'=>1),
149 array(
'type'=>
'int',
'label'=>
'StatusSell',
'checked'=>1,
'enabled'=>1,
'position'=>1),
150 array(
'type'=>
'int',
'label'=>
'StatusBuy',
'checked'=>1,
'enabled'=>1,
'position'=>1),
162if (
GETPOST(
'cancel',
'alpha')) {
166if (!
GETPOST(
'confirmmassaction',
'alpha') && $massaction !=
'presend' && $massaction !=
'confirm_presend') {
170$parameters = array();
171$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
176if (empty($reshook)) {
178 include DOL_DOCUMENT_ROOT.
'/core/actions_changeselectedfields.inc.php';
181 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
182 foreach ($object->fields as $key => $val) {
184 if (preg_match(
'/^(date|timestamp|datetime)/', $val[
'type'])) {
185 $search[$key.
'_dtstart'] =
'';
186 $search[$key.
'_dtend'] =
'';
189 $search[
'sellby_dtstart'] =
'';
190 $search[
'eatby_dtstart'] =
'';
191 $search[
'sellby_dtend'] =
'';
192 $search[
'eatby_dtend'] =
'';
200 $search_warehouse_categ =
"";
201 $search_toolowstock =
'';
202 $search_subjecttolotserial =
'';
204 $search_warehouse =
'';
207 $search_stock_physique =
'';
209 $search_array_options = array();
211 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')
212 ||
GETPOST(
'button_search_x',
'alpha') ||
GETPOST(
'button_search.x',
'alpha') ||
GETPOST(
'button_search',
'alpha')) {
230$form =
new Form($db);
235$helpurl =
'EN:Module_Stocks_En|FR:Module_Stock|ES:Módulo_Stocks';
236$title = $langs->trans(
"ProductsAndServices");
240$sql =
'SELECT p.rowid, p.ref, p.label, p.barcode, p.price, p.price_ttc, p.price_base_type, p.entity,';
241$sql .=
' p.fk_product_type, p.tms as datem,';
242$sql .=
' p.duration, p.tosell as statut, p.tobuy, p.seuil_stock_alerte, p.desiredstock, p.stock, p.tosell, p.tobuy, p.tobatch,';
243$sql .=
' ps.fk_entrepot, ps.reel,';
244$sql .=
' e.ref as warehouse_ref, e.lieu as warehouse_lieu, e.fk_parent as warehouse_parent,';
245$sql .=
' pb.batch, pb.eatby as oldeatby, pb.sellby as oldsellby,';
246$sql .=
' pl.rowid as lotid, pl.eatby, pl.sellby,';
247$sql .=
' SUM(pb.qty) as stock_physique, COUNT(pb.rowid) as nbinbatchtable';
249$parameters = array();
250$reshook = $hookmanager->executeHooks(
'printFieldListSelect', $parameters, $object);
251$sql .= $hookmanager->resPrint;
252$sql .=
' FROM '.MAIN_DB_PREFIX.
'product as p';
253$sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'product_stock as ps on p.rowid = ps.fk_product';
254$sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'entrepot as e on ps.fk_entrepot = e.rowid';
255$sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'product_batch as pb on pb.fk_product_stock = ps.rowid';
256$sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'product_lot as pl on pl.fk_product = p.rowid AND pl.batch = pb.batch';
258$parameters = array();
259$reshook = $hookmanager->executeHooks(
'printFieldListFrom', $parameters, $object);
260$sql .= $hookmanager->resPrint;
261$sql .=
" WHERE p.entity IN (".getEntity(
'product').
") AND e.entity IN (".
getEntity(
'stock').
")";
262if (!empty($search_categ) && $search_categ !=
'-1') {
264 if ($search_categ == -2) {
265 $sql .=
" NOT EXISTS ";
270 $sql .=
" SELECT cp.fk_categorie, cp.fk_product";
271 $sql .=
" FROM " . MAIN_DB_PREFIX .
"categorie_product as cp";
272 $sql .=
" WHERE cp.fk_product = p.rowid";
273 if ($search_categ > 0) {
274 $sql .=
" AND cp.fk_categorie = " . ((int) $search_categ);
278if (!empty($search_warehouse_categ) && $search_warehouse_categ !=
'-1') {
280 if ($search_warehouse_categ == -2) {
281 $sql .=
" NOT EXISTS ";
286 $sql .=
" SELECT cp.fk_categorie, cp.fk_warehouse";
287 $sql .=
" FROM " . MAIN_DB_PREFIX .
"categorie_warehouse as cp";
288 $sql .=
" WHERE cp.fk_warehouse = e.rowid";
289 if ($search_warehouse_categ > 0) {
290 $sql .=
" AND cp.fk_categorie = " . ((int) $search_warehouse_categ);
295 $sql .=
natural_search(array(
'p.ref',
'p.label',
'p.description',
'p.note'), $search_all);
300 $sql .=
" AND p.fk_product_type = '1'";
302 $sql .=
" AND p.fk_product_type <> '1'";
305if ($search_subjecttolotserial) {
306 $sql .=
" AND p.tobatch > 0";
311if ($search_barcode) {
317if (!empty($tosell)) {
318 $sql .=
" AND p.tosell = ".((int) $tosell);
321 $sql .=
" AND p.tobuy = ".((int) $tobuy);
323if (!empty($canvas)) {
324 $sql .=
" AND p.canvas = '".$db->escape($canvas).
"'";
327 $sql .=
" AND p.rowid = pf.fk_product AND pf.fk_soc = ".((int) $fourn_id);
329if ($search_warehouse) {
336foreach ($search as $key => $val) {
337 if (array_key_exists($key, $object->fields)) {
338 if ($key ==
'status' && $search[$key] == -1) {
341 $mode_search = (($object->isInt($object->fields[$key]) || $object->isFloat($object->fields[$key])) ? 1 : 0);
342 if ((strpos($object->fields[$key][
'type'],
'integer:') === 0) || (strpos($object->fields[$key][
'type'],
'sellist:') === 0) || !empty($object->fields[$key][
'arrayofkeyval'])) {
343 if ($search[$key] ==
'-1' || ($search[$key] ===
'0' && (empty($object->fields[$key][
'arrayofkeyval']) || !array_key_exists(
'0', $object->fields[$key][
'arrayofkeyval'])))) {
348 if ($search[$key] !=
'') {
349 $sql .=
natural_search(
"t.".$db->escape($key), $search[$key], (($key ==
'status') ? 2 : $mode_search));
352 if (preg_match(
'/(_dtstart|_dtend)$/', $key) && $search[$key] !=
'') {
353 $columnName = preg_replace(
'/(_dtstart|_dtend)$/',
'', $key);
354 if ($columnName ==
'eatby' || $columnName ==
'sellby') {
355 if (preg_match(
'/_dtstart$/', $key)) {
356 $sql .=
" AND pl.".$db->escape($columnName).
" >= '".$db->idate($search[$key]).
"'";
358 if (preg_match(
'/_dtend$/', $key)) {
359 $sql .=
" AND pl.".$db->escape($columnName).
" <= '".$db->idate($search[$key]).
"'";
366$parameters = array();
367$reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters, $object);
368$sql .= $hookmanager->resPrint;
370$sql .=
" GROUP BY p.rowid, p.ref, p.label, p.barcode, p.price, p.price_ttc, p.price_base_type, p.entity,";
371$sql .=
" p.fk_product_type, p.tms,";
372$sql .=
" p.duration, p.tosell, p.tobuy, p.seuil_stock_alerte, p.desiredstock, p.stock, p.tosell, p.tobuy, p.tobatch,";
373$sql .=
" ps.fk_entrepot, ps.reel,";
374$sql .=
" e.ref, e.lieu, e.fk_parent,";
375$sql .=
" pb.batch, pb.eatby, pb.sellby,";
376$sql .=
" pl.rowid, pl.eatby, pl.sellby";
378$parameters = array();
379$reshook = $hookmanager->executeHooks(
'printFieldListGroupBy', $parameters, $object);
380$sql .= $hookmanager->resPrint;
382if ($search_toolowstock) {
383 $sql_having .=
" HAVING SUM(".$db->ifsql(
'ps.reel IS NULL',
'0',
'ps.reel').
") < p.seuil_stock_alerte";
385if ($search_stock_physique !=
'') {
386 $natural_search_physique =
natural_search(
'SUM(' . $db->ifsql(
'pb.qty IS NULL', $db->ifsql(
'ps.reel IS NULL',
'0',
'ps.reel'),
'pb.qty') .
')', $search_stock_physique, 1, 1);
387 $natural_search_physique =
" " . substr($natural_search_physique, 1, -1);
388 if (!empty($sql_having)) {
389 $sql_having .=
" AND";
391 $sql_having .=
" HAVING";
393 $sql_having .= $natural_search_physique;
396$parameters = array();
397$reshook = $hookmanager->executeHooks(
'printFieldListHaving', $parameters, $object);
398if (!empty($hookmanager->resPrint)) {
399 if (!empty($sql_having)) {
400 $sql_having .=
" AND";
402 $sql_having .=
" HAVING";
404 $sql_having .= $hookmanager->resPrint;
406if (!empty($sql_having)) {
413$nbtotalofrecords =
'';
415 $resql = $db->query($sql);
416 $nbtotalofrecords = $db->num_rows($resql);
418 if (($page * $limit) > $nbtotalofrecords) {
426$sql .= $db->order($sortfield, $sortorder);
428 $sql .= $db->plimit($limit + 1, $offset);
431$resql = $db->query($sql);
437$num = $db->num_rows($resql);
441if ($num == 1 &&
GETPOST(
'autojumpifoneonly') && ($search_all || $snom || $sref)) {
442 $objp = $db->fetch_object($resql);
443 header(
"Location: card.php?id=$objp->rowid");
449 $texte = $langs->trans(
"Services");
451 $texte = $langs->trans(
"Products");
454 $texte = $langs->trans(
"ProductsAndServices");
456$texte .=
' ('.$langs->trans(
"StocksByLotSerial").
')';
460 $param .=
'&mode='.urlencode($mode);
462if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
463 $param .=
'&contextpage='.urlencode($contextpage);
465if ($limit > 0 && $limit != $conf->liste_limit) {
466 $param .=
'&limit='.((int) $limit);
468foreach ($search as $key => $val) {
469 if (is_array($search[$key]) && count($search[$key])) {
470 foreach ($search[$key] as $skey) {
472 $param .=
'&search_'.$key.
'[]='.urlencode($skey);
475 } elseif ($search[$key] !=
'') {
476 $param .=
'&search_'.$key.
'='.urlencode($search[$key]);
479if ($optioncss !=
'') {
480 $param .=
'&optioncss='.urlencode($optioncss);
483 $param .=
"&search_all=".urlencode($search_all);
486 $param .=
"&tosell=".urlencode($tosell);
489 $param .=
"&tobuy=".urlencode($tobuy);
492 $param .=
"&type=".urlencode($type);
495 $param .=
"&fourn_id=".urlencode($fourn_id);
498 $param .=
"&snom=".urlencode($snom);
501 $param .=
"&sref=".urlencode($sref);
504 $param .=
"&search_batch=".urlencode($search_batch);
507 $param .=
"&sbarcode=".urlencode($sbarcode);
509if ($search_warehouse) {
510 $param .=
"&search_warehouse=".urlencode($search_warehouse);
512if ($search_toolowstock) {
513 $param .=
"&search_toolowstock=".urlencode($search_toolowstock);
515if ($search_subjecttolotserial) {
516 $param .=
"&search_subjecttolotserial=".urlencode($search_subjecttolotserial);
519 $param .=
"&search_sale=".urlencode($search_sale);
521if (!empty($search_categ) && $search_categ !=
'-1') {
522 $param .=
"&search_categ=".urlencode($search_categ);
524if (!empty($search_warehouse_categ) && $search_warehouse_categ !=
'-1') {
525 $param .=
"&search_warehouse_categ=".urlencode($search_warehouse_categ);
527if ($search_stock_physique) {
528 $param .=
'&search_stock_physique=' . urlencode($search_stock_physique);
535print
'<form id="searchFormList" action="'.$_SERVER[
"PHP_SELF"].
'" method="POST" name="formulaire">'.
"\n";
536if ($optioncss !=
'') {
537 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
539print
'<input type="hidden" name="token" value="'.newToken().
'">';
540print
'<input type="hidden" name="action" value="list">';
541print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
542print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
543print
'<input type="hidden" name="type" value="'.$type.
'">';
544print
'<input type="hidden" name="page" value="'.$page.
'">';
545print
'<input type="hidden" name="contextpage" value="'.$contextpage.
'">';
546print
'<input type="hidden" name="mode" value="'.$mode.
'">';
548print_barre_liste($texte, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder,
'', $num, $nbtotalofrecords,
'product', 0,
'',
'', $limit, 0, 0, 1);
563if (isModEnabled(
'categorie')) {
564 $moreforfilter .=
'<div class="divsearchfield">';
565 $moreforfilter .=
img_picto($langs->trans(
'ProductsCategoriesShort'),
'category',
'class="pictofixedwidth"');
566 $moreforfilter .= $htmlother->select_categories(Categorie::TYPE_PRODUCT, $search_categ,
'search_categ', 1, $langs->trans(
"ProductsCategoryShort"),
'maxwidth400');
567 $moreforfilter .=
'</div>';
570if (isModEnabled(
'categorie')) {
571 $moreforfilter .=
'<div class="divsearchfield">';
572 $moreforfilter .=
img_picto($langs->trans(
'StockCategoriesShort'),
'category',
'class="pictofixedwidth"');
573 $moreforfilter .= $htmlother->select_categories(Categorie::TYPE_WAREHOUSE, $search_warehouse_categ,
'search_warehouse_categ', 1, $langs->trans(
"StockCategoriesShort"),
'maxwidth400');
574 $moreforfilter .=
'</div>';
577$moreforfilter.=
'<label for="search_subjecttolotserial">'.$langs->trans(
"SubjectToLotSerialOnly").
' </label><input type="checkbox" id="search_subjecttolotserial" name="search_subjecttolotserial" value="1"'.($search_subjecttolotserial ?
' checked' :
'').
'>';
580if (!empty($moreforfilter)) {
581 print
'<div class="liste_titre liste_titre_bydiv centpercent">';
582 print $moreforfilter;
583 $parameters = array();
584 $reshook = $hookmanager->executeHooks(
'printFieldPreListTitle', $parameters);
585 print $hookmanager->resPrint;
590print
'<div class="div-table-responsive">';
591print
'<table class="tagtable nobottomiftotal liste'.($moreforfilter ?
" listwithfilterbefore" :
"").
'">';
595print
'<tr class="liste_titre_filter">';
598 print
'<td class="liste_titre maxwidthsearch">';
599 $searchpicto = $form->showFilterButtons();
603print
'<td class="liste_titre">';
604print
'<input class="flat" type="text" name="sref" size="6" value="'.dol_escape_htmltag($sref).
'">';
606print
'<td class="liste_titre">';
607print
'<input class="flat" type="text" name="snom" size="8" value="'.dol_escape_htmltag($snom).
'">';
609if (isModEnabled(
"service") && $type == 1) {
610 print
'<td class="liste_titre">';
615print
'<td class="liste_titre"><input class="flat" type="text" name="search_warehouse" size="6" value="'.dol_escape_htmltag($search_warehouse).
'"></td>';
616print
'<td class="liste_titre center"><input class="flat" type="text" name="search_batch" size="6" value="'.dol_escape_htmltag($search_batch).
'"></td>';
618 print
'<td class="liste_titre center">';
620 print
'<div class="nowrap">';
621 print $form->selectDate($search[$key.
'_dtstart'] ? $search[$key.
'_dtstart'] :
'',
"search_".$key.
"_dtstart", 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'From'));
623 print
'<div class="nowrap">';
624 print $form->selectDate($search[$key.
'_dtend'] ? $search[$key.
'_dtend'] :
'',
"search_".$key.
"_dtend", 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'to'));
629 print
'<td class="liste_titre center">';
631 print
'<div class="nowrap">';
632 print $form->selectDate($search[$key.
'_dtstart'] ? $search[$key.
'_dtstart'] :
'',
"search_".$key.
"_dtstart", 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'From'));
634 print
'<div class="nowrap">';
635 print $form->selectDate($search[$key.
'_dtend'] ? $search[$key.
'_dtend'] :
'',
"search_".$key.
"_dtend", 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'to'));
640print
'<td class="liste_titre right">';
641print
'<input class="flat" type="text" size="5" name="search_stock_physique" value="'.dol_escape_htmltag($search_stock_physique).
'">';
643print
'<td class="liste_titre"> </td>';
644print
'<td class="liste_titre"> </td>';
645print
'<td class="liste_titre"> </td>';
646$parameters = array();
647$reshook = $hookmanager->executeHooks(
'printFieldListOption', $parameters);
648print $hookmanager->resPrint;
651 print
'<td class="liste_titre maxwidthsearch">';
652 $searchpicto = $form->showFilterButtons();
658$totalarray = array();
659$totalarray[
'nbfield'] = 0;
663print
'<tr class="liste_titre">';
670if (isModEnabled(
"service") && $type == 1) {
671 print_liste_field_titre(
"Duration", $_SERVER[
"PHP_SELF"],
"p.duration",
'', $param,
"", $sortfield, $sortorder,
'center ');
675print_liste_field_titre(
"Batch", $_SERVER[
"PHP_SELF"],
"pb.batch",
'', $param,
"", $sortfield, $sortorder,
'center ');
677 print_liste_field_titre(
"SellByDate", $_SERVER[
"PHP_SELF"],
"pl.sellby",
'', $param,
"", $sortfield, $sortorder,
'center ');
680 print_liste_field_titre(
"EatByDate", $_SERVER[
"PHP_SELF"],
"pl.eatby",
'', $param,
"", $sortfield, $sortorder,
'center ');
682print_liste_field_titre(
"PhysicalStock", $_SERVER[
"PHP_SELF"],
"stock_physique",
'', $param,
"", $sortfield, $sortorder,
'right ');
686print_liste_field_titre(
"ProductStatusOnSell", $_SERVER[
"PHP_SELF"],
"p.tosell",
"", $param,
'', $sortfield, $sortorder,
'right ');
687print_liste_field_titre(
"ProductStatusOnBuy", $_SERVER[
"PHP_SELF"],
"p.tobuy",
"", $param,
'', $sortfield, $sortorder,
'right ');
689$parameters = array(
'param'=>$param,
'sortfield'=>$sortfield,
'sortorder'=>$sortorder);
690$reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters);
691print $hookmanager->resPrint;
697$product_static =
new Product($db);
704$savnbfield = $totalarray[
'nbfield'];
705$totalarray[
'nbfield'] = 0;
706$imaxinloop = ($limit ? min($num, $limit) : $num);
707while ($i < $imaxinloop) {
708 $objp = $db->fetch_object($resql);
713 $sql =
"SELECT label";
714 $sql .=
" FROM ".MAIN_DB_PREFIX.
"product_lang";
715 $sql .=
" WHERE fk_product = ".((int) $objp->rowid);
716 $sql .=
" AND lang = '".$db->escape($langs->getDefaultLang()).
"'";
719 $result = $db->query($sql);
721 $objtp = $db->fetch_object($result);
722 if (!empty($objtp->label)) {
723 $objp->label = $objtp->label;
728 $product_static->ref = $objp->ref;
729 $product_static->id = $objp->rowid;
730 $product_static->label = $objp->label;
731 $product_static->type = $objp->fk_product_type;
732 $product_static->entity = $objp->entity;
733 $product_static->status = $objp->tosell;
734 $product_static->status_buy = $objp->tobuy;
735 $product_static->status_batch = $objp->tobatch;
737 $product_lot_static->batch = $objp->batch;
738 $product_lot_static->fk_product = $objp->rowid;
739 $product_lot_static->id = $objp->lotid;
740 $product_lot_static->eatby = $objp->eatby;
741 $product_lot_static->sellby = $objp->sellby;
744 $warehousetmp->id = $objp->fk_entrepot;
745 $warehousetmp->ref = $objp->warehouse_ref;
746 $warehousetmp->label = $objp->warehouse_ref;
747 $warehousetmp->fk_parent = $objp->warehouse_parent;
755 $totalarray[
'nbfield']++;
760 print
'<td class="nowrap">';
761 print $product_static->getNomUrl(1,
'', 16);
765 $totalarray[
'nbfield']++;
769 print
'<td>'.$objp->label.
'</td>';
771 $totalarray[
'nbfield']++;
774 if (isModEnabled(
"service") && $type == 1) {
775 print
'<td class="center">';
777 if (preg_match(
'/([0-9]+)y/i', $objp->duration, $regs)) {
778 print $regs[1].
' '.$langs->trans(
"DurationYear");
779 } elseif (preg_match(
'/([0-9]+)m/i', $objp->duration, $regs)) {
780 print $regs[1].
' '.$langs->trans(
"DurationMonth");
781 } elseif (preg_match(
'/([0-9]+)d/i', $objp->duration, $regs)) {
782 print $regs[1].
' '.$langs->trans(
"DurationDay");
784 print $objp->duration;
787 $totalarray[
'nbfield']++;
796 print
'<td class="nowrap">';
797 if ($objp->fk_entrepot > 0) {
798 print $warehousetmp->getNomUrl(1);
801 $totalarray[
'nbfield']++;
806 print
'<td class="center nowrap">';
807 if ($product_lot_static->batch) {
808 print $product_lot_static->getNomUrl(1);
811 $totalarray[
'nbfield']++;
816 print
'<td class="center">'.dol_print_date($db->jdate($objp->sellby),
'day').
'</td>';
818 $totalarray[
'nbfield']++;
823 print
'<td class="center">'.dol_print_date($db->jdate($objp->eatby),
'day').
'</td>';
825 $totalarray[
'nbfield']++;
829 print
'<td class="right">';
831 if (is_null($objp->stock_physique)) {
832 if (!empty($objp->reel)) {
833 if ($objp->reel < 0) {
834 print
'<span class="warning">';
837 if ($objp->reel < 0) {
840 print($objp->stock_physique < 0 ?
' '.img_warning() :
'');
843 if (!empty($objp->stock_physique)) {
844 if ($objp->stock_physique < 0) {
845 print
'<span class="warning">';
847 print
price2num($objp->stock_physique,
'MS');
848 if ($objp->stock_physique < 0) {
851 print($objp->stock_physique < 0 ?
' '.img_warning() : (($objp->stock_physique > 1 && $objp->tobatch == 2) ?
' '.
img_warning($langs->trans(
'IlligalQtyForSerialNumbers')) :
''));
856 $totalarray[
'nbfield']++;
859 print
'<td class="right">';
860 print
img_picto($langs->trans(
"StockMovement"),
'movement',
'class="pictofixedwidth"');
861 print
'<a href="'.DOL_URL_ROOT.
'/product/stock/movement_list.php?idproduct='.$product_static->id.
'&search_warehouse='.$objp->fk_entrepot.
'&search_batch='.($objp->batch !=
'Undefined' ? $objp->batch :
'Undefined').
'">'.$langs->trans(
"Movements").
'</a>';
864 $totalarray[
'nbfield']++;
867 print
'<td class="right nowrap">'.$product_static->LibStatut($objp->statut, 5, 0).
'</td>';
869 $totalarray[
'nbfield']++;
872 print
'<td class="right nowrap">'.$product_static->LibStatut($objp->tobuy, 5, 1).
'</td>';
874 $totalarray[
'nbfield']++;
878 $parameters = array(
'obj'=>$objp);
879 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $product);
880 print $hookmanager->resPrint;
886 $totalarray[
'nbfield']++;
897 foreach ($arrayfields as $key => $val) {
898 if (!empty($val[
'checked'])) {
902 print
'<tr><td colspan="'.$colspan.
'"><span class="opacitymedium">'.$langs->trans(
"NoRecordFound").
'</span></td></tr>';
908print
'</table>'.
"\n";
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
Empty header.
Class to manage warehouses.
Class to manage products or services.
Class with list of lots and properties.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed informations (by default a local PHP server timestamp) Re...
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
natural_search($fields, $value, $mode=0, $nofirstand=0)
Generate natural SQL search string for a criteria (this criteria can be tested on one or several fiel...
dol_strlen($string, $stringencoding='UTF-8')
Make a strlen call.
dol_now($mode='auto')
Return date for now.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
dol_sort_array(&$array, $index, $order='asc', $natsort=0, $case_sensitive=0, $keepindex=0)
Advanced sort array by second index function, which produces ascending (default) or descending output...
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
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.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
getEntity($element, $shared=1, $currentobject=null)
Get list of entity id to use.
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.