From 4644cd7d09dd3b78fe7e99609d01ffd68f664ffa Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 11 Jun 2005 11:39:38 +0000 Subject: [PATCH] =?UTF-8?q?Fix:=20D=E9buggage=20de=20la=20gestion=20des=20?= =?UTF-8?q?fournisseurs,=20photos=20et=20prix=20sur=20les=20produits?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- htdocs/product/fiche.php | 654 ++++++++++++++------------------ htdocs/product/fournisseurs.php | 239 ++++++++---- htdocs/product/photos.php | 205 ++++++---- htdocs/product/price.php | 126 ++++-- htdocs/product/stats/fiche.php | 52 ++- 5 files changed, 687 insertions(+), 589 deletions(-) diff --git a/htdocs/product/fiche.php b/htdocs/product/fiche.php index 32959044665..0b59d08ab6c 100644 --- a/htdocs/product/fiche.php +++ b/htdocs/product/fiche.php @@ -1,6 +1,6 @@ - * Copyright (C) 2004 Laurent Destailleur + * Copyright (C) 2004-2005 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 @@ -22,10 +22,10 @@ */ /** - \file htdocs/product/fiche.php - \ingroup product - \brief Page de la fiche produit - \version $Revision$ + \file htdocs/product/fiche.php + \ingroup product + \brief Page de la fiche produit + \version $Revision$ */ require("./pre.inc.php"); @@ -216,30 +216,6 @@ if ($_GET["action"] == 'remove_fourn') } } - -if ($_POST["action"] == 'update_price' && - $_POST["cancel"] <> $langs->trans("Cancel") && $user->rights->produit->creer) -{ - $product = new Product($db); - - $result = $product->fetch($_GET["id"]); - - $product->price = ereg_replace(" ","",$_POST["price"]); - - if ( $product->update_price($product->id, $user) > 0 ) - - { - $_GET["action"] = ''; - $mesg = 'Fiche mise à jour'; - } - else - { - $_GET["action"] = 'edit_price'; - $mesg = 'Fiche non mise à jour !' . "
" . $product->mesg_error; - } -} - - if ($_POST["cancel"] == $langs->trans("Cancel")) { $action = ''; @@ -252,8 +228,7 @@ llxHeader("","",$langs->trans("CardProduct0")); /* - * Création du produit - * + * Action création du produit */ if ($_GET["action"] == 'create' && $user->rights->produit->creer) { @@ -322,335 +297,265 @@ if ($_GET["action"] == 'create' && $user->rights->produit->creer) print ''; print ''; } + + +/* + * Fiche produit + */ +if ($_GET["id"]) +{ + + if ($_GET["action"] <> 're-edit') + { + $product = new Product($db); + $result = $product->fetch($_GET["id"]); + } + + if ( $result ) + { + + if ($_GET["action"] <> 'edit' && $_GET["action"] <> 're-edit') + { + /* + * En mode visu + */ + + $h=0; + + $head[$h][0] = DOL_URL_ROOT."/product/fiche.php?id=".$product->id; + $head[$h][1] = $langs->trans("Card"); + $hselected = $h; + $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"); + $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++; + + + dolibarr_fiche_head($head, $hselected, $langs->trans("CardProduct".$product->type).' : '.$product->ref); + + + print($mesg); + print ''; + print ""; + print ''; + print ''; + print ''; + print ''; + + // Prix + print ''; + if ($product->type == 0) $nbligne=5; + else $nbligne=5; + print ''; + + // Statut + print ''; + + $langs->load("bills"); + print ''; + if ($product->type == 0 && defined("MAIN_MODULE_STOCK")) + { + print ''; + if ($product->no_stock) + { + print "'; + } + print ''; + + if ($product->type == 1) + { + print ''; + } + print "
'.$langs->trans("Ref").''.$product->ref.'
'.$langs->trans("Label").''.$product->libelle.'
'.$langs->trans("SellingPrice").''.price($product->price).''; + + $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)"; + + $result=$db->query($sql); + if ($result) + { + $num_fournisseur = $db->num_rows($result); + $i = 0; + print ''; + print ''; + $var=True; + while ($i < $num_fournisseur) + { + $objp = $db->fetch_object($result); + $var=!$var; + print ""; + print ''; + print ''; + $i++; + } + print '
'.$langs->trans("Suppliers").'
'.$objp->nom.''; + print ''; + print img_disable($langs->trans("Remove")).'
'; + $db->free($result); + } + print '
'.$langs->trans("Status").''; + if ($product->envente) print $langs->trans("OnSell"); + else print $langs->trans("NotOnSell"); + print '
'.$langs->trans("VATRate").''.$product->tva_tx.' %
'.$langs->trans("Stock").'Pas de définition de stock pour ce produit"; + } + else + { + if ($product->stock_reel <= $product->seuil_stock_alerte) + { + print ''.$product->stock_reel.' Seuil : '.$product->seuil_stock_alerte; + } + else + { + print "".$product->stock_reel; + } + } + print '
'.$langs->trans("Description").''.nl2br($product->description).'
'.$langs->trans("Duration").''.$product->duration_value.' '; + + if ($product->duration_value > 1) + { + $dur=array("d"=>$langs->trans("Days"),"w"=>$langs->trans("Weeks"),"m"=>$langs->trans("Months"),"y"=>$langs->trans("Years")); + } + else { + $dur=array("d"=>$langs->trans("Day"),"w"=>$langs->trans("Week"),"m"=>$langs->trans("Month"),"y"=>$langs->trans("Year")); + } + print $langs->trans($dur[$product->duration_unit])." "; + + print '

\n"; + + print "\n"; + } + + /* + * Ajouter un fournisseur + */ + if ($_GET["action"] == 'ajout_fourn' && $user->rights->produit->creer) + { + $langs->load("suppliers"); + + print_titre($langs->trans("AddSupplier")); + print '
'; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print '
'.$langs->trans("Suppliers").''; + + $html=new Form($db); + $html->select_societes('','id_fourn','fournisseur=1'); + + print ''.$langs->trans("Ref").'
'; + print ' '; + print '
'; + print '
'; + } + } + + /* + * Fiche en mode edition + */ + if (($_GET["action"] == 'edit' || $_GET["action"] == 're-edit') && $user->rights->produit->creer) + { + + print_fiche_titre('Edition de la fiche '.$types[$product->type].' : '.$product->ref, ""); + + if ($mesg) { + print '
'.$mesg.'

'; + } + + print "
\n"; + print ''; + print ''; + print ''; + print "".''; + print ''; + + $langs->load("bills"); + print ''; + print ''; + if ($product->type == 0 && defined("MAIN_MODULE_STOCK")) + { + print "".''; + } + else + { + print ''; + } + print '"; + + if ($product->type == 1) + { + print ''; + } + + print ''; + print '
'.$langs->trans("Ref").'
'.$langs->trans("Label").'
'.$langs->trans("VATRate").''; + $html = new Form($db); + print $html->select_tva("tva_tx", $product->tva_tx); + print '
'.$langs->trans("Status").''; + print '
Seuil stock'; + print ''; + print '
'.$langs->trans("Description").''; + print '
'.$langs->trans("Duration").''; + print '  '; + print 'duration_unit=='d'?' checked':'').'>'.$langs->trans("Day"); + print '  '; + print 'duration_unit=='w'?' checked':'').'>'.$langs->trans("Week"); + print '  '; + print 'duration_unit=='m'?' checked':'').'>'.$langs->trans("Month"); + print '  '; + print 'duration_unit=='y'?' checked':'').'>'.$langs->trans("Year"); + + print '
 '; + print '
