diff --git a/htdocs/product/stock/product.php b/htdocs/product/stock/product.php index 46e0aebfee3..649ef6077ad 100644 --- a/htdocs/product/stock/product.php +++ b/htdocs/product/stock/product.php @@ -1,6 +1,6 @@ - * Copyright (C) 2004 Laurent Destailleur + * Copyright (C) 2004-2005 Laurent Destailleur * Copyright (C) 2004 Eric Seigne * * This program is free software; you can redistribute it and/or modify @@ -23,11 +23,11 @@ */ -/*! - \file htdocs/product/stock/product.php - \ingroup product - \brief Page de la fiche produit - \version $Revision$ +/** + \file htdocs/product/stock/product.php + \ingroup product + \brief Page de la fiche produit + \version $Revision$ */ require("./pre.inc.php"); @@ -101,261 +101,273 @@ if ($_POST["action"] == "transfert_stock" && $_POST["cancel"] <> $langs->trans(" if ($_GET["id"]) { - $product = new Product($db); - - if ( $product->fetch($_GET["id"])) + $product = new Product($db); + + if ( $product->fetch($_GET["id"])) { - $h=0; - - $head[$h][0] = DOL_URL_ROOT."/product/fiche.php?id=".$product->id; - $head[$h][1] = $langs->trans("Card"); - $h++; - - $head[$h][0] = DOL_URL_ROOT."/product/price.php?id=".$product->id; - $head[$h][1] = $langs->trans("Price"); - $h++; - - - $head[$h][0] = DOL_URL_ROOT."/product/photos.php?id=".$product->id; - $head[$h][1] = $langs->trans("Photos"); - $h++; - - if ($product->type == 0) - { - if ($conf->stock->enabled) - { - $head[$h][0] = DOL_URL_ROOT."/product/stock/product.php?id=".$product->id; - $head[$h][1] = $langs->trans("Stock"); - $hselected = $h; - $h++; - } - } - if ($conf->fournisseur->enabled) { - $head[$h][0] = DOL_URL_ROOT."/product/fournisseurs.php?id=".$product->id; - $head[$h][1] = $langs->trans("Suppliers"); - $h++; - } + $h=0; - $head[$h][0] = DOL_URL_ROOT."/product/stats/fiche.php?id=".$product->id; - $head[$h][1] = $langs->trans("Statistics"); - $h++; + $head[$h][0] = DOL_URL_ROOT."/product/fiche.php?id=".$product->id; + $head[$h][1] = $langs->trans("Card"); + $h++; - //erics: pour créer des produits composés de x 'sous' produits - $head[$h][0] = DOL_URL_ROOT."/product/pack.php?id=".$product->id; - $head[$h][1] = $langs->trans('Packs'); - $h++; - - $head[$h][0] = DOL_URL_ROOT."/product/stats/facture.php?id=".$product->id; - $head[$h][1] = $langs->trans('Bills'); - $h++; - - dolibarr_fiche_head($head, $hselected, $langs->trans("CardProduct".$product->type).' : '.$product->ref); - - print($mesg); - - print ''; - print ""; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print "
'.$langs->trans("Ref").''.$product->ref.''; - if ($product->envente) - { - print $langs->trans("OnSell"); - } - else - { - print $langs->trans("NotOnSell"); - } - print '
'.$langs->trans("Label").''.$product->libelle.''.$langs->trans("Statistics").'
'.$langs->trans("SellingPrice").''.price($product->price).''; - print $langs->trans("Suppliers").' ['.$langs->trans("Add").']'; - - $sql = "SELECT s.nom, s.idp"; - $sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."product_fournisseur as pf"; - $sql .=" WHERE pf.fk_soc = s.idp AND pf.fk_product =$product->id"; - $sql .= " ORDER BY lower(s.nom)"; - - if ( $db->query($sql) ) - { - $num = $db->num_rows(); - $i = 0; - print ''; - $var=True; - while ($i < $num) - { - $objp = $db->fetch_object( $i); - $var=!$var; - print ""; - print ''; - $i++; - } - print '
'.$objp->nom.'
'; - $db->free(); - } - - print '
Stock seuil'.$product->seuil_stock_alerte.'
"; - - /* - * Contenu des stocks - * - */ - print '
'; - print ''; - $sql = "SELECT e.rowid, e.label, ps.reel FROM ".MAIN_DB_PREFIX."entrepot as e, ".MAIN_DB_PREFIX."product_stock as ps"; - $sql .= " WHERE ps.fk_entrepot = e.rowid AND ps.fk_product = ".$product->id; - $sql .= " ORDER BY lower(e.label)"; - - if ($db->query($sql)) - { - $num = $db->num_rows(); - $i = 0; $total = 0; - while ($i < $num) - { - $obj = $db->fetch_object( $i); - print ''; ; - $total = $total + $obj->reel; - $i++; - } - } - print '
'.$langs->trans("Warehouse").'Valeur du stock
'.$obj->label.''.$obj->reel.'
'.$langs->trans("Total").':'.$total."
"; - print '
'; + $head[$h][0] = DOL_URL_ROOT."/product/price.php?id=".$product->id; + $head[$h][1] = $langs->trans("Price"); + $h++; + + if($product->type == 0) + { + if ($user->rights->barcode->lire) + { + if ($conf->barcode->enabled) + { + $head[$h][0] = DOL_URL_ROOT."/product/barcode.php?id=".$product->id; + $head[$h][1] = $langs->trans("BarCode"); + $h++; + } + } + } + + $head[$h][0] = DOL_URL_ROOT."/product/photos.php?id=".$product->id; + $head[$h][1] = $langs->trans("Photos"); + $h++; + + if ($product->type == 0) + { + if ($conf->stock->enabled) + { + $head[$h][0] = DOL_URL_ROOT."/product/stock/product.php?id=".$product->id; + $head[$h][1] = $langs->trans("Stock"); + $hselected = $h; + $h++; + } + } + if ($conf->fournisseur->enabled) { + $head[$h][0] = DOL_URL_ROOT."/product/fournisseurs.php?id=".$product->id; + $head[$h][1] = $langs->trans("Suppliers"); + $h++; + } + + $head[$h][0] = DOL_URL_ROOT."/product/stats/fiche.php?id=".$product->id; + $head[$h][1] = $langs->trans("Statistics"); + $h++; + + //erics: pour créer des produits composés de x 'sous' produits + $head[$h][0] = DOL_URL_ROOT."/product/pack.php?id=".$product->id; + $head[$h][1] = $langs->trans('Packs'); + $h++; + + $head[$h][0] = DOL_URL_ROOT."/product/stats/facture.php?id=".$product->id; + $head[$h][1] = $langs->trans('Bills'); + $h++; + + dolibarr_fiche_head($head, $hselected, $langs->trans("CardProduct".$product->type).' : '.$product->ref); + + print($mesg); + + print ''; + print ""; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print "
'.$langs->trans("Ref").''.$product->ref.''; + if ($product->envente) + { + print $langs->trans("OnSell"); + } + else + { + print $langs->trans("NotOnSell"); + } + print '
'.$langs->trans("Label").''.$product->libelle.''.$langs->trans("Statistics").'
'.$langs->trans("SellingPrice").''.price($product->price).''; + print $langs->trans("Suppliers").' ['.$langs->trans("Add").']'; + + $sql = "SELECT s.nom, s.idp"; + $sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."product_fournisseur as pf"; + $sql .=" WHERE pf.fk_soc = s.idp AND pf.fk_product =$product->id"; + $sql .= " ORDER BY lower(s.nom)"; + + if ( $db->query($sql) ) + { + $num = $db->num_rows(); + $i = 0; + print ''; + $var=True; + while ($i < $num) + { + $objp = $db->fetch_object( $i); + $var=!$var; + print ""; + print ''; + $i++; + } + print '
'.$objp->nom.'
'; + $db->free(); + } + + print '
Stock seuil'.$product->seuil_stock_alerte.'
"; + + /* + * Contenu des stocks + * + */ + print '
'; + print ''; + $sql = "SELECT e.rowid, e.label, ps.reel FROM ".MAIN_DB_PREFIX."entrepot as e, ".MAIN_DB_PREFIX."product_stock as ps"; + $sql .= " WHERE ps.fk_entrepot = e.rowid AND ps.fk_product = ".$product->id; + $sql .= " ORDER BY lower(e.label)"; + + if ($db->query($sql)) + { + $num = $db->num_rows(); + $i = 0; $total = 0; + while ($i < $num) + { + $obj = $db->fetch_object( $i); + print ''; ; + $total = $total + $obj->reel; + $i++; + } + } + print '
'.$langs->trans("Warehouse").'Valeur du stock
'.$obj->label.''.$obj->reel.'
'.$langs->trans("Total").':'.$total."
"; + print '
'; } - print ''; + print ''; - /* - * Correction du stock - * - */ - if ($_GET["action"] == "correction") + /* + * Correction du stock + * + */ + if ($_GET["action"] == "correction") { - print_titre ("Correction du stock"); - print "
id\" method=\"post\">\n"; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print '
'.$langs->trans("Warehouse").'Nb de pièce
 '; - print '
'; - print '
'; + print_titre ("Correction du stock"); + print "
id\" method=\"post\">\n"; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print '
'.$langs->trans("Warehouse").'Nb de pièce
 '; + print '
'; + print '
'; } - /* - * Transfert de pièces - * - */ - if ($_GET["action"] == "transfert") + /* + * Transfert de pièces + * + */ + if ($_GET["action"] == "transfert") { - print_titre ("Transfert de stock"); - print "
id\" method=\"post\">\n"; - print ''; - print ''; - print ''; + print_titre ("Transfert de stock"); + print "id\" method=\"post\">\n"; + print ''; + print '
'.$langs->trans("Source").'
'; + print ''; - print ''; - print ''; - print '
'.$langs->trans("Source").''.$langs->trans("Target").'Nb de pièce
 '; - print '
'; - print '
'; + $sql = "SELECT e.rowid, e.label FROM ".MAIN_DB_PREFIX."entrepot as e"; + $sql .= " WHERE statut = 1"; + $sql .= " ORDER BY lower(e.label)"; + + if ($db->query($sql)) + { + $num = $db->num_rows(); + $i = 0; + while ($i < $num) + { + $obj = $db->fetch_object( $i); + print '