diff --git a/htdocs/fourn/fournisseur.product.class.php b/htdocs/fourn/fournisseur.product.class.php index 9035a79b1f8..d0e4f2925c1 100644 --- a/htdocs/fourn/fournisseur.product.class.php +++ b/htdocs/fourn/fournisseur.product.class.php @@ -21,7 +21,7 @@ /** \file htdocs/fourn/fournisseur.product.class.php \ingroup produit - \brief Fichier de la classe des produits prédéfinis + \brief Fichier de la classe des produits pr�d�finis \version $Id$ */ @@ -31,7 +31,7 @@ require_once DOL_DOCUMENT_ROOT."/fourn/fournisseur.class.php"; /** \class Product - \brief Classe permettant la gestion des produits prédéfinis + \brief Classe permettant la gestion des produits pr�d�finis */ class ProductFournisseur extends Product { @@ -146,12 +146,12 @@ class ProductFournisseur extends Product function remove_product_fournisseur_price($rowid) { global $conf; - + $this->db->begin(); $sql = "DELETE FROM ".MAIN_DB_PREFIX."product_fournisseur_price"; $sql.= " WHERE rowid = ".$rowid; - + dol_syslog("ProductFournisseur::remove_product_fournisseur_price sql=".$sql); $resql = $this->db->query($sql); if ($resql) @@ -162,7 +162,7 @@ class ProductFournisseur extends Product $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_fournisseur_price as pfp ON pfp.fk_product_fournisseur = pf.rowid"; $sql.= " WHERE pfp.rowid IS NULL"; $sql.= " AND pf.entity = ".$conf->entity; - + dol_syslog("ProductFournisseur::remove_product_fournisseur_price sql=".$sql); $resql = $this->db->query($sql); if ($resql) @@ -175,7 +175,7 @@ class ProductFournisseur extends Product $sql = "DELETE FROM ".MAIN_DB_PREFIX."product_fournisseur"; $sql.= " WHERE rowid = ".$rowidpf; - + dol_syslog("ProductFournisseur::remove_product_fournisseur_price sql=".$sql); $resql2 = $this->db->query($sql); if (! $resql2) @@ -223,11 +223,11 @@ class ProductFournisseur extends Product { $this->fourn_ref = $ref; - /* Mise à jour du prix */ + /* Mise � jour du prix */ $this->update_buyprice($qty, $buyprice, $user); - /* Mise à jour de la référence */ + /* Mise � jour de la r�f�rence */ $sql = "UPDATE ".MAIN_DB_PREFIX."product_fournisseur "; $sql .= " SET ref_fourn = '" . $this->fourn_ref ."'"; @@ -241,7 +241,7 @@ class ProductFournisseur extends Product /** * \brief Modifie le prix d'achat pour un fournisseur * \param qty Quantite min pour lequel le prix est valide - * \param buyprice Prix d'achat pour la quantité min + * \param buyprice Prix d'achat pour la quantit� min * \param user Objet user de l'utilisateur qui modifie * \param price_base_type HT or TTC * \param fourn Supplier @@ -255,7 +255,7 @@ class ProductFournisseur extends Product $error=0; $this->db->begin(); - // Supprime prix courant du fournisseur pour cette quantité + // Supprime prix courant du fournisseur pour cette quantit� $sql = "DELETE FROM ".MAIN_DB_PREFIX."product_fournisseur_price "; if ($this->product_fourn_price_id) { @@ -275,7 +275,7 @@ class ProductFournisseur extends Product } $unitBuyPrice = price2num($buyprice/$qty,'MU'); - // Ajoute prix courant du fournisseur pour cette quantité + // Ajoute prix courant du fournisseur pour cette quantit� $sql = "INSERT INTO ".MAIN_DB_PREFIX."product_fournisseur_price"; $sql.= " SET datec = ".$this->db->idate(mktime()); $sql.= " ,fk_product_fournisseur = ".$this->product_fourn_id; @@ -328,18 +328,18 @@ class ProductFournisseur extends Product /** - \brief Modifie le prix d'achat pour un fournisseur par la référecne du produit chez le fournisseur + \brief Modifie le prix d'achat pour un fournisseur par la r�f�recne du produit chez le fournisseur \param id_fourn Id du fournisseur \param product_fourn_ref Ref du produit chez le fournisseur \param qty Quantite pour lequel le prix est valide - \param buyprice Prix d'achat pour la quantité + \param buyprice Prix d'achat pour la quantit� \param user Objet user de l'utilisateur qui modifie \return int <0 si KO, >0 si OK */ function UpdateBuyPriceByFournRef($id_fourn, $product_fourn_ref, $qty, $buyprice, $user, $price_base_type='HT') { global $conf; - + $result=0; // Recherche id produit pour cette ref et fournisseur @@ -353,7 +353,7 @@ class ProductFournisseur extends Product { if ($obj = $this->db->fetch_object($resql)) { - // Met a jour prix pour la qté + // Met a jour prix pour la qt� $this->id = $obj->fk_product; $result = $this->update_buyprice($id_fourn, $qty, $buyprice, $user, $price_base_type); } @@ -364,14 +364,17 @@ class ProductFournisseur extends Product /** - * \brief Charge les informations relatives à un fournisseur + * \brief Charge les informations relatives a un fournisseur * \param fournid id du fournisseur * \return int < 0 si erreur, > 0 si ok */ function fetch_fourn_data($fournid) { global $conf; - + + // Check parameters + if (empty($fournid)) return -1; + $sql = "SELECT rowid, ref_fourn"; $sql.= " FROM ".MAIN_DB_PREFIX."product_fournisseur "; $sql.= " WHERE fk_product = ".$this->id; @@ -390,13 +393,13 @@ class ProductFournisseur extends Product else { $this->error=$this->db->error(); - dol_syslog("Product::fetch_fourn_data error=".$this->error, LOG_ERR); + dol_syslog("ProductFournisseur::fetch_fourn_data error=".$this->error, LOG_ERR); return -1; } } /** - * \brief Charge les informations relatives à un prix de fournisseur + * \brief Charge les informations relatives � un prix de fournisseur * \param rowid id ligne * \return int < 0 if KO, 0 if OK but not found, > 0 if OK */ @@ -409,7 +412,7 @@ class ProductFournisseur extends Product $sql.= " WHERE pfp.rowid = ".$rowid; $sql.= " AND pf.rowid = pfp.fk_product_fournisseur"; - dol_syslog("Product::fetch_product_fournisseur_price sql=".$sql, LOG_DEBUG); + dol_syslog("ProductFournisseur::fetch_product_fournisseur_price sql=".$sql, LOG_DEBUG); $resql = $this->db->query($sql) ; if ($resql) { @@ -434,7 +437,7 @@ class ProductFournisseur extends Product else { $this->error=$this->db->error(); - dol_syslog("Product::fetch_product_fournisseur_price error=".$this->error, LOG_ERR); + dol_syslog("ProductFournisseur::fetch_product_fournisseur_price error=".$this->error, LOG_ERR); return -1; } } diff --git a/htdocs/langs/en_US/stocks.lang b/htdocs/langs/en_US/stocks.lang index 937b36df6af..ae32a4f308f 100644 --- a/htdocs/langs/en_US/stocks.lang +++ b/htdocs/langs/en_US/stocks.lang @@ -63,7 +63,7 @@ IdWarehouse=Id warehouse DescWareHouse=Description warehouse LieuWareHouse=Localisation warehouse WarehousesAndProducts=Warehouses and products -AverageUnitPricePMP=Average price -EstimatedStockValueForProduct=Estimated value for product's stock -EstimatedStockValueInWarehouse=Estimated value in warehouse -EstimatedStockValue=Estimated value in stock \ No newline at end of file +AverageUnitPricePMPShort=Average input price +AverageUnitPricePMP=Average input price +EstimatedStockValueShort=Estimated value of stock +EstimatedStockValue=Estimated value of stock \ No newline at end of file diff --git a/htdocs/langs/fr_FR/stocks.lang b/htdocs/langs/fr_FR/stocks.lang index a4e2108d563..92c8bd1008e 100644 --- a/htdocs/langs/fr_FR/stocks.lang +++ b/htdocs/langs/fr_FR/stocks.lang @@ -63,7 +63,7 @@ IdWarehouse=Id entrepôt DescWareHouse=Description entrepôt LieuWareHouse=Lieu entrepôt WarehousesAndProducts=Entrepôts et produits -AverageUnitPricePMP=Prix moyen pondéré (PMP) -EstimatedStockValueForProduct=Valeur estimée du produit en stock -EstimatedStockValueInWarehouse=Valeur estimée dans l'entrepot -EstimatedStockValue=Valeur estimée du stock \ No newline at end of file +AverageUnitPricePMPShort=Prix moyen pondéré (PMP) +AverageUnitPricePMP=Prix moyen pondéré (PMP) d'aquisition +EstimatedStockValueShort=Valorisation (PMP) +EstimatedStockValue=Valorisation aquisition stock (PMP) \ No newline at end of file diff --git a/htdocs/product.class.php b/htdocs/product.class.php index ec7645f58da..732c0c13b3e 100644 --- a/htdocs/product.class.php +++ b/htdocs/product.class.php @@ -1651,6 +1651,7 @@ class Product extends CommonObject $sql.= " FROM ".MAIN_DB_PREFIX."product_fournisseur"; $sql.= " WHERE fk_product = ".$this->id." AND fk_soc = ".$id_fourn." AND ref_fourn = '".$ref_fourn."'"; + dol_syslog("Product::add_fournisseur sql=".$sql); $resql=$this->db->query($sql); if ($resql) { @@ -1661,6 +1662,7 @@ class Product extends CommonObject $sql .= " (datec, fk_product, fk_soc, ref_fourn, fk_user_author)"; $sql .= " VALUES (".$this->db->idate(mktime()).", ".$this->id.", ".$id_fourn.", '".$ref_fourn."', ".$user->id.")"; + dol_syslog("Product::add_fournisseur sql=".$sql); if ($this->db->query($sql)) { $this->product_fourn_id = $this->db->last_insert_id(MAIN_DB_PREFIX."product_fournisseur"); @@ -1668,7 +1670,8 @@ class Product extends CommonObject } else { - $this->error=$this->db->error(); + $this->error=$this->db->lasterror(); + dol_syslog("Product::add_fournisseur ".$this->error, LOG_ERR); return -1; } } @@ -1689,7 +1692,7 @@ class Product extends CommonObject } else { - $this->error=$this->db->error(); + $this->error=$this->db->lasterror(); return -2; } } diff --git a/htdocs/product/fournisseurs.php b/htdocs/product/fournisseurs.php index c236d2d3ae0..12f32e1f047 100644 --- a/htdocs/product/fournisseurs.php +++ b/htdocs/product/fournisseurs.php @@ -178,9 +178,9 @@ if ($_GET["id"] || $_GET["ref"]) if ($_GET["action"] <> 're-edit') { $product = new ProductFournisseur($db); - if ($_GET["ref"]) $result = $product->fetch('',$_GET["ref"]); - if ($_GET["id"]) $result = $product->fetch($_GET["id"]); - $product->fetch_fourn_data($_GET["socid"]); + $result = $product->fetch($_GET["id"],$_GET["ref"]); + $result = $product->fetch_fourn_data($_REQUEST["id_fourn"]); + //print 'eeeee'.$_GET["socid"];exit; llxHeader("","",$langs->trans("CardProduct".$product->type)); } diff --git a/htdocs/product/stock/fiche-valo.php b/htdocs/product/stock/fiche-valo.php index cf7b192dd4c..3d31e3cb429 100644 --- a/htdocs/product/stock/fiche-valo.php +++ b/htdocs/product/stock/fiche-valo.php @@ -92,7 +92,7 @@ if ($_GET["id"]) print ''.$langs->trans("Ref").''; print $form->showrefnav($entrepot,'id','',1,'rowid','libelle'); print ''; - + print ''.$langs->trans("LocationSummary").''.$entrepot->lieu.''; // Description @@ -127,24 +127,31 @@ if ($_GET["id"]) print "
\n"; $year = strftime("%Y",time()); - + $file=DOL_DATA_ROOT.'/entrepot/temp/entrepot-'.$entrepot->id.'-'.($year).'.png'; + // TODO Build graph in $file from a table called llx_stock_log + + + + + + if (file_exists($file)) { $url=DOL_URL_ROOT.'/viewimage.php?modulepart=graph_stock&file=entrepot-'.$entrepot->id.'-'.$year.'.png'; - print 'Valorisation du stock année '.($year).''; - + print 'Valorisation du stock annee '.($year).''; + if (file_exists(DOL_DATA_ROOT.'/entrepot/temp/entrepot-'.$entrepot->id.'-'.($year-1).'.png')) { $url=DOL_URL_ROOT.'/viewimage.php?modulepart=graph_stock&file=entrepot-'.$entrepot->id.'-'.($year-1).'.png'; - print '
Valorisation du stock année '.($year-1).''; + print '
Valorisation du stock annee '.($year-1).''; } } else { $langs->load("errors"); - if ($user->admin) print info_admin($langs->trans("WarningBuildScriptNotRunned",'stock-graph.php')); + print $langs->trans("FeatureNotYetAvailable"); } print "
"; diff --git a/htdocs/product/stock/fiche.php b/htdocs/product/stock/fiche.php index 3f068363829..7f50a7cba9d 100644 --- a/htdocs/product/stock/fiche.php +++ b/htdocs/product/stock/fiche.php @@ -326,8 +326,8 @@ else print_liste_field_titre($langs->trans("Product"),"", "p.ref","&id=".$_GET['id'],"","",$sortfield,$sortorder); print_liste_field_titre($langs->trans("Label"),"", "p.label","&id=".$_GET['id'],"","",$sortfield,$sortorder); print_liste_field_titre($langs->trans("Units"),"", "ps.reel","&id=".$_GET['id'],"",'align="right"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("AverageUnitPricePMP"),"", "ps.pmp","&id=".$_GET['id'],"",'align="center"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("EstimatedStockValueInWarehouse"),"", "","&id=".$_GET['id'],"",'align="center"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("AverageUnitPricePMPShort"),"", "ps.pmp","&id=".$_GET['id'],"",'align="center"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("EstimatedStockValueShort"),"", "","&id=".$_GET['id'],"",'align="center"',$sortfield,$sortorder); if ($user->rights->stock->mouvement->creer) print ' '; if ($user->rights->stock->creer) print ' '; print ""; diff --git a/htdocs/product/stock/mouvementstock.class.php b/htdocs/product/stock/mouvementstock.class.php index 6e6c841e709..fe97412bbf7 100644 --- a/htdocs/product/stock/mouvementstock.class.php +++ b/htdocs/product/stock/mouvementstock.class.php @@ -42,7 +42,7 @@ class MouvementStock * \param user User object * \param fk_product Id of product * \param entrepot_id Id of warehouse - * \param qty Qty of movement + * \param qty Qty of movement (can be <0 or >0) * \param type Direction of movement: 2=output (stock decrease), 3=input (stock increase) * \param type Unit price HT of product * \return int <0 if KO, >0 if OK @@ -116,18 +116,21 @@ class MouvementStock } } - // Calculate new PMP. Price should always be >0 or 0. pmp should always be >0 or 0. + // Calculate new PMP. if (! $error) { $newpmp=0; $newpmpwarehouse=0; - if ($price > 0) + // Note: PMP is calculated on stock input only (type = 3). If type == 3, qty should be > 0. + // Note: Price should always be >0 or 0. PMP should be always >0 (calculated on input) + if ($type == 3 && $price > 0) { - if (($oldqty + $qty) == 0) $newpmp=0; - else if ($oldpmp > 0) $newpmp=price2num((($oldqty * $oldpmp) + ($qty * $price)) / ($oldqty + $qty), 'MU'); + $oldqtytouse=($oldqty >= 0?$oldqty:0); + // We make a test on oldpmp>0 to avoid to use normal rule on old data with no pmp field defined + if ($oldpmp > 0) $newpmp=price2num((($oldqtytouse * $oldpmp) + ($qty * $price)) / ($oldqtytouse + $qty), 'MU'); else $newpmp=$price; - if (($oldqtywarehouse + $qty) == 0) $newpmpwarehouse=0; - else if ($oldpmpwarehouse > 0) $newpmpwarehouse=price2num((($oldqtywarehouse * $oldpmpwarehouse) + ($qty * $price)) / ($oldqtywarehouse + $qty), 'MU'); + $oldqtywarehousetouse=($oldqtywarehouse >= 0?$oldqty:0); + if ($oldpmpwarehouse > 0) $newpmpwarehouse=price2num((($oldqtywarehousetouse * $oldpmpwarehouse) + ($qty * $price)) / ($oldqtywarehousetouse + $qty), 'MU'); else $newpmpwarehouse=$price; } else diff --git a/htdocs/product/stock/product.php b/htdocs/product/stock/product.php index c118ed6eaa6..243397841c1 100644 --- a/htdocs/product/stock/product.php +++ b/htdocs/product/stock/product.php @@ -351,8 +351,8 @@ print ''; print '
'; print ''; print ''; -print ''; -print ''; +print ''; +print ''; print ''; $sql = "SELECT e.rowid, e.label, ps.reel, ps.pmp"; diff --git a/htdocs/product/stock/valo.php b/htdocs/product/stock/valo.php index 537ae23ac89..dcd3afd8003 100644 --- a/htdocs/product/stock/valo.php +++ b/htdocs/product/stock/valo.php @@ -1,6 +1,6 @@ - * Copyright (C) 2004-2008 Laurent Destailleur + * Copyright (C) 2004-2009 Laurent Destailleur * Copyright (C) 2005-2009 Regis Houssin * * This program is free software; you can redistribute it and/or modify @@ -54,8 +54,9 @@ $year = strftime("%Y",time()); */ // Affichage valorisation par entrepot -$sql = "SELECT e.rowid as ref, e.label, e.statut, e.lieu"; -$sql.= " FROM ".MAIN_DB_PREFIX."entrepot as e"; +$sql = "SELECT e.rowid as ref, e.label, e.statut, e.lieu,"; +$sql.= " SUM(ps.pmp * ps.reel) as estimatedvalue"; +$sql.= " FROM ".MAIN_DB_PREFIX."entrepot as e LEFT JOIN ".MAIN_DB_PREFIX."product_stock as ps ON e.rowid = ps.fk_entrepot"; $sql.= " WHERE e.entity = ".$conf->entity; if ($sref) { @@ -69,6 +70,7 @@ if ($sall) $sql.= " OR e.address LIKE '%".addslashes($sall)."%'"; $sql.= " OR e.ville LIKE '%".addslashes($sall)."%')"; } +$sql.= " GROUP BY e.rowid, e.label, e.statut, e.lieu"; $sql.= " ORDER BY $sortfield $sortorder "; $sql.= $db->plimit($limit + 1, $offset); @@ -87,7 +89,7 @@ if ($result) print ""; print_liste_field_titre($langs->trans("Ref"),"valo.php", "e.label","","","",$sortfield,$sortorder); print_liste_field_titre($langs->trans("LocationSummary"),"valo.php", "e.lieu","","","",$sortfield,$sortorder); - print_liste_field_titre($langs->trans("PMPValue"),"valo.php", "valo",'','','align="right"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("EstimatedStockValue"),"valo.php", "valo",'','','align="right"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("Status"),"valo.php", "e.statut",'','','align="right"',$sortfield,$sortorder); print "\n"; @@ -103,12 +105,11 @@ if ($result) print ''; print ''; print ''; print ''; print "\n"; - $total += $objp->valo; + $total += price2num($objp->estimatedvalue,'MU'); $var=!$var; $i++; } @@ -129,14 +130,14 @@ if ($result) if (file_exists(DOL_DATA_ROOT.'/entrepot/temp/'.$file)) { $url=DOL_URL_ROOT.'/viewimage.php?modulepart=graph_stock&file='.$file; - print 'Valorisation du stock année '.($year).''; + print 'Valorisation du stock ann�e '.($year).''; } $file='entrepot-'.($year-1).'.png'; if (file_exists(DOL_DATA_ROOT.'/entrepot/temp/'.$file)) { $url=DOL_URL_ROOT.'/viewimage.php?modulepart=graph_stock&file='.$file; - print '
Valorisation du stock année '.($year-1).''; + print '
Valorisation du stock ann�e '.($year-1).''; } } diff --git a/scripts/cron/batch_stock_buildgraph.php b/scripts/cron/batch_stock_buildgraph.php deleted file mode 100644 index 8ca77817a24..00000000000 --- a/scripts/cron/batch_stock_buildgraph.php +++ /dev/null @@ -1,239 +0,0 @@ - - * Copyright (C) 2007 Laurent Destailleur - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -/** - \file scripts/cron/stock-graph.php - \ingroup stock - \brief Cr�� le graph de valorisation du stock - \version $Id$ - */ - -// Test si mode CLI -$sapi_type = php_sapi_name(); -$script_file=__FILE__; -if (eregi('([^\\\/]+)$',$script_file,$reg)) $script_file=$reg[1]; - -if (substr($sapi_type, 0, 3) == 'cgi') { - echo "Erreur: Vous utilisez l'interpreteur PHP pour le mode CGI. Pour executer $script_file en ligne de commande, vous devez utiliser l'interpreteur PHP pour le mode CLI.\n"; - exit; -} - -// Recupere env dolibarr -$version='$Revision$'; -$path=eregi_replace($script_file,'',$_SERVER["PHP_SELF"]); - -require_once($path."../../htdocs/master.inc.php"); -require_once(DOL_DOCUMENT_ROOT."/core/dolgraph.class.php"); -require_once(DOL_DOCUMENT_ROOT."//cron/functions_cron.lib.php"); - -print '***** '.$script_file.' ('.$version.') *****'."\n"; -print '--- start'."\n"; - - -/* - * Main - */ - -$error=0; - -$verbose = 0; -for ($i = 1 ; $i < sizeof($argv) ; $i++) -{ - if ($argv[$i] == "-v") - { - $verbose = 1; - } - if ($argv[$i] == "-vv") - { - $verbose = 2; - } - if ($argv[$i] == "-vvv") - { - $verbose = 3; - } -} - - -$dir = $conf->stock->dir_temp; -$result=create_exdir($dir); - - -$sql = "SELECT distinct(fk_entrepot)"; -$sql .= " FROM ".MAIN_DB_PREFIX."entrepot_valorisation"; - -$resql = $db->query($sql) ; -$entrepots = array(); -if ($resql) -{ - $i = 0; - while ($row = $db->fetch_row($resql)) - { - $entrepots[$row[0]] = $row[0]; - } - $db->free($resql); -} -else -{ - dol_print_error($db,$sql); -} - -$now = time(); -$year = strftime('%Y',$now); -$day = strftime('%j', $now); -for ($i = 0 ; $i < strftime('%j',$now) ; $i++) -{ - foreach ($entrepots as $key => $ent) - { - $values[$key][$i] = 0; - } - $values[0][$i] = 0; - $legends[$i] = strftime('%b',dol_mktime(12,0,0,1,1,2006) + ($i * 3600 * 24)); - //print $legends[$i].strftime('%j',$now); -} - -/* - * Read values - */ -$sql = "SELECT date_format(date_calcul,'%j'), valo_pmp, fk_entrepot"; -$sql .= " FROM ".MAIN_DB_PREFIX."entrepot_valorisation as e"; -$sql .= " WHERE date_format(date_calcul, '%Y') = '".$year."'"; -$sql .= " ORDER BY date_calcul ASC"; - -$resql = $db->query($sql) ; - -if ($resql) -{ - $i = 0; - $last_day = 0; - while ($row = $db->fetch_row($resql)) - { - if ($last_day > 0) - { - for ($j = $last_day + 1 ; $j < $row[0] ; $j++) - { - foreach ($entrepots as $key => $ent) - { - $values[$key][$j] = $values[$key][$last_day]; - } - $values[0][$j] = $values[0][$last_day]; - } - } - $last_day = $row[0]; - - $max_day = $row[0]; - $values[$row[2]][$row[0]] = $row[1]; - $values[0][$row[0]] += $row[1]; - - $total[$row[2]] += abs($row[1]); - $total[0] += abs($row[1]); - $i++; - } - $db->free($resql); -} -else -{ - dol_print_error($db,$sql); -} - -for ($i = $max_day + 1 ; $i < ($day + 1) ; $i++) -{ - foreach ($entrepots as $key => $ent) - { - $values[$key][$i] = $values[$key][$max_day]; - } - $values[0][$i] = $values[0][$max_day]; -} - - -// PMP = (quantit�s en stock x pmp ancien + nouvelles quantit�s x prix d'acquisition)/ (anciennes quantit�s + nouvelles quantit�s) - -/* - * For each warehouse - */ -foreach ($entrepots as $key => $ent) -{ - $file = $dir ."/entrepot-".$key."-".$year.".png"; - $title = "Valorisation PMP du stock de l'entrep�t (euros HT) sur l'ann�e ".$year; - - if ($total[$key] > 0) - graph_datas($file, $title, $values[$key], $legends); - - if ($verbose) - print "$file\n"; -} - -/* - * For all warehouses - */ -$file = $dir."/entrepot-".$year.".png"; -$title = "Valorisation PMP (Prix Moyen Pond�r�) du stock global (euros HT) sur l'ann�e ".$year; - -if ($total[$key] > 0) -graph_datas($file, $title, $values[0], $legends); - -if ($verbose) -print "$file\n"; - - - -/** \brief Build graph - * \param file File - * \param title Title - * \param values Value - * \param legends Legend - */ -function graph_datas($file, $title, $values, $legends) -{ - $width=800; - $height=230; - - print "Build graph ".$file."\n"; - - $newvalues=array(); - foreach ($values as $abs=>$ord) - { - $newvalues[]=array($legends[$abs],$ord); - } - - $px = new DolGraph(); - $px->SetData($newvalues); - //$px->SetLegend(''); - $px->SetMaxValue($px->GetCeilMaxValue()); - $px->SetMinValue($px->GetFloorMinValue()); - $px->SetTitle($title); - $px->SetWidth($width); - $px->SetHeight($height); - $px->SetType('lines'); - $px->setBgColor('default'); - $px->setBgColorGrid(array(255,255,255)); - $px->SetHideXGrid(true); - $px->SetLabelInterval(31); - $px->draw($file); -} - -if (! $error) -{ - print '--- end ok'."\n"; -} -else -{ - print '--- end error code='.$error."\n"; -} - -?>
'.$langs->trans("Warehouse").''.$langs->trans("NumberOfUnit").''.$langs->trans("AverageUnitPricePMP").''.$langs->trans("EstimatedStockValue").''.$langs->trans("AverageUnitPricePMPShort").''.$langs->trans("EstimatedStockValueShort").'
'.img_object($langs->trans("ShowWarehouse"),'stock').' '.$objp->label.''.$objp->lieu.''; - // This value is real QTY * PMP of products in llx_product_stock for the warehouse - print $langs->trans("FeatureNotYetAvailableShort"); + print price(price2num($objp->estimatedvalue,'MT')); print ''.$entrepot->LibStatut($objp->statut,5).'