diff --git a/htdocs/product/liste.php b/htdocs/product/liste.php index 662dbdce902..d542e48d3ec 100644 --- a/htdocs/product/liste.php +++ b/htdocs/product/liste.php @@ -125,15 +125,22 @@ $sql.= ' p.duration, p.tosell, p.tobuy, p.seuil_stock_alerte'; $sql.= ' FROM '.MAIN_DB_PREFIX.'product as p'; // We'll need this table joined to the select in order to filter by categ if ($search_categ) $sql.= ", ".MAIN_DB_PREFIX."categorie_product as cp"; -if ($_GET["fourn_id"] > 0) +if ($_GET["fourn_id"] > 0) // The DISTINCT is used to avoid duplicate from this link { $fourn_id = $_GET["fourn_id"]; $sql.= ", ".MAIN_DB_PREFIX."product_fournisseur as pf"; } $sql.= " WHERE p.entity = ".$conf->entity; if ($search_categ) $sql.= " AND p.rowid = cp.fk_product"; // Join for the needed table to filter by categ -if (!$user->rights->produit->hidden) $sql.=' AND (p.hidden=0 OR p.fk_product_type != 0)'; -if (!$user->rights->service->hidden) $sql.=' AND (p.hidden=0 OR p.fk_product_type != 1)'; +if (!$user->rights->produit->hidden && !$user->rights->service->hidden) +{ + $sql.=' AND p.hidden=0'; +} +else +{ + if (!$user->rights->produit->hidden) $sql.=' AND (p.hidden=0 OR p.fk_product_type != 0)'; + if (!$user->rights->service->hidden) $sql.=' AND (p.hidden=0 OR p.fk_product_type != 1)'; +} if ($sall) { $sql.= " AND (p.ref like '%".addslashes($sall)."%' OR p.label like '%".addslashes($sall)."%' OR p.description like '%".addslashes($sall)."%' OR p.note like '%".addslashes($sall)."%')"; @@ -154,6 +161,10 @@ if (isset($_GET["tosell"]) && dol_strlen($_GET["tosell"]) > 0) { $sql.= " AND p.tosell = ".addslashes($_GET["tosell"]); } +if (isset($_GET["tobuy"]) && dol_strlen($_GET["tobuy"]) > 0) +{ + $sql.= " AND p.tobuy = ".$_GET["tobuy"]; +} if (dol_strlen($canvas) > 0) { $sql.= " AND p.canvas = '".addslashes($canvas)."'"; @@ -171,6 +182,10 @@ if ($search_categ) { $sql .= " AND cp.fk_categorie = ".addslashes($search_categ); } +$sql.= " GROUP BY p.rowid, p.ref, p.label, p.barcode, p.price, p.price_ttc, p.price_base_type,"; +$sql.= " p.fk_product_type, p.tms,"; +$sql.= " p.duration, p.tosell, p.tobuy, p.seuil_stock_alerte"; +if (GETPOST("toolowstock")) $sql.= " HAVING SUM(s.reel) < p.seuil_stock_alerte"; // Not used yet $sql.= $db->order($sortfield,$sortorder); $sql.= $db->plimit($limit + 1 ,$offset); $resql = $db->query($sql) ; @@ -247,33 +262,7 @@ if ($resql) $template_dir = DOL_DOCUMENT_ROOT . '/theme/'.$conf->theme.'/tpl/product/'.$_GET["canvas"].'/'; } - /*if ($object->smarty) - { - $template = 'list.tpl'; - $smarty->template_dir = $template_dir; - - $smarty->assign('fieldlist', $fieldlist); - $smarty->assign('datas', $datas); - $smarty->assign('url_root', $dolibarr_main_url_root); - $smarty->assign('theme', $conf->theme); - $smarty->assign('langs', $langs); - $smarty->assign('title_picto', $title_picto); - $smarty->assign('title_text', $title_text); - - // Enable caching - //$smarty->caching = true; - - //$smarty->debugging = true; - - $smarty->display($template, $_GET["canvas"]); - - // Suppression de la version compilee - $smarty->clear_compiled_tpl($template); - } - else - {*/ include($template_dir.'list.tpl.php'); // Include native PHP templates - /*}*/ } else { @@ -429,14 +418,10 @@ if ($resql) { $product_static->id = $objp->rowid; $product_static->load_stock(); - if ($product_static->stock_reel < $objp->seuil_stock_alerte) - { - print ''.$product_static->stock_reel.' '.img_warning($langs->trans("StockTooLow")).''; - } - else - { - print ''.$product_static->stock_reel.''; - } + print ''; + if ($product_static->stock_reel < $objp->seuil_stock_alerte) print img_warning($langs->trans("StockTooLow")).' '; + print $product_static->stock_reel; + print ''; } else { diff --git a/htdocs/product/reassort.php b/htdocs/product/reassort.php index 1c578780767..9dc9512e264 100644 --- a/htdocs/product/reassort.php +++ b/htdocs/product/reassort.php @@ -80,20 +80,21 @@ $htmlother=new FormOther($db); $title=$langs->trans("ProductsAndServices"); -$sql = 'SELECT p.rowid, p.ref, p.label, p.price, p.fk_product_type, p.tms as datem,'; +$sql = 'SELECT p.rowid, p.ref, p.label, p.barcode, p.price, p.price_ttc, p.price_base_type,'; +$sql.= ' p.fk_product_type, p.tms as datem,'; $sql.= ' p.duration, p.tosell as statut, p.tobuy, p.seuil_stock_alerte,'; $sql.= ' SUM(s.reel) as stock_physique'; -$sql.= ' FROM '.MAIN_DB_PREFIX.'product_stock as s,'; -$sql.= ' '.MAIN_DB_PREFIX.'product as p'; +$sql.= ' FROM '.MAIN_DB_PREFIX.'product as p'; // We'll need this table joined to the select in order to filter by categ if ($search_categ) $sql.= ", ".MAIN_DB_PREFIX."categorie_product as cp"; -if ($_GET["fourn_id"] > 0) +// We disable this because this create duplicate lines +/*if ($_GET["fourn_id"] > 0) { $fourn_id = $_GET["fourn_id"]; $sql.= ", ".MAIN_DB_PREFIX."product_fournisseur as pf"; -} -$sql.= " WHERE p.rowid = s.fk_product"; -$sql.= " AND p.entity = ".$conf->entity; +}*/ +$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_stock as s on p.rowid = s.fk_product'; +$sql.= " WHERE p.entity = ".$conf->entity; if ($search_categ) $sql.= " AND p.rowid = cp.fk_product"; // Join for the needed table to filter by categ if (!$user->rights->produit->hidden && !$user->rights->service->hidden) { @@ -108,22 +109,18 @@ if ($sall) { $sql.= " AND (p.ref like '%".addslashes($sall)."%' OR p.label like '%".addslashes($sall)."%' OR p.description like '%".addslashes($sall)."%' OR p.note like '%".addslashes($sall)."%')"; } -if ($type==1) +# if the type is not 1, we show all products (type = 0,2,3) +if (dol_strlen($type)) { - $sql.= " AND p.fk_product_type = '1'"; -} -else -{ - $sql.= " AND p.fk_product_type <> '1'"; -} -if ($sref) -{ - $sql.= " AND p.ref like '%".$sref."%'"; -} -if ($snom) -{ - $sql.= " AND p.label like '%".addslashes($snom)."%'"; + if ($type==1) { + $sql.= " AND p.fk_product_type = '1'"; + } else { + $sql.= " AND p.fk_product_type <> '1'"; + } } +if ($sref) $sql.= " AND p.ref like '%".$sref."%'"; +if ($sbarcode) $sql.= " AND p.barcode like '%".$sbarcode."%'"; +if ($snom) $sql.= " AND p.label like '%".addslashes($snom)."%'"; if (isset($_GET["tosell"]) && dol_strlen($_GET["tosell"]) > 0) { $sql.= " AND p.tosell = ".$_GET["tosell"]; @@ -132,6 +129,10 @@ if (isset($_GET["tobuy"]) && dol_strlen($_GET["tobuy"]) > 0) { $sql.= " AND p.tobuy = ".$_GET["tobuy"]; } +if (dol_strlen($canvas) > 0) +{ + $sql.= " AND p.canvas = '".addslashes($canvas)."'"; +} if($catid) { $sql.= " AND cp.fk_categorie = ".$catid; @@ -145,8 +146,10 @@ if ($search_categ) { $sql .= " AND cp.fk_categorie = ".addslashes($search_categ); } -$sql.= " GROUP BY p.rowid, p.ref, p.label, p.price, p.fk_product_type, p.tms,"; +$sql.= " GROUP BY p.rowid, p.ref, p.label, p.barcode, p.price, p.price_ttc, p.price_base_type,"; +$sql.= " p.fk_product_type, p.tms,"; $sql.= " p.duration, p.tosell, p.tobuy, p.seuil_stock_alerte"; +if (GETPOST("toolowstock")) $sql.= " HAVING SUM(s.reel) < p.seuil_stock_alerte"; // Not used yet $sql.= $db->order($sortfield,$sortorder); $sql.= $db->plimit($limit + 1 ,$offset); $resql = $db->query($sql) ; @@ -224,6 +227,7 @@ if ($resql) $moreforfilter.=$htmlother->select_categories(0,$search_categ,'search_categ'); $moreforfilter.='       '; } + $moreforfilter.='     '.$langs->trans("StockTooLow").' '; if ($moreforfilter) { print ''; @@ -263,7 +267,7 @@ if ($resql) print ''; } print ' '; - print ' '; + print ' '; print ' '; print ' '; print ''; @@ -317,8 +321,9 @@ if ($resql) } //print ''.$objp->stock_theorique.''; print ''.$objp->seuil_stock_alerte.''; - print ''.$objp->stock_physique; - if ($objp->seuil_stock_alerte && ($objp->stock_physique < $objp->seuil_stock_alerte)) print ' '.img_warning($langs->trans("StockTooLow")); + print ''; + if ($objp->seuil_stock_alerte && ($objp->stock_physique < $objp->seuil_stock_alerte)) print img_warning($langs->trans("StockTooLow")).' '; + print $objp->stock_physique; print ''; print ''.$langs->trans("Movements").''; print ''.$product_static->LibStatut($objp->statut,5,0).'';