diff --git a/htdocs/product/reassortlot.php b/htdocs/product/reassortlot.php index c5463e3e4e2..031ef60ff6e 100644 --- a/htdocs/product/reassortlot.php +++ b/htdocs/product/reassortlot.php @@ -33,11 +33,18 @@ require_once DOL_DOCUMENT_ROOT.'/product/stock/class/productlot.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; require_once DOL_DOCUMENT_ROOT.'/product/stock/class/entrepot.class.php'; +require_once DOL_DOCUMENT_ROOT.'/product/stock/class/productlot.class.php'; // Load translation files required by the page $langs->loadLangs(array('products', 'stocks', 'productbatch')); -$action = GETPOST('action', 'aZ09'); +$action = GETPOST('action', 'aZ09') ?GETPOST('action', 'aZ09') : 'view'; // The action 'add', 'create', 'edit', 'update', 'view', ... +$massaction = GETPOST('massaction', 'alpha'); // The bulk action (combo box choice into lists) +$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'myobjectlist'; // To manage different context of search +$backtopage = GETPOST('backtopage', 'alpha'); // Go back to a dedicated page +$optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print') +$mode = GETPOST('mode', 'aZ'); + $sref = GETPOST("sref", 'alpha'); $snom = GETPOST("snom", 'alpha'); $sall = trim((GETPOST('search_all', 'alphanohtml') != '') ?GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml')); @@ -52,25 +59,21 @@ $fourn_id = GETPOST("fourn_id", 'int'); $sbarcode = GETPOST("sbarcode", 'int'); $search_stock_physique = GETPOST('search_stock_physique', 'alpha'); +// Load variable for pagination +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'aZ09comma'); $sortorder = GETPOST('sortorder', 'aZ09comma'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); -if (empty($page) || $page < 0) { +if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) { + // If $page is not defined, or '' or -1 or if we click on clear filters $page = 0; } -if (!$sortfield) { - $sortfield = "p.ref"; -} -if (!$sortorder) { - $sortorder = "ASC"; -} -$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; -if (empty($page) || $page == -1) { - $page = 0; -} // If $page is not defined, or '' or -1 $offset = $limit * $page; +$pageprev = $page - 1; +$pagenext = $page + 1; -// Load sale and categ filters +// Initialize array of search criterias +$object = new Product($db); $search_sale = GETPOST("search_sale"); if (GETPOSTISSET('catid')) { $search_categ = GETPOST('catid', 'int'); @@ -78,6 +81,33 @@ if (GETPOSTISSET('catid')) { $search_categ = GETPOST('search_categ', 'int'); } +// Fetch optionals attributes and labels +$extrafields->fetch_name_optionals_label($object->table_element); +//$extrafields->fetch_name_optionals_label($object->table_element_line); + +$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); + +// Default sort order (if not yet defined by previous GETPOST) +if (!$sortfield) { + reset($object->fields); // Reset is required to avoid key() to return null. + $sortfield = "p.".key($object->fields); // Set here default search field. By default 1st field in definition. +} +if (!$sortorder) { + $sortorder = "ASC"; +} + +// Initialize array of search criterias +$search = array(); +foreach ($object->fields as $key => $val) { + if (GETPOST('search_'.$key, 'alpha') !== '') { + $search[$key] = GETPOST('search_'.$key, 'alpha'); + } + if (preg_match('/^(date|timestamp|datetime)/', $val['type'])) { + $search[$key.'_dtstart'] = dol_mktime(0, 0, 0, GETPOST('search_'.$key.'_dtstartmonth', 'int'), GETPOST('search_'.$key.'_dtstartday', 'int'), GETPOST('search_'.$key.'_dtstartyear', 'int')); + $search[$key.'_dtend'] = dol_mktime(23, 59, 59, GETPOST('search_'.$key.'_dtendmonth', 'int'), GETPOST('search_'.$key.'_dtendday', 'int'), GETPOST('search_'.$key.'_dtendyear', 'int')); + } +} + // Get object canvas (By default, this is not defined, so standard usage of dolibarr) $canvas = GETPOST("canvas"); $objcanvas = null; @@ -98,21 +128,62 @@ $result = restrictedArea($user, 'produit|service', 0, 'product&product'); * Actions */ -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 - $sref = ""; - $snom = ""; - $sall = ""; - $tosell = ""; - $tobuy = ""; - $search_sale = ""; - $search_categ = ""; - $toolowstock = ''; - $search_batch = ''; - $search_warehouse = ''; - $fourn_id = ''; - $sbarcode = ''; - $search_stock_physique = ''; +if (GETPOST('cancel', 'alpha')) { + $action = 'list'; + $massaction = ''; } +if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { + $massaction = ''; +} + +$parameters = array(); +$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks +if ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +} + +if (empty($reshook)) { + // Selection of new fields + include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; + + // Purge search criteria + 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 + foreach ($object->fields as $key => $val) { + $search[$key] = ''; + if (preg_match('/^(date|timestamp|datetime)/', $val['type'])) { + $search[$key.'_dtstart'] = ''; + $search[$key.'_dtend'] = ''; + } + } + $sref = ""; + $snom = ""; + $sall = ""; + $tosell = ""; + $tobuy = ""; + $search_sale = ""; + $search_categ = ""; + $toolowstock = ''; + $search_batch = ''; + $search_warehouse = ''; + $fourn_id = ''; + $sbarcode = ''; + $search_stock_physique = ''; + $toselect = array(); + $search_array_options = array(); + } + if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha') + || GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha')) { + $massaction = ''; // Protection to avoid mass action if we force a new search during a mass action confirmation + } + + // Mass actions + /*$objectclass = 'MyObject'; + $objectlabel = 'MyObject'; + $uploaddir = $conf->mymodule->dir_output; + include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; + */ +} + /* @@ -122,8 +193,12 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x' $form = new Form($db); $htmlother = new FormOther($db); +$now = dol_now(); + $helpurl = 'EN:Module_Stocks_En|FR:Module_Stock|ES:Módulo_Stocks'; $title = $langs->trans("ProductsAndServices"); +$morejs = array(); +$morecss = array(); $sql = 'SELECT p.rowid, p.ref, p.label, p.barcode, p.price, p.price_ttc, p.price_base_type, p.entity,'; $sql .= ' p.fk_product_type, p.tms as datem,'; @@ -217,318 +292,334 @@ if ($search_stock_physique != '') { if (!empty($sql_having)) { $sql .= $sql_having; } -$sql .= $db->order($sortfield, $sortorder); $nbtotalofrecords = ''; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $db->query($sql); $nbtotalofrecords = $db->num_rows($result); - if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0 + + if (($page * $limit) > $nbtotalofrecords) { // if total of record found is smaller than page * limit, goto and load page 0 $page = 0; $offset = 0; } + $db->free($resql); } -$sql .= $db->plimit($limit + 1, $offset); +// Complete request and execute it with limit +$sql .= $db->order($sortfield, $sortorder); +if ($limit) { + $sql .= $db->plimit($limit + 1, $offset); +} $resql = $db->query($sql); -if ($resql) { - $num = $db->num_rows($resql); - - $i = 0; - - if ($num == 1 && GETPOST('autojumpifoneonly') && ($sall or $snom or $sref)) { - $objp = $db->fetch_object($resql); - header("Location: card.php?id=$objp->rowid"); - exit; - } - - if (isset($type)) { - if ($type == 1) { - $texte = $langs->trans("Services"); - } else { - $texte = $langs->trans("Products"); - } - } else { - $texte = $langs->trans("ProductsAndServices"); - } - $texte .= ' ('.$langs->trans("StocksByLotSerial").')'; - - $param = ''; - if ($limit > 0 && $limit != $conf->liste_limit) { - $param .= '&limit='.urlencode($limit); - } - if ($sall) { - $param .= "&sall=".urlencode($sall); - } - if ($tosell) { - $param .= "&tosell=".urlencode($tosell); - } - if ($tobuy) { - $param .= "&tobuy=".urlencode($tobuy); - } - if ($type != '') { - $param .= "&type=".urlencode($type); - } - if ($fourn_id) { - $param .= "&fourn_id=".urlencode($fourn_id); - } - if ($snom) { - $param .= "&snom=".urlencode($snom); - } - if ($sref) { - $param .= "&sref=".urlencode($sref); - } - if ($search_batch) { - $param .= "&search_batch=".urlencode($search_batch); - } - if ($sbarcode) { - $param .= "&sbarcode=".urlencode($sbarcode); - } - if ($search_warehouse) { - $param .= "&search_warehouse=".urlencode($search_warehouse); - } - if ($toolowstock) { - $param .= "&toolowstock=".urlencode($toolowstock); - } - if ($search_sale) { - $param .= "&search_sale=".urlencode($search_sale); - } - if (!empty($search_categ) && $search_categ != '-1') { - $param .= "&search_categ=".urlencode($search_categ); - } - if ($search_stock_physique) { - $param .= '&search_stock_physique=' . urlencode($search_stock_physique); - } - /*if ($eatby) $param.="&eatby=".$eatby; - if ($sellby) $param.="&sellby=".$sellby;*/ - - llxHeader("", $title, $helpurl, $texte); - - print '
'; - print ''; - print ''; - print ''; - print ''; - - print_barre_liste($texte, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'product', 0, '', '', $limit, 0, 0, 1); - - - if ($search_categ > 0) { - print "
"; - $c = new Categorie($db); - $c->fetch($search_categ); - $ways = $c->print_all_ways(' > ', 'product/reassortlot.php'); - print " > ".$ways[0]."
\n"; - print "

"; - } - - // Filter on categories - $moreforfilter = ''; - if (!empty($conf->categorie->enabled)) { - $moreforfilter .= '
'; - $moreforfilter .= img_picto($langs->trans('Categories'), 'category', 'class="pictofixedwidth"'); - $moreforfilter .= $htmlother->select_categories(Categorie::TYPE_PRODUCT, $search_categ, 'search_categ', 1); - $moreforfilter .= '
'; - } - //$moreforfilter.=$langs->trans("StockTooLow").' '; - - if (!empty($moreforfilter)) { - print '
'; - print $moreforfilter; - $parameters = array(); - $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; - print '
'; - } - - - print '
'; - print ''; - - // Fields title search - print ''; - print ''; - print ''; - if (!empty($conf->service->enabled) && $type == 1) { - print ''; - } - print ''; - print ''; - if (empty($conf->global->PRODUCT_DISABLE_SELLBY)) { - print ''; - } - if (empty($conf->global->PRODUCT_DISABLE_EATBY)) { - print ''; - } - // Physical stock - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - - //Line for column titles - print ""; - print_liste_field_titre("Ref", $_SERVER["PHP_SELF"], "p.ref", '', $param, "", $sortfield, $sortorder); - print_liste_field_titre("Label", $_SERVER["PHP_SELF"], "p.label", '', $param, "", $sortfield, $sortorder); - if (!empty($conf->service->enabled) && $type == 1) { - print_liste_field_titre("Duration", $_SERVER["PHP_SELF"], "p.duration", '', $param, "", $sortfield, $sortorder, 'center '); - } - print_liste_field_titre("Warehouse", $_SERVER["PHP_SELF"], "e.ref", '', $param, "", $sortfield, $sortorder); - //print_liste_field_titre("DesiredStock", $_SERVER["PHP_SELF"], "p.desiredstock",$param,"",'',$sortfield,$sortorder, 'right ); - print_liste_field_titre("Batch", $_SERVER["PHP_SELF"], "pb.batch", '', $param, "", $sortfield, $sortorder, 'center '); - if (empty($conf->global->PRODUCT_DISABLE_SELLBY)) { - print_liste_field_titre("SellByDate", $_SERVER["PHP_SELF"], "pb.sellby", '', $param, "", $sortfield, $sortorder, 'center '); - } - if (empty($conf->global->PRODUCT_DISABLE_EATBY)) { - print_liste_field_titre("EatByDate", $_SERVER["PHP_SELF"], "pb.eatby", '', $param, "", $sortfield, $sortorder, 'center '); - } - print_liste_field_titre("PhysicalStock", $_SERVER["PHP_SELF"], "stock_physique", '', $param, "", $sortfield, $sortorder, 'right '); - // TODO Add info of running suppliers/customers orders - //print_liste_field_titre("TheoreticalStock",$_SERVER["PHP_SELF"], "stock_theorique",$param,"",'',$sortfield,$sortorder, 'right '); - print_liste_field_titre(''); - print_liste_field_titre("ProductStatusOnSell", $_SERVER["PHP_SELF"], "p.tosell", "", $param, '', $sortfield, $sortorder, 'right '); - print_liste_field_titre("ProductStatusOnBuy", $_SERVER["PHP_SELF"], "p.tobuy", "", $param, '', $sortfield, $sortorder, 'right '); - print_liste_field_titre(''); - print "\n"; - - $product_static = new Product($db); - $product_lot_static = new Productlot($db); - $warehousetmp = new Entrepot($db); - - while ($i < min($num, $limit)) { - $objp = $db->fetch_object($resql); - - // Multilangs - if (!empty($conf->global->MAIN_MULTILANGS)) { // si l'option est active - $sql = "SELECT label"; - $sql .= " FROM ".MAIN_DB_PREFIX."product_lang"; - $sql .= " WHERE fk_product = ".((int) $objp->rowid); - $sql .= " AND lang = '".$db->escape($langs->getDefaultLang())."'"; - $sql .= " LIMIT 1"; - - $result = $db->query($sql); - if ($result) { - $objtp = $db->fetch_object($result); - if (!empty($objtp->label)) { - $objp->label = $objtp->label; - } - } - } - - $product_static->ref = $objp->ref; - $product_static->id = $objp->rowid; - $product_static->label = $objp->label; - $product_static->type = $objp->fk_product_type; - $product_static->entity = $objp->entity; - $product_static->status = $objp->tosell; - $product_static->status_buy = $objp->tobuy; - $product_static->status_batch = $objp->tobatch; - - $product_lot_static->batch = $objp->batch; - $product_lot_static->product_id = $objp->rowid; - $product_lot_static->id = $objp->lotid; - $product_lot_static->eatby = $objp->eatby; - $product_lot_static->sellby = $objp->sellby; - - - $warehousetmp->id = $objp->fk_entrepot; - $warehousetmp->ref = $objp->warehouse_ref; - $warehousetmp->label = $objp->warehouse_ref; - $warehousetmp->fk_parent = $objp->warehouse_parent; - - print ''; - - // Ref - print ''; - - // Label - print ''; - - if (!empty($conf->service->enabled) && $type == 1) { - print ''; - } - //print ''; - //print ''; - //print ''; - - // Warehouse - print ''; - - // Lot - print ''; - - if (empty($conf->global->PRODUCT_DISABLE_SELLBY)) { - print ''; - } - - if (empty($conf->global->PRODUCT_DISABLE_EATBY)) { - print ''; - } - - print ''; - - print ''; - - print ''; - - print ''; - - print ''; - - print "\n"; - $i++; - } - - print "
'; - print ''; - print ''; - print ''; - print ''; - print ' '; - print '  '; - print ''; - print '   '; - $searchpicto = $form->showFilterAndCheckAddButtons(0); - print $searchpicto; - print '
'; - print $product_static->getNomUrl(1, '', 16); - //if ($objp->stock_theorique < $objp->seuil_stock_alerte) print ' '.img_warning($langs->trans("StockTooLow")); - print ''.$objp->label.''; - if (preg_match('/([0-9]+)y/i', $objp->duration, $regs)) { - print $regs[1].' '.$langs->trans("DurationYear"); - } elseif (preg_match('/([0-9]+)m/i', $objp->duration, $regs)) { - print $regs[1].' '.$langs->trans("DurationMonth"); - } elseif (preg_match('/([0-9]+)d/i', $objp->duration, $regs)) { - print $regs[1].' '.$langs->trans("DurationDay"); - } else { - print $objp->duration; - } - print ''.$objp->stock_theorique.''.$objp->seuil_stock_alerte.''.$objp->desiredstock.''; - if ($objp->fk_entrepot > 0) { - print $warehousetmp->getNomUrl(1); - } - print ''; - if ($product_lot_static->batch) { - print $product_lot_static->getNomUrl(1); - } - print ''.dol_print_date($db->jdate($objp->sellby), 'day').''.dol_print_date($db->jdate($objp->eatby), 'day').''; - //if ($objp->seuil_stock_alerte && ($objp->stock_physique < $objp->seuil_stock_alerte)) print img_warning($langs->trans("StockTooLow")).' '; - print $objp->stock_physique; - print ''; - print img_picto($langs->trans("StockMovement"), 'movement', 'class="pictofixedwidth"'); - print ''.$langs->trans("Movements").''; - print ''.$product_static->LibStatut($objp->statut, 5, 0).''.$product_static->LibStatut($objp->tobuy, 5, 1).'
"; - print '
'; - print '
'; - - $db->free($resql); -} else { +if (!$resql) { dol_print_error($db); + exit; } +$num = $db->num_rows($resql); + +$i = 0; + +if ($num == 1 && GETPOST('autojumpifoneonly') && ($sall or $snom or $sref)) { + $objp = $db->fetch_object($resql); + header("Location: card.php?id=$objp->rowid"); + exit; +} + +if (isset($type)) { + if ($type == 1) { + $texte = $langs->trans("Services"); + } else { + $texte = $langs->trans("Products"); + } +} else { + $texte = $langs->trans("ProductsAndServices"); +} +$texte .= ' ('.$langs->trans("StocksByLotSerial").')'; + +$param = ''; +if ($limit > 0 && $limit != $conf->liste_limit) { + $param .= '&limit='.urlencode($limit); +} +if ($sall) { + $param .= "&sall=".urlencode($sall); +} +if ($tosell) { + $param .= "&tosell=".urlencode($tosell); +} +if ($tobuy) { + $param .= "&tobuy=".urlencode($tobuy); +} +if ($type != '') { + $param .= "&type=".urlencode($type); +} +if ($fourn_id) { + $param .= "&fourn_id=".urlencode($fourn_id); +} +if ($snom) { + $param .= "&snom=".urlencode($snom); +} +if ($sref) { + $param .= "&sref=".urlencode($sref); +} +if ($search_batch) { + $param .= "&search_batch=".urlencode($search_batch); +} +if ($sbarcode) { + $param .= "&sbarcode=".urlencode($sbarcode); +} +if ($search_warehouse) { + $param .= "&search_warehouse=".urlencode($search_warehouse); +} +if ($toolowstock) { + $param .= "&toolowstock=".urlencode($toolowstock); +} +if ($search_sale) { + $param .= "&search_sale=".urlencode($search_sale); +} +if (!empty($search_categ) && $search_categ != '-1') { + $param .= "&search_categ=".urlencode($search_categ); +} +if ($search_stock_physique) { + $param .= '&search_stock_physique=' . urlencode($search_stock_physique); +} +/*if ($eatby) $param.="&eatby=".$eatby; +if ($sellby) $param.="&sellby=".$sellby;*/ + +llxHeader("", $title, $helpurl, $texte); + +print '
'; +print ''; +print ''; +print ''; +print ''; + +print_barre_liste($texte, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'product', 0, '', '', $limit, 0, 0, 1); + + +if ($search_categ > 0) { + print "
"; + $c = new Categorie($db); + $c->fetch($search_categ); + $ways = $c->print_all_ways(' > ', 'product/reassortlot.php'); + print " > ".$ways[0]."
\n"; + print "

"; +} + +// Filter on categories +$moreforfilter = ''; +if (!empty($conf->categorie->enabled)) { + $moreforfilter .= '
'; + $moreforfilter .= img_picto($langs->trans('Categories'), 'category', 'class="pictofixedwidth"'); + $moreforfilter .= $htmlother->select_categories(Categorie::TYPE_PRODUCT, $search_categ, 'search_categ', 1); + $moreforfilter .= '
'; +} +//$moreforfilter.=$langs->trans("StockTooLow").' '; + +if (!empty($moreforfilter)) { + print '
'; + print $moreforfilter; + $parameters = array(); + $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + print '
'; +} + + +print '
'; +print ''; + +// Fields title search +// -------------------------------------------------------------------- +print ''; +print ''; +print ''; +if (!empty($conf->service->enabled) && $type == 1) { + print ''; +} +print ''; +print ''; +if (empty($conf->global->PRODUCT_DISABLE_SELLBY)) { + print ''; +} +if (empty($conf->global->PRODUCT_DISABLE_EATBY)) { + print ''; +} +// Physical stock +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; + +//Line for column titles +print ""; +print_liste_field_titre("Ref", $_SERVER["PHP_SELF"], "p.ref", '', $param, "", $sortfield, $sortorder); +print_liste_field_titre("Label", $_SERVER["PHP_SELF"], "p.label", '', $param, "", $sortfield, $sortorder); +if (!empty($conf->service->enabled) && $type == 1) { + print_liste_field_titre("Duration", $_SERVER["PHP_SELF"], "p.duration", '', $param, "", $sortfield, $sortorder, 'center '); +} +print_liste_field_titre("Warehouse", $_SERVER["PHP_SELF"], "e.ref", '', $param, "", $sortfield, $sortorder); +//print_liste_field_titre("DesiredStock", $_SERVER["PHP_SELF"], "p.desiredstock",$param,"",'',$sortfield,$sortorder, 'right ); +print_liste_field_titre("Batch", $_SERVER["PHP_SELF"], "pb.batch", '', $param, "", $sortfield, $sortorder, 'center '); +if (empty($conf->global->PRODUCT_DISABLE_SELLBY)) { + print_liste_field_titre("SellByDate", $_SERVER["PHP_SELF"], "pl.sellby", '', $param, "", $sortfield, $sortorder, 'center '); +} +if (empty($conf->global->PRODUCT_DISABLE_EATBY)) { + print_liste_field_titre("EatByDate", $_SERVER["PHP_SELF"], "pl.eatby", '', $param, "", $sortfield, $sortorder, 'center '); +} +print_liste_field_titre("PhysicalStock", $_SERVER["PHP_SELF"], "stock_physique", '', $param, "", $sortfield, $sortorder, 'right '); +// TODO Add info of running suppliers/customers orders +//print_liste_field_titre("TheoreticalStock",$_SERVER["PHP_SELF"], "stock_theorique",$param,"",'',$sortfield,$sortorder, 'right '); +print_liste_field_titre(''); +print_liste_field_titre("ProductStatusOnSell", $_SERVER["PHP_SELF"], "p.tosell", "", $param, '', $sortfield, $sortorder, 'right '); +print_liste_field_titre("ProductStatusOnBuy", $_SERVER["PHP_SELF"], "p.tobuy", "", $param, '', $sortfield, $sortorder, 'right '); +print_liste_field_titre(''); +print "\n"; + +$product_static = new Product($db); +$product_lot_static = new Productlot($db); +$warehousetmp = new Entrepot($db); + +// Loop on record +// -------------------------------------------------------------------- +$i = 0; +$savnbfield = $totalarray['nbfield']; +$totalarray['nbfield'] = 0; +$imaxinloop = ($limit ? min($num, $limit) : $num); +while ($i < $imaxinloop) { + $objp = $db->fetch_object($resql); + + // Multilangs + if (!empty($conf->global->MAIN_MULTILANGS)) { // si l'option est active + // TODO Use a cache + $sql = "SELECT label"; + $sql .= " FROM ".MAIN_DB_PREFIX."product_lang"; + $sql .= " WHERE fk_product = ".((int) $objp->rowid); + $sql .= " AND lang = '".$db->escape($langs->getDefaultLang())."'"; + $sql .= " LIMIT 1"; + + $result = $db->query($sql); + if ($result) { + $objtp = $db->fetch_object($result); + if (!empty($objtp->label)) { + $objp->label = $objtp->label; + } + } + } + + $product_static->ref = $objp->ref; + $product_static->id = $objp->rowid; + $product_static->label = $objp->label; + $product_static->type = $objp->fk_product_type; + $product_static->entity = $objp->entity; + $product_static->status = $objp->tosell; + $product_static->status_buy = $objp->tobuy; + $product_static->status_batch = $objp->tobatch; + + $product_lot_static->batch = $objp->batch; + $product_lot_static->product_id = $objp->rowid; + $product_lot_static->id = $objp->lotid; + $product_lot_static->eatby = $objp->eatby; + $product_lot_static->sellby = $objp->sellby; + + + $warehousetmp->id = $objp->fk_entrepot; + $warehousetmp->ref = $objp->warehouse_ref; + $warehousetmp->label = $objp->warehouse_ref; + $warehousetmp->fk_parent = $objp->warehouse_parent; + + print ''; + + // Ref + print ''; + + // Label + print ''; + + if (!empty($conf->service->enabled) && $type == 1) { + print ''; + } + //print ''; + //print ''; + //print ''; + + // Warehouse + print ''; + + // Lot + print ''; + + if (empty($conf->global->PRODUCT_DISABLE_SELLBY)) { + print ''; + } + + if (empty($conf->global->PRODUCT_DISABLE_EATBY)) { + print ''; + } + + print ''; + + print ''; + + print ''; + + print ''; + + print ''; + + print "\n"; + $i++; +} + +$db->free($resql); + +print '
'; +print ''; +print ''; +print ''; +print ''; + print ' '; + print '  '; +print ''; +print '   '; +$searchpicto = $form->showFilterAndCheckAddButtons(0); +print $searchpicto; +print '
'; + print $product_static->getNomUrl(1, '', 16); + //if ($objp->stock_theorique < $objp->seuil_stock_alerte) print ' '.img_warning($langs->trans("StockTooLow")); + print ''.$objp->label.''; + if (preg_match('/([0-9]+)y/i', $objp->duration, $regs)) { + print $regs[1].' '.$langs->trans("DurationYear"); + } elseif (preg_match('/([0-9]+)m/i', $objp->duration, $regs)) { + print $regs[1].' '.$langs->trans("DurationMonth"); + } elseif (preg_match('/([0-9]+)d/i', $objp->duration, $regs)) { + print $regs[1].' '.$langs->trans("DurationDay"); + } else { + print $objp->duration; + } + print ''.$objp->stock_theorique.''.$objp->seuil_stock_alerte.''.$objp->desiredstock.''; + if ($objp->fk_entrepot > 0) { + print $warehousetmp->getNomUrl(1); + } + print ''; + if ($product_lot_static->batch) { + print $product_lot_static->getNomUrl(1); + } + print ''.dol_print_date($db->jdate($objp->sellby), 'day').''.dol_print_date($db->jdate($objp->eatby), 'day').''; + //if ($objp->seuil_stock_alerte && ($objp->stock_physique < $objp->seuil_stock_alerte)) print img_warning($langs->trans("StockTooLow")).' '; + print $objp->stock_physique; + print ''; + print img_picto($langs->trans("StockMovement"), 'movement', 'class="pictofixedwidth"'); + print ''.$langs->trans("Movements").''; + print ''.$product_static->LibStatut($objp->statut, 5, 0).''.$product_static->LibStatut($objp->tobuy, 5, 1).'
'."\n"; +print '
'."\n"; + +print '
'."\n"; + + // End of page llxFooter(); $db->close();