diff --git a/htdocs/product/stock/entrepot.class.php b/htdocs/product/stock/entrepot.class.php index f191745a153..324bfe7f8e5 100644 --- a/htdocs/product/stock/entrepot.class.php +++ b/htdocs/product/stock/entrepot.class.php @@ -54,7 +54,7 @@ class Entrepot extends CommonObject /* * \brief Constructeur de l'objet entrepot - * \param DB Handler d'accès à la base de donnée + * \param DB Handler d'acc�s � la base de donn�e */ function Entrepot($DB) { @@ -67,7 +67,7 @@ class Entrepot extends CommonObject /* * \brief Creation d'un entrepot en base - * \param Objet user qui crée l'entrepot + * \param Objet user qui cr�e l'entrepot */ function create($user) { @@ -122,7 +122,7 @@ class Entrepot extends CommonObject /* * \brief Mise a jour des information d'un entrepot - * \param id id de l'entrepot à modifier + * \param id id de l'entrepot � modifier * \param user */ function update($id, $user) @@ -162,8 +162,8 @@ class Entrepot extends CommonObject /** - * \brief Recupéeration de la base d'un entrepot - * \param id id de l'entrepot a récupérer + * \brief Recup�eration de la base d'un entrepot + * \param id id de l'entrepot a r�cup�rer */ function fetch ($id) { @@ -262,7 +262,7 @@ class Entrepot extends CommonObject /** - * \brief Renvoie la liste des entrepôts ouverts + * \brief Renvoie la liste des entrep�ts ouverts */ function list_array() { @@ -290,13 +290,16 @@ class Entrepot extends CommonObject } /** - * \brief Renvoie le stock (nombre de produits) de l'entrepot + * \brief Renvoie le stock (nombre de produits) et valorisation de l'entrepot + * \return Array Array('nb'=>Nb, 'value'=>Value) */ function nb_products() { global $conf,$user; - $sql = "SELECT sum(ps.reel)"; + $ret=array(); + + $sql = "SELECT sum(ps.reel) as nb, sum(ps.reel * ps.pmp) as value"; $sql .= " FROM llx_product_stock as ps"; if ($conf->categorie->enabled && !$user->rights->categorie->voir) { @@ -309,24 +312,28 @@ class Entrepot extends CommonObject $sql.= ' AND IFNULL(c.visible,1)=1'; } + //print $sql; $result = $this->db->query($sql) ; - - if ( $result ) + if ($result) { - $row = $this->db->fetch_row(0); - return $row[0]; + $obj = $this->db->fetch_object($result); + $ret['nb']=$obj->nb; + $ret['value']=$obj->value; $this->db->free(); } else { - return 0; + $this->error=$this->db->lasterror(); + return -1; } + + return $ret; } /** - * \brief Retourne le libellé du statut d'un entrepot (ouvert, ferme) - * \param mode 0=libellé long, 1=libellé court, 2=Picto + Libellé court, 3=Picto, 4=Picto + Libellé long + * \brief Retourne le libell� du statut d'un entrepot (ouvert, ferme) + * \param mode 0=libell� long, 1=libell� court, 2=Picto + Libell� court, 3=Picto, 4=Picto + Libell� long * \return string Libelle */ function getLibStatut($mode=0) @@ -335,10 +342,10 @@ class Entrepot extends CommonObject } /** - * \brief Renvoi le libellé d'un statut donné + * \brief Renvoi le libell� d'un statut donn� * \param statut Id statut - * \param mode 0=libellé long, 1=libellé court, 2=Picto + Libellé court, 3=Picto, 4=Picto + Libellé long, 5=Libellé court + Picto - * \return string Libellé du statut + * \param mode 0=libell� long, 1=libell� court, 2=Picto + Libell� court, 3=Picto, 4=Picto + Libell� long, 5=Libell� court + Picto + * \return string Libell� du statut */ function LibStatut($statut,$mode=0) { diff --git a/htdocs/product/stock/fiche-valo.php b/htdocs/product/stock/fiche-valo.php index 3d31e3cb429..deb59397d33 100644 --- a/htdocs/product/stock/fiche-valo.php +++ b/htdocs/product/stock/fiche-valo.php @@ -1,6 +1,6 @@ - * Copyright (C) 2008 Laurent Destailleur +/* Copyright (C) 2006 Rodolphe Quiedeville + * Copyright (C) 2008-2009 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 @@ -112,9 +112,18 @@ if ($_GET["id"]) // Statut print ''.$langs->trans("Status").''.$entrepot->getLibStatut(4).''; + $calcproducts=$entrepot->nb_products(); + + // Nb of products print ''.$langs->trans("NumberOfProducts").''; - print $entrepot->nb_products(); + print empty($calcproducts['nb'])?'0':$calcproducts['nb']; print ""; + + // Value + print ''.$langs->trans("EstimatedStockValueShort").''; + print empty($calcproducts['value'])?'0':$calcproducts['value']; + print ""; + print ""; print ''; diff --git a/htdocs/product/stock/fiche.php b/htdocs/product/stock/fiche.php index 7f50a7cba9d..0bae3a88237 100644 --- a/htdocs/product/stock/fiche.php +++ b/htdocs/product/stock/fiche.php @@ -255,13 +255,16 @@ else // Description print ''.$langs->trans("Description").''.nl2br($entrepot->description).''; + // Address print ''.$langs->trans('Address').''; print $entrepot->address; print ''; + // Ville print ''.$langs->trans('Zip').''.$entrepot->cp.''; print ''.$langs->trans('Town').''.$entrepot->ville.''; + // Country print ''.$langs->trans('Country').''; print $entrepot->pays; print ''; @@ -269,10 +272,16 @@ else // Statut print ''.$langs->trans("Status").''.$entrepot->getLibStatut(4).''; + $calcproducts=$entrepot->nb_products(); + // Nb of products print ''.$langs->trans("NumberOfProducts").''; - $nb=$entrepot->nb_products(); - print empty($nb)?'0':$nb; + print empty($calcproducts['nb'])?'0':$calcproducts['nb']; + print ""; + + // Value + print ''.$langs->trans("EstimatedStockValueShort").''; + print empty($calcproducts['value'])?'0':$calcproducts['value']; print ""; // Last movement @@ -326,12 +335,15 @@ 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("AverageUnitPricePMPShort"),"", "ps.pmp","&id=".$_GET['id'],"",'align="center"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("EstimatedStockValueShort"),"", "","&id=".$_GET['id'],"",'align="center"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("AverageUnitPricePMPShort"),"", "ps.pmp","&id=".$_GET['id'],"",'align="right"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("EstimatedStockValueShort"),"", "","&id=".$_GET['id'],"",'align="right"',$sortfield,$sortorder); if ($user->rights->stock->mouvement->creer) print ' '; if ($user->rights->stock->creer) print ' '; print ""; + $totalunit=0; + $totalvalue=0; + $sql = "SELECT p.rowid as rowid, p.ref, p.label as produit, p.fk_product_type as type,"; $sql.= " ps.pmp, ps.reel as value"; $sql.= " FROM ".MAIN_DB_PREFIX."product_stock ps, ".MAIN_DB_PREFIX."product p"; @@ -348,7 +360,6 @@ else $sql.= ' AND IFNULL(c.visible,1)=1'; } $sql.= " ORDER BY " . $sortfield . " " . $sortorder; - //$sql .= $db->plimit($limit + 1 ,$offset); $resql = $db->query($sql) ; @@ -390,10 +401,12 @@ else print ''.$objp->produit.''; print ''.$objp->value.''; + $totalunit+=$objp->value; - print ''.price(price2num($objp->pmp,'MU')).''; + print ''.price(price2num($objp->pmp,'MU')).''; - print ''.price(price2num($objp->pmp*$objp->value,'MT')).''; + print ''.price(price2num($objp->pmp*$objp->value,'MT')).''; + $totalvalue+=price2num($objp->pmp*$objp->value,'MT'); if ($user->rights->stock->mouvement->creer) { @@ -413,6 +426,15 @@ else $i++; } $db->free($resql); + + print ''.$langs->trans("Total").''; + print ''.$totalunit.''; + print ' '; + print ''.$totalvalue.''; + print ' '; + print ' '; + print ''; + } else { diff --git a/htdocs/product/stock/info.php b/htdocs/product/stock/info.php index 236118c3026..262deec7b96 100644 --- a/htdocs/product/stock/info.php +++ b/htdocs/product/stock/info.php @@ -17,10 +17,10 @@ */ /** - \file htdocs/product/stock/info.php - \ingroup facture - \brief Page des informations d'un entrepot - \version $Id$ + * \file htdocs/product/stock/info.php + * \ingroup stock + * \brief Page des informations d'un entrepot + * \version $Id$ */ require("./pre.inc.php"); diff --git a/htdocs/product/stock/mouvement.php b/htdocs/product/stock/mouvement.php index b22a1bdc571..ce2c29bbbe4 100644 --- a/htdocs/product/stock/mouvement.php +++ b/htdocs/product/stock/mouvement.php @@ -166,9 +166,56 @@ if ($resql) print ''.$langs->trans("LocationSummary").''.$entrepot->lieu.''; + // Description + print ''.$langs->trans("Description").''.nl2br($entrepot->description).''; + + // Address + print ''.$langs->trans('Address').''; + print $entrepot->address; + print ''; + + // Ville + print ''.$langs->trans('Zip').''.$entrepot->cp.''; + print ''.$langs->trans('Town').''.$entrepot->ville.''; + + // Country + print ''.$langs->trans('Country').''; + print $entrepot->pays; + print ''; + // Statut print ''.$langs->trans("Status").''.$entrepot->getLibStatut(4).''; + $calcproducts=$entrepot->nb_products(); + + // Nb of products + print ''.$langs->trans("NumberOfProducts").''; + print empty($calcproducts['nb'])?'0':$calcproducts['nb']; + print ""; + + // Value + print ''.$langs->trans("EstimatedStockValueShort").''; + print empty($calcproducts['value'])?'0':$calcproducts['value']; + print ""; + + // Last movement + $sql = "SELECT max( ".$db->pdate("m.datem").") as datem"; + $sql .= " FROM llx_stock_mouvement as m"; + $sql .= " WHERE m.fk_entrepot = '".$entrepot->id."';"; + $resqlbis = $db->query($sql); + if ($resqlbis) + { + $row = $db->fetch_row($resqlbis); + } + else + { + dol_print_error($db); + } + + print ''.$langs->trans("LastMovement").''; + print ''.dol_print_date($row[0]).''; + print ""; + print ""; print ''; diff --git a/htdocs/product/stock/user.php b/htdocs/product/stock/user.php index 06553fe5264..3a9a91355d3 100644 --- a/htdocs/product/stock/user.php +++ b/htdocs/product/stock/user.php @@ -20,11 +20,11 @@ */ /** - \file htdocs/product/stock/user.php - \ingroup stock - \brief Page to link dolibarr users with warehouses - \version $Id$ -*/ + \file htdocs/product/stock/user.php + \ingroup stock + \brief Page to link dolibarr users with warehouses + \version $Id$ + */ require("./pre.inc.php"); @@ -49,132 +49,131 @@ $mesg = ''; /* -* Affichage fiche en mode création -* -*/ + * View + */ llxHeader("","",$langs->trans("WarehouseCard")); $form=new Form($db); - if ($_GET["id"]) - { - if ($mesg) print $mesg; - - $entrepot = new Entrepot($db); - $result = $entrepot->fetch($_GET["id"]); - if ($result < 0) - { - dol_print_error($db); - } - - /* - * Affichage fiche - */ - if ($_GET["action"] <> 'edit' && $_GET["action"] <> 're-edit') - { - - /* - * Affichage onglets - */ - $h = 0; - - $head[$h][0] = DOL_URL_ROOT.'/product/stock/fiche.php?id='.$entrepot->id; - $head[$h][1] = $langs->trans("WarehouseCard"); - $h++; - - $head[$h][0] = DOL_URL_ROOT.'/product/stock/mouvement.php?id='.$entrepot->id; - $head[$h][1] = $langs->trans("StockMovements"); - $h++; - - $head[$h][0] = DOL_URL_ROOT.'/product/stock/fiche-valo.php?id='.$entrepot->id; - $head[$h][1] = $langs->trans("EnhancedValue"); - $h++; +if ($_GET["id"]) +{ + if ($mesg) print $mesg; - $head[$h][0] = DOL_URL_ROOT.'/product/stock/user.php?id='.$entrepot->id; - $head[$h][1] = $langs->trans("Users"); - $hselected=$h; - $h++; - - $head[$h][0] = DOL_URL_ROOT.'/product/stock/info.php?id='.$entrepot->id; - $head[$h][1] = $langs->trans("Info"); - $h++; + $entrepot = new Entrepot($db); + $result = $entrepot->fetch($_GET["id"]); + if ($result < 0) + { + dol_print_error($db); + } - dol_fiche_head($head, $hselected, $langs->trans("Warehouse").': '.$entrepot->libelle); - - print ''; - - // Ref - print ''; - - print ''; - - // Description - print ''; + /* + * Affichage fiche + */ + if ($_GET["action"] <> 'edit' && $_GET["action"] <> 're-edit') + { - print ''; - - print ''; - print ''; - - print ''; - - // Statut - print ''; - - print "
'.$langs->trans("Ref").''.$entrepot->libelle.'
'.$langs->trans("LocationSummary").''.$entrepot->lieu.'
'.$langs->trans("Description").''.nl2br($entrepot->description).'
'.$langs->trans('Address').''; - print $entrepot->address; - print '
'.$langs->trans('Zip').''.$entrepot->cp.''.$langs->trans('Town').''.$entrepot->ville.'
'.$langs->trans('Country').''; - print $entrepot->pays; - print '
'.$langs->trans("Status").''.$entrepot->getLibStatut(4).'
"; - - print ''; - - - /* ************************************************************************** */ - /* */ - /* Barre d'action */ - /* */ - /* ************************************************************************** */ - - print "
\n"; - - print "
"; + /* + * Affichage onglets + */ + $h = 0; - - /* ************************************************************************** */ - /* */ - /* Affichage des utilisateurs de l'entrepot */ - /* */ - /* ************************************************************************** */ - print '
'; - - print ''; - print ""; - print_liste_field_titre($langs->trans("User"),"", "p.ref","&id=".$_GET['id'],"",'align="left"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("Label"),"", "p.label","&id=".$_GET['id'],"",'align="center"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("Units"),"", "ps.reel","&id=".$_GET['id'],"",'align="center"',$sortfield,$sortorder); - print ""; - $sql = "SELECT u.rowid as rowid, u.name, u.firstname, ue.send, ue.consult "; - $sql .= " FROM ".MAIN_DB_PREFIX."user_entrepot as ue, ".MAIN_DB_PREFIX."user as u "; + $head[$h][0] = DOL_URL_ROOT.'/product/stock/fiche.php?id='.$entrepot->id; + $head[$h][1] = $langs->trans("WarehouseCard"); + $h++; - $sql .= " WHERE ue.fk_user = u.rowid "; - $sql .= " AND ue.fk_entrepot = ".$entrepot->id; - - //$sql .= " ORDER BY " . $sortfield . " " . $sortorder; - //$sql .= $db->plimit($limit + 1 ,$offset); - - $resql = $db->query($sql) ; - if ($resql) - { - $num = $db->num_rows($resql); - $i = 0; - $var=True; - while ($i < $num) - { + $head[$h][0] = DOL_URL_ROOT.'/product/stock/mouvement.php?id='.$entrepot->id; + $head[$h][1] = $langs->trans("StockMovements"); + $h++; + + $head[$h][0] = DOL_URL_ROOT.'/product/stock/fiche-valo.php?id='.$entrepot->id; + $head[$h][1] = $langs->trans("EnhancedValue"); + $h++; + + $head[$h][0] = DOL_URL_ROOT.'/product/stock/user.php?id='.$entrepot->id; + $head[$h][1] = $langs->trans("Users"); + $hselected=$h; + $h++; + + $head[$h][0] = DOL_URL_ROOT.'/product/stock/info.php?id='.$entrepot->id; + $head[$h][1] = $langs->trans("Info"); + $h++; + + dol_fiche_head($head, $hselected, $langs->trans("Warehouse").': '.$entrepot->libelle); + + print '
'; + + // Ref + print ''; + + print ''; + + // Description + print ''; + + print ''; + + print ''; + print ''; + + print ''; + + // Statut + print ''; + + print "
'.$langs->trans("Ref").''.$entrepot->libelle.'
'.$langs->trans("LocationSummary").''.$entrepot->lieu.'
'.$langs->trans("Description").''.nl2br($entrepot->description).'
'.$langs->trans('Address').''; + print $entrepot->address; + print '
'.$langs->trans('Zip').''.$entrepot->cp.''.$langs->trans('Town').''.$entrepot->ville.'
'.$langs->trans('Country').''; + print $entrepot->pays; + print '
'.$langs->trans("Status").''.$entrepot->getLibStatut(4).'
"; + + print ''; + + + /* ************************************************************************** */ + /* */ + /* Barre d'action */ + /* */ + /* ************************************************************************** */ + + print "
\n"; + + print "
"; + + + /* ************************************************************************** */ + /* */ + /* Affichage des utilisateurs de l'entrepot */ + /* */ + /* ************************************************************************** */ + print '
'; + + print ''; + print ""; + print_liste_field_titre($langs->trans("User"),"", "p.ref","&id=".$_GET['id'],"",'align="left"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("Label"),"", "p.label","&id=".$_GET['id'],"",'align="center"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("Units"),"", "ps.reel","&id=".$_GET['id'],"",'align="center"',$sortfield,$sortorder); + print ""; + $sql = "SELECT u.rowid as rowid, u.name, u.firstname, ue.send, ue.consult "; + $sql .= " FROM ".MAIN_DB_PREFIX."user_entrepot as ue, ".MAIN_DB_PREFIX."user as u "; + + $sql .= " WHERE ue.fk_user = u.rowid "; + $sql .= " AND ue.fk_entrepot = ".$entrepot->id; + + //$sql .= " ORDER BY " . $sortfield . " " . $sortorder; + //$sql .= $db->plimit($limit + 1 ,$offset); + + $resql = $db->query($sql) ; + if ($resql) + { + $num = $db->num_rows($resql); + $i = 0; + $var=True; + while ($i < $num) + { $objp = $db->fetch_object($resql); - + $var=!$var; print ""; @@ -185,16 +184,16 @@ $form=new Form($db); print ''; print ""; $i++; - } - $db->free($resql); - } - else - { - dol_print_error($db); - } - print "
'.$objp->send.'
\n"; - } - } + } + $db->free($resql); + } + else + { + dol_print_error($db); + } + print "\n"; + } +} $db->close();