From bb6209d3cb9d0b20fee5ed16b3b8f9f5e965e1dc Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 27 Apr 2005 00:29:32 +0000 Subject: [PATCH] Qual: Mutualisation de la liste des produits par la fonction html->select_produit --- htdocs/compta/facture.php | 35 +++++------------------------ htdocs/contrat/fiche.php | 31 +++---------------------- htdocs/html.form.class.php | 46 +++++++++++++++++++++++++++++++++++--- 3 files changed, 51 insertions(+), 61 deletions(-) diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index c2ae624f00a..9b5ae92558a 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -604,33 +604,6 @@ if ($_GET["action"] == 'create') { print ' '; print ''; - /* - * - * Liste des elements - * - */ - $sql = "SELECT p.rowid,p.label,p.ref,p.price FROM ".MAIN_DB_PREFIX."product as p "; - $sql .= " WHERE envente = 1"; - $sql .= " ORDER BY p.nbvente DESC LIMIT ".$conf->liste_limit; - if ( $db->query($sql) ) - { - $opt = ""; - if ($result) - { - $num = $db->num_rows(); $i = 0; - while ($i < $num) - { - $objp = $db->fetch_object(); - $opt .= "\n"; - $i++; - } - } - $db->free(); - } - else - { - dolibarr_print_error($db); - } print ''; print ''; @@ -639,7 +612,9 @@ if ($_GET["action"] == 'create') } for ($i = 1 ; $i <= $NBLINES ; $i++) { - print ''; + print ''; print ''; print ''; print ''; @@ -648,7 +623,7 @@ if ($_GET["action"] == 'create') print ''; } @@ -1551,7 +1526,7 @@ else else { /* Facture non trouvée */ - print "Facture inexistante"; + print "Facture ".$_GET["facid"]." inexistante"; } } else diff --git a/htdocs/contrat/fiche.php b/htdocs/contrat/fiche.php index fdbffe16b51..d5b97d0d2fa 100644 --- a/htdocs/contrat/fiche.php +++ b/htdocs/contrat/fiche.php @@ -619,33 +619,6 @@ else */ if ($user->rights->contrat->creer) { - $sql = "SELECT p.rowid, p.label, p.ref, p.price, p.duration"; - $sql.= " FROM ".MAIN_DB_PREFIX."product as p "; - $sql.= " WHERE p.envente = 1"; - $sql.= " ORDER BY p.nbvente DESC LIMIT 20"; - - if ( $db->query($sql) ) - { - $opt = ""; - - $num = $db->num_rows(); - $i = 0; - while ($i < $num) - { - $objp = $db->fetch_object(); - $opt .= "\n"; - $i++; - } - - $db->free(); - } - else - { - dolibarr_print_error($db); - } - print ''; print ''; print ''; @@ -674,7 +647,9 @@ else $var=!$var; print ""; print ''; - print ''; + print ''; print ''; print ''; print ''; diff --git a/htdocs/html.form.class.php b/htdocs/html.form.class.php index f6fdadeb6da..9e8607b2af8 100644 --- a/htdocs/html.form.class.php +++ b/htdocs/html.form.class.php @@ -270,7 +270,6 @@ class Form * \brief Retourne la liste déroulante des sociétés * \param */ - function select_societes($selected='',$htmlname='soc_id') { // On recherche les societes @@ -306,11 +305,11 @@ class Form } } + /** * \brief Retourne la liste déroulante des contacts d'une société donnée * */ - function select_contacts($socid,$selected='',$htmlname='contactid') { // On recherche les societes @@ -350,11 +349,52 @@ class Form } + /** + * \brief Retourne la liste des produits + * \param selected Produit présélectionné + * \param filtretype Pour filtre sur type de produit + */ + function select_produits($selected='',$htmlname='productid',$filtretype='',$limit=20) + { + $sql = "SELECT p.rowid, p.label, p.ref, p.price, p.duration"; + $sql.= " FROM ".MAIN_DB_PREFIX."product as p "; + $sql.= " WHERE p.envente = 1"; + if ($filtretype && $filtretype != '') $sql.=" AND p.fk_product_type=".$filtretype; + $sql.= " ORDER BY p.nbvente DESC"; + $sql.= " LIMIT $limit"; + + $result=$this->db->query($sql); + if ($result) + { + print ''; + + $this->db->free($result); + } + else + { + dolibarr_print_error($db); + } + } + + /** * \brief Retourne le nom d'un pays * \param id id du pays */ - function pays_name($id) { $sql = "SELECT rowid, libelle FROM ".MAIN_DB_PREFIX."c_pays";
Services/Produits prédéfinis'.$langs->trans("Qty").''.$langs->trans("Discount").'    
'; + $html->select_produits('',"idprod$i"); + print '% '; print 'Du '; print $html->select_date('',"date_start$i",0,0,1); - print ' au '; + print '
au '; print $html->select_date('',"date_end$i",0,0,1); print '
 '; + $html->select_produits('','p_idprod'); + print '%