From bbb6fc162c24f3facdf198ec58c0ed9a6f9babf9 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 23 Aug 2005 19:31:25 +0000 Subject: [PATCH] =?UTF-8?q?Qual:=20Mise=20en=20commun=20dans=20la=20method?= =?UTF-8?q?e=20html->show=5Fdocuments=20du=20code=20des=20zones=20d'affich?= =?UTF-8?q?ages=20des=20documents=20PDF=20g=E9n=E9r=E9s.=20(Afin=20de=20pr?= =?UTF-8?q?=E9parer=20la=20g=E9n=E9ration=20des=20PDF=20incluant=20le=20ch?= =?UTF-8?q?oix=20du=20model=20=E0=20la=20vol=E9e).?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- htdocs/comm/addpropal.php | 8 +-- htdocs/comm/propal.php | 61 +++++------------ htdocs/comm/propal_model_pdf.class.php | 67 ------------------- htdocs/compta/facture.php | 49 +++----------- htdocs/compta/propal.php | 37 ++++------ htdocs/expedition/commande.php | 22 +++--- htdocs/expedition/fiche.php | 40 +++++------ htdocs/html.form.class.php | 8 ++- .../modules/commande/modules_commande.php | 42 ++++++++++-- .../modules/facture/modules_facture.php | 34 +++++++++- .../modules/fichinter/modules_fichinter.php | 41 ++++++++++-- .../modules/propale/modules_propale.php | 48 ++++++++++--- 12 files changed, 222 insertions(+), 235 deletions(-) delete mode 100644 htdocs/comm/propal_model_pdf.class.php diff --git a/htdocs/comm/addpropal.php b/htdocs/comm/addpropal.php index 5652bf0e589..1c278f2c82b 100644 --- a/htdocs/comm/addpropal.php +++ b/htdocs/comm/addpropal.php @@ -29,7 +29,6 @@ */ require("./pre.inc.php"); -require("./propal_model_pdf.class.php"); $langs->load("propal"); $langs->load("projects"); @@ -197,9 +196,10 @@ if ($_GET["action"] == 'create') print 'Modèle'; print ''; - $html = new Form($db); - $modelpdf = new Propal_Model_pdf($db); - $html->select_array("modelpdf",$modelpdf->liste_array(),PROPALE_ADDON_PDF); + include_once(DOL_DOCUMENT_ROOT.'/includes/modules/propale/modules_propale.php'); + $model=new ModelePDFPropales(); + $liste=$model->liste_modeles($this->db); + $html->select_array("modelpdf",$liste,PROPALE_ADDON_PDF); print ""; print '
'; diff --git a/htdocs/comm/propal.php b/htdocs/comm/propal.php index aac73939864..ee35efdd596 100644 --- a/htdocs/comm/propal.php +++ b/htdocs/comm/propal.php @@ -42,7 +42,6 @@ $langs->load('bills'); if ($conf->projet->enabled) require_once(DOL_DOCUMENT_ROOT.'/project.class.php'); if ($conf->commande->enabled) require_once(DOL_DOCUMENT_ROOT.'/commande/commande.class.php'); -require_once('./propal_model_pdf.class.php'); require_once('../propal.class.php'); require_once('../actioncomm.class.php'); require_once(DOL_DOCUMENT_ROOT.'/lib/CMailFile.class.php'); @@ -883,51 +882,25 @@ if ($_GET['propalid'] > 0) } print ''; + + + + print '
'; - - print '
'; - - /* - * Documents - */ - if ($propal->brouillon == 1) - { - print '
'; - print ''; - } - print_titre($langs->trans('Documents')); - - print ''; - $propref = sanitize_string($propal->ref); - $file = $conf->propal->dir_output . '/'.$propref.'/'.$propref.'.pdf'; - $relativepath = $propref.'/'.$propref.'.pdf'; - - $var=true; - - if (file_exists($file)) - { - print ''; - print ''; - print ''; - print ''; - } - - if ($propal->brouillon == 1 && $user->rights->propale->creer) - { - print ''; - } - print "
'.$langs->trans('Propal').' PDF'.$propal->ref.'.pdf'.filesize($file). ' bytes'.strftime('%d %B %Y %H:%M:%S',filemtime($file)).'
Modèle'; - $html = new Form($db); - $modelpdf = new Propal_Model_pdf($db); - $html->select_array('modelpdf',$modelpdf->liste_array(),$propal->modelpdf); - print ''; - print '
\n"; - - if ($propal->brouillon == 1) - { - print '
'; - } + /* + * Documents générés + */ + $filename=sanitize_string($propal->ref); + $filedir=$conf->propal->dir_output . "/" . sanitize_string($propal->ref); + $urlsource=$_SERVER["PHP_SELF"]."?propalid=".$propal->id; + $genallowed=$user->rights->propale->creer; + $delallowed=$user->rights->propale->supprimer; + + $var=true; + + print "
\n"; + $form->show_documents('propal',$filename,$filedir,$urlsource,$genallowed,$delallowed,$propal->modelpdf); /* diff --git a/htdocs/comm/propal_model_pdf.class.php b/htdocs/comm/propal_model_pdf.class.php deleted file mode 100644 index cb057bf064b..00000000000 --- a/htdocs/comm/propal_model_pdf.class.php +++ /dev/null @@ -1,67 +0,0 @@ - - * - * $Id$ - * $Source$ - * - * 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 - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * - */ - -class Propal_Model_Pdf { - - var $nom; - - function Propal_Model_Pdf($DB) - { - $this->db = $DB ; - } - /* - * - * - * - */ - - function liste_array() - { - $projets = array(); - - $sql = "SELECT nom FROM ".MAIN_DB_PREFIX."propal_model_pdf"; - - if ($this->db->query($sql) ) - { - $nump = $this->db->num_rows(); - - if ($nump) - { - $i = 0; - while ($i < $nump) - { - $obj = $this->db->fetch_object(); - - $projets[$obj->nom] = $obj->nom; - $i++; - } - } - return $projets; - } - else - { - print $this->db->error(); - } - - } -} -?> diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index 22c2384403a..d6ee0345fa2 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -1389,48 +1389,19 @@ else /* * Documents générés - * Le fichier de facture détaillée est de la forme - * REFFACTURE-XXXXXX-detail.pdf ou XXXXX est une forme diverse */ - - $facref = sanitize_string($fac->ref); - $file = $conf->facture->dir_output . "/" . $facref . "/" . $facref . ".pdf"; - $relativepath = "${facref}/${facref}.pdf"; - + $filename=sanitize_string($fac->ref); + $filedir=$conf->facture->dir_output . "/" . sanitize_string($fac->ref); + $urlsource=$_SERVER["PHP_SELF"]."?facid=".$fac->id; +// $genallowed=($fac->statut == 1 && ($fac->paye == 0 || $user->admin) && $user->rights->facture->creer); +// $delallowed=$user->rights->facture->supprimer; + $genallowed=0; + $delallowed=0; + $var=true; - if (file_exists($file)) - { - print "
\n"; - print_titre("Documents"); - print ''; - - print ""; - - print ''; - print ''; - print ''; - print ''; - - - $dir = $conf->facture->dir_output . "/" . $facref . "/"; - $handle=opendir($dir); - - while (($file = readdir($handle))!==false) - { - if (is_readable($dir.$file) && substr($file, -10) == 'detail.pdf') - { - print ""; - $relativepathdetail = "${facref}/$file"; - - print ''; - print ''; - print ''; - print ''; - } - } - print "
".$langs->trans("Bill")." PDF'.$fac->ref.'.pdf'.filesize($file). ' bytes'.strftime("%d %b %Y %H:%M:%S",filemtime($file)).'
Facture détaillée'.$file.''.filesize($dir.$file). ' bytes'.strftime("%d %b %Y %H:%M:%S",filemtime($dir.$file)).'
\n"; - } + print "
\n"; + $html->show_documents('facture',$filename,$filedir,$urlsource,$genallowed,$delallowed); /* diff --git a/htdocs/compta/propal.php b/htdocs/compta/propal.php index c985fc85caf..5750a1edf32 100644 --- a/htdocs/compta/propal.php +++ b/htdocs/compta/propal.php @@ -453,30 +453,21 @@ if ($_GET["propalid"]) print '"; } - print '
'; - /* - * Documents - */ + /* + * Documents générés + */ + $filename=sanitize_string($propal->ref); + $filedir=$conf->propal->dir_output . "/" . sanitize_string($propal->ref); + $urlsource=$_SERVER["PHP_SELF"]."?propalid=".$propal->id; + $genallowed=0; + $delallowed=0; + + $var=true; + + print "
\n"; + $form->show_documents('propal',$filename,$filedir,$urlsource,$genallowed,$delallowed); + - print_titre($langs->trans('Documents')); - - print ''; - $propref = sanitize_string($propal->ref); - $file = $conf->propal->dir_output . '/'.$propref.'/'.$propref.'.pdf'; - $relativepath = $propref.'/'.$propref.'.pdf'; - - $var=true; - - if (file_exists($file)) - { - print ''; - print ''; - print ''; - print ''; - } - - print "
'.$langs->trans('Propal').' PDF'.$propal->ref.'.pdf'.filesize($file). ' bytes'.strftime('%d %B %Y %H:%M:%S',filemtime($file)).'
\n"; - - /* * Commandes rattachées */ diff --git a/htdocs/expedition/commande.php b/htdocs/expedition/commande.php index cc57ce211b8..689e340108a 100644 --- a/htdocs/expedition/commande.php +++ b/htdocs/expedition/commande.php @@ -104,11 +104,12 @@ if ($_GET["id"] > 0) $h++; } - dolibarr_fiche_head($head, $hselected, $soc->nom." / ".$langs->trans("Order")." : $commande->ref"); + dolibarr_fiche_head($head, $hselected, $langs->trans("Order").": $commande->ref"); + /* - * Confirmation de la validation - * - */ + * Confirmation de la validation + * + */ if ($_GET["action"] == 'cloture') { $html->form_confirm("commande.php?id=".$_GET["id"],"Clôturer la commande","Etes-vous sûr de vouloir clôturer cette commande ?","confirm_cloture"); @@ -143,13 +144,14 @@ if ($_GET["id"] > 0) print '
'.nl2br($commande->note)."

