From a60cece2dea2c96be4f96f53c7fe1dcba6c9bd59 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 19 Aug 2010 20:58:08 +0000 Subject: [PATCH] Add status (tosell/tobuy) on stock list --- htdocs/product/class/product.class.php | 25 ++++++++-------- htdocs/product/reassort.php | 40 +++++++++++++++++--------- 2 files changed, 40 insertions(+), 25 deletions(-) diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 22c941a6320..c10e97cd80e 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -87,7 +87,7 @@ class Product extends CommonObject // Statut indique si le produit est en vente '1' ou non '0' var $status; // Status indicate whether the product is available for purchase '1' or not '0' - var $status_buy; + var $status_buy; // Statut indique si le produit est un produit fini '1' ou une matiere premiere '0' var $finished; @@ -2203,16 +2203,17 @@ class Product extends CommonObject } /** - * \brief Return label of a given status - * \param status Statut - * \param mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto - * \return string Label of status + * \brief Return label of a given status + * \param status Statut + * \param mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto + * \param type 0=Status "to sell", 1=Status "to buy" + * \return string Label of status */ function LibStatut($status,$mode=0,$type=0) { global $langs; $langs->load('products'); - + if ($mode == 0) { if ($status == 0) return ($type==0 ? $langs->trans('ProductStatusNotOnSellShort'):$langs->trans('ProductStatusNotOnBuyShort')); @@ -2225,8 +2226,8 @@ class Product extends CommonObject } if ($mode == 2) { - if ($status == 0) return img_picto($langs->trans('ProductStatusNotOnSell'),'statut5').' '.($type==0 ? $langs->trans('ProductStatusNotOnSellShort'):$langs->trans('ProductStatusNotOnBuy')); - if ($status == 1) return img_picto($langs->trans('ProductStatusOnSell'),'statut4').' '.($type==0 ? $langs->trans('ProductStatusOnSellShort'):$langs->trans('ProductStatusOnBuy')); + if ($status == 0) return img_picto($langs->trans('ProductStatusNotOnSell'),'statut5').' '.($type==0 ? $langs->trans('ProductStatusNotOnSellShort'):$langs->trans('ProductStatusNotOnBuyShort')); + if ($status == 1) return img_picto($langs->trans('ProductStatusOnSell'),'statut4').' '.($type==0 ? $langs->trans('ProductStatusOnSellShort'):$langs->trans('ProductStatusOnBuyShort')); } if ($mode == 3) { @@ -2240,8 +2241,8 @@ class Product extends CommonObject } if ($mode == 5) { - if ($status == 0) return $langs->trans('ProductStatusNotOnSellShort').' '.img_picto($langs->trans('ProductStatusNotOnSell'),'statut5'); - if ($status == 1) return $langs->trans('ProductStatusOnSellShort').' '.img_picto($langs->trans('ProductStatusOnSell'),'statut4'); + if ($status == 0) return ($type==0 ? $langs->trans('ProductStatusNotOnSellShort'):$langs->trans('ProductStatusNotOnBuyShort')).' '.img_picto(($type==0 ? $langs->trans('ProductStatusNotOnSell'):$langs->trans('ProductStatusNotOnBuy')),'statut5'); + if ($status == 1) return ($type==0 ? $langs->trans('ProductStatusOnSellShort'):$langs->trans('ProductStatusOnBuyShort')).' '.img_picto(($type==0 ? $langs->trans('ProductStatusOnSell'):$langs->trans('ProductStatusOnBuy')),'statut4'); } return $langs->trans('Unknown'); } @@ -2859,11 +2860,11 @@ class Product extends CommonObject // Status $statutarray=array('1' => $langs->trans("OnSell"), '0' => $langs->trans("NotOnSell")); $this->tpl['status'] = $html->selectarray('statut',$statutarray,$this->status); - + //To Buy $statutarray=array('1' => $langs->trans("Yes"), '0' => $langs->trans("No")); $this->tpl['tobuy'] = $html->selectarray('tobuy',$statutarray,$this->status_buy); - + // Hidden if ($this->user->rights->produit->hidden) { diff --git a/htdocs/product/reassort.php b/htdocs/product/reassort.php index f914ee3af0a..4a318c122e7 100644 --- a/htdocs/product/reassort.php +++ b/htdocs/product/reassort.php @@ -1,6 +1,6 @@ - * Copyright (C) 2004-2009 Laurent Destailleur + * Copyright (C) 2004-2010 Laurent Destailleur * Copyright (C) 2005-2009 Regis Houssin * * This program is free software; you can redistribute it and/or modify @@ -81,7 +81,7 @@ $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.= ' p.duration, p.tosell as statut, p.seuil_stock_alerte,'; +$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'; @@ -128,6 +128,10 @@ if (isset($_GET["tosell"]) && strlen($_GET["tosell"]) > 0) { $sql.= " AND p.tosell = ".$_GET["tosell"]; } +if (isset($_GET["tobuy"]) && strlen($_GET["tobuy"]) > 0) +{ + $sql.= " AND p.tobuy = ".$_GET["tobuy"]; +} if($catid) { $sql.= " AND cp.fk_categorie = ".$catid; @@ -141,7 +145,8 @@ if ($search_categ) { $sql .= " AND cp.fk_categorie = ".addslashes($search_categ); } -$sql.= " GROUP BY p.rowid"; +$sql.= " GROUP BY p.rowid, p.ref, p.label, p.price, p.fk_product_type, p.tms,"; +$sql.= " p.duration, p.tosell, p.tobuy, p.seuil_stock_alerte"; $sql.= $db->order($sortfield,$sortorder); $sql.= $db->plimit($limit + 1 ,$offset); $resql = $db->query($sql) ; @@ -163,6 +168,10 @@ if ($resql) { $tosell = (isset($_GET["tosell"])?$_GET["tosell"]:$_POST["tosell"]); } + if (isset($_GET["tobuy"]) || isset($_POST["tobuy"])) + { + $tobuy = (isset($_GET["tobuy"])?$_GET["tobuy"]:$_POST["tobuy"]); + } @@ -183,7 +192,7 @@ if ($resql) if ($sref || $snom || $sall || $_POST["search"]) { - print_barre_liste($texte, $page, "reassort.php", "&sref=".$sref."&snom=".$snom."&sall=".$sall."&tosell=".$_POST["tosell"], $sortfield, $sortorder,'',$num); + print_barre_liste($texte, $page, "reassort.php", "&sref=".$sref."&snom=".$snom."&sall=".$sall."&tosell=".$_POST["tosell"]."&tobuy=".$_POST["tobuy"], $sortfield, $sortorder,'',$num); } else { @@ -223,17 +232,20 @@ if ($resql) print ''; } + $param="&tosell=$tosell&tobuy=$tobuy".(isset($type)?"&type=$type":"")."&fourn_id=$fourn_id&snom=$snom&sref=$sref"; + // Lignes des titres print ""; - print_liste_field_titre($langs->trans("Ref"),"reassort.php", "p.ref","&tosell=$tosell".(isset($type)?"&type=$type":"")."&fourn_id=$fourn_id&snom=$snom&sref=$sref","","",$sortfield,$sortorder); - print_liste_field_titre($langs->trans("Label"),"reassort.php", "p.label","&tosell=$tosell&".(isset($type)?"&type=$type":"")."&fourn_id=$fourn_id&snom=$snom&sref=$sref","","",$sortfield,$sortorder); - if ($conf->service->enabled && $type == 1) print_liste_field_titre($langs->trans("Duration"),"reassort.php", "p.duration","&tosell=$tosell&".(isset($type)?"&type=$type":"")."&fourn_id=$fourn_id&snom=$snom&sref=$sref","",'align="center"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("MininumStock"),"reassort.php", "p.seuil_stock_alerte","&tosell=$tosell&".(isset($type)?"&type=$type":"")."&fourn_id=$fourn_id&snom=$snom&sref=$sref","",'align="right"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("PhysicalStock"),"reassort.php", "stock_physique","&tosell=$tosell&".(isset($type)?"&type=$type":"")."&fourn_id=$fourn_id&snom=$snom&sref=$sref","",'align="right"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("Ref"),"reassort.php", "p.ref",$param,"","",$sortfield,$sortorder); + print_liste_field_titre($langs->trans("Label"),"reassort.php", "p.label",$param,"","",$sortfield,$sortorder); + if ($conf->service->enabled && $type == 1) print_liste_field_titre($langs->trans("Duration"),"reassort.php", "p.duration",$param,"",'align="center"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("MininumStock"),"reassort.php", "p.seuil_stock_alerte",$param,"",'align="right"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("PhysicalStock"),"reassort.php", "stock_physique",$param,"",'align="right"',$sortfield,$sortorder); // TODO Add info of running suppliers/customers orders - //print_liste_field_titre($langs->trans("TheoreticalStock"),"reassort.php", "stock_theorique","&tosell=$tosell&".(isset($type)?"&type=$type":"")."&fourn_id=$fourn_id&snom=$snom&sref=$sref","",'align="right"',$sortfield,$sortorder); + //print_liste_field_titre($langs->trans("TheoreticalStock"),"reassort.php", "stock_theorique",$param,"",'align="right"',$sortfield,$sortorder); print ' '; - print_liste_field_titre($langs->trans("Status"),"reassort.php", "p.tosell","&tosell=$tosell&".(isset($type)?"&type=$type":"")."&fourn_id=$fourn_id&snom=$snom&sref=$sref","",'align="right"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("Sell"),"reassort.php", "p.tosell",$param,"",'align="right"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("Buy"),"reassort.php", "p.tobuy",$param,"",'align="right"',$sortfield,$sortorder); print "\n"; // Lignes des champs de filtre @@ -253,6 +265,7 @@ if ($resql) print ' '; print ' '; print ' '; + print ' '; print ''; print ''; print ''; @@ -306,7 +319,8 @@ if ($resql) print ''.$objp->seuil_stock_alerte.''; print ''.$objp->stock_physique.''; print ''.$langs->trans("Movements").''; - print ''.$product_static->LibStatut($objp->statut,5).''; + print ''.$product_static->LibStatut($objp->statut,5,0).''; + print ''.$product_static->LibStatut($objp->tobuy,5,1).''; print "\n"; $i++; } @@ -318,7 +332,7 @@ if ($resql) { if ($sref || $snom || $sall || $_POST["search"]) { - print_barre_liste('', $page, "reassort.php", "&sref=".$sref."&snom=".$snom."&sall=".$sall."&tosell=".$_POST["tosell"], $sortfield, $sortorder,'',$num, 0, ''); + print_barre_liste('', $page, "reassort.php", "&sref=".$sref."&snom=".$snom."&sall=".$sall."&tosell=".$_POST["tosell"]."&tobuy=".$_POST["tobuy"], $sortfield, $sortorder,'',$num, 0, ''); } else {