diff --git a/htdocs/product/stock/replenish.php b/htdocs/product/stock/replenish.php index 75f0f66a1a4..4404780abae 100644 --- a/htdocs/product/stock/replenish.php +++ b/htdocs/product/stock/replenish.php @@ -26,7 +26,6 @@ require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php'; -require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php'; $langs->load("products"); @@ -73,8 +72,6 @@ $sref = GETPOST('sref'); $snom = GETPOST('snom'); $sall = GETPOST('sall'); $type = GETPOST('type','int'); -$sbarcode = GETPOST('sbarcode'); -$catid = GETPOST('catid','int'); $tobuy = GETPOST('tobuy'); $sortfield = GETPOST('sortfield','alpha'); @@ -82,7 +79,7 @@ $sortorder = GETPOST('sortorder','alpha'); $page = GETPOST('page','int'); if (!$sortfield) { - $sortfield = 'stock_physique'; + $sortfield = 'p.ref'; } if (!$sortorder) { @@ -91,32 +88,6 @@ if (!$sortorder) { $limit = $conf->liste_limit; $offset = $limit * $page ; -// Load sale and categ filters -$search_sale = GETPOST('search_sale'); -$search_categ = GETPOST('search_categ'); - -// Get object canvas -//(By default, this is not defined, so standard usage of dolibarr) -$canvas = GETPOST('canvas'); -$objcanvas = ''; -if (! empty($canvas)) { - require_once DOL_DOCUMENT_ROOT . '/core/class/canvas.class.php'; - $objcanvas = new Canvas($db,$action); - $objcanvas->getCanvas('product', 'list', $canvas); -} - -if (! empty($_POST['button_removefilter_x'])) { - $sref = ''; - $snom = ''; - $sall = ''; - $search_sale = ''; - $search_categ = ''; - $type = ''; - $catid = ''; -} - - - /* * Actions */ @@ -179,7 +150,6 @@ if($action == 'order') { } $id = $order->create($user); if($id < 0) { - //error stuff $fail++; setEventMessage($langs->trans('OrderFail'), 'errors'); } @@ -196,29 +166,20 @@ if($action == 'order') { /* * View */ -$htmlother=new FormOther($db); +$title = $langs->trans('Replenishment'); -$title=$langs->trans('Replenishment'); - -$sql = 'SELECT p.rowid, p.ref, p.label, p.barcode, p.price'; +$sql = 'SELECT p.rowid, p.ref, p.label, p.price'; $sql .= ', p.price_ttc, p.price_base_type,p.fk_product_type'; $sql .= ', p.tms as datem, p.duration, p.tobuy, p.seuil_stock_alerte,'; $sql .= ' SUM(s.reel) as stock_physique'; $sql .= ', p.desiredstock'; -$sql .= ' FROM (' . MAIN_DB_PREFIX . 'product as p'; -// need this table joined to the select in order to filter by categ -if ($search_categ) { - $sql.= ", " . MAIN_DB_PREFIX . "categorie_product as cp"; -} -$sql .= ') LEFT JOIN ' . MAIN_DB_PREFIX . 'product_fournisseur_price as pf'; +$sql .= ' FROM ' . MAIN_DB_PREFIX . 'product as p'; +$sql .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'product_fournisseur_price as pf'; $sql .= ' ON p.rowid = pf.fk_product'; $sql .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'product_stock as s'; $sql .= ' ON p.rowid = s.fk_product'; - $sql.= ' WHERE p.entity IN (' . getEntity("product", 1) . ')'; -if ($search_categ) { // Join for the needed table to filter by categ - $sql .= ' AND p.rowid = cp.fk_product'; -} + if ($sall) { $sql .= ' AND (p.ref LIKE "%'.$db->escape($sall).'%" '; $sql .= 'OR p.label LIKE "%'.$db->escape($sall).'%" '; @@ -237,9 +198,6 @@ if (dol_strlen($type)) { if ($sref) { $sql .= ' AND p.ref LIKE "%' . $sref . '%"'; } -if ($sbarcode) { - $sql .= ' AND p.barcode LIKE "%' . $sbarcode . '%"'; -} if ($snom) { $sql .= ' AND p.label LIKE "%' . $db->escape($snom) . '%"'; } @@ -249,17 +207,10 @@ $sql .= ' AND p.tobuy = 1'; if (!empty($canvas)) { $sql .= ' AND p.canvas = "' . $db->escape($canvas) . '"'; } -if($catid) { - $sql .= ' AND cp.fk_categorie = ' . $catid; -} $sql .= ' AND p.rowid = pf.fk_product'; -// Insert categ filter -if ($search_categ) { - $sql .= ' AND cp.fk_categorie = ' . $db->escape($search_categ); -} -$sql .= ' GROUP BY p.rowid, p.ref, p.label, p.barcode, p.price'; +$sql .= ' GROUP BY p.rowid, p.ref, p.label, p.price'; $sql .= ', p.price_ttc, p.price_base_type,p.fk_product_type, p.tms'; $sql .= ', p.duration, p.tobuy, p.seuil_stock_alerte'; $sql .= ', p.desiredstock'; @@ -279,8 +230,7 @@ if ($resql) { $helpurl = 'EN:Module_Stocks_En|FR:Module_Stock|'; $helpurl .= 'ES:Módulo_Stocks'; - $texte = $langs->trans('Replenishment'); - llxHeader('', $title, $helpurl, $texte); + llxHeader('', $title, $helpurl, $title); $head = array(); $head[0][0] = DOL_URL_ROOT.'/product/stock/replenish.php'; $head[0][1] = $title; @@ -316,15 +266,6 @@ if ($resql) { $num); } - if (!empty($catid)) { - print '