'; + print '
'; + /* - * Lignes de commandes - * - */ - echo ''; + * Lignes de commandes + * + */ + echo '
'; $sql = "SELECT l.fk_product, l.description, l.price, l.qty, l.rowid, l.tva_tx, l.remise_percent, l.subprice"; $sql.= " FROM ".MAIN_DB_PREFIX."commandedet as l "; @@ -233,7 +235,6 @@ if ($_GET["id"] > 0) if (! $num) { print $langs->trans("None").'
'; - print '
'; } } @@ -248,7 +249,6 @@ if ($_GET["id"] > 0) */ if ($reste_a_livrer_total > 0 && $commande->brouillon == 0) { - print ''; print ''; print ''; diff --git a/htdocs/expedition/fiche.php b/htdocs/expedition/fiche.php index 6db19d2e914..3ce58b29a4d 100644 --- a/htdocs/expedition/fiche.php +++ b/htdocs/expedition/fiche.php @@ -31,6 +31,7 @@ require("./pre.inc.php"); +$langs->load("bills"); if (!$user->rights->expedition->lire) accessforbidden(); @@ -444,28 +445,10 @@ else dolibarr_print_error($db); } - print "

\n"; + print "
\n"; print "\n\n"; - /* - * - */ - $file = $expedition->pdf_filename; - if (file_exists($file)) - { - print_titre($langs->trans("Documents")); - print ''; - print ""; - - $b = ereg_replace($conf->expedition->dir_output."/","",$file); - - print ''; - print ''; - print ''; - print "
".$langs->trans("Sending")." PDF'.basename($file).''.filesize($file). ' bytes'.dolibarr_print_date(filemtime($file),"%d %B %Y %H:%M:%S").'
"; - } - /* * @@ -489,10 +472,27 @@ else print ''; } + + /* + * Documents générés + */ + $filename=sanitize_string($expedition->id); + $filedir=$conf->expedition->dir_output . "/" .get_exdir($expedition->id); + $urlsource=$_SERVER["PHP_SELF"]."?id=".$expedition->id; + //$genallowed=$user->rights->expedition->creer; + //$delallowed=$user->rights->expedition->supprimer; + $genallowed=0; + $delallowed=0; + + $var=true; + + print "
\n"; + $html->show_documents('expedition',$filename,$filedir,$urlsource,$genallowed,$delallowed,$propal->modelpdf); + + /* * Déjà livré * - * */ $sql = "SELECT cd.fk_product, cd.description, cd.rowid, cd.qty as qty_commande"; $sql .= " , ed.qty as qty_livre, e.ref"; diff --git a/htdocs/html.form.class.php b/htdocs/html.form.class.php index 060024566d8..cc536a66b99 100644 --- a/htdocs/html.form.class.php +++ b/htdocs/html.form.class.php @@ -1386,11 +1386,15 @@ class Form $liste=array(); if ($modulepart == 'propal') { - $liste=$this->select("ee","select nom as id, nom as lib from ".MAIN_DB_PREFIX."propal_model_pdf"); + include_once(DOL_DOCUMENT_ROOT.'/includes/modules/propale/modules_propale.php'); + $model=new ModelePDFPropales(); + $liste=$model->liste_modeles($this->db); } elseif ($modulepart == 'facture') { - $liste=$this->select(""); + include_once(DOL_DOCUMENT_ROOT.'/includes/modules/facture/modules_facture.php'); + $model=new ModelePDFFactures(); + $liste=$model->liste_modeles($this->db); } else { diff --git a/htdocs/includes/modules/commande/modules_commande.php b/htdocs/includes/modules/commande/modules_commande.php index 4a9ec458648..cfa9a948276 100644 --- a/htdocs/includes/modules/commande/modules_commande.php +++ b/htdocs/includes/modules/commande/modules_commande.php @@ -1,6 +1,6 @@ - * Copyright (C) 2004 Laurent Destailleur + * Copyright (C) 2004-2005 Laurent Destailleur * Copyright (C) 2004 Eric Seigne * * This program is free software; you can redistribute it and/or modify @@ -23,7 +23,8 @@ * */ -/** \file htdocs/includes/modules/commande/modules_commande.php +/** + \file htdocs/includes/modules/commande/modules_commande.php \ingroup commande \brief Fichier contenant la classe mère de generation des commandes en PDF et la classe mère de numérotation des commandes @@ -32,8 +33,9 @@ -/** \class ModelePDFCommandes - \brief Classe mère des modèles de commandes +/** + \class ModelePDFCommandes + \brief Classe mère des modèles de commandes */ class ModelePDFCommandes extends FPDF @@ -48,12 +50,40 @@ class ModelePDFCommandes extends FPDF return $this->error; } + /** + * \brief Renvoi la liste des modèles actifs + */ + function liste_modeles($db) + { + $liste=array(); + $sql =""; + + $resql = $db->query($sql); + if ($resql) + { + $num = $db->num_rows($resql); + $i = 0; + while ($i < $num) + { + $row = $db->fetch_row($resql); + $liste[$row[0]]=$row[1]; + $i++; + } + } + else + { + return -1; + } + return $liste; + } + } -/** \class ModeleNumRefCommandes - \brief Classe mère des modèles de numérotation des références de commandes +/** + \class ModeleNumRefCommandes + \brief Classe mère des modèles de numérotation des références de commandes */ class ModeleNumRefCommandes diff --git a/htdocs/includes/modules/facture/modules_facture.php b/htdocs/includes/modules/facture/modules_facture.php index 06e0b14bdbf..78d887c7974 100644 --- a/htdocs/includes/modules/facture/modules_facture.php +++ b/htdocs/includes/modules/facture/modules_facture.php @@ -36,8 +36,9 @@ require_once(DOL_DOCUMENT_ROOT."/compta/bank/account.class.php"); // Requis ca -/** \class ModelePDFFactures - \brief Classe mère des modèles de facture +/** + \class ModelePDFFactures + \brief Classe mère des modèles de facture */ class ModelePDFFactures extends FPDF @@ -45,13 +46,40 @@ class ModelePDFFactures extends FPDF var $error=''; /** - \brief Renvoi le dernier message d'erreur de création de facture + * \brief Renvoi le dernier message d'erreur de création de facture */ function pdferror() { return $this->error; } + /** + * \brief Renvoi la liste des modèles actifs + */ + function liste_modeles($db) + { + $liste=array(); + $sql =""; + + $resql = $db->query($sql); + if ($resql) + { + $num = $db->num_rows($resql); + $i = 0; + while ($i < $num) + { + $row = $db->fetch_row($resql); + $liste[$row[0]]=$row[1]; + $i++; + } + } + else + { + return -1; + } + return $liste; + } + } diff --git a/htdocs/includes/modules/fichinter/modules_fichinter.php b/htdocs/includes/modules/fichinter/modules_fichinter.php index 35a41dbb8ab..456bae5b8fa 100644 --- a/htdocs/includes/modules/fichinter/modules_fichinter.php +++ b/htdocs/includes/modules/fichinter/modules_fichinter.php @@ -40,26 +40,55 @@ class ModelePDFFicheinter extends FPDF { var $error=''; - /** \brief Constructeur + /** + \brief Constructeur */ function ModelePDFFicheinter() { } - /** - \brief Renvoi le dernier message d'erreur de création de fiche intervention - */ + /** + \brief Renvoi le dernier message d'erreur de création de fiche intervention + */ function pdferror() { return $this->error; } + /** + * \brief Renvoi la liste des modèles actifs + */ + function liste_modeles($db) + { + $liste=array(); + $sql =""; + + $resql = $db->query($sql); + if ($resql) + { + $num = $db->num_rows($resql); + $i = 0; + while ($i < $num) + { + $row = $db->fetch_row($resql); + $liste[$row[0]]=$row[1]; + $i++; + } + } + else + { + return -1; + } + return $liste; + } + } -/** \class ModeleNumRefFicheinter - \brief Classe mère des modèles de numérotation des références de fiches d'intervention +/** + \class ModeleNumRefFicheinter + \brief Classe mère des modèles de numérotation des références de fiches d'intervention */ class ModeleNumRefFicheinter diff --git a/htdocs/includes/modules/propale/modules_propale.php b/htdocs/includes/modules/propale/modules_propale.php index 176906b5d08..845e0e8dc28 100644 --- a/htdocs/includes/modules/propale/modules_propale.php +++ b/htdocs/includes/modules/propale/modules_propale.php @@ -38,21 +38,49 @@ class ModelePDFPropales extends FPDF { - var $error=''; - - /** - \brief Renvoi le dernier message d'erreur de création de propale - */ - function pdferror() + var $error=''; + + /** + * \brief Renvoi le dernier message d'erreur de création de propale + */ + function pdferror() { - return $this->error; + return $this->error; + } + + /** + * \brief Renvoi la liste des modèles actifs + */ + function liste_modeles($db) + { + $liste=array(); + $sql ="SELECT nom as id, nom as lib"; + $sql.=" FROM ".MAIN_DB_PREFIX."propal_model_pdf"; + + $resql = $db->query($sql); + if ($resql) + { + $num = $db->num_rows($resql); + $i = 0; + while ($i < $num) + { + $row = $db->fetch_row($resql); + $liste[$row[0]]=$row[1]; + $i++; + } + } + else + { + return -1; + } + return $liste; } - } -/**\class ModeleNumRefPropales - \brief Classe mère des modèles de numérotation des références de propales +/** + \class ModeleNumRefPropales + \brief Classe mère des modèles de numérotation des références de propales */ class ModeleNumRefPropales