From 15967a8ddd7176437eef72eb907186a5924f6b12 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 10 Jun 2008 22:51:18 +0000 Subject: [PATCH] Look: Modif esthetiques --- htdocs/html.formfile.class.php | 576 ++++++++++++++++----------------- 1 file changed, 284 insertions(+), 292 deletions(-) diff --git a/htdocs/html.formfile.class.php b/htdocs/html.formfile.class.php index 108440f7ff1..838b2c76cbb 100644 --- a/htdocs/html.formfile.class.php +++ b/htdocs/html.formfile.class.php @@ -17,66 +17,66 @@ */ /** - \file htdocs/html.formfile.class.php - \brief Fichier de la classe des fonctions prédéfinie de composants html fichiers - \version $Id$ -*/ + \file htdocs/html.formfile.class.php + \brief Fichier de la classe des fonctions prédéfinie de composants html fichiers + \version $Id$ + */ /** - \class FormFile - \brief Classe permettant la génération de composants html fichiers -*/ + \class FormFile + \brief Classe permettant la génération de composants html fichiers + */ class FormFile { var $db; var $error; - + /** - * \brief Constructeur - * \param DB handler d'accès base de donnée - */ + * \brief Constructeur + * \param DB handler d'accès base de donnée + */ function FormFile($DB) { $this->db = $DB; - + return 1; } /** - * \brief Affiche formulaire ajout fichier - * \param url Url - * \param titre Titre zone - * \param addcancel 1=Ajoute un bouton 'Annuler' - * \param sectionid If upload must be done inside a particular ECM section - * \return int <0 si ko, >0 si ok - */ + * \brief Affiche formulaire ajout fichier + * \param url Url + * \param titre Titre zone + * \param addcancel 1=Ajoute un bouton 'Annuler' + * \param sectionid If upload must be done inside a particular ECM section + * \return int <0 si ko, >0 si ok + */ function form_attach_new_file($url,$titre='',$addcancel=0, $sectionid=0) { global $conf,$langs; - + if ($conf->upload != 0) { print "\n\n\n"; - + if (! $titre) $titre=$langs->trans("AttachANewFile"); print_titre($titre); print '
'; print ''; - + print ''; print '
'; - + $max=$conf->upload; // En Kb $maxphp=@ini_get('upload_max_filesize'); // En inconnu if (eregi('m$',$maxphp)) $maxphp=$maxphp*1024; if (eregi('k$',$maxphp)) $maxphp=$maxphp; // Now $max and $maxphp are in Kb if ($maxphp > 0) $max=min($max,$maxphp); - + if ($conf->upload > 0) { print ''; @@ -84,13 +84,13 @@ class FormFile print ''; print '   '; print ''; - + if ($addcancel) { print '   '; print ''; } - + print ' ('.$langs->trans("MaxSize").': '.$max.' '.$langs->trans("Kb"); print ' '.info_admin($langs->trans("ThisLimitIsDefinedInSetup",$max,$maxphp),1); print ')'; @@ -99,292 +99,284 @@ class FormFile print ''; print '
'; - + print "\n\n\n"; } - + return 1; } - - - /** - * \brief Affiche la cartouche de la liste des documents d'une propale, facture... - * \param modulepart propal=propal, facture=facture, ... - * \param filename Sous rep à scanner (vide si filedir deja complet) - * \param filedir Repertoire à scanner - * \param urlsource Url page origine - * \param genallowed Génération autorisée (1/0 ou array des formats) - * \param delallowed Suppression autorisée (1/0) - * \param modelselected Modele à pré-sélectionner par défaut - * \param modelliste Tableau des modeles possibles - * \param forcenomultilang N'affiche pas option langue meme si MAIN_MULTILANGS défini - * \param iconPDF N'affiche que l'icone PDF avec le lien (1/0) - * \remarks Le fichier de facture détaillée est de la forme - * REFFACTURE-XXXXXX-detail.pdf ou XXXXX est une forme diverse - * \return int <0 si ko, nbre de fichiers affichés si ok - */ - function show_documents($modulepart,$filename,$filedir,$urlsource,$genallowed,$delallowed=0,$modelselected='',$modelliste=array(),$forcenomultilang=0,$iconPDF=0) - { - // filedir = conf->...dir_ouput."/".get_exdir(id) - include_once(DOL_DOCUMENT_ROOT.'/lib/files.lib.php'); - - global $langs,$bc,$conf; - $var=true; - - if ($iconPDF == 1) - { - $genallowed = ''; - $delallowed = 0; - $modelselected = ''; - $modelliste = ''; - $forcenomultilang=0; - } - - $filename = sanitize_string($filename); - $headershown=0; - $i=0; - // Affiche en-tete tableau - if ($genallowed) - { - $modellist=array(); - if ($modulepart == 'propal') - { - if (is_array($genallowed)) $modellist=$genallowed; - else - { - include_once(DOL_DOCUMENT_ROOT.'/includes/modules/propale/modules_propale.php'); - $model=new ModelePDFPropales(); - $modellist=$model->liste_modeles($this->db); - } - } - else if ($modulepart == 'commande') - { - if (is_array($genallowed)) $modellist=$genallowed; - else - { - include_once(DOL_DOCUMENT_ROOT.'/includes/modules/commande/modules_commande.php'); - $model=new ModelePDFCommandes(); - $modellist=$model->liste_modeles($this->db); - } - } - elseif ($modulepart == 'expedition') - { - if (is_array($genallowed)) $modellist=$genallowed; - else - { - include_once(DOL_DOCUMENT_ROOT.'/expedition/mods/pdf/ModelePdfExpedition.class.php'); - $model=new ModelePDFExpedition(); - $modellist=$model->liste_modeles($this->db); - } - } - elseif ($modulepart == 'livraison') - { - if (is_array($genallowed)) $modellist=$genallowed; - else - { - include_once(DOL_DOCUMENT_ROOT.'/livraison/mods/modules_livraison.php'); - $model=new ModelePDFDeliveryOrder(); - $modellist=$model->liste_modeles($this->db); - } - } - else if ($modulepart == 'ficheinter') - { - if (is_array($genallowed)) $modellist=$genallowed; - else - { - include_once(DOL_DOCUMENT_ROOT.'/includes/modules/fichinter/modules_fichinter.php'); - $model=new ModelePDFFicheinter(); - $modellist=$model->liste_modeles($this->db); - } - } - elseif ($modulepart == 'facture') - { - if (is_array($genallowed)) $modellist=$genallowed; - else - { - include_once(DOL_DOCUMENT_ROOT.'/includes/modules/facture/modules_facture.php'); - $model=new ModelePDFFactures(); - $modellist=$model->liste_modeles($this->db); - } - } - elseif ($modulepart == 'export') - { - if (is_array($genallowed)) $modellist=$genallowed; - else - { - include_once(DOL_DOCUMENT_ROOT.'/includes/modules/export/modules_export.php'); - $model=new ModeleExports(); - $modellist=$model->liste_modeles($this->db); - } - } - else if ($modulepart == 'commande_fournisseur') - { - if (is_array($genallowed)) $modellist=$genallowed; - else - { - include_once(DOL_DOCUMENT_ROOT.'/fourn/commande/modules/modules_commandefournisseur.php'); - $model=new ModelePDFSuppliersOrders(); - $modellist=$model->liste_modeles($this->db); - } - } - else if ($modulepart == 'facture_fournisseur') - { - if (is_array($genallowed)) $modellist=$genallowed; - else - { - include_once(DOL_DOCUMENT_ROOT.'/fourn/facture/modules/modules_facturefournisseur.php'); - $model=new ModelePDFFacturesSuppliers(); - $modellist=$model->liste_modeles($this->db); - } - } - else if ($modulepart == 'remisecheque') - { - if (is_array($genallowed)) $modellist=$genallowed; - else - { - // ?? - } - } - else - { - dolibarr_print_error($this->db,'Bad value for modulepart'); - return -1; - } - - $headershown=1; - - $html = new Form($db); - - print '
'; - print ''; - - print_titre($langs->trans("Documents")); - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - } + /** + * \brief Affiche la cartouche de la liste des documents d'une propale, facture... + * \param modulepart propal=propal, facture=facture, ... + * \param filename Sous rep à scanner (vide si filedir deja complet) + * \param filedir Repertoire à scanner + * \param urlsource Url page origine + * \param genallowed Génération autorisée (1/0 ou array des formats) + * \param delallowed Suppression autorisée (1/0) + * \param modelselected Modele à pré-sélectionner par défaut + * \param modelliste Tableau des modeles possibles + * \param forcenomultilang N'affiche pas option langue meme si MAIN_MULTILANGS défini + * \param iconPDF N'affiche que l'icone PDF avec le lien (1/0) + * \remarks Le fichier de facture détaillée est de la forme + * REFFACTURE-XXXXXX-detail.pdf ou XXXXX est une forme diverse + * \return int <0 si ko, nbre de fichiers affichés si ok + */ + function show_documents($modulepart,$filename,$filedir,$urlsource,$genallowed,$delallowed=0,$modelselected='',$modelliste=array(),$forcenomultilang=0,$iconPDF=0) + { + // filedir = conf->...dir_ouput."/".get_exdir(id) + include_once(DOL_DOCUMENT_ROOT.'/lib/files.lib.php'); - // Recupe liste des fichiers - $png = ''; - $filter = ''; - if ($iconPDF==1) - { - $png = '|\.png$'; - $filter = $filename.'.pdf'; - } - $file_list=dol_dir_list($filedir,'files',0,$filter,'\.meta$'.$png,'date',SORT_DESC); - - // Affiche en-tete tableau si non deja affiché + global $langs,$bc,$conf; + $var=true; + + if ($iconPDF == 1) + { + $genallowed = ''; + $delallowed = 0; + $modelselected = ''; + $modelliste = ''; + $forcenomultilang=0; + } + + $filename = sanitize_string($filename); + $headershown=0; + $i=0; + + // Affiche en-tete tableau + if ($genallowed) + { + $modellist=array(); + if ($modulepart == 'propal') + { + if (is_array($genallowed)) $modellist=$genallowed; + else + { + include_once(DOL_DOCUMENT_ROOT.'/includes/modules/propale/modules_propale.php'); + $model=new ModelePDFPropales(); + $modellist=$model->liste_modeles($this->db); + } + } + else if ($modulepart == 'commande') + { + if (is_array($genallowed)) $modellist=$genallowed; + else + { + include_once(DOL_DOCUMENT_ROOT.'/includes/modules/commande/modules_commande.php'); + $model=new ModelePDFCommandes(); + $modellist=$model->liste_modeles($this->db); + } + } + elseif ($modulepart == 'expedition') + { + if (is_array($genallowed)) $modellist=$genallowed; + else + { + include_once(DOL_DOCUMENT_ROOT.'/expedition/mods/pdf/ModelePdfExpedition.class.php'); + $model=new ModelePDFExpedition(); + $modellist=$model->liste_modeles($this->db); + } + } + elseif ($modulepart == 'livraison') + { + if (is_array($genallowed)) $modellist=$genallowed; + else + { + include_once(DOL_DOCUMENT_ROOT.'/livraison/mods/modules_livraison.php'); + $model=new ModelePDFDeliveryOrder(); + $modellist=$model->liste_modeles($this->db); + } + } + else if ($modulepart == 'ficheinter') + { + if (is_array($genallowed)) $modellist=$genallowed; + else + { + include_once(DOL_DOCUMENT_ROOT.'/includes/modules/fichinter/modules_fichinter.php'); + $model=new ModelePDFFicheinter(); + $modellist=$model->liste_modeles($this->db); + } + } + elseif ($modulepart == 'facture') + { + if (is_array($genallowed)) $modellist=$genallowed; + else + { + include_once(DOL_DOCUMENT_ROOT.'/includes/modules/facture/modules_facture.php'); + $model=new ModelePDFFactures(); + $modellist=$model->liste_modeles($this->db); + } + } + elseif ($modulepart == 'export') + { + if (is_array($genallowed)) $modellist=$genallowed; + else + { + include_once(DOL_DOCUMENT_ROOT.'/includes/modules/export/modules_export.php'); + $model=new ModeleExports(); + $modellist=$model->liste_modeles($this->db); + } + } + else if ($modulepart == 'commande_fournisseur') + { + if (is_array($genallowed)) $modellist=$genallowed; + else + { + include_once(DOL_DOCUMENT_ROOT.'/fourn/commande/modules/modules_commandefournisseur.php'); + $model=new ModelePDFSuppliersOrders(); + $modellist=$model->liste_modeles($this->db); + } + } + else if ($modulepart == 'facture_fournisseur') + { + if (is_array($genallowed)) $modellist=$genallowed; + else + { + include_once(DOL_DOCUMENT_ROOT.'/fourn/facture/modules/modules_facturefournisseur.php'); + $model=new ModelePDFFacturesSuppliers(); + $modellist=$model->liste_modeles($this->db); + } + } + else if ($modulepart == 'remisecheque') + { + if (is_array($genallowed)) $modellist=$genallowed; + else + { + // ?? + } + } + else + { + dolibarr_print_error($this->db,'Bad value for modulepart'); + return -1; + } + + $headershown=1; + + $html = new Form($db); + + print ''; + print ''; + + print_titre($langs->trans("Documents")); + print '
'.$langs->trans('Model').''; - $html->select_array('model',$modellist,$modelselected,0,0,1); - $texte=$langs->trans('Generate'); - print ''; - if($conf->global->MAIN_MULTILANGS && ! $forcenomultilang) - { - $html->select_lang($langs->getDefaultLang()); - } - else - { - print ' '; - } - print ''; - print ''; - print '
'; + + print ''; + print ''; + print ''; + print ''; + } + + // Recupe liste des fichiers + $png = ''; + $filter = ''; + if ($iconPDF==1) + { + $png = '|\.png$'; + $filter = $filename.'.pdf'; + } + $file_list=dol_dir_list($filedir,'files',0,$filter,'\.meta$'.$png,'date',SORT_DESC); + + // Affiche en-tete tableau si non deja affiché if (sizeof($file_list) && ! $headershown && !$iconPDF) { $headershown=1; - print_titre($langs->trans("Documents")); - print '
'.$langs->trans('Model').' '; + $html->select_array('model',$modellist,$modelselected,0,0,1); + $texte=$langs->trans('Generate'); + print ''; + if($conf->global->MAIN_MULTILANGS && ! $forcenomultilang) + { + $html->select_lang($langs->getDefaultLang()); + } + else + { + print ' '; + } + print ''; + print ''; + print '
'; - } - + print_titre($langs->trans("Documents")); + print '
'; + } + // Boucle sur chaque ligne trouvée foreach($file_list as $i => $file) { + $var=!$var; + // Défini chemin relatif par rapport au module pour lien download - $relativepath=$file["name"]; // Cas general - if ($filename) $relativepath=$filename."/".$file["name"]; // Cas propal, facture... - // Autre cas - if ($modulepart == 'don') { $relativepath = get_exdir($filename,2).$file["name"]; } - if ($modulepart == 'export') { $relativepath = $file["name"]; } - - // Défini le type MIME du document - if (eregi('\.([^\.]+)$',$file["name"],$reg)) $extension=$reg[1]; - $mimetype=strtoupper($extension); - if ($extension == 'pdf') $mimetype='PDF'; - if ($extension == 'html') $mimetype='HTML'; - if (eregi('\-detail\.pdf',$file["name"])) $mimetype='PDF Détaillé'; + $relativepath=$file["name"]; // Cas general + if ($filename) $relativepath=$filename."/".$file["name"]; // Cas propal, facture... + // Autre cas + if ($modulepart == 'don') { $relativepath = get_exdir($filename,2).$file["name"]; } + if ($modulepart == 'export') { $relativepath = $file["name"]; } - if (!$iconPDF) print ""; + if (!$iconPDF) print ""; - // Affiche colonne type MIME - if (!$iconPDF) print ''; - // Affiche nom fichier avec lien download - if (!$iconPDF) print ''; - // Affiche taille fichier - if (!$iconPDF) print ''; - // Affiche date fichier - if (!$iconPDF) print ''; + // Affiche taille fichier + if (!$iconPDF) print ''; + // Affiche date fichier + if (!$iconPDF) print ''; if ($delallowed) { - print ''; + print ''; } - if (!$iconPDF) print ''; + if (!$iconPDF) print ''; + + $i++; + } + + + if ($headershown) + { + // Affiche pied du tableau + print "
'.$mimetype.''; - print ''; - if (!$iconPDF) - { - print $file["name"]; - } - else - { - print img_pdf($file["name"],2); - } + // Affiche nom fichier avec lien download + if (!$iconPDF) print ''; + print ''; + if (!$iconPDF) + { + print img_mime($file["name"]).' '.dolibarr_trunc($file["name"],28); + } + else + { + print img_pdf($file["name"],2); + } print ''; if (!$iconPDF) print ''.filesize($filedir."/".$file["name"]). ' bytes'.dolibarr_print_date(filemtime($filedir."/".$file["name"]),'dayhour').''.filesize($filedir."/".$file["name"]). ' bytes'.dolibarr_print_date(filemtime($filedir."/".$file["name"]),'dayhour').''.img_delete().''.img_delete().'
\n"; + if ($genallowed) + { + print '
'; + } + } - $i++; - } - - - if ($headershown) - { - // Affiche pied du tableau - print "
\n"; - if ($genallowed) - { - print ''; - } - } - return ($i?$i:$headershown); } - + /** - * \brief Show list of documents in a directory - * \param filearray Array of files loaded by dol_dir_list function - * \param object Object on which document is linked to - * \param modulepart Value for modulepart used by download wrapper - * \param param Parameters on sort links - * \param forcedownload Mime type is forced to 'application/binary' to have a download - * \param relativepath Relative path of docs (autodefined if not provided) - * \param permtodelete Permission to delete - * \return int <0 if KO, nb of files shown if OK - */ - function list_of_documents($filearray,$object,$modulepart,$param,$forcedownload=0,$relativepath='',$permtodelete=1) - { - global $user, $conf, $langs; - global $bc; - global $sortfield, $sortorder; - + * \brief Show list of documents in a directory + * \param filearray Array of files loaded by dol_dir_list function + * \param object Object on which document is linked to + * \param modulepart Value for modulepart used by download wrapper + * \param param Parameters on sort links + * \param forcedownload Mime type is forced to 'application/binary' to have a download + * \param relativepath Relative path of docs (autodefined if not provided) + * \param permtodelete Permission to delete + * \return int <0 if KO, nb of files shown if OK + */ + function list_of_documents($filearray,$object,$modulepart,$param,$forcedownload=0,$relativepath='',$permtodelete=1) + { + global $user, $conf, $langs; + global $bc; + global $sortfield, $sortorder; + // Affiche liste des documents existant - print_titre($langs->trans("AttachedFiles")); - + print_titre($langs->trans("AttachedFiles")); + $url=$_SERVER["PHP_SELF"]; print ''; print ''; @@ -393,15 +385,15 @@ class FormFile print_liste_field_titre($langs->trans("Date"),$_SERVER["PHP_SELF"],"date","",$param,'align="center"',$sortfield,$sortorder); print ''; print ''; - + $var=true; foreach($filearray as $key => $file) { if (!is_dir($dir.$file['name']) - && $file['name'] != '.' - && $file['name'] != '..' - && $file['name'] != 'CVS' - && ! eregi('\.meta$',$file['name'])) + && $file['name'] != '.' + && $file['name'] != '..' + && $file['name'] != 'CVS' + && ! eregi('\.meta$',$file['name'])) { // Define relative path used to store the file if (! $relativepath) @@ -409,7 +401,7 @@ class FormFile $relativepath=$object->ref.'/'; if ($modulepart == 'facture_fournisseur') $relativepath=get_exdir($object->id,2).$relativepath; } - + $var=!$var; print "'; print ''; print '\n"; } }
 
"; print ''.dol_print_size($file['size']).''.dolibarr_print_date($file['date'],"dayhour").''; - //print ' '; + //print ' '; if ($permtodelete) - print ''.img_delete().''; + print ''.img_delete().''; else - print ' '; + print ' '; print "