From 79a694a546f733af0f5ead009c4ca94fe5d2a541 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur <eldy@users.sourceforge.net> Date: Thu, 23 Dec 2004 17:52:48 +0000 Subject: [PATCH] =?UTF-8?q?Fix:=20Meilleure=20gestion=20erreur=20sur=20la?= =?UTF-8?q?=20g=E9n=E9ration=20des=20propales=20PDF=20et=20correction=20d'?= =?UTF-8?q?erreurs.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/propale/modules_propale.php | 1 + .../propale/pdf_propale_adytek.modules.php | 28 ++++++--- .../propale/pdf_propale_bleu.modules.php | 28 ++++++--- .../propale/pdf_propale_jaune.modules.php | 30 ++++++--- .../propale/pdf_propale_rouge.modules.php | 62 ++++++++++++------- .../propale/pdf_propale_vert.modules.php | 28 ++++++--- 6 files changed, 124 insertions(+), 53 deletions(-) diff --git a/htdocs/includes/modules/propale/modules_propale.php b/htdocs/includes/modules/propale/modules_propale.php index f4f3039741a..5e81554851e 100644 --- a/htdocs/includes/modules/propale/modules_propale.php +++ b/htdocs/includes/modules/propale/modules_propale.php @@ -131,6 +131,7 @@ function propale_pdf_create($db, $facid, $modele='') } else { + dolibarr_syslog("Erreur dans propale_pdf_create"); dolibarr_print_error($db,$obj->pdferror()); return 0; } diff --git a/htdocs/includes/modules/propale/pdf_propale_adytek.modules.php b/htdocs/includes/modules/propale/pdf_propale_adytek.modules.php index bb364b59ba3..be85802beda 100644 --- a/htdocs/includes/modules/propale/pdf_propale_adytek.modules.php +++ b/htdocs/includes/modules/propale/pdf_propale_adytek.modules.php @@ -43,31 +43,45 @@ class pdf_propale_adytek extends ModelePDFPropales $this->db = $db; $this->name = "Adytek"; $this->description = "Mod�le de proposition Adytek"; + $this->error = ""; } - /*! + + function pdferror() + { + return $this->error(); + } + + /** \brief Fonction g�n�rant la propale sur le disque \param id id de la propale � g�n�rer + \return int 1=ok, 0=ko */ function write_pdf_file($id) { - global $user; + global $user,$conf; + $propale = new Propal($this->db,"",$id); if ($propale->fetch($id)) { - if (defined("PROPALE_OUTPUTDIR")) + if ($conf->propal->dir_output) { - $dir = PROPALE_OUTPUTDIR . "/" . $propale->ref ; - umask(0); + $dir = $conf->propal->dir_output . "/" . $propale->ref ; if (! file_exists($dir)) { - mkdir($dir, 0755); + umask(0); + if (! mkdir($dir, 0755)) + { + $this->error=$langs->trans("ErrorCanNotCreateDir",$dir); + return 0; + } } } else { - print "PROPALE_OUTPUTDIR non d�finit !"; + $this->error=$langs->trans("ErrorConstantNotDefined","PROPALE_OUTPUTDIR"); + return 0; } $file = $dir . "/" . $propale->ref . ".pdf"; diff --git a/htdocs/includes/modules/propale/pdf_propale_bleu.modules.php b/htdocs/includes/modules/propale/pdf_propale_bleu.modules.php index 2f227393933..aa4dcb8de4e 100644 --- a/htdocs/includes/modules/propale/pdf_propale_bleu.modules.php +++ b/htdocs/includes/modules/propale/pdf_propale_bleu.modules.php @@ -43,31 +43,45 @@ class pdf_propale_bleu extends ModelePDFPropales $this->db = $db; $this->name = "bleu"; $this->description = "Mod�le de propale sans remise."; + $this->error = ""; } - /*! + + function pdferror() + { + return $this->error(); + } + + /** \brief Fonction g�n�rant la propale sur le disque \param id id de la propale � g�n�rer + \return int 1=ok, 0=ko */ function write_pdf_file($id) { - global $user; + global $user,$conf; + $propale = new Propal($this->db,"",$id); if ($propale->fetch($id)) { - if (defined("PROPALE_OUTPUTDIR")) + if ($conf->propal->dir_output) { - $dir = PROPALE_OUTPUTDIR . "/" . $propale->ref ; - umask(0); + $dir = $conf->propal->dir_output . "/" . $propale->ref ; if (! file_exists($dir)) { - mkdir($dir, 0755); + umask(0); + if (! mkdir($dir, 0755)) + { + $this->error=$langs->trans("ErrorCanNotCreateDir",$dir); + return 0; + } } } else { - print "PROPALE_OUTPUTDIR non d�finit !"; + $this->error=$langs->trans("ErrorConstantNotDefined","PROPALE_OUTPUTDIR"); + return 0; } $file = $dir . "/" . $propale->ref . ".pdf"; diff --git a/htdocs/includes/modules/propale/pdf_propale_jaune.modules.php b/htdocs/includes/modules/propale/pdf_propale_jaune.modules.php index 230966b7084..d316e2fc084 100644 --- a/htdocs/includes/modules/propale/pdf_propale_jaune.modules.php +++ b/htdocs/includes/modules/propale/pdf_propale_jaune.modules.php @@ -43,31 +43,45 @@ class pdf_propale_jaune extends ModelePDFPropales $this->db = $db; $this->name = "Jaune"; $this->description = "Mod�le de proposition Jaune"; + $this->error = ""; } - /*! + + function pdferror() + { + return $this->error(); + } + + /** \brief Fonction g�n�rant la propale sur le disque \param id id de la propale � g�n�rer + \return int 1=ok, 0=ko */ function write_pdf_file($id) { - global $user; + global $user,$conf; + $propale = new Propal($this->db,"",$id); if ($propale->fetch($id)) { - if (defined("PROPALE_OUTPUTDIR")) + if ($conf->propal->dir_output) + { + $dir = $conf->propal->dir_output . "/" . $propale->ref ; + if (! file_exists($dir)) { - $dir = PROPALE_OUTPUTDIR . "/" . $propale->ref ; umask(0); - if (! file_exists($dir)) + if (! mkdir($dir, 0755)) { - mkdir($dir, 0755); + $this->error=$langs->trans("ErrorCanNotCreateDir",$dir); + return 0; + } } } else { - print "PROPALE_OUTPUTDIR non d�finit !"; + $this->error=$langs->trans("ErrorConstantNotDefined","PROPALE_OUTPUTDIR"); + return 0; } $file = $dir . "/" . $propale->ref . ".pdf"; @@ -78,7 +92,7 @@ class pdf_propale_jaune extends ModelePDFPropales $pdf=new FPDF('P','mm','A4'); $pdf->Open(); - $pdf->SetTitle($fac->ref); + $pdf->SetTitle($propale->ref); $pdf->SetSubject("Proposition commerciale"); $pdf->SetCreator("Dolibarr ".DOL_VERSION); $pdf->SetAuthor($user->fullname); diff --git a/htdocs/includes/modules/propale/pdf_propale_rouge.modules.php b/htdocs/includes/modules/propale/pdf_propale_rouge.modules.php index 77237e9a70c..cef1c250a7e 100644 --- a/htdocs/includes/modules/propale/pdf_propale_rouge.modules.php +++ b/htdocs/includes/modules/propale/pdf_propale_rouge.modules.php @@ -1,5 +1,6 @@ <?php /* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org> + * Copyright (C) 2004 Laurent Destailleur <eldy@users.sourceforge.net> * * 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 @@ -21,54 +22,71 @@ * */ -/*! \file htdocs/includes/modules/propale/pdf_propale_rouge.modules.php - \ingroup propale - \brief Fichier de la classe permettant de g�n�rer les propales au mod�le Rouge - \version $Revision$ +/** + \file htdocs/includes/modules/propale/pdf_propale_rouge.modules.php + \ingroup propale + \brief Fichier de la classe permettant de g�n�rer les propales au mod�le Rouge + \version $Revision$ */ -/*! \class pdf_propale_rouge - \brief Classe permettant de g�n�rer les propales au mod�le Rouge +/** + \class pdf_propale_rouge + \brief Classe permettant de g�n�rer les propales au mod�le Rouge */ class pdf_propale_rouge extends ModelePDFPropales { - /*! \brief Constructeur - \param db handler acc�s base de donn�e + /*! \brief Constructeur + \param db handler acc�s base de donn�e */ function pdf_propale_rouge($db=0) { $this->db = $db; $this->name = "rouge"; $this->description = "Mod�le de propale par d�faut"; + $this->error = ""; } - /*! \brief Fonction g�n�rant la propale sur le disque - \param id id de la propale � g�n�rer + + function pdferror() + { + return $this->error(); + } + + /** + \brief Fonction g�n�rant la propale sur le disque + \param id id de la propale � g�n�rer + \return int 1=ok, 0=ko */ function write_pdf_file($id) { - global $user; + global $user,$conf; + $propale = new Propal($this->db,"",$id); if ($propale->fetch($id)) { - if (defined("PROPALE_OUTPUTDIR")) + if ($conf->propal->dir_output) { - $dir = PROPALE_OUTPUTDIR . "/" . $propale->ref ; - umask(0); - if (! file_exists($dir)) - { - mkdir($dir, 0755); - } + $dir = $conf->propal->dir_output . "/" . $propale->ref ; + if (! file_exists($dir)) + { + umask(0); + if (! mkdir($dir, 0755)) + { + $this->error=$langs->trans("ErrorCanNotCreateDir",$dir); + return 0; + } + } } else { - print "PROPALE_OUTPUTDIR non d�finit !"; + $this->error=$langs->trans("ErrorConstantNotDefined","PROPALE_OUTPUTDIR"); + return 0; } - + $file = $dir . "/" . $propale->ref . ".pdf"; if (file_exists($dir)) @@ -203,10 +221,6 @@ class pdf_propale_rouge extends ModelePDFPropales } - /* - * - */ - $pdf->Output($file); return 1; } diff --git a/htdocs/includes/modules/propale/pdf_propale_vert.modules.php b/htdocs/includes/modules/propale/pdf_propale_vert.modules.php index f0eee862cc2..695842392ff 100644 --- a/htdocs/includes/modules/propale/pdf_propale_vert.modules.php +++ b/htdocs/includes/modules/propale/pdf_propale_vert.modules.php @@ -43,31 +43,45 @@ class pdf_propale_vert extends ModelePDFPropales $this->db = $db; $this->name = "vert"; $this->description = "Affichage de la remise par produit"; + $this->error = ""; } - /*! + + function pdferror() + { + return $this->error(); + } + + /** \brief Fonction g�n�rant la propale sur le disque \param id id de la propale � g�n�rer + \return int 1=ok, 0=ko */ function write_pdf_file($id) { - global $user; + global $user,$conf; + $propale = new Propal($this->db,"",$id); if ($propale->fetch($id)) { - if (defined("PROPALE_OUTPUTDIR")) + if ($conf->propal->dir_output) + { + $dir = $conf->propal->dir_output . "/" . $propale->ref ; + if (! file_exists($dir)) { - $dir = PROPALE_OUTPUTDIR . "/" . $propale->ref ; umask(0); - if (! file_exists($dir)) + if (! mkdir($dir, 0755)) { - mkdir($dir, 0755); + $this->error=$langs->trans("ErrorCanNotCreateDir",$dir); + return 0; + } } } else { - print "PROPALE_OUTPUTDIR non d�finit !"; + $this->error=$langs->trans("ErrorConstantNotDefined","PROPALE_OUTPUTDIR"); + return 0; } $file = $dir . "/" . $propale->ref . ".pdf"; -- GitLab