'; + print '
'; + } +} else { - /* - * Fiche produit - */ - if ($_GET["id"]) - { - - if ($_GET["action"] <> 're-edit') - { - $product = new Product($db); - $result = $product->fetch($_GET["id"]); - } - - if ( $result ) - { - - if ($_GET["action"] <> 'edit' && $_GET["action"] <> 're-edit') - { - /* - * En mode visu - */ - - $h=0; - - $head[$h][0] = DOL_URL_ROOT."/product/fiche.php?id=".$product->id; - $head[$h][1] = $langs->trans("Card"); - $hselected = $h; - $h++; - - $head[$h][0] = DOL_URL_ROOT."/product/price.php?id=".$product->id; - $head[$h][1] = $langs->trans("Price"); - $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"); - $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/photos.php?id=".$product->id; - $head[$h][1] = $langs->trans("Photos"); - $h++; - - $head[$h][0] = DOL_URL_ROOT."/product/stats/fiche.php?id=".$product->id; - $head[$h][1] = $langs->trans('Statistics'); - $h++; - - - dolibarr_fiche_head($head, $hselected, $langs->trans("CardProduct".$product->type).' : '.$product->ref); - - - print($mesg); - print ''; - print ""; - print ''; - print ''; - print ''; - print ''; - if ($product->type == 0) - { - $nblignefour=4; - } - else - { - $nblignefour=4; - } - - print ''; - - $langs->load("bills"); - print ''; - if ($product->type == 0 && defined("MAIN_MODULE_STOCK")) - { - print ''; - if ($product->no_stock) - { - print "'; - } - print ''; - - if ($product->type == 1) - { - 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("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)"; - - $result=$db->query($sql); - if ($result) - { - $num_fournisseur = $db->num_rows($result); - $i = 0; - print ''; - $var=True; - while ($i < $num_fournisseur) - { - $objp = $db->fetch_object($result); - $var=!$var; - print ""; - print ''; - print ''; - $i++; - } - print '
'.$objp->nom.''; - print ''; - print img_disable($langs->trans("Remove")).'
'; - $db->free($result); - } - - print '
'.$langs->trans("VATRate").''.$product->tva_tx.' %
'.$langs->trans("Stock").'Pas de définition de stock pour ce produit"; - } - else - { - if ($product->stock_reel <= $product->seuil_stock_alerte) - { - print ''.$product->stock_reel.' Seuil : '.$product->seuil_stock_alerte; - } - else - { - print "".$product->stock_reel; - } - } - print '
'.$langs->trans("Description").''.nl2br($product->description).'
'.$langs->trans("Duration").''.$product->duration_value.' '; - - if ($product->duration_value > 1) - { - $dur=array("d"=>$langs->trans("Days"),"w"=>$langs->trans("Weeks"),"m"=>$langs->trans("Months"),"y"=>$langs->trans("Years")); - } - else { - $dur=array("d"=>$langs->trans("Day"),"w"=>$langs->trans("Week"),"m"=>$langs->trans("Month"),"y"=>$langs->trans("Year")); - } - print $langs->trans($dur[$product->duration_unit])." "; - - print '

\n"; - - print "\n"; - } - - - /* - * Edition du prix - * - */ - if ($_GET["action"] == 'edit_price' && $user->rights->produit->creer) - { - print '
'.$langs->trans("NewPrice").'
'; - print '
'; - print ''; - print ''; - print ''; - print ''; - print ''; - print '
'.$langs->trans('SellingPrice').'
 '; - print '
'; - print '
'; - } - - - /* - * Ajouter un fournisseur - * - */ - if ($_GET["action"] == 'ajout_fourn' && $user->rights->produit->creer) - { - $langs->load("suppliers"); - - print_titre($langs->trans("AddSupplier")); - print '
'; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print '
'.$langs->trans("Suppliers").''.$langs->trans("Ref").'
'; - print ' '; - print '
'; - print '
'; - } - - /* - * Ajouter une photo - * - */ - if ($_GET["action"] == 'ajout_photo' && $conf->upload && $user->rights->produit->creer && $product->isproduct) - { - print_titre($langs->trans("AddPhoto")); - - print '
'; - print ''; - print ''; - - print ''; - print ''; - print ''; - - print ''; - print '
'.$langs->trans("File").' ('.$langs->trans("Size").' <= '.$conf->maxfilesize.')
'; - print '   '; - - print '
'; - print '
'; - } - - } - - /* - * - * Fiche en mode edition - * - */ - if (($_GET["action"] == 'edit' || $_GET["action"] == 're-edit') && $user->rights->produit->creer) - { - - print_fiche_titre('Edition de la fiche '.$types[$product->type].' : '.$product->ref, ""); - - if ($mesg) { - print '
'.$mesg.'

'; - } - - print "
\n"; - print ''; - print ''; - print ''; - print "".''; - print ''; - - $langs->load("bills"); - print ''; - print ''; - if ($product->type == 0 && defined("MAIN_MODULE_STOCK")) - { - print "".''; - } - else - { - print ''; - } - print '"; - - if ($product->type == 1) - { - print ''; - } - - print ''; - print '
'.$langs->trans("Ref").'
'.$langs->trans("Label").'
'.$langs->trans("VATRate").''; - $html = new Form($db); - print $html->select_tva("tva_tx", $product->tva_tx); - print '
'.$langs->trans("Status").''; - print '
Seuil stock'; - print ''; - print '
'.$langs->trans("Description").''; - print '
'.$langs->trans("Duration").''; - print '  '; - print 'duration_unit=='d'?' checked':'').'>'.$langs->trans("Day"); - print '  '; - print 'duration_unit=='w'?' checked':'').'>'.$langs->trans("Week"); - print '  '; - print 'duration_unit=='m'?' checked':'').'>'.$langs->trans("Month"); - print '  '; - print 'duration_unit=='y'?' checked':'').'>'.$langs->trans("Year"); - - print '
 '; - print '
'; - print '
'; - } - } - else - { - print $langs->trans("ErrorUnknown"); - } + print $langs->trans("ErrorUnknown"); } @@ -664,37 +569,40 @@ print "\n
\n"; if ($_GET["action"] == '') { - if ($product->type == 0 && $user->rights->produit->commander && $num_fournisseur == 1) + if ($product->type == 0 && $user->rights->produit->commander && $num_fournisseur == 1) { - print ''; - print $langs->trans("Order").''; + print ''; + print $langs->trans("Order").''; + } + + if ( $user->rights->produit->creer) + { + print ''.$langs->trans("Edit").''; } - if ( $user->rights->produit->creer && $product->isproduct && $conf->upload) + if ($user->rights->produit->modifier || $user->rights->produit->creer) { - print ''; - print $langs->trans("AddPhoto").''; + print ''.$langs->trans("UpdatePrice").''; } - if ( $user->rights->produit->creer) + if ( $user->rights->produit->creer && $conf->upload) { - print ''; - print $langs->trans("UpdatePrice").''; + print ''; + print $langs->trans("AddPhoto").''; } - if ( $user->rights->produit->creer) + if ($user->rights->produit->modifier || $user->rights->produit->creer) { - print ''.$langs->trans("Edit").''; + print ''; + print $langs->trans("AddSupplier").''; } - } -print "\n
\n"; +print "\n
\n"; /* * Photo - * */ if ($_GET["id"] && $_GET["action"]=='') { @@ -914,5 +822,5 @@ if ($_GET["id"] && $_GET["action"] == '' && $product->envente) $db->close(); -llxFooter("Dernière modification $Date$ révision $Revision$"); +llxFooter('$Date$ - $Revision$'); ?> diff --git a/htdocs/product/fournisseurs.php b/htdocs/product/fournisseurs.php index 71a736dd86a..35881eea7f0 100644 --- a/htdocs/product/fournisseurs.php +++ b/htdocs/product/fournisseurs.php @@ -33,34 +33,64 @@ require("../propal.class.php"); require("../facture.class.php"); $langs->load("products"); +$langs->load("suppliers"); $user->getrights('produit'); $user->getrights('propale'); $user->getrights('facture'); $mesg = ''; -if (!$user->rights->produit->lire) -{ - accessforbidden(); -} +if (! $user->rights->produit->lire) accessforbidden(); $types[0] = $langs->trans("Product"); $types[1] = $langs->trans("Service"); + +/* + * Actions + */ + if ($_POST["action"] == 'updateprice' && $_POST["cancel"] <> $langs->trans("Cancel")) { - $product = new Product($db); - if( $product->fetch($_GET["id"]) ) + $product = new Product($db); + if( $product->fetch($_GET["id"]) ) { - $product->update_buyprice($_POST["id_fourn"], $_POST["qty"], $_POST["price"], $user); + $db->begin(); + + $error=0; + + if ($_POST["ref_fourn"]) { + $ret=$product->add_fournisseur($user, $_POST["id_fourn"], $_POST["ref_fourn"]); + if ($ret < 0) { + $error++; + $mesg='
'.$product->error.'
'; + } + } + + if ($_POST["qty"]) { + $ret=$product->update_buyprice($_POST["id_fourn"], $_POST["qty"], $_POST["price"], $user); + if ($ret < 0) { + $error++; + $mesg='
'.$product->error.'
'; + } + } + + if (! $error) + { + $db->commit(); + } + else { + $db->rollback(); + } } } if ($_POST["cancel"] == $langs->trans("Cancel")) { - $action = ''; - Header("Location: fournisseurs.php?id=".$_GET["id"]); + $action = ''; + Header("Location: fournisseurs.php?id=".$_GET["id"]); + exit; } @@ -87,13 +117,16 @@ if ($_GET["id"]) /* * En mode visu */ + // Zone recherche + /* Deja présent dans menu gauche print '
'; print '
'; print ''; print $langs->trans("Ref").':    '; print $langs->trans("Label").':  '; print '
'; + */ $h=0; @@ -105,6 +138,10 @@ if ($_GET["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) @@ -123,10 +160,6 @@ if ($_GET["id"]) $h++; } - $head[$h][0] = DOL_URL_ROOT."/product/photos.php?id=".$product->id; - $head[$h][1] = $langs->trans("Photos"); - $h++; - $head[$h][0] = DOL_URL_ROOT."/product/stats/fiche.php?id=".$product->id; $head[$h][1] = $langs->trans('Statistics'); $h++; @@ -135,99 +168,147 @@ if ($_GET["id"]) dolibarr_fiche_head($head, $hselected, $langs->trans("CardProduct".$product->type).' : '.$product->ref); print($mesg); + print ''; - print ''; - print ''; + print ''; print ''; print ''; + + // Statut + print ''; + print '
'.$langs->trans("Ref").''.$product->ref.''.$langs->trans("Status").' : '; - if ($product->envente) - { - print $langs->trans("OnSell"); - } - else - { - print $langs->trans("NotOnSell"); - } - print '
'.$langs->trans("Ref").''.$product->ref.'
'.$langs->trans("Label").''.$product->libelle.'
'.$langs->trans("SellingPrice").''.price($product->price).'
'.$langs->trans("Status").''; + if ($product->envente) print $langs->trans("OnSell"); + else print $langs->trans("NotOnSell"); + print '

'; - print ''; + + print "\n"; - if ($product->type == 0) - { - $nblignefour=4; - } - else - { - $nblignefour=4; - } + // Formulaire ajout prix + if ($_GET["action"] == 'add_price' && $user->rights->produit->creer) + { + $langs->load("suppliers"); + + print '
'.$langs->trans("ChangeSupplierPrice").'
'; + + print '
'; + print ''; + print ''; + + if ($_GET["id_fourn"]) { + print ''; + } else { + print ''; + print ''; + } + + print ''; + print ''; + print ''; + + print ''; + print ''; + print '
'.$langs->trans("Supplier").''; + $html=new Form($db); + $html->select_societes('','id_fourn','fournisseur=1'); + print '
'.$langs->trans("Ref").''; + print ''; + print '
'.$langs->trans("Qty").''.$langs->trans("Price").'
 '; + print '
'; + } + + /* ************************************************************************** */ + /* */ + /* Barre d'action */ + /* */ + /* ************************************************************************** */ + + print "\n
\n"; + + if ($_GET["action"] != 'add_price') { + + print ''; + print $langs->trans("AddSupplierPrice").''; + + } + + print "\n
\n"; + print '
'; + + + // Titre liste des fournisseurs + print ''; + if ($product->type == 0) $nblignefour=4; + else $nblignefour=4; print ''; print ''; print ''; - print ''; + print ''; + print ''; + print ''; print ''; - - $sql = "SELECT s.nom, s.idp, pf.ref_fourn, pfp.price, pfp.quantity"; - $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; - $sql .= " , ".MAIN_DB_PREFIX."product_fournisseur as pf"; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_fournisseur_price as pfp"; - $sql .=" ON pf.fk_soc = pfp.fk_soc AND pf.fk_product = pfp.fk_product"; - $sql .=" WHERE pf.fk_soc = s.idp AND pf.fk_product = ".$product->id; - $sql .= " ORDER BY lower(s.nom), pfp.quantity"; - if ( $db->query($sql) ) + // Liste des fournisseurs + $sql = "SELECT s.nom, s.idp, pf.ref_fourn, pfp.price, pfp.quantity"; + $sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."product_fournisseur as pf"; + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_fournisseur_price as pfp"; + $sql.= " ON pf.fk_soc = pfp.fk_soc AND pf.fk_product = pfp.fk_product"; + $sql.= " WHERE pf.fk_soc = s.idp AND pf.fk_product = ".$product->id; + $sql.= " ORDER BY lower(s.nom), pfp.quantity"; + + $resql=$db->query($sql); + if ($resql) { - $num = $db->num_rows(); + $num = $db->num_rows($resql); $i = 0; $var=True; while ($i < $num) { - $objp = $db->fetch_object(); + $objp = $db->fetch_object($resql); $var=!$var; + print ""; print ''; + + // Fournisseur print ''; + + // Quantité print ''; + // Prix quantité print '"; + print $objp->price?price($objp->price):""; + print ''; + + // Prix unitaire + print ''; + + print ''; + print ''; - if ($_GET["action"] == 'add_price' - && $user->rights->produit->creer - && $_GET["qty"] == $objp->quantity - && $_GET["id_fourn"] == $objp->idp) - { - $langs->load("suppliers"); - - - print ''; - print ''; - print ''; - - print ''; - - print ''; - print ''; - print ''; - print ''; - } $i++; } - $db->free(); + $db->free($resql); } - - print ''; - print "
'; print $langs->trans("Suppliers").''.$langs->trans("Ref").''.$langs->trans("Qty").''.$langs->trans("BuiingPrice").''.$langs->trans("BuyingPrice").''.$langs->trans("UnitPrice").' 
'.$objp->nom.''.$objp->ref_fourn.''; print $objp->quantity; print ''; - print price($objp->price); - print ''; - print img_edit(). "'; + print $objp->quantity?price($objp->price / $objp->quantity):" "; + print ''; + if ($user->rights->produit->modifier) { + print ''.img_edit().""; + } + print '
Modifier le prix
  '; - print '

\n"; - print "\n"; + else { + dolibarr_print_error($db); + } + + print ''; } } } @@ -237,17 +318,7 @@ else } -/* ************************************************************************** */ -/* */ -/* Barre d'action */ -/* */ -/* ************************************************************************** */ - -print "\n
\n"; - -print "\n
\n"; - $db->close(); -llxFooter("Dernière modification $Date$ révision $Revision$"); +llxFooter('$Date$ - $Revision$'); ?> diff --git a/htdocs/product/photos.php b/htdocs/product/photos.php index a66fb93c568..81fb84202bf 100644 --- a/htdocs/product/photos.php +++ b/htdocs/product/photos.php @@ -18,7 +18,6 @@ * * $Id$ * $Source$ - * */ /** @@ -41,118 +40,164 @@ $mesg = ''; if (!$user->rights->produit->lire) accessforbidden(); - $types[0] = $langs->trans("Product"); $types[1] = $langs->trans("Service"); + /* - * + * Actions */ if ( $_POST["sendit"] && defined('MAIN_UPLOAD_DOC') && MAIN_UPLOAD_DOC == 1) { - if ($_GET["id"]) - { - $product = new Product($db); - $result = $product->fetch($_GET["id"]); + if ($_GET["id"]) + { + $product = new Product($db); + $result = $product->fetch($_GET["id"]); - // if (doliMoveFileUpload($_FILES['userfile']['tmp_name'], $upload_dir . "/" . $_FILES['userfile']['name'])) + // if (doliMoveFileUpload($_FILES['userfile']['tmp_name'], $upload_dir . "/" . $_FILES['userfile']['name'])) - // var_dump($_FILES); + // var_dump($_FILES); - $product->add_photo($conf->produit->dir_output, $_FILES['photofile']); + $product->add_photo($conf->produit->dir_output, $_FILES['photofile']); } } + + /* * */ llxHeader("","",$langs->trans("CardProduct0")); -/* - * Fiche produit - */ + if ($_GET["id"]) { - - $product = new Product($db); - $result = $product->fetch($_GET["id"]); - - if ( $result ) - { + $product = new Product($db); + $result = $product->fetch($_GET["id"]); - /* - * En mode visu - */ - - $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++; - - if ($conf->stock->enabled) - { - $head[$h][0] = DOL_URL_ROOT."/product/stock/product.php?id=".$product->id; - $head[$h][1] = $langs->trans("Stock"); - $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/photos.php?id=".$product->id; - $head[$h][1] = $langs->trans("Photos"); - $hselected = $h; - $h++; - - $head[$h][0] = DOL_URL_ROOT."/product/stats/fiche.php?id=".$product->id; - $head[$h][1] = $langs->trans('Statistics'); - $h++; + if ($result) + { + /* + * En mode visu + */ - dolibarr_fiche_head($head, $hselected, $langs->trans("CardProduct".$product->type).' : '.$product->ref); + $h=0; - print($mesg); - print ''; - print ""; - print ''; - print ''; - print ''; - print ''; + $head[$h][0] = DOL_URL_ROOT."/product/fiche.php?id=".$product->id; + $head[$h][1] = $langs->trans("Card"); + $h++; - print "
'.$langs->trans("Ref").''.$product->ref.''; - if ($product->envente) - { - print $langs->trans("OnSell"); - } - else - { - print $langs->trans("NotOnSell"); - } - print '
'.$langs->trans("Label").''.$product->libelle.'

\n"; + $head[$h][0] = DOL_URL_ROOT."/product/price.php?id=".$product->id; + $head[$h][1] = $langs->trans("Price"); + $h++; - // Affiche photos - $nbphoto=$product->show_photos($conf->produit->dir_output,1); - if ($nbphoto < 1) print $langs->trans("NoPhotoYet")."

"; - print "\n"; - } + $head[$h][0] = DOL_URL_ROOT."/product/photos.php?id=".$product->id; + $head[$h][1] = $langs->trans("Photos"); + $hselected = $h; + $h++; + + if ($conf->stock->enabled) + { + $head[$h][0] = DOL_URL_ROOT."/product/stock/product.php?id=".$product->id; + $head[$h][1] = $langs->trans("Stock"); + $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++; + + dolibarr_fiche_head($head, $hselected, $langs->trans("CardProduct".$product->type).' : '.$product->ref); + + print($mesg); + + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + + // Prix + print ''; + + // Statut + print ''; + + print "
'.$langs->trans("Ref").''.$product->ref.'
'.$langs->trans("Label").''.$product->libelle.'
'.$langs->trans("SellingPrice").''.price($product->price).'
'.$langs->trans("Status").''; + if ($product->envente) print $langs->trans("OnSell"); + else print $langs->trans("NotOnSell"); + print '

\n"; + + print "\n"; + + + + /* ************************************************************************** */ + /* */ + /* Barre d'action */ + /* */ + /* ************************************************************************** */ + + print "\n
\n"; + + if ($_GET["action"] != 'ajout_photo' && $user->rights->produit->creer && $conf->upload) + { + print ''; + print $langs->trans("AddPhoto").''; + } + + print "\n
\n"; + + /* + * Ajouter une photo + */ + if ($_GET["action"] == 'ajout_photo' && $conf->upload && $user->rights->produit->creer) + { + print_titre($langs->trans("AddPhoto")); + + print '
'; + print ''; + print ''; + + print ''; + print ''; + print ''; + + print ''; + print '
'.$langs->trans("File").' ('.$langs->trans("Size").' <= '.$conf->maxfilesize.')
'; + print '   '; + + print '
'; + print '
'; + } + + + // Affiche photos + if ($_GET["action"] != 'ajout_photo') { + print '
'; + $nbphoto=$product->show_photos($conf->produit->dir_output,1); + if ($nbphoto < 1) print $langs->trans("NoPhotoYet")."

"; + print '
'; + } + } } else { - print $langs->trans("ErrorUnknown"); + print $langs->trans("ErrorUnknown"); } $db->close(); -llxFooter("Dernière modification $Date$ révision $Revision$"); +llxFooter('$Date$ - $Revision$'); ?> diff --git a/htdocs/product/price.php b/htdocs/product/price.php index 8f564cfff09..8279004a527 100644 --- a/htdocs/product/price.php +++ b/htdocs/product/price.php @@ -42,11 +42,36 @@ $types[0] = $langs->trans("Product"); $types[1] = $langs->trans("Service"); +/* + * Actions + */ + +if ($_POST["action"] == 'update_price' && + $_POST["cancel"] <> $langs->trans("Cancel") && $user->rights->produit->creer) +{ + $product = new Product($db); + + $result = $product->fetch($_GET["id"]); + + $product->price = ereg_replace(" ","",$_POST["price"]); + + if ( $product->update_price($product->id, $user) > 0 ) + + { + $_GET["action"] = ''; + $mesg = 'Fiche mise à jour'; + } + else + { + $_GET["action"] = 'edit_price'; + $mesg = 'Fiche non mise à jour !' . "
" . $product->mesg_error; + } +} + /* - * - * + * Affiche historique prix */ llxHeader("","",$langs->trans("Price")); @@ -66,6 +91,10 @@ $head[$h][1] = $langs->trans("Price"); $hselected=$h; $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) @@ -82,10 +111,6 @@ if ($conf->fournisseur->enabled) { $h++; } -$head[$h][0] = DOL_URL_ROOT."/product/photos.php?id=".$product->id; -$head[$h][1] = $langs->trans("Photos"); -$h++; - $head[$h][0] = DOL_URL_ROOT."/product/stats/fiche.php?id=".$product->id; $head[$h][1] = $langs->trans("Statistics"); $h++; @@ -93,7 +118,66 @@ $h++; dolibarr_fiche_head($head, $hselected, $langs->trans("CardProduct".$product->type).' : '.$product->ref); +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +// Prix +print ''; + +// Statut +print ''; + +print "
'.$langs->trans("Ref").''.$product->ref.'
'.$langs->trans("Label").''.$product->libelle.'
'.$langs->trans("SellingPrice").''.price($product->price).'
'.$langs->trans("Status").''; +if ($product->envente) print $langs->trans("OnSell"); +else print $langs->trans("NotOnSell"); +print '

\n"; + +print "\n"; + + + +/* ************************************************************************** */ +/* */ +/* Barre d'action */ +/* */ +/* ************************************************************************** */ + +print "\n
\n"; + +if ($_GET["action"] == '') +{ + if ($user->rights->produit->modifier || $user->rights->produit->creer) + { + print ''.$langs->trans("UpdatePrice").''; + } +} + +print "\n
\n"; + + +/* + * Edition du prix + */ +if ($_GET["action"] == 'edit_price' && $user->rights->produit->creer) +{ + print '
'.$langs->trans("NewPrice").'
'; + print '
'; + print ''; + print ''; + print ''; + print ''; + print ''; + print '
'.$langs->trans('SellingPrice').'
 '; + print '
'; + print '
'; +} + + +// Liste des evolutions du prix $sql = "SELECT p.rowid, p.price, ".$db->pdate("p.date_price")." as dp, u.login"; $sql .= " FROM ".MAIN_DB_PREFIX."product_price as p, llx_user as u"; $sql .= " WHERE fk_product = ".$product->id; @@ -111,7 +195,7 @@ if ($result) $db->free($result) ; // Il doit au moins y avoir la ligne de prix initial. - // On l'ajoute donc pour remettre à niveau pb vieilles versions + // On l'ajoute donc pour remettre à niveau (pb vieilles versions) $product->update_price($product->id, $user); $result = $db->query($sql) ; @@ -120,6 +204,8 @@ if ($result) if ($num > 0) { + print '
'; + print ''; print ''; @@ -135,7 +221,7 @@ if ($result) $objp = $db->fetch_object($result); $var=!$var; print ""; - print ""; + print ""; print ""; print ""; @@ -152,30 +238,8 @@ else dolibarr_print_error($db); } -print "\n"; - - - -/* ************************************************************************** */ -/* */ -/* Barre d'action */ -/* */ -/* ************************************************************************** */ - -print "\n
\n"; - -if ($_GET["action"] == '') -{ - if ($user->rights->produit->modifier || $user->rights->produit->creer) - { - print ''.$langs->trans("UpdatePrice").''; - } -} - -print "\n
\n"; - $db->close(); -llxFooter("Dernière modification $Date$ révision $Revision$"); +llxFooter('$Date$ - $Revision$'); ?> diff --git a/htdocs/product/stats/fiche.php b/htdocs/product/stats/fiche.php index 9c1d64ee044..24227e72e0c 100644 --- a/htdocs/product/stats/fiche.php +++ b/htdocs/product/stats/fiche.php @@ -1,6 +1,6 @@ - * Copyright (c) 2004 Laurent Destailleur + * Copyright (c) 2004-2005 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 @@ -21,11 +21,11 @@ * */ -/*! - \file htdocs/product/stats/fiche.php - \ingroup product - \brief Page des stats produits - \version $Revision$ +/** + \file htdocs/product/stats/fiche.php + \ingroup product + \brief Page des stats produits + \version $Revision$ */ require("./pre.inc.php"); @@ -48,12 +48,12 @@ else } -llxHeader('','Statistiques produits'); +llxHeader('',$langs->trans("Statistics")); $mesg = ''; + /* - * * */ @@ -62,11 +62,11 @@ if ($_GET["id"]) $product = new Product($db); $result = $product->fetch($_GET["id"]); - if ( $result ) + if ($result) { // Efface rep obsolete if(is_dir(DOL_DOCUMENT_ROOT."/document/produits")) - rmdir(DOL_DOCUMENT_ROOT."/document/produits"); + rmdir(DOL_DOCUMENT_ROOT."/document/produits"); // Création répertoire pour images générées // $conf->produit->dir_images définit dans master.inc.php @@ -119,6 +119,10 @@ if ($_GET["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) @@ -136,10 +140,6 @@ if ($_GET["id"]) $h++; } - $head[$h][0] = DOL_URL_ROOT."/product/photos.php?id=".$product->id; - $head[$h][1] = $langs->trans("Photos"); - $h++; - $head[$h][0] = DOL_URL_ROOT."/product/stats/fiche.php?id=".$product->id; $head[$h][1] = $langs->trans("Statistics"); $hselected=$h; @@ -149,11 +149,13 @@ if ($_GET["id"]) dolibarr_fiche_head($head, $hselected, $langs->trans("CardProduct".$product->type).' : '.$product->ref); - print '
".dolibarr_print_date($objp->dp,"%d %B %Y %H:%M:%S")."".dolibarr_print_date($objp->dp,"%d %b %Y %H:%M:%S")."".price($objp->price)."".$objp->login."
'; - print ''; - print ''; - print ''; - print ''; + print '
'.$langs->trans("Ref").''.$product->ref.''.$langs->trans("Statistics").'
'.$langs->trans("Label").''.$product->libelle.'
'; + print ''; + print ''; + print ''; + print ''; + + print ''; print ''; - print ''; + + // Statut + print ''; + print "
'.$langs->trans("Ref").''.$product->ref.'
'.$langs->trans("Label").''.$product->libelle.'
'.$langs->trans("SellingPrice").''.price($product->price).''; // Propals if ($conf->propal->enabled) @@ -175,7 +177,13 @@ if ($_GET["id"]) print ''.$langs->trans("Bills").' : '.$product->count_facture($socid); } print '
'.$langs->trans("CurrentPrice").''.price($product->price).'
'.$langs->trans("Status").''; + if ($product->envente) print $langs->trans("OnSell"); + else print $langs->trans("NotOnSell"); + print '
"; print '
'; @@ -249,7 +257,9 @@ else dolibarr_print_error(); } + $db->close(); -llxFooter("Dernière modification $Date$ révision $Revision$"); +llxFooter('$Date$ - $Revision$'); + ?>