From c1e5eea5f8310bc0847d6dc9869d8277332d8da3 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 23 Aug 2005 18:04:15 +0000 Subject: [PATCH] Correction methode select et ajout methode show_documents. --- htdocs/html.form.class.php | 161 ++++++++++++++++++++++++++----------- 1 file changed, 113 insertions(+), 48 deletions(-) diff --git a/htdocs/html.form.class.php b/htdocs/html.form.class.php index 3ce2ac59363..060024566d8 100644 --- a/htdocs/html.form.class.php +++ b/htdocs/html.form.class.php @@ -1142,54 +1142,38 @@ class Form } } - /** - * \brief Affiche liste déroulante - * - */ - function select($name, $sql, $id='') - { - - $result = $this->db->query($sql); - if ($result) - { - - print '"; - } - else - { - print $this->db->error(); - } - - } + /** + * \brief Affiche liste déroulante depuis requete SQL + * \param Nom de la zone select + * \param Requete sql + * \param Id présélectionné + */ + function select($name, $sql, $id='') + { + $resql = $this->db->query($sql); + if ($resql) + { + print '\n"; + } + else + { + dolibarr_print_error($this->db); + } + } /** \brief Affiche un select à partir d'un tableau @@ -1368,6 +1352,87 @@ class Form print "\n\n\n"; } + /** + * \brief Affiche la cartouche de la liste des documents d'une propale, facture... + * \param modulepart propal=propal, facture=facture, ... + * \param filename Nom fichier + * \param filedir Repertoire à scanner + * \param urlsource Url page origine + * \param genallowed Génération autorisée + * \param delallowed Suppression autorisée + * \remarks Le fichier de facture détaillée est de la forme + * REFFACTURE-XXXXXX-detail.pdf ou XXXXX est une forme diverse + */ + function show_documents($modulepart,$filename,$filedir,$urlsource,$genallowed,$delallowed=0,$modelselected='') + { + global $langs,$bc; + $var=true; + + $filename = sanitize_string($filename); + $relativepath = "${filename}/${filename}.pdf"; + $fullpathfile = $filedir . "/" . $filename . ".pdf"; + + if ($genallowed) + { + print '
'; + print ''; + } + + print_titre($langs->trans("Documents")); + print ''; + + if ($genallowed) + { + $liste=array(); + if ($modulepart == 'propal') + { + $liste=$this->select("ee","select nom as id, nom as lib from ".MAIN_DB_PREFIX."propal_model_pdf"); + } + elseif ($modulepart == 'facture') + { + $liste=$this->select(""); + } + else + { + dolibarr_print_error($this->db,'Bad value for modulepart'); + } + print ''; + } + + if (is_dir($filedir)) + { + $handle=opendir($filedir); + while (($file = readdir($handle))!==false) + { + if (is_readable($filedir."/".$file) && eregi('\.pdf$',$file)) + { + print ""; + if (eregi('\-detail\.pdf',$file)) print ''; + else print ''; + + $relativepathdetail = "${filename}/$file"; + + print ''; + print ''; + print ''; + print ''; + } + } + } + + print "
'.$langs->trans('Model').''; + $this->select_array('modelpdf',$liste,$modelselected); + $texte=$langs->trans('Generate'); + print ''; + print '
PDF DétailléPDF'.$file.''.filesize($filedir."/".$file). ' bytes'.strftime("%d %b %Y %H:%M:%S",filemtime($filedir."/".$file)).'
\n"; + + if ($genallowed) + { + print '
'; + } + + } + } ?>