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'));
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');
63$search_stock_physique =
GETPOST(
'search_stock_physique',
'alpha');
67$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
68$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
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')) {
86$search_warehouse_categ =
GETPOSTINT(
'search_warehouse_categ');
89$extrafields->fetch_name_optionals_label(
$object->table_element);
92$search_array_options = $extrafields->getOptionalsFromPost(
$object->table_element,
'',
'search_');
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'])) {
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 array(
'type' =>
'varchar',
'label' =>
'Ref',
'checked' => 1,
'enabled' => 1,
'position' => 1),
137 array(
'type' =>
'varchar',
'label' =>
'Label',
'checked' => 1,
'enabled' => 1,
'position' => 1),
138 array(
'type' =>
'int',
'label' =>
'Warehouse',
'checked' => 1,
'enabled' => 1,
'position' => 1),
139 array(
'type' =>
'varchar',
'label' =>
'Lot',
'checked' => 1,
'enabled' => 1,
'position' => 1),
140 array(
'type' =>
'varchar',
'label' =>
'DLC',
'checked' => 1,
'enabled' => 1,
'position' => 1),
141 array(
'type' =>
'varchar',
'label' =>
'DLUO',
'checked' => 1,
'enabled' => 1,
'position' => 1),
142 array(
'type' =>
'int',
'label' =>
'Stock',
'checked' => 1,
'enabled' => 1,
'position' => 1),
143 array(
'type' =>
'int',
'label' =>
'StatusSell',
'checked' => 1,
'enabled' => 1,
'position' => 1),
144 array(
'type' =>
'int',
'label' =>
'StatusBuy',
'checked' => 1,
'enabled' => 1,
'position' => 1),
153 $socid = $user->socid;
155$result =
restrictedArea($user,
'produit|service', 0,
'product&product');
163if (
GETPOST(
'cancel',
'alpha')) {
167if (!
GETPOST(
'confirmmassaction',
'alpha') && $massaction !=
'presend' && $massaction !=
'confirm_presend') {
171$parameters = array();
172$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
177if (empty($reshook)) {
179 include DOL_DOCUMENT_ROOT.
'/core/actions_changeselectedfields.inc.php';
182 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
183 foreach (
$object->fields as $key => $val) {
185 if (preg_match(
'/^(date|timestamp|datetime)/', $val[
'type'])) {
186 $search[$key.
'_dtstart'] =
'';
187 $search[$key.
'_dtend'] =
'';
190 $search[
'sellby_dtstart'] =
'';
191 $search[
'eatby_dtstart'] =
'';
192 $search[
'sellby_dtend'] =
'';
193 $search[
'eatby_dtend'] =
'';
201 $search_warehouse_categ =
"";
202 $search_toolowstock =
'';
203 $search_subjecttolotserial =
'';
205 $search_warehouse =
'';
208 $search_stock_physique =
'';
210 $search_array_options = array();
212 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')
213 ||
GETPOST(
'button_search_x',
'alpha') ||
GETPOST(
'button_search.x',
'alpha') ||
GETPOST(
'button_search',
'alpha')) {
231$form =
new Form($db);
236$helpurl =
'EN:Module_Stocks_En|FR:Module_Stock|ES:Módulo_Stocks';
237$title = $langs->trans(
"ProductsAndServices");
241$sql =
'SELECT p.rowid, p.ref, p.label, p.barcode, p.price, p.price_ttc, p.price_base_type, p.entity,';
242$sql .=
' p.fk_product_type, p.tms as datem,';
243$sql .=
' p.duration, p.tosell as statut, p.tobuy, p.seuil_stock_alerte, p.desiredstock, p.stock, p.tosell, p.tobuy, p.tobatch,';
244$sql .=
' ps.fk_entrepot, ps.reel,';
245$sql .=
' e.ref as warehouse_ref, e.lieu as warehouse_lieu, e.fk_parent as warehouse_parent,';
246$sql .=
' pb.batch, pb.eatby as oldeatby, pb.sellby as oldsellby,';
247$sql .=
' pl.rowid as lotid, pl.eatby, pl.sellby,';
248$sql .=
' SUM(pb.qty) as stock_physique, COUNT(pb.rowid) as nbinbatchtable';
250$parameters = array();
251$reshook = $hookmanager->executeHooks(
'printFieldListSelect', $parameters, $object);
252$sql .= $hookmanager->resPrint;
253$sql .=
' FROM '.MAIN_DB_PREFIX.
'product as p';
254$sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'product_stock as ps on p.rowid = ps.fk_product';
255$sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'entrepot as e on ps.fk_entrepot = e.rowid';
256$sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'product_batch as pb on pb.fk_product_stock = ps.rowid';
257$sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'product_lot as pl on pl.fk_product = p.rowid AND pl.batch = pb.batch';
259$parameters = array();
260$reshook = $hookmanager->executeHooks(
'printFieldListFrom', $parameters, $object);
261$sql .= $hookmanager->resPrint;
262$sql .=
" WHERE p.entity IN (".getEntity(
'product').
") AND e.entity IN (".
getEntity(
'stock').
")";
263if (!empty($search_categ) && $search_categ !=
'-1') {
265 if ($search_categ == -2) {
266 $sql .=
" NOT EXISTS ";
271 $sql .=
" SELECT cp.fk_categorie, cp.fk_product";
272 $sql .=
" FROM " . MAIN_DB_PREFIX .
"categorie_product as cp";
273 $sql .=
" WHERE cp.fk_product = p.rowid";
274 if ($search_categ > 0) {
275 $sql .=
" AND cp.fk_categorie = " . ((int) $search_categ);
279if (!empty($search_warehouse_categ) && $search_warehouse_categ !=
'-1') {
281 if ($search_warehouse_categ == -2) {
282 $sql .=
" NOT EXISTS ";
287 $sql .=
" SELECT cp.fk_categorie, cp.fk_warehouse";
288 $sql .=
" FROM " . MAIN_DB_PREFIX .
"categorie_warehouse as cp";
289 $sql .=
" WHERE cp.fk_warehouse = e.rowid";
290 if ($search_warehouse_categ > 0) {
291 $sql .=
" AND cp.fk_categorie = " . ((int) $search_warehouse_categ);
296 $sql .=
natural_search(array(
'p.ref',
'p.label',
'p.description',
'p.note'), $search_all);
301 $sql .=
" AND p.fk_product_type = '1'";
303 $sql .=
" AND p.fk_product_type <> '1'";
306if ($search_subjecttolotserial) {
307 $sql .=
" AND p.tobatch > 0";
312if ($search_barcode) {
318if (!empty($tosell)) {
319 $sql .=
" AND p.tosell = ".((int) $tosell);
322 $sql .=
" AND p.tobuy = ".((int) $tobuy);
324if (!empty($canvas)) {
325 $sql .=
" AND p.canvas = '".$db->escape($canvas).
"'";
328 $sql .=
" AND p.rowid = pf.fk_product AND pf.fk_soc = ".((int) $fourn_id);
330if ($search_warehouse) {
337foreach ($search as $key => $val) {
338 if (array_key_exists($key,
$object->fields)) {
339 if ($key ==
'status' && $search[$key] == -1) {
343 if ((strpos(
$object->fields[$key][
'type'],
'integer:') === 0) || (strpos(
$object->fields[$key][
'type'],
'sellist:') === 0) || !empty(
$object->fields[$key][
'arrayofkeyval'])) {
344 if ($search[$key] ==
'-1' || ($search[$key] ===
'0' && (empty(
$object->fields[$key][
'arrayofkeyval']) || !array_key_exists(
'0',
$object->fields[$key][
'arrayofkeyval'])))) {
349 if ($search[$key] !=
'') {
350 $sql .=
natural_search(
"t.".$db->escape($key), $search[$key], (($key ==
'status') ? 2 : $mode_search));
353 if (preg_match(
'/(_dtstart|_dtend)$/', $key) && $search[$key] !=
'') {
354 $columnName = preg_replace(
'/(_dtstart|_dtend)$/',
'', $key);
355 if ($columnName ==
'eatby' || $columnName ==
'sellby') {
356 if (preg_match(
'/_dtstart$/', $key)) {
357 $sql .=
" AND pl.".$db->escape($columnName).
" >= '".$db->idate($search[$key]).
"'";
359 if (preg_match(
'/_dtend$/', $key)) {
360 $sql .=
" AND pl.".$db->escape($columnName).
" <= '".$db->idate($search[$key]).
"'";
367$parameters = array();
368$reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters, $object);
369$sql .= $hookmanager->resPrint;
371$sql .=
" GROUP BY p.rowid, p.ref, p.label, p.barcode, p.price, p.price_ttc, p.price_base_type, p.entity,";
372$sql .=
" p.fk_product_type, p.tms,";
373$sql .=
" p.duration, p.tosell, p.tobuy, p.seuil_stock_alerte, p.desiredstock, p.stock, p.tosell, p.tobuy, p.tobatch,";
374$sql .=
" ps.fk_entrepot, ps.reel,";
375$sql .=
" e.ref, e.lieu, e.fk_parent,";
376$sql .=
" pb.batch, pb.eatby, pb.sellby,";
377$sql .=
" pl.rowid, pl.eatby, pl.sellby";
379$parameters = array();
380$reshook = $hookmanager->executeHooks(
'printFieldListGroupBy', $parameters, $object);
381$sql .= $hookmanager->resPrint;
383if ($search_toolowstock) {
384 $sql_having .=
" HAVING SUM(".$db->ifsql(
'ps.reel IS NULL',
'0',
'ps.reel').
") < p.seuil_stock_alerte";
386if ($search_stock_physique !=
'') {
387 $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);
388 $natural_search_physique =
" " . substr($natural_search_physique, 1, -1);
389 if (!empty($sql_having)) {
390 $sql_having .=
" AND";
392 $sql_having .=
" HAVING";
394 $sql_having .= $natural_search_physique;
397$parameters = array();
398$reshook = $hookmanager->executeHooks(
'printFieldListHaving', $parameters, $object);
399if (!empty($hookmanager->resPrint)) {
400 if (!empty($sql_having)) {
401 $sql_having .=
" AND";
403 $sql_having .=
" HAVING";
405 $sql_having .= $hookmanager->resPrint;
407if (!empty($sql_having)) {
414$nbtotalofrecords =
'';
416 $resql = $db->query($sql);
417 $nbtotalofrecords = $db->num_rows($resql);
419 if (($page * $limit) > $nbtotalofrecords) {
427$sql .= $db->order($sortfield, $sortorder);
429 $sql .= $db->plimit($limit + 1, $offset);
432$resql = $db->query($sql);
438$num = $db->num_rows($resql);
442if ($num == 1 &&
GETPOST(
'autojumpifoneonly') && ($search_all || $snom || $sref)) {
443 $objp = $db->fetch_object($resql);
444 header(
"Location: card.php?id=$objp->rowid");
450 $texte = $langs->trans(
"Services");
452 $texte = $langs->trans(
"Products");
455 $texte = $langs->trans(
"ProductsAndServices");
457$texte .=
' ('.$langs->trans(
"StocksByLotSerial").
')';
461 $param .=
'&mode='.urlencode($mode);
463if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
464 $param .=
'&contextpage='.urlencode($contextpage);
466if ($limit > 0 && $limit != $conf->liste_limit) {
467 $param .=
'&limit='.((int) $limit);
469foreach ($search as $key => $val) {
470 if (is_array($search[$key]) && count($search[$key])) {
471 foreach ($search[$key] as $skey) {
473 $param .=
'&search_'.$key.
'[]='.urlencode($skey);
476 } elseif ($search[$key] !=
'') {
477 $param .=
'&search_'.$key.
'='.urlencode($search[$key]);
480if ($optioncss !=
'') {
481 $param .=
'&optioncss='.urlencode($optioncss);
484 $param .=
"&search_all=".urlencode($search_all);
487 $param .=
"&tosell=".urlencode($tosell);
490 $param .=
"&tobuy=".urlencode($tobuy);
493 $param .=
"&type=".urlencode((
string) ($type));
496 $param .=
"&fourn_id=".urlencode((
string) ($fourn_id));
499 $param .=
"&snom=".urlencode($snom);
502 $param .=
"&sref=".urlencode($sref);
505 $param .=
"&search_batch=".urlencode($search_batch);
508 $param .=
"&sbarcode=".urlencode((
string) ($sbarcode));
510if ($search_warehouse) {
511 $param .=
"&search_warehouse=".urlencode($search_warehouse);
513if ($search_toolowstock) {
514 $param .=
"&search_toolowstock=".urlencode($search_toolowstock);
516if ($search_subjecttolotserial) {
517 $param .=
"&search_subjecttolotserial=".urlencode($search_subjecttolotserial);
520 $param .=
"&search_sale=".urlencode($search_sale);
522if (!empty($search_categ) && $search_categ !=
'-1') {
523 $param .=
"&search_categ=".urlencode((
string) ($search_categ));
525if (!empty($search_warehouse_categ) && $search_warehouse_categ !=
'-1') {
526 $param .=
"&search_warehouse_categ=".urlencode((
string) ($search_warehouse_categ));
528if ($search_stock_physique) {
529 $param .=
'&search_stock_physique=' . urlencode($search_stock_physique);
534llxHeader(
"", $title, $helpurl, $texte, 0, 0,
'',
'',
'',
'mod-product page-reassortlot');
536print
'<form id="searchFormList" action="'.$_SERVER[
"PHP_SELF"].
'" method="POST" name="formulaire">'.
"\n";
537if ($optioncss !=
'') {
538 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
540print
'<input type="hidden" name="token" value="'.newToken().
'">';
541print
'<input type="hidden" name="action" value="list">';
542print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
543print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
544print
'<input type="hidden" name="type" value="'.$type.
'">';
545print
'<input type="hidden" name="page" value="'.$page.
'">';
546print
'<input type="hidden" name="contextpage" value="'.$contextpage.
'">';
547print
'<input type="hidden" name="mode" value="'.$mode.
'">';
549print_barre_liste($texte, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder,
'', $num, $nbtotalofrecords,
'product', 0,
'',
'', $limit, 0, 0, 1);
564if (isModEnabled(
'category')) {
565 $moreforfilter .=
'<div class="divsearchfield">';
566 $moreforfilter .=
img_picto($langs->trans(
'ProductsCategoriesShort'),
'category',
'class="pictofixedwidth"');
567 $moreforfilter .= $htmlother->select_categories(Categorie::TYPE_PRODUCT, $search_categ,
'search_categ', 1, $langs->trans(
"ProductsCategoryShort"),
'maxwidth400');
568 $moreforfilter .=
'</div>';
571if (isModEnabled(
'category')) {
572 $moreforfilter .=
'<div class="divsearchfield">';
573 $moreforfilter .=
img_picto($langs->trans(
'StockCategoriesShort'),
'category',
'class="pictofixedwidth"');
574 $moreforfilter .= $htmlother->select_categories(Categorie::TYPE_WAREHOUSE, $search_warehouse_categ,
'search_warehouse_categ', 1, $langs->trans(
"StockCategoriesShort"),
'maxwidth400');
575 $moreforfilter .=
'</div>';
578$moreforfilter .=
'<label for="search_subjecttolotserial">'.$langs->trans(
"SubjectToLotSerialOnly").
' </label><input type="checkbox" id="search_subjecttolotserial" name="search_subjecttolotserial" value="1"'.($search_subjecttolotserial ?
' checked' :
'').
'>';
581if (!empty($moreforfilter)) {
582 print
'<div class="liste_titre liste_titre_bydiv centpercent">';
583 print $moreforfilter;
584 $parameters = array();
585 $reshook = $hookmanager->executeHooks(
'printFieldPreListTitle', $parameters, $object, $action);
586 print $hookmanager->resPrint;
591print
'<div class="div-table-responsive">';
592print
'<table class="tagtable nobottomiftotal liste'.($moreforfilter ?
" listwithfilterbefore" :
"").
'">';
596print
'<tr class="liste_titre_filter">';
599 print
'<td class="liste_titre maxwidthsearch">';
600 $searchpicto = $form->showFilterButtons();
604print
'<td class="liste_titre">';
605print
'<input class="flat" type="text" name="sref" size="6" value="'.dol_escape_htmltag($sref).
'">';
607print
'<td class="liste_titre">';
608print
'<input class="flat" type="text" name="snom" size="8" value="'.dol_escape_htmltag($snom).
'">';
610if (isModEnabled(
"service") && $type == 1) {
611 print
'<td class="liste_titre">';
616print
'<td class="liste_titre"><input class="flat" type="text" name="search_warehouse" size="6" value="'.dol_escape_htmltag($search_warehouse).
'"></td>';
617print
'<td class="liste_titre center"><input class="flat" type="text" name="search_batch" size="6" value="'.dol_escape_htmltag($search_batch).
'"></td>';
619 print
'<td class="liste_titre center">';
621 print
'<div class="nowrap">';
622 print $form->selectDate($search[$key.
'_dtstart'] ? $search[$key.
'_dtstart'] :
'',
"search_".$key.
"_dtstart", 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'From'));
624 print
'<div class="nowrap">';
625 print $form->selectDate($search[$key.
'_dtend'] ? $search[$key.
'_dtend'] :
'',
"search_".$key.
"_dtend", 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'to'));
630 print
'<td class="liste_titre center">';
632 print
'<div class="nowrap">';
633 print $form->selectDate($search[$key.
'_dtstart'] ? $search[$key.
'_dtstart'] :
'',
"search_".$key.
"_dtstart", 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'From'));
635 print
'<div class="nowrap">';
636 print $form->selectDate($search[$key.
'_dtend'] ? $search[$key.
'_dtend'] :
'',
"search_".$key.
"_dtend", 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'to'));
641print
'<td class="liste_titre right">';
642print
'<input class="flat" type="text" size="5" name="search_stock_physique" value="'.dol_escape_htmltag($search_stock_physique).
'">';
644print
'<td class="liste_titre"> </td>';
645print
'<td class="liste_titre"> </td>';
646print
'<td class="liste_titre"> </td>';
647$parameters = array();
648$reshook = $hookmanager->executeHooks(
'printFieldListOption', $parameters);
649print $hookmanager->resPrint;
652 print
'<td class="liste_titre maxwidthsearch">';
653 $searchpicto = $form->showFilterButtons();
659$totalarray = array();
660$totalarray[
'nbfield'] = 0;
664print
'<tr class="liste_titre">';
671if (isModEnabled(
"service") && $type == 1) {
672 print_liste_field_titre(
"Duration", $_SERVER[
"PHP_SELF"],
"p.duration",
'', $param,
"", $sortfield, $sortorder,
'center ');
676print_liste_field_titre(
"Batch", $_SERVER[
"PHP_SELF"],
"pb.batch",
'', $param,
"", $sortfield, $sortorder,
'center ');
678 print_liste_field_titre(
"SellByDate", $_SERVER[
"PHP_SELF"],
"pl.sellby",
'', $param,
"", $sortfield, $sortorder,
'center ');
681 print_liste_field_titre(
"EatByDate", $_SERVER[
"PHP_SELF"],
"pl.eatby",
'', $param,
"", $sortfield, $sortorder,
'center ');
683print_liste_field_titre(
"PhysicalStock", $_SERVER[
"PHP_SELF"],
"stock_physique",
'', $param,
"", $sortfield, $sortorder,
'right ');
687print_liste_field_titre(
"ProductStatusOnSell", $_SERVER[
"PHP_SELF"],
"p.tosell",
"", $param,
'', $sortfield, $sortorder,
'right ');
688print_liste_field_titre(
"ProductStatusOnBuy", $_SERVER[
"PHP_SELF"],
"p.tobuy",
"", $param,
'', $sortfield, $sortorder,
'right ');
690$parameters = array(
'param' => $param,
'sortfield' => $sortfield,
'sortorder' => $sortorder);
691$reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters);
692print $hookmanager->resPrint;
698$product_static =
new Product($db);
705$savnbfield = $totalarray[
'nbfield'];
706$totalarray[
'nbfield'] = 0;
707$imaxinloop = ($limit ? min($num, $limit) : $num);
708while ($i < $imaxinloop) {
709 $objp = $db->fetch_object($resql);
714 $sql =
"SELECT label";
715 $sql .=
" FROM ".MAIN_DB_PREFIX.
"product_lang";
716 $sql .=
" WHERE fk_product = ".((int) $objp->rowid);
717 $sql .=
" AND lang = '".$db->escape($langs->getDefaultLang()).
"'";
720 $result = $db->query($sql);
722 $objtp = $db->fetch_object($result);
723 if (!empty($objtp->label)) {
724 $objp->label = $objtp->label;
729 $product_static->ref = $objp->ref;
730 $product_static->id = $objp->rowid;
731 $product_static->label = $objp->label;
732 $product_static->type = $objp->fk_product_type;
733 $product_static->entity = $objp->entity;
734 $product_static->status = $objp->tosell;
735 $product_static->status_buy = $objp->tobuy;
736 $product_static->status_batch = $objp->tobatch;
738 $product_lot_static->batch = $objp->batch;
739 $product_lot_static->fk_product = $objp->rowid;
740 $product_lot_static->id = $objp->lotid;
741 $product_lot_static->eatby = $objp->eatby;
742 $product_lot_static->sellby = $objp->sellby;
745 $warehousetmp->id = $objp->fk_entrepot;
746 $warehousetmp->ref = $objp->warehouse_ref;
747 $warehousetmp->label = $objp->warehouse_ref;
748 $warehousetmp->fk_parent = $objp->warehouse_parent;
756 $totalarray[
'nbfield']++;
761 print
'<td class="nowrap">';
762 print $product_static->getNomUrl(1,
'', 16);
766 $totalarray[
'nbfield']++;
770 print
'<td>'.$objp->label.
'</td>';
772 $totalarray[
'nbfield']++;
775 if (isModEnabled(
"service") && $type == 1) {
776 print
'<td class="center">';
778 if (preg_match(
'/([0-9]+)y/i', $objp->duration, $regs)) {
779 print $regs[1].
' '.$langs->trans(
"DurationYear");
780 } elseif (preg_match(
'/([0-9]+)m/i', $objp->duration, $regs)) {
781 print $regs[1].
' '.$langs->trans(
"DurationMonth");
782 } elseif (preg_match(
'/([0-9]+)d/i', $objp->duration, $regs)) {
783 print $regs[1].
' '.$langs->trans(
"DurationDay");
785 print $objp->duration;
788 $totalarray[
'nbfield']++;
797 print
'<td class="nowrap">';
798 if ($objp->fk_entrepot > 0) {
799 print $warehousetmp->getNomUrl(1);
802 $totalarray[
'nbfield']++;
807 print
'<td class="center nowrap">';
808 if ($product_lot_static->batch) {
809 print $product_lot_static->getNomUrl(1);
812 $totalarray[
'nbfield']++;
817 print
'<td class="center">'.dol_print_date($db->jdate($objp->sellby),
'day').
'</td>';
819 $totalarray[
'nbfield']++;
824 print
'<td class="center">'.dol_print_date($db->jdate($objp->eatby),
'day').
'</td>';
826 $totalarray[
'nbfield']++;
830 print
'<td class="right">';
832 if (is_null($objp->stock_physique)) {
833 if (!empty($objp->reel)) {
834 if ($objp->reel < 0) {
835 print
'<span class="warning">';
838 if ($objp->reel < 0) {
841 print($objp->stock_physique < 0 ?
' '.img_warning() :
'');
844 if (!empty($objp->stock_physique)) {
845 if ($objp->stock_physique < 0) {
846 print
'<span class="warning">';
848 print
price2num($objp->stock_physique,
'MS');
849 if ($objp->stock_physique < 0) {
852 print($objp->stock_physique < 0 ?
' '.img_warning() : (($objp->stock_physique > 1 && $objp->tobatch == 2) ?
' '.
img_warning($langs->trans(
'IlligalQtyForSerialNumbers')) :
''));
857 $totalarray[
'nbfield']++;
860 print
'<td class="right">';
861 print
img_picto($langs->trans(
"StockMovement"),
'movement',
'class="pictofixedwidth"');
862 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>';
865 $totalarray[
'nbfield']++;
868 print
'<td class="right nowrap">'.$product_static->LibStatut($objp->statut, 5, 0).
'</td>';
870 $totalarray[
'nbfield']++;
873 print
'<td class="right nowrap">'.$product_static->LibStatut($objp->tobuy, 5, 1).
'</td>';
875 $totalarray[
'nbfield']++;
879 $parameters = array(
'obj' => $objp);
880 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $product);
881 print $hookmanager->resPrint;
887 $totalarray[
'nbfield']++;
898 foreach ($arrayfields as $key => $val) {
899 if (!empty($val[
'checked'])) {
903 print
'<tr><td colspan="'.$colspan.
'"><span class="opacitymedium">'.$langs->trans(
"NoRecordFound").
'</span></td></tr>';
909print
'</table>'.
"\n";
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
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 information (by default a local PHP server timestamp) Rep...
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
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.
dol_sort_array(&$array, $index, $order='asc', $natsort=0, $case_sensitive=0, $keepindex=0)
Advanced sort array by the value of a given key, which produces ascending (default) or descending out...
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
print_barre_liste($title, $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.
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.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
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.