Look: Modif esthetiques

This commit is contained in:
Laurent Destailleur 2008-06-10 22:51:18 +00:00
parent 1390a2af60
commit 15967a8ddd

View File

@ -17,16 +17,16 @@
*/ */
/** /**
\file htdocs/html.formfile.class.php \file htdocs/html.formfile.class.php
\brief Fichier de la classe des fonctions prédéfinie de composants html fichiers \brief Fichier de la classe des fonctions prédéfinie de composants html fichiers
\version $Id$ \version $Id$
*/ */
/** /**
\class FormFile \class FormFile
\brief Classe permettant la génération de composants html fichiers \brief Classe permettant la génération de composants html fichiers
*/ */
class FormFile class FormFile
{ {
var $db; var $db;
@ -34,9 +34,9 @@ class FormFile
/** /**
* \brief Constructeur * \brief Constructeur
* \param DB handler d'accès base de donnée * \param DB handler d'accès base de donnée
*/ */
function FormFile($DB) function FormFile($DB)
{ {
$this->db = $DB; $this->db = $DB;
@ -46,13 +46,13 @@ class FormFile
/** /**
* \brief Affiche formulaire ajout fichier * \brief Affiche formulaire ajout fichier
* \param url Url * \param url Url
* \param titre Titre zone * \param titre Titre zone
* \param addcancel 1=Ajoute un bouton 'Annuler' * \param addcancel 1=Ajoute un bouton 'Annuler'
* \param sectionid If upload must be done inside a particular ECM section * \param sectionid If upload must be done inside a particular ECM section
* \return int <0 si ko, >0 si ok * \return int <0 si ko, >0 si ok
*/ */
function form_attach_new_file($url,$titre='',$addcancel=0, $sectionid=0) function form_attach_new_file($url,$titre='',$addcancel=0, $sectionid=0)
{ {
global $conf,$langs; global $conf,$langs;
@ -107,283 +107,275 @@ class FormFile
} }
/** /**
* \brief Affiche la cartouche de la liste des documents d'une propale, facture... * \brief Affiche la cartouche de la liste des documents d'une propale, facture...
* \param modulepart propal=propal, facture=facture, ... * \param modulepart propal=propal, facture=facture, ...
* \param filename Sous rep à scanner (vide si filedir deja complet) * \param filename Sous rep à scanner (vide si filedir deja complet)
* \param filedir Repertoire à scanner * \param filedir Repertoire à scanner
* \param urlsource Url page origine * \param urlsource Url page origine
* \param genallowed Génération autorisée (1/0 ou array des formats) * \param genallowed Génération autorisée (1/0 ou array des formats)
* \param delallowed Suppression autorisée (1/0) * \param delallowed Suppression autorisée (1/0)
* \param modelselected Modele à pré-sélectionner par défaut * \param modelselected Modele à pré-sélectionner par défaut
* \param modelliste Tableau des modeles possibles * \param modelliste Tableau des modeles possibles
* \param forcenomultilang N'affiche pas option langue meme si MAIN_MULTILANGS défini * \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) * \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 * \remarks Le fichier de facture détaillée est de la forme
* REFFACTURE-XXXXXX-detail.pdf ou XXXXX est une forme diverse * REFFACTURE-XXXXXX-detail.pdf ou XXXXX est une forme diverse
* \return int <0 si ko, nbre de fichiers affichés si ok * \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) function show_documents($modulepart,$filename,$filedir,$urlsource,$genallowed,$delallowed=0,$modelselected='',$modelliste=array(),$forcenomultilang=0,$iconPDF=0)
{ {
// filedir = conf->...dir_ouput."/".get_exdir(id) // filedir = conf->...dir_ouput."/".get_exdir(id)
include_once(DOL_DOCUMENT_ROOT.'/lib/files.lib.php'); include_once(DOL_DOCUMENT_ROOT.'/lib/files.lib.php');
global $langs,$bc,$conf; global $langs,$bc,$conf;
$var=true; $var=true;
if ($iconPDF == 1) if ($iconPDF == 1)
{ {
$genallowed = ''; $genallowed = '';
$delallowed = 0; $delallowed = 0;
$modelselected = ''; $modelselected = '';
$modelliste = ''; $modelliste = '';
$forcenomultilang=0; $forcenomultilang=0;
} }
$filename = sanitize_string($filename); $filename = sanitize_string($filename);
$headershown=0; $headershown=0;
$i=0; $i=0;
// Affiche en-tete tableau // Affiche en-tete tableau
if ($genallowed) if ($genallowed)
{ {
$modellist=array(); $modellist=array();
if ($modulepart == 'propal') if ($modulepart == 'propal')
{ {
if (is_array($genallowed)) $modellist=$genallowed; if (is_array($genallowed)) $modellist=$genallowed;
else else
{ {
include_once(DOL_DOCUMENT_ROOT.'/includes/modules/propale/modules_propale.php'); include_once(DOL_DOCUMENT_ROOT.'/includes/modules/propale/modules_propale.php');
$model=new ModelePDFPropales(); $model=new ModelePDFPropales();
$modellist=$model->liste_modeles($this->db); $modellist=$model->liste_modeles($this->db);
} }
} }
else if ($modulepart == 'commande') else if ($modulepart == 'commande')
{ {
if (is_array($genallowed)) $modellist=$genallowed; if (is_array($genallowed)) $modellist=$genallowed;
else else
{ {
include_once(DOL_DOCUMENT_ROOT.'/includes/modules/commande/modules_commande.php'); include_once(DOL_DOCUMENT_ROOT.'/includes/modules/commande/modules_commande.php');
$model=new ModelePDFCommandes(); $model=new ModelePDFCommandes();
$modellist=$model->liste_modeles($this->db); $modellist=$model->liste_modeles($this->db);
} }
} }
elseif ($modulepart == 'expedition') elseif ($modulepart == 'expedition')
{ {
if (is_array($genallowed)) $modellist=$genallowed; if (is_array($genallowed)) $modellist=$genallowed;
else else
{ {
include_once(DOL_DOCUMENT_ROOT.'/expedition/mods/pdf/ModelePdfExpedition.class.php'); include_once(DOL_DOCUMENT_ROOT.'/expedition/mods/pdf/ModelePdfExpedition.class.php');
$model=new ModelePDFExpedition(); $model=new ModelePDFExpedition();
$modellist=$model->liste_modeles($this->db); $modellist=$model->liste_modeles($this->db);
} }
} }
elseif ($modulepart == 'livraison') elseif ($modulepart == 'livraison')
{ {
if (is_array($genallowed)) $modellist=$genallowed; if (is_array($genallowed)) $modellist=$genallowed;
else else
{ {
include_once(DOL_DOCUMENT_ROOT.'/livraison/mods/modules_livraison.php'); include_once(DOL_DOCUMENT_ROOT.'/livraison/mods/modules_livraison.php');
$model=new ModelePDFDeliveryOrder(); $model=new ModelePDFDeliveryOrder();
$modellist=$model->liste_modeles($this->db); $modellist=$model->liste_modeles($this->db);
} }
} }
else if ($modulepart == 'ficheinter') else if ($modulepart == 'ficheinter')
{ {
if (is_array($genallowed)) $modellist=$genallowed; if (is_array($genallowed)) $modellist=$genallowed;
else else
{ {
include_once(DOL_DOCUMENT_ROOT.'/includes/modules/fichinter/modules_fichinter.php'); include_once(DOL_DOCUMENT_ROOT.'/includes/modules/fichinter/modules_fichinter.php');
$model=new ModelePDFFicheinter(); $model=new ModelePDFFicheinter();
$modellist=$model->liste_modeles($this->db); $modellist=$model->liste_modeles($this->db);
} }
} }
elseif ($modulepart == 'facture') elseif ($modulepart == 'facture')
{ {
if (is_array($genallowed)) $modellist=$genallowed; if (is_array($genallowed)) $modellist=$genallowed;
else else
{ {
include_once(DOL_DOCUMENT_ROOT.'/includes/modules/facture/modules_facture.php'); include_once(DOL_DOCUMENT_ROOT.'/includes/modules/facture/modules_facture.php');
$model=new ModelePDFFactures(); $model=new ModelePDFFactures();
$modellist=$model->liste_modeles($this->db); $modellist=$model->liste_modeles($this->db);
} }
} }
elseif ($modulepart == 'export') elseif ($modulepart == 'export')
{ {
if (is_array($genallowed)) $modellist=$genallowed; if (is_array($genallowed)) $modellist=$genallowed;
else else
{ {
include_once(DOL_DOCUMENT_ROOT.'/includes/modules/export/modules_export.php'); include_once(DOL_DOCUMENT_ROOT.'/includes/modules/export/modules_export.php');
$model=new ModeleExports(); $model=new ModeleExports();
$modellist=$model->liste_modeles($this->db); $modellist=$model->liste_modeles($this->db);
} }
} }
else if ($modulepart == 'commande_fournisseur') else if ($modulepart == 'commande_fournisseur')
{ {
if (is_array($genallowed)) $modellist=$genallowed; if (is_array($genallowed)) $modellist=$genallowed;
else else
{ {
include_once(DOL_DOCUMENT_ROOT.'/fourn/commande/modules/modules_commandefournisseur.php'); include_once(DOL_DOCUMENT_ROOT.'/fourn/commande/modules/modules_commandefournisseur.php');
$model=new ModelePDFSuppliersOrders(); $model=new ModelePDFSuppliersOrders();
$modellist=$model->liste_modeles($this->db); $modellist=$model->liste_modeles($this->db);
} }
} }
else if ($modulepart == 'facture_fournisseur') else if ($modulepart == 'facture_fournisseur')
{ {
if (is_array($genallowed)) $modellist=$genallowed; if (is_array($genallowed)) $modellist=$genallowed;
else else
{ {
include_once(DOL_DOCUMENT_ROOT.'/fourn/facture/modules/modules_facturefournisseur.php'); include_once(DOL_DOCUMENT_ROOT.'/fourn/facture/modules/modules_facturefournisseur.php');
$model=new ModelePDFFacturesSuppliers(); $model=new ModelePDFFacturesSuppliers();
$modellist=$model->liste_modeles($this->db); $modellist=$model->liste_modeles($this->db);
} }
} }
else if ($modulepart == 'remisecheque') else if ($modulepart == 'remisecheque')
{ {
if (is_array($genallowed)) $modellist=$genallowed; if (is_array($genallowed)) $modellist=$genallowed;
else else
{ {
// ?? // ??
} }
} }
else else
{ {
dolibarr_print_error($this->db,'Bad value for modulepart'); dolibarr_print_error($this->db,'Bad value for modulepart');
return -1; return -1;
} }
$headershown=1; $headershown=1;
$html = new Form($db); $html = new Form($db);
print '<form action="'.$urlsource.'#builddoc" method="post">'; print '<form action="'.$urlsource.'#builddoc" method="post">';
print '<input type="hidden" name="action" value="builddoc">'; print '<input type="hidden" name="action" value="builddoc">';
print_titre($langs->trans("Documents")); print_titre($langs->trans("Documents"));
print '<table class="border" width="100%">'; print '<table class="border" width="100%">';
print '<tr '.$bc[$var].'>'; print '<tr '.$bc[$var].'>';
print '<td>'.$langs->trans('Model').'</td>'; print '<td align="center">'.$langs->trans('Model').' ';
print '<td align="center">'; $html->select_array('model',$modellist,$modelselected,0,0,1);
$html->select_array('model',$modellist,$modelselected,0,0,1); $texte=$langs->trans('Generate');
$texte=$langs->trans('Generate'); print '</td>';
print '</td>'; print '<td align="center">';
print '<td align="center">'; if($conf->global->MAIN_MULTILANGS && ! $forcenomultilang)
if($conf->global->MAIN_MULTILANGS && ! $forcenomultilang) {
{ $html->select_lang($langs->getDefaultLang());
$html->select_lang($langs->getDefaultLang()); }
} else
else {
{ print '&nbsp;';
print '&nbsp;'; }
} print '</td>';
print '</td>'; print '<td align="center" colspan="'.($delallowed?'2':'1').'">';
print '<td align="center" colspan="'.($delallowed?'2':'1').'">'; print '<input class="button" type="submit" value="'.$texte.'">';
print '<input class="button" type="submit" value="'.$texte.'">'; print '</td></tr>';
print '</td></tr>'; }
}
// Recupe liste des fichiers // Recupe liste des fichiers
$png = ''; $png = '';
$filter = ''; $filter = '';
if ($iconPDF==1) if ($iconPDF==1)
{ {
$png = '|\.png$'; $png = '|\.png$';
$filter = $filename.'.pdf'; $filter = $filename.'.pdf';
} }
$file_list=dol_dir_list($filedir,'files',0,$filter,'\.meta$'.$png,'date',SORT_DESC); $file_list=dol_dir_list($filedir,'files',0,$filter,'\.meta$'.$png,'date',SORT_DESC);
// Affiche en-tete tableau si non deja affiché // Affiche en-tete tableau si non deja affiché
if (sizeof($file_list) && ! $headershown && !$iconPDF) if (sizeof($file_list) && ! $headershown && !$iconPDF)
{ {
$headershown=1; $headershown=1;
print_titre($langs->trans("Documents")); print_titre($langs->trans("Documents"));
print '<table class="border" width="100%">'; print '<table class="border" width="100%">';
} }
// Boucle sur chaque ligne trouvée // Boucle sur chaque ligne trouvée
foreach($file_list as $i => $file) foreach($file_list as $i => $file)
{ {
$var=!$var;
// Défini chemin relatif par rapport au module pour lien download // Défini chemin relatif par rapport au module pour lien download
$relativepath=$file["name"]; // Cas general $relativepath=$file["name"]; // Cas general
if ($filename) $relativepath=$filename."/".$file["name"]; // Cas propal, facture... if ($filename) $relativepath=$filename."/".$file["name"]; // Cas propal, facture...
// Autre cas // Autre cas
if ($modulepart == 'don') { $relativepath = get_exdir($filename,2).$file["name"]; } if ($modulepart == 'don') { $relativepath = get_exdir($filename,2).$file["name"]; }
if ($modulepart == 'export') { $relativepath = $file["name"]; } if ($modulepart == 'export') { $relativepath = $file["name"]; }
// Défini le type MIME du document if (!$iconPDF) print "<tr ".$bc[$var].">";
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é';
if (!$iconPDF) print "<tr $bc[$var]>"; // Affiche nom fichier avec lien download
if (!$iconPDF) print '<td>';
// Affiche colonne type MIME print '<a href="'.DOL_URL_ROOT . '/document.php?modulepart='.$modulepart.'&amp;file='.urlencode($relativepath).'">';
if (!$iconPDF) print '<td nowrap>'.$mimetype.'</td>'; if (!$iconPDF)
// Affiche nom fichier avec lien download {
if (!$iconPDF) print '<td>'; print img_mime($file["name"]).' '.dolibarr_trunc($file["name"],28);
print '<a href="'.DOL_URL_ROOT . '/document.php?modulepart='.$modulepart.'&amp;file='.urlencode($relativepath).'">'; }
if (!$iconPDF) else
{ {
print $file["name"]; print img_pdf($file["name"],2);
} }
else
{
print img_pdf($file["name"],2);
}
print '</a>'; print '</a>';
if (!$iconPDF) print '</td>'; if (!$iconPDF) print '</td>';
// Affiche taille fichier // Affiche taille fichier
if (!$iconPDF) print '<td align="right">'.filesize($filedir."/".$file["name"]). ' bytes</td>'; if (!$iconPDF) print '<td align="right">'.filesize($filedir."/".$file["name"]). ' bytes</td>';
// Affiche date fichier // Affiche date fichier
if (!$iconPDF) print '<td align="right">'.dolibarr_print_date(filemtime($filedir."/".$file["name"]),'dayhour').'</td>'; if (!$iconPDF) print '<td align="right">'.dolibarr_print_date(filemtime($filedir."/".$file["name"]),'dayhour').'</td>';
if ($delallowed) if ($delallowed)
{ {
print '<td><a href="'.DOL_URL_ROOT.'/document.php?action=remove_file&amp;modulepart='.$modulepart.'&amp;file='.urlencode($relativepath).'&amp;urlsource='.urlencode($urlsource).'">'.img_delete().'</a></td>'; print '<td><a href="'.DOL_URL_ROOT.'/document.php?action=remove_file&amp;modulepart='.$modulepart.'&amp;file='.urlencode($relativepath).'&amp;urlsource='.urlencode($urlsource).'">'.img_delete().'</a></td>';
} }
if (!$iconPDF) print '</tr>'; if (!$iconPDF) print '</tr>';
$i++; $i++;
} }
if ($headershown) if ($headershown)
{ {
// Affiche pied du tableau // Affiche pied du tableau
print "</table>\n"; print "</table>\n";
if ($genallowed) if ($genallowed)
{ {
print '</form>'; print '</form>';
} }
} }
return ($i?$i:$headershown); return ($i?$i:$headershown);
} }
/** /**
* \brief Show list of documents in a directory * \brief Show list of documents in a directory
* \param filearray Array of files loaded by dol_dir_list function * \param filearray Array of files loaded by dol_dir_list function
* \param object Object on which document is linked to * \param object Object on which document is linked to
* \param modulepart Value for modulepart used by download wrapper * \param modulepart Value for modulepart used by download wrapper
* \param param Parameters on sort links * \param param Parameters on sort links
* \param forcedownload Mime type is forced to 'application/binary' to have a download * \param forcedownload Mime type is forced to 'application/binary' to have a download
* \param relativepath Relative path of docs (autodefined if not provided) * \param relativepath Relative path of docs (autodefined if not provided)
* \param permtodelete Permission to delete * \param permtodelete Permission to delete
* \return int <0 if KO, nb of files shown if OK * \return int <0 if KO, nb of files shown if OK
*/ */
function list_of_documents($filearray,$object,$modulepart,$param,$forcedownload=0,$relativepath='',$permtodelete=1) function list_of_documents($filearray,$object,$modulepart,$param,$forcedownload=0,$relativepath='',$permtodelete=1)
{ {
global $user, $conf, $langs; global $user, $conf, $langs;
global $bc; global $bc;
global $sortfield, $sortorder; global $sortfield, $sortorder;
// Affiche liste des documents existant // Affiche liste des documents existant
print_titre($langs->trans("AttachedFiles")); print_titre($langs->trans("AttachedFiles"));
$url=$_SERVER["PHP_SELF"]; $url=$_SERVER["PHP_SELF"];
print '<table width="100%" class="noborder">'; print '<table width="100%" class="noborder">';
@ -398,10 +390,10 @@ class FormFile
foreach($filearray as $key => $file) foreach($filearray as $key => $file)
{ {
if (!is_dir($dir.$file['name']) if (!is_dir($dir.$file['name'])
&& $file['name'] != '.' && $file['name'] != '.'
&& $file['name'] != '..' && $file['name'] != '..'
&& $file['name'] != 'CVS' && $file['name'] != 'CVS'
&& ! eregi('\.meta$',$file['name'])) && ! eregi('\.meta$',$file['name']))
{ {
// Define relative path used to store the file // Define relative path used to store the file
if (! $relativepath) if (! $relativepath)
@ -424,9 +416,9 @@ class FormFile
print '<td align="right">'; print '<td align="right">';
//print '&nbsp;'; //print '&nbsp;';
if ($permtodelete) if ($permtodelete)
print '<a href="'.$url.'?id='.$object->id.'&amp;section='.$_REQUEST["section"].'&amp;action=delete&urlfile='.urlencode($file['name']).'">'.img_delete().'</a>'; print '<a href="'.$url.'?id='.$object->id.'&amp;section='.$_REQUEST["section"].'&amp;action=delete&urlfile='.urlencode($file['name']).'">'.img_delete().'</a>';
else else
print '&nbsp;'; print '&nbsp;';
print "</td></tr>\n"; print "</td></tr>\n";
} }
} }