33require
'../main.inc.php';
34require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
35require_once DOL_DOCUMENT_ROOT.
'/product/stock/class/productlot.class.php';
36require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formother.class.php';
37require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
38require_once DOL_DOCUMENT_ROOT.
'/product/stock/class/entrepot.class.php';
39require_once DOL_DOCUMENT_ROOT.
'/product/stock/class/productlot.class.php';
42$langs->loadLangs(array(
'products',
'stocks',
'productbatch',
'categories'));
44$action =
GETPOST(
'action',
'aZ09') ?
GETPOST(
'action',
'aZ09') :
'view';
45$massaction =
GETPOST(
'massaction',
'alpha');
46$contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'myobjectlist';
47$backtopage =
GETPOST(
'backtopage',
'alpha');
48$optioncss =
GETPOST(
'optioncss',
'aZ');
51$sref =
GETPOST(
"sref",
'alpha');
52$snom =
GETPOST(
"snom",
'alpha');
53$search_all = trim((
GETPOST(
'search_all',
'alphanohtml') !=
'') ?
GETPOST(
'search_all',
'alphanohtml') :
GETPOST(
'sall',
'alphanohtml'));
55$search_barcode =
GETPOST(
"search_barcode",
'alpha');
56$search_warehouse =
GETPOST(
'search_warehouse',
'alpha');
57$search_batch =
GETPOST(
'search_batch',
'alpha');
58$search_toolowstock =
GETPOST(
'search_toolowstock');
59$search_subjecttolotserial =
GETPOST(
'search_subjecttolotserial');
64$search_stock_physique =
GETPOST(
'search_stock_physique',
'alpha');
68$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
69$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
71if (empty($page) || $page < 0 ||
GETPOST(
'button_search',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
75$offset = $limit * $page;
81$search_sale =
GETPOST(
"search_sale");
82if (GETPOSTISSET(
'catid')) {
87$search_warehouse_categ =
GETPOSTINT(
'search_warehouse_categ');
90$extrafields->fetch_name_optionals_label(
$object->table_element);
93$search_array_options = $extrafields->getOptionalsFromPost(
$object->table_element,
'',
'search_');
98 $sortfield =
"p.".key(
$object->fields);
107foreach (
$object->fields as $key => $val) {
108 if (
GETPOST(
'search_'.$key,
'alpha') !==
'') {
109 $search[$key] =
GETPOST(
'search_'.$key,
'alpha');
111 if (preg_match(
'/^(date|timestamp|datetime)/', $val[
'type'])) {
126if (!empty($canvas)) {
127 require_once DOL_DOCUMENT_ROOT.
'/core/class/canvas.class.php';
128 $objcanvas =
new Canvas($db, $action);
129 $objcanvas->getCanvas(
'product',
'list', $canvas);
133$hookmanager->initHooks(array(
'reassortlotlist'));
137 array(
'type' =>
'varchar',
'label' =>
'Ref',
'checked' => 1,
'enabled' => 1,
'position' => 1),
138 array(
'type' =>
'varchar',
'label' =>
'Label',
'checked' => 1,
'enabled' => 1,
'position' => 1),
139 array(
'type' =>
'int',
'label' =>
'Warehouse',
'checked' => 1,
'enabled' => 1,
'position' => 1),
140 array(
'type' =>
'varchar',
'label' =>
'Lot',
'checked' => 1,
'enabled' => 1,
'position' => 1),
141 array(
'type' =>
'varchar',
'label' =>
'DLC',
'checked' => 1,
'enabled' => 1,
'position' => 1),
142 array(
'type' =>
'varchar',
'label' =>
'DLUO',
'checked' => 1,
'enabled' => 1,
'position' => 1),
143 array(
'type' =>
'int',
'label' =>
'Stock',
'checked' => 1,
'enabled' => 1,
'position' => 1),
144 array(
'type' =>
'int',
'label' =>
'StatusSell',
'checked' => 1,
'enabled' => 1,
'position' => 1),
145 array(
'type' =>
'int',
'label' =>
'StatusBuy',
'checked' => 1,
'enabled' => 1,
'position' => 1),
154 $socid = $user->socid;
156$result =
restrictedArea($user,
'produit|service', 0,
'product&product');
164if (
GETPOST(
'cancel',
'alpha')) {
168if (!
GETPOST(
'confirmmassaction',
'alpha') && $massaction !=
'presend' && $massaction !=
'confirm_presend') {
172$parameters = array();
173$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
178if (empty($reshook)) {
180 include DOL_DOCUMENT_ROOT.
'/core/actions_changeselectedfields.inc.php';
183 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
184 foreach (
$object->fields as $key => $val) {
186 if (preg_match(
'/^(date|timestamp|datetime)/', $val[
'type'])) {
187 $search[$key.
'_dtstart'] =
'';
188 $search[$key.
'_dtend'] =
'';
191 $search[
'sellby_dtstart'] =
'';
192 $search[
'eatby_dtstart'] =
'';
193 $search[
'sellby_dtend'] =
'';
194 $search[
'eatby_dtend'] =
'';
202 $search_warehouse_categ =
"";
203 $search_toolowstock =
'';
204 $search_subjecttolotserial =
'';
206 $search_warehouse =
'';
209 $search_stock_physique =
'';
211 $search_array_options = array();
213 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')
214 ||
GETPOST(
'button_search_x',
'alpha') ||
GETPOST(
'button_search.x',
'alpha') ||
GETPOST(
'button_search',
'alpha')) {
232$form =
new Form($db);
237$helpurl =
'EN:Module_Stocks_En|FR:Module_Stock|ES:Módulo_Stocks';
238$title = $langs->trans(
"ProductsAndServices");
242$sql =
'SELECT p.rowid, p.ref, p.label, p.barcode, p.price, p.price_ttc, p.price_base_type, p.entity,';
243$sql .=
' p.fk_product_type, p.tms as datem,';
244$sql .=
' p.duration, p.tosell as statut, p.tobuy, p.seuil_stock_alerte, p.desiredstock, p.stock, p.tosell, p.tobuy, p.tobatch,';
245$sql .=
' ps.fk_entrepot, ps.reel,';
246$sql .=
' e.ref as warehouse_ref, e.lieu as warehouse_lieu, e.fk_parent as warehouse_parent,';
247$sql .=
' pb.batch, pb.eatby as oldeatby, pb.sellby as oldsellby,';
248$sql .=
' pl.rowid as lotid, pl.eatby, pl.sellby,';
249$sql .=
' SUM(pb.qty) as stock_physique, COUNT(pb.rowid) as nbinbatchtable';
251$parameters = array();
252$reshook = $hookmanager->executeHooks(
'printFieldListSelect', $parameters, $object);
253$sql .= $hookmanager->resPrint;
254$sql .=
' FROM '.MAIN_DB_PREFIX.
'product as p';
255$sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'product_stock as ps on p.rowid = ps.fk_product';
256$sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'entrepot as e on ps.fk_entrepot = e.rowid';
257$sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'product_batch as pb on pb.fk_product_stock = ps.rowid';
258$sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'product_lot as pl on pl.fk_product = p.rowid AND pl.batch = pb.batch';
260$parameters = array();
261$reshook = $hookmanager->executeHooks(
'printFieldListFrom', $parameters, $object);
262$sql .= $hookmanager->resPrint;
263$sql .=
" WHERE p.entity IN (".getEntity(
'product').
") AND e.entity IN (".
getEntity(
'stock').
")";
264if (!empty($search_categ) && $search_categ !=
'-1') {
266 if ($search_categ == -2) {
267 $sql .=
" NOT EXISTS ";
272 $sql .=
" SELECT cp.fk_categorie, cp.fk_product";
273 $sql .=
" FROM " . MAIN_DB_PREFIX .
"categorie_product as cp";
274 $sql .=
" WHERE cp.fk_product = p.rowid";
275 if ($search_categ > 0) {
276 $sql .=
" AND cp.fk_categorie = " . ((int) $search_categ);
280if (!empty($search_warehouse_categ) && $search_warehouse_categ !=
'-1') {
282 if ($search_warehouse_categ == -2) {
283 $sql .=
" NOT EXISTS ";
288 $sql .=
" SELECT cp.fk_categorie, cp.fk_warehouse";
289 $sql .=
" FROM " . MAIN_DB_PREFIX .
"categorie_warehouse as cp";
290 $sql .=
" WHERE cp.fk_warehouse = e.rowid";
291 if ($search_warehouse_categ > 0) {
292 $sql .=
" AND cp.fk_categorie = " . ((int) $search_warehouse_categ);
297 $sql .=
natural_search(array(
'p.ref',
'p.label',
'p.description',
'p.note'), $search_all);
302 $sql .=
" AND p.fk_product_type = '1'";
304 $sql .=
" AND p.fk_product_type <> '1'";
307if ($search_subjecttolotserial) {
308 $sql .=
" AND p.tobatch > 0";
313if ($search_barcode) {
319if (!empty($tosell)) {
320 $sql .=
" AND p.tosell = ".((int) $tosell);
323 $sql .=
" AND p.tobuy = ".((int) $tobuy);
325if (!empty($canvas)) {
326 $sql .=
" AND p.canvas = '".$db->escape($canvas).
"'";
329 $sql .=
" AND p.rowid = pf.fk_product AND pf.fk_soc = ".((int) $fourn_id);
331if ($search_warehouse) {
338foreach ($search as $key => $val) {
339 if (array_key_exists($key,
$object->fields)) {
340 if ($key ==
'status' && $search[$key] == -1) {
344 if ((strpos(
$object->fields[$key][
'type'],
'integer:') === 0) || (strpos(
$object->fields[$key][
'type'],
'sellist:') === 0) || !empty(
$object->fields[$key][
'arrayofkeyval'])) {
345 if ($search[$key] ==
'-1' || ($search[$key] ===
'0' && (empty(
$object->fields[$key][
'arrayofkeyval']) || !array_key_exists(
'0',
$object->fields[$key][
'arrayofkeyval'])))) {
350 if ($search[$key] !=
'') {
351 $sql .=
natural_search(
"t.".$db->escape($key), $search[$key], (($key ==
'status') ? 2 : $mode_search));
354 if (preg_match(
'/(_dtstart|_dtend)$/', $key) && $search[$key] !=
'') {
355 $columnName = preg_replace(
'/(_dtstart|_dtend)$/',
'', $key);
356 if ($columnName ==
'eatby' || $columnName ==
'sellby') {
357 if (preg_match(
'/_dtstart$/', $key)) {
358 $sql .=
" AND pl.".$db->escape($columnName).
" >= '".$db->idate($search[$key]).
"'";
360 if (preg_match(
'/_dtend$/', $key)) {
361 $sql .=
" AND pl.".$db->escape($columnName).
" <= '".$db->idate($search[$key]).
"'";
368$parameters = array();
369$reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters, $object);
370$sql .= $hookmanager->resPrint;
372$sql .=
" GROUP BY p.rowid, p.ref, p.label, p.barcode, p.price, p.price_ttc, p.price_base_type, p.entity,";
373$sql .=
" p.fk_product_type, p.tms,";
374$sql .=
" p.duration, p.tosell, p.tobuy, p.seuil_stock_alerte, p.desiredstock, p.stock, p.tosell, p.tobuy, p.tobatch,";
375$sql .=
" ps.fk_entrepot, ps.reel,";
376$sql .=
" e.ref, e.lieu, e.fk_parent,";
377$sql .=
" pb.batch, pb.eatby, pb.sellby,";
378$sql .=
" pl.rowid, pl.eatby, pl.sellby";
380$parameters = array();
381$reshook = $hookmanager->executeHooks(
'printFieldListGroupBy', $parameters, $object);
382$sql .= $hookmanager->resPrint;
384if ($search_toolowstock) {
385 $sql_having .=
" HAVING SUM(".$db->ifsql(
'ps.reel IS NULL',
'0',
'ps.reel').
") < p.seuil_stock_alerte";
387if ($search_stock_physique !=
'') {
388 $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);
389 $natural_search_physique =
" " . substr($natural_search_physique, 1, -1);
390 if (!empty($sql_having)) {
391 $sql_having .=
" AND";
393 $sql_having .=
" HAVING";
395 $sql_having .= $natural_search_physique;
398$parameters = array();
399$reshook = $hookmanager->executeHooks(
'printFieldListHaving', $parameters, $object);
400if (!empty($hookmanager->resPrint)) {
401 if (!empty($sql_having)) {
402 $sql_having .=
" AND";
404 $sql_having .=
" HAVING";
406 $sql_having .= $hookmanager->resPrint;
408if (!empty($sql_having)) {
415$nbtotalofrecords =
'';
417 $resql = $db->query($sql);
418 $nbtotalofrecords = $db->num_rows($resql);
420 if (($page * $limit) > $nbtotalofrecords) {
428$sql .= $db->order($sortfield, $sortorder);
430 $sql .= $db->plimit($limit + 1, $offset);
433$resql = $db->query($sql);
439$num = $db->num_rows($resql);
443if ($num == 1 &&
GETPOST(
'autojumpifoneonly') && ($search_all || $snom || $sref)) {
444 $objp = $db->fetch_object($resql);
445 header(
"Location: card.php?id=$objp->rowid");
451 $texte = $langs->trans(
"Services");
453 $texte = $langs->trans(
"Products");
456 $texte = $langs->trans(
"ProductsAndServices");
458$texte .=
' ('.$langs->trans(
"StocksByLotSerial").
')';
462 $param .=
'&mode='.urlencode($mode);
464if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
465 $param .=
'&contextpage='.urlencode($contextpage);
467if ($limit > 0 && $limit != $conf->liste_limit) {
468 $param .=
'&limit='.((int) $limit);
470foreach ($search as $key => $val) {
471 if (is_array($search[$key]) && count($search[$key])) {
472 foreach ($search[$key] as $skey) {
474 $param .=
'&search_'.$key.
'[]='.urlencode($skey);
477 } elseif ($search[$key] !=
'') {
478 $param .=
'&search_'.$key.
'='.urlencode($search[$key]);
481if ($optioncss !=
'') {
482 $param .=
'&optioncss='.urlencode($optioncss);
485 $param .=
"&search_all=".urlencode($search_all);
488 $param .=
"&tosell=".urlencode($tosell);
491 $param .=
"&tobuy=".urlencode($tobuy);
494 $param .=
"&type=".urlencode((
string) ($type));
497 $param .=
"&fourn_id=".urlencode((
string) ($fourn_id));
500 $param .=
"&snom=".urlencode($snom);
503 $param .=
"&sref=".urlencode($sref);
506 $param .=
"&search_batch=".urlencode($search_batch);
509 $param .=
"&sbarcode=".urlencode((
string) ($sbarcode));
511if ($search_warehouse) {
512 $param .=
"&search_warehouse=".urlencode($search_warehouse);
514if ($search_toolowstock) {
515 $param .=
"&search_toolowstock=".urlencode($search_toolowstock);
517if ($search_subjecttolotserial) {
518 $param .=
"&search_subjecttolotserial=".urlencode($search_subjecttolotserial);
521 $param .=
"&search_sale=".urlencode($search_sale);
523if (!empty($search_categ) && $search_categ !=
'-1') {
524 $param .=
"&search_categ=".urlencode((
string) ($search_categ));
526if (!empty($search_warehouse_categ) && $search_warehouse_categ !=
'-1') {
527 $param .=
"&search_warehouse_categ=".urlencode((
string) ($search_warehouse_categ));
529if ($search_stock_physique) {
530 $param .=
'&search_stock_physique=' . urlencode($search_stock_physique);
535llxHeader(
"", $title, $helpurl, $texte, 0, 0,
'',
'',
'',
'mod-product page-reassortlot');
537print
'<form id="searchFormList" action="'.$_SERVER[
"PHP_SELF"].
'" method="POST" name="formulaire">'.
"\n";
538if ($optioncss !=
'') {
539 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
541print
'<input type="hidden" name="token" value="'.newToken().
'">';
542print
'<input type="hidden" name="action" value="list">';
543print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
544print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
545print
'<input type="hidden" name="type" value="'.$type.
'">';
546print
'<input type="hidden" name="page" value="'.$page.
'">';
547print
'<input type="hidden" name="contextpage" value="'.$contextpage.
'">';
548print
'<input type="hidden" name="mode" value="'.$mode.
'">';
550print_barre_liste($texte, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder,
'', $num, $nbtotalofrecords,
'product', 0,
'',
'', $limit, 0, 0, 1);
565if (isModEnabled(
'category')) {
566 $moreforfilter .=
'<div class="divsearchfield">';
567 $moreforfilter .=
img_picto($langs->trans(
'ProductsCategoriesShort'),
'category',
'class="pictofixedwidth"');
568 $moreforfilter .= $htmlother->select_categories(Categorie::TYPE_PRODUCT, $search_categ,
'search_categ', 1, $langs->trans(
"ProductsCategoryShort"),
'maxwidth400');
569 $moreforfilter .=
'</div>';
572if (isModEnabled(
'category')) {
573 $moreforfilter .=
'<div class="divsearchfield">';
574 $moreforfilter .=
img_picto($langs->trans(
'StockCategoriesShort'),
'category',
'class="pictofixedwidth"');
575 $moreforfilter .= $htmlother->select_categories(Categorie::TYPE_WAREHOUSE, $search_warehouse_categ,
'search_warehouse_categ', 1, $langs->trans(
"StockCategoriesShort"),
'maxwidth400');
576 $moreforfilter .=
'</div>';
579$moreforfilter .=
'<label for="search_subjecttolotserial">'.$langs->trans(
"SubjectToLotSerialOnly").
' </label><input type="checkbox" id="search_subjecttolotserial" name="search_subjecttolotserial" value="1"'.($search_subjecttolotserial ?
' checked' :
'').
'>';
582if (!empty($moreforfilter)) {
583 print
'<div class="liste_titre liste_titre_bydiv centpercent">';
584 print $moreforfilter;
585 $parameters = array();
586 $reshook = $hookmanager->executeHooks(
'printFieldPreListTitle', $parameters, $object, $action);
587 print $hookmanager->resPrint;
592print
'<div class="div-table-responsive">';
593print
'<table class="tagtable nobottomiftotal liste'.($moreforfilter ?
" listwithfilterbefore" :
"").
'">';
597print
'<tr class="liste_titre_filter">';
600 print
'<td class="liste_titre maxwidthsearch">';
601 $searchpicto = $form->showFilterButtons();
605print
'<td class="liste_titre">';
606print
'<input class="flat" type="text" name="sref" size="6" value="'.dol_escape_htmltag($sref).
'">';
608print
'<td class="liste_titre">';
609print
'<input class="flat" type="text" name="snom" size="8" value="'.dol_escape_htmltag($snom).
'">';
611if (isModEnabled(
"service") && $type == 1) {
612 print
'<td class="liste_titre">';
617print
'<td class="liste_titre"><input class="flat" type="text" name="search_warehouse" size="6" value="'.dol_escape_htmltag($search_warehouse).
'"></td>';
618print
'<td class="liste_titre center"><input class="flat" type="text" name="search_batch" size="6" value="'.dol_escape_htmltag($search_batch).
'"></td>';
620 print
'<td class="liste_titre center">';
622 print
'<div class="nowrap">';
623 print $form->selectDate($search[$key.
'_dtstart'] ? $search[$key.
'_dtstart'] :
'',
"search_".$key.
"_dtstart", 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'From'));
625 print
'<div class="nowrap">';
626 print $form->selectDate($search[$key.
'_dtend'] ? $search[$key.
'_dtend'] :
'',
"search_".$key.
"_dtend", 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'to'));
631 print
'<td class="liste_titre center">';
633 print
'<div class="nowrap">';
634 print $form->selectDate($search[$key.
'_dtstart'] ? $search[$key.
'_dtstart'] :
'',
"search_".$key.
"_dtstart", 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'From'));
636 print
'<div class="nowrap">';
637 print $form->selectDate($search[$key.
'_dtend'] ? $search[$key.
'_dtend'] :
'',
"search_".$key.
"_dtend", 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'to'));
642print
'<td class="liste_titre right">';
643print
'<input class="flat" type="text" size="5" name="search_stock_physique" value="'.dol_escape_htmltag($search_stock_physique).
'">';
645print
'<td class="liste_titre"> </td>';
646print
'<td class="liste_titre"> </td>';
647print
'<td class="liste_titre"> </td>';
648$parameters = array();
649$reshook = $hookmanager->executeHooks(
'printFieldListOption', $parameters);
650print $hookmanager->resPrint;
653 print
'<td class="liste_titre maxwidthsearch">';
654 $searchpicto = $form->showFilterButtons();
660$totalarray = array();
661$totalarray[
'nbfield'] = 0;
665print
'<tr class="liste_titre">';
672if (isModEnabled(
"service") && $type == 1) {
673 print_liste_field_titre(
"Duration", $_SERVER[
"PHP_SELF"],
"p.duration",
'', $param,
"", $sortfield, $sortorder,
'center ');
677print_liste_field_titre(
"Batch", $_SERVER[
"PHP_SELF"],
"pb.batch",
'', $param,
"", $sortfield, $sortorder,
'center ');
679 print_liste_field_titre(
"SellByDate", $_SERVER[
"PHP_SELF"],
"pl.sellby",
'', $param,
"", $sortfield, $sortorder,
'center ');
682 print_liste_field_titre(
"EatByDate", $_SERVER[
"PHP_SELF"],
"pl.eatby",
'', $param,
"", $sortfield, $sortorder,
'center ');
684print_liste_field_titre(
"PhysicalStock", $_SERVER[
"PHP_SELF"],
"stock_physique",
'', $param,
"", $sortfield, $sortorder,
'right ');
688print_liste_field_titre(
"ProductStatusOnSell", $_SERVER[
"PHP_SELF"],
"p.tosell",
"", $param,
'', $sortfield, $sortorder,
'right ');
689print_liste_field_titre(
"ProductStatusOnBuy", $_SERVER[
"PHP_SELF"],
"p.tobuy",
"", $param,
'', $sortfield, $sortorder,
'right ');
691$parameters = array(
'param' => $param,
'sortfield' => $sortfield,
'sortorder' => $sortorder);
692$reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters);
693print $hookmanager->resPrint;
699$product_static =
new Product($db);
706$savnbfield = $totalarray[
'nbfield'];
707$totalarray[
'nbfield'] = 0;
708$imaxinloop = ($limit ? min($num, $limit) : $num);
709while ($i < $imaxinloop) {
710 $objp = $db->fetch_object($resql);
715 $sql =
"SELECT label";
716 $sql .=
" FROM ".MAIN_DB_PREFIX.
"product_lang";
717 $sql .=
" WHERE fk_product = ".((int) $objp->rowid);
718 $sql .=
" AND lang = '".$db->escape($langs->getDefaultLang()).
"'";
721 $result = $db->query($sql);
723 $objtp = $db->fetch_object($result);
724 if (!empty($objtp->label)) {
725 $objp->label = $objtp->label;
730 $product_static->ref = $objp->ref;
731 $product_static->id = $objp->rowid;
732 $product_static->label = $objp->label;
733 $product_static->type = $objp->fk_product_type;
734 $product_static->entity = $objp->entity;
735 $product_static->status = $objp->tosell;
736 $product_static->status_buy = $objp->tobuy;
737 $product_static->status_batch = $objp->tobatch;
739 $product_lot_static->batch = $objp->batch;
740 $product_lot_static->fk_product = $objp->rowid;
741 $product_lot_static->id = $objp->lotid;
742 $product_lot_static->eatby = $objp->eatby;
743 $product_lot_static->sellby = $objp->sellby;
746 $warehousetmp->id = $objp->fk_entrepot;
747 $warehousetmp->ref = $objp->warehouse_ref;
748 $warehousetmp->label = $objp->warehouse_ref;
749 $warehousetmp->fk_parent = $objp->warehouse_parent;
757 $totalarray[
'nbfield']++;
762 print
'<td class="nowrap">';
763 print $product_static->getNomUrl(1,
'', 16);
767 $totalarray[
'nbfield']++;
771 print
'<td>'.$objp->label.
'</td>';
773 $totalarray[
'nbfield']++;
776 if (isModEnabled(
"service") && $type == 1) {
777 print
'<td class="center">';
779 if (preg_match(
'/([0-9]+)y/i', $objp->duration, $regs)) {
780 print $regs[1].
' '.$langs->trans(
"DurationYear");
781 } elseif (preg_match(
'/([0-9]+)m/i', $objp->duration, $regs)) {
782 print $regs[1].
' '.$langs->trans(
"DurationMonth");
783 } elseif (preg_match(
'/([0-9]+)d/i', $objp->duration, $regs)) {
784 print $regs[1].
' '.$langs->trans(
"DurationDay");
786 print $objp->duration;
789 $totalarray[
'nbfield']++;
798 print
'<td class="nowrap">';
799 if ($objp->fk_entrepot > 0) {
800 print $warehousetmp->getNomUrl(1);
803 $totalarray[
'nbfield']++;
808 print
'<td class="center nowrap">';
809 if ($product_lot_static->batch) {
810 print $product_lot_static->getNomUrl(1);
813 $totalarray[
'nbfield']++;
818 print
'<td class="center">'.dol_print_date($db->jdate($objp->sellby),
'day').
'</td>';
820 $totalarray[
'nbfield']++;
825 print
'<td class="center">'.dol_print_date($db->jdate($objp->eatby),
'day').
'</td>';
827 $totalarray[
'nbfield']++;
831 print
'<td class="right">';
833 if (is_null($objp->stock_physique)) {
834 if (!empty($objp->reel)) {
835 if ($objp->reel < 0) {
836 print
'<span class="warning">';
839 if ($objp->reel < 0) {
842 print($objp->stock_physique < 0 ?
' '.img_warning() :
'');
845 if (!empty($objp->stock_physique)) {
846 if ($objp->stock_physique < 0) {
847 print
'<span class="warning">';
849 print
price2num($objp->stock_physique,
'MS');
850 if ($objp->stock_physique < 0) {
853 print($objp->stock_physique < 0 ?
' '.img_warning() : (($objp->stock_physique > 1 && $objp->tobatch == 2) ?
' '.
img_warning($langs->trans(
'IlligalQtyForSerialNumbers')) :
''));
858 $totalarray[
'nbfield']++;
861 print
'<td class="right">';
862 print
img_picto($langs->trans(
"StockMovement"),
'movement',
'class="pictofixedwidth"');
863 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>';
866 $totalarray[
'nbfield']++;
869 print
'<td class="right nowrap">'.$product_static->LibStatut($objp->statut, 5, 0).
'</td>';
871 $totalarray[
'nbfield']++;
874 print
'<td class="right nowrap">'.$product_static->LibStatut($objp->tobuy, 5, 1).
'</td>';
876 $totalarray[
'nbfield']++;
880 $parameters = array(
'obj' => $objp);
881 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $product);
882 print $hookmanager->resPrint;
888 $totalarray[
'nbfield']++;
899 foreach ($arrayfields as $key => $val) {
900 if (!empty($val[
'checked'])) {
904 print
'<tr><td colspan="'.$colspan.
'"><span class="opacitymedium">'.$langs->trans(
"NoRecordFound").
'</span></td></tr>';
910print
'</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($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
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...
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
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.
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 a 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.