diff --git a/htdocs/includes/modules/propale/modules_propale.php b/htdocs/includes/modules/propale/modules_propale.php index f4f3039741a5fb9e5dfee7ed95f72725b6208c50..5e81554851edcc80e16ac1c2c1456efb679118d3 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 bb364b59ba35c197b7f68f42035db48343517352..be85802bedaec90ba1bc5a19c6d7b4450d8c33fe 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 2f2273939336a07181260e8a14903289771b6a9b..aa4dcb8de4ea30dbdc93566af6599a150decff5f 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 230966b70841033fc4f860ca01ad14f2dd2cf40a..d316e2fc0847ef76d014c588701d62310c062102 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 77237e9a70c7c30f891f9fe2249384973c00f255..cef1c250a7ebce6cf6f86bc144b41207b879bfc2 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 f0eee862cc2e29c859625eff6be5bacc8ee7f2e4..695842392ff09f3cef46c684fc95d24f901aca2f 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";