From 44bde866eea93a15fb81060bcba58c8180fb05fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Salvador?= Date: Mon, 8 Jul 2013 11:13:33 +0200 Subject: [PATCH] link to go to the second tab and only display orders related to a certain product --- htdocs/product/stock/lib/replenishment.lib.php | 17 +++++++++++++++++ htdocs/product/stock/replenish.php | 13 +++++++++---- htdocs/product/stock/replenishorders.php | 6 +++--- 3 files changed, 29 insertions(+), 7 deletions(-) diff --git a/htdocs/product/stock/lib/replenishment.lib.php b/htdocs/product/stock/lib/replenishment.lib.php index 0283c538d53..470ca7fc2e1 100644 --- a/htdocs/product/stock/lib/replenishment.lib.php +++ b/htdocs/product/stock/lib/replenishment.lib.php @@ -21,6 +21,7 @@ * \ingroup produit * \brief Contains functions used in replenish.php and replenishorders.php */ +require_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.commande.class.php'; function dispatched($order_id) { @@ -103,4 +104,20 @@ function ordered($product_id) } } +function getProducts($order_id) +{ + global $db; + $order = new CommandeFournisseur($db); + $f = $order->fetch($order_id); + $products = array(); + if($f) { + foreach($order->lines as $line) { + if (!in_array($line->fk_product, $products)) { + $products[] = $line->fk_product; + } + } + } + return $products; +} + ?> diff --git a/htdocs/product/stock/replenish.php b/htdocs/product/stock/replenish.php index b4812a87842..eeb1ec79cd2 100644 --- a/htdocs/product/stock/replenish.php +++ b/htdocs/product/stock/replenish.php @@ -422,11 +422,14 @@ if ($resql) { //virtual stock to compute the stock to buy value $stocktobuy = max($objp->desiredstock - $stock - $ordered, 0); $disabled = ''; - if ($ordered > 0) { - $picto = img_picto('', './img/yes', '', 1); + if($ordered > 0) { if($ordered + $stock >= $objp->desiredstock) { + $picto = img_picto('', './img/yes', '', 1); $disabled = 'disabled="disabled"'; } + else { + $picto = img_picto('', './img/no', '', 1); + } } else { $picto = img_picto('', './img/no', '', 1); } @@ -458,10 +461,12 @@ if ($resql) { $warning, $stock, '', '', - $ordered, ' ', $picto, + '', + $ordered, ' ', $picto, '', '', - '', + '', '', '', $form->select_product_fourn_price($prod->id, diff --git a/htdocs/product/stock/replenishorders.php b/htdocs/product/stock/replenishorders.php index 45bbf4c5150..ed76755cfc0 100644 --- a/htdocs/product/stock/replenishorders.php +++ b/htdocs/product/stock/replenishorders.php @@ -61,7 +61,7 @@ $sttc = GETPOST('search_ttc', 'int'); $sall = GETPOST('search_all', 'alpha'); $sdate = GETPOST('search_date', 'alpha'); $page = GETPOST('page', 'int'); - +$sproduct = GETPOST('sproduct', 'int'); $sortorder = GETPOST('sortorder', 'alpha'); $sortfield = GETPOST('sortfield', 'alpha'); @@ -259,8 +259,8 @@ if ($resql) { while ($i < min($num,$conf->liste_limit)) { $obj = $db->fetch_object($resql); $var = !$var; - - if (!dispatched($obj->rowid)) { + if(!dispatched($obj->rowid) && + (!$sproduct || in_array($sproduct, getProducts($obj->rowid)))) { $href = DOL_URL_ROOT . '/fourn/commande/fiche.php?id=' . $obj->rowid; echo '', // Ref