From ffe32f655c73c88a769789b1b43d659c71f2c6e3 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 21 Oct 2007 23:56:56 +0000 Subject: [PATCH] =?UTF-8?q?Fix:=20Apercu=20sur=20bon=20de=20r=E9ceptions?= =?UTF-8?q?=20de=20livraison?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- htdocs/admin/commande.php | 2 +- htdocs/admin/expedition.php | 1 - htdocs/admin/facture.php | 2 +- htdocs/admin/fichinter.php | 2 +- htdocs/admin/fournisseur.php | 2 +- htdocs/admin/livraison.php | 108 +++++++++++------- htdocs/admin/propale.php | 2 +- .../paiement/cheque/pdf/pdf_blochet.class.php | 2 +- .../paiement/cheque/remisecheque.class.php | 2 +- htdocs/compta/paiement/rapport.php | 2 +- .../mods/methode_expedition.modules.php | 2 +- .../modules/modules_commandefournisseur.php | 2 +- .../modules/pdf/pdf_muscadet.modules.php | 2 +- .../modules/commande/modules_commande.php | 2 +- .../modules/commande/pdf_edison.modules.php | 2 +- .../modules/commande/pdf_einstein.modules.php | 2 +- .../modules/facture/modules_facture.php | 2 +- .../modules/facture/pdf_crabe.modules.php | 2 +- .../modules/facture/pdf_huitre.modules.php | 2 +- .../modules/facture/pdf_oursin.modules.php | 2 +- .../modules/fichinter/modules_fichinter.php | 2 +- .../modules/fichinter/pdf_soleil.modules.php | 6 +- .../modules/propale/modules_propale.php | 2 +- .../propale/pdf_propale_azur.modules.php | 2 +- .../propale/pdf_propale_bleu.modules.php | 2 +- .../propale/pdf_propale_jaune.modules.php | 2 +- .../propale/pdf_propale_rouge.modules.php | 2 +- .../propale/pdf_propale_vert.modules.php | 2 +- .../modules/rapport/pdf_paiement.class.php | 4 +- htdocs/livraison/livraison.class.php | 6 +- htdocs/livraison/mods/modules_livraison.php | 2 +- .../mods/pdf/pdf_sirocco.modules.php | 60 ++++++---- .../livraison/mods/pdf/pdf_typhon.modules.php | 44 +++---- 33 files changed, 156 insertions(+), 125 deletions(-) diff --git a/htdocs/admin/commande.php b/htdocs/admin/commande.php index 7eb7220fde0..bd154916b5c 100644 --- a/htdocs/admin/commande.php +++ b/htdocs/admin/commande.php @@ -61,7 +61,7 @@ if ($_GET["action"] == 'specimen') $obj = new $classname($db); - if ($obj->write_pdf_file($commande) > 0) + if ($obj->write_file($commande) > 0) { header("Location: ".DOL_URL_ROOT."/document.php?modulepart=commande&file=SPECIMEN.pdf"); return; diff --git a/htdocs/admin/expedition.php b/htdocs/admin/expedition.php index 8513d026780..d8d77c8f83d 100644 --- a/htdocs/admin/expedition.php +++ b/htdocs/admin/expedition.php @@ -21,7 +21,6 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * * $Id$ - * $Source$ */ /** diff --git a/htdocs/admin/facture.php b/htdocs/admin/facture.php index 6342db6918c..9244d64a188 100644 --- a/htdocs/admin/facture.php +++ b/htdocs/admin/facture.php @@ -64,7 +64,7 @@ if ($_GET["action"] == 'specimen') $obj = new $classname($db); - if ($obj->write_pdf_file($facture,$langs) > 0) + if ($obj->write_file($facture,$langs) > 0) { header("Location: ".DOL_URL_ROOT."/document.php?modulepart=facture&file=SPECIMEN.pdf"); return; diff --git a/htdocs/admin/fichinter.php b/htdocs/admin/fichinter.php index 75ad8e6d226..b14769c3344 100644 --- a/htdocs/admin/fichinter.php +++ b/htdocs/admin/fichinter.php @@ -62,7 +62,7 @@ if ($_GET["action"] == 'specimen') $obj = new $classname($db); - if ($obj->write_pdf_file($inter,$langs) > 0) + if ($obj->write_file($inter,$langs) > 0) { header("Location: ".DOL_URL_ROOT."/document.php?modulepart=ficheinter&file=SPECIMEN.pdf"); return; diff --git a/htdocs/admin/fournisseur.php b/htdocs/admin/fournisseur.php index 26ad2eae243..9b6271065b9 100644 --- a/htdocs/admin/fournisseur.php +++ b/htdocs/admin/fournisseur.php @@ -62,7 +62,7 @@ if ($_GET["action"] == 'specimen') $obj = new $classname($db); - if ($obj->write_pdf_file($commande,$langs) > 0) + if ($obj->write_file($commande,$langs) > 0) { header("Location: ".DOL_URL_ROOT."/document.php?modulepart=commande_fournisseur&file=SPECIMEN.pdf"); return; diff --git a/htdocs/admin/livraison.php b/htdocs/admin/livraison.php index 1f0d1a1f75f..5fb49b88675 100644 --- a/htdocs/admin/livraison.php +++ b/htdocs/admin/livraison.php @@ -21,7 +21,6 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * * $Id$ - * $Source$ */ /** @@ -46,6 +45,35 @@ if (!$user->admin) accessforbidden(); /* * Actions */ +if ($_GET["action"] == 'specimen') +{ + $modele=$_GET["module"]; + + $exp = new Expedition($db); + $exp->initAsSpecimen(); + $exp->fetch_commande(); + + // Charge le modele + $dir = DOL_DOCUMENT_ROOT . "/livraison/mods/pdf/"; + $file = "pdf_".$modele.".modules.php"; + if (file_exists($dir.$file)) + { + $classname = "pdf_".$modele; + require_once($dir.$file); + + $obj = new $classname($db); + + if ($obj->write_file($exp,$langs) > 0) + { + header("Location: ".DOL_URL_ROOT."/document.php?modulepart=livraison&file=SPECIMEN.pdf"); + return; + } + } + else + { + $mesg='
'.$langs->trans("ErrorModuleNotFound").'
'; + } +} if ($_GET["action"] == 'set') { @@ -166,47 +194,47 @@ if ($handle) while (($file = readdir($handle))!==false) { if (substr($file, 0, 14) == 'mod_livraison_' && substr($file, strlen($file)-3, 3) == 'php') - { - $file = substr($file, 0, strlen($file)-4); + { + $file = substr($file, 0, strlen($file)-4); - require_once(DOL_DOCUMENT_ROOT ."/livraison/mods/".$file.".php"); + require_once(DOL_DOCUMENT_ROOT ."/livraison/mods/".$file.".php"); - $module = new $file; + $module = new $file; - $var=!$var; - print ''.$module->nom."\n"; - print $module->info(); - print ''; + $var=!$var; + print ''.$module->nom."\n"; + print $module->info(); + print ''; - // Affiche example - print ''.$module->getExample().''; - - print ''; - if ($conf->global->LIVRAISON_ADDON == "$file") - { - print img_tick($langs->trans("Activated")); - } - else - { - print ''.$langs->trans("Default").''; - } - print ''; - - $livraison=new Livraison($db); - - // Info - $htmltooltip=''; - $nextval=$module->getNextValue($mysoc,$livraison); - if ($nextval != $langs->trans("NotAvailable")) - { - $htmltooltip=''.$langs->trans("NextValue").': '.$nextval; - } - print ''; - print $html->textwithhelp('',$htmltooltip,1,0); - print ''; - - print ''; - } + // Affiche example + print ''.$module->getExample().''; + + print ''; + if ($conf->global->LIVRAISON_ADDON == "$file") + { + print img_tick($langs->trans("Activated")); + } + else + { + print ''.$langs->trans("Default").''; + } + print ''; + + $livraison=new Livraison($db); + + // Info + $htmltooltip=''; + $nextval=$module->getNextValue($mysoc,$livraison); + if ($nextval != $langs->trans("NotAvailable")) + { + $htmltooltip=''.$langs->trans("NextValue").': '.$nextval; + } + print ''; + print $html->textwithhelp('',$htmltooltip,1,0); + print ''; + + print ''; + } } closedir($handle); } @@ -272,9 +300,9 @@ if(is_dir($dir)) print $name; print "\n"; require_once($dir.$file); - $obj = new $classname($db); + $module = new $classname($db); - print $obj->description; + print $module->description; print ''; // Activ diff --git a/htdocs/admin/propale.php b/htdocs/admin/propale.php index 1831d3f3662..edd03e88b06 100644 --- a/htdocs/admin/propale.php +++ b/htdocs/admin/propale.php @@ -64,7 +64,7 @@ if ($_GET["action"] == 'specimen') $module = new $classname($db); - if ($module->write_pdf_file($propal) > 0) + if ($module->write_file($propal) > 0) { header("Location: ".DOL_URL_ROOT."/document.php?modulepart=propal&file=SPECIMEN.pdf"); return; diff --git a/htdocs/compta/paiement/cheque/pdf/pdf_blochet.class.php b/htdocs/compta/paiement/cheque/pdf/pdf_blochet.class.php index 739ae4c7b3d..8309fbc9f9a 100644 --- a/htdocs/compta/paiement/cheque/pdf/pdf_blochet.class.php +++ b/htdocs/compta/paiement/cheque/pdf/pdf_blochet.class.php @@ -197,7 +197,7 @@ class BordereauChequeBlochet \param month mois du rapport \param year annee du rapport */ - function write_pdf_file($_dir, $number) + function write_file($_dir, $number) { global $langs; diff --git a/htdocs/compta/paiement/cheque/remisecheque.class.php b/htdocs/compta/paiement/cheque/remisecheque.class.php index e14d6c044e3..ac5ddac96c1 100644 --- a/htdocs/compta/paiement/cheque/remisecheque.class.php +++ b/htdocs/compta/paiement/cheque/remisecheque.class.php @@ -418,7 +418,7 @@ class RemiseCheque $pdf->account = &$account; - $pdf->write_pdf_file(DOL_DATA_ROOT.'/compta/bordereau', $this->number ); + $pdf->write_file(DOL_DATA_ROOT.'/compta/bordereau', $this->number ); } /** diff --git a/htdocs/compta/paiement/rapport.php b/htdocs/compta/paiement/rapport.php index 8f7786f1512..aa8d459eeaf 100644 --- a/htdocs/compta/paiement/rapport.php +++ b/htdocs/compta/paiement/rapport.php @@ -55,7 +55,7 @@ if (! $year) { $year=date("Y"); } if ($_POST["action"] == 'gen') { $rap = new pdf_paiement($db); - $rap->write_pdf_file($dir, $_POST["remonth"], $_POST["reyear"]); + $rap->write_file($dir, $_POST["remonth"], $_POST["reyear"]); $year = $_POST["reyear"]; } diff --git a/htdocs/expedition/mods/methode_expedition.modules.php b/htdocs/expedition/mods/methode_expedition.modules.php index 2b381ee7cde..07866648176 100644 --- a/htdocs/expedition/mods/methode_expedition.modules.php +++ b/htdocs/expedition/mods/methode_expedition.modules.php @@ -79,7 +79,7 @@ class methode_expedition } } - function write_pdf_file($id) + function write_file($id) { global $user; $propale = new Propal($this->db,"",$id); diff --git a/htdocs/fourn/commande/modules/modules_commandefournisseur.php b/htdocs/fourn/commande/modules/modules_commandefournisseur.php index 07d991194bb..b8e4c364c2a 100644 --- a/htdocs/fourn/commande/modules/modules_commandefournisseur.php +++ b/htdocs/fourn/commande/modules/modules_commandefournisseur.php @@ -165,7 +165,7 @@ function supplier_order_pdf_create($db, $comid, $modele='',$outputlangs='') $obj = new $classname($db); - if ($obj->write_pdf_file($comid,$outputlangs) > 0) + if ($obj->write_file($comid,$outputlangs) > 0) { // on supprime l'image correspondant au preview supplier_order_delete_preview($db, $comid); diff --git a/htdocs/fourn/commande/modules/pdf/pdf_muscadet.modules.php b/htdocs/fourn/commande/modules/pdf/pdf_muscadet.modules.php index 80b36e41e80..a95b9f0ff59 100644 --- a/htdocs/fourn/commande/modules/pdf/pdf_muscadet.modules.php +++ b/htdocs/fourn/commande/modules/pdf/pdf_muscadet.modules.php @@ -123,7 +123,7 @@ class pdf_muscadet extends ModelePDFSuppliersOrders \remarks MAIN_INFO_TVAINTRA \remarks MAIN_INFO_LOGO */ - function write_pdf_file($com,$outputlangs='') + function write_file($com,$outputlangs='') { global $user,$langs,$conf; diff --git a/htdocs/includes/modules/commande/modules_commande.php b/htdocs/includes/modules/commande/modules_commande.php index b348452d713..be7648f551d 100644 --- a/htdocs/includes/modules/commande/modules_commande.php +++ b/htdocs/includes/modules/commande/modules_commande.php @@ -199,7 +199,7 @@ function commande_pdf_create($db, $id, $modele='', $outputlangs='') $obj = new $classname($db); - if ($obj->write_pdf_file($id, $outputlangs) > 0) + if ($obj->write_file($id, $outputlangs) > 0) { // on supprime l'image correspondant au preview commande_delete_preview($db, $id); diff --git a/htdocs/includes/modules/commande/pdf_edison.modules.php b/htdocs/includes/modules/commande/pdf_edison.modules.php index 34978f5e174..42c3b45d257 100644 --- a/htdocs/includes/modules/commande/pdf_edison.modules.php +++ b/htdocs/includes/modules/commande/pdf_edison.modules.php @@ -74,7 +74,7 @@ class pdf_edison extends ModelePDFCommandes \param id id de la propale à générer \return int 1=ok, 0=ko */ - function write_pdf_file($com,$outputlangs='') + function write_file($com,$outputlangs='') { global $user,$conf,$langs,$mysco; diff --git a/htdocs/includes/modules/commande/pdf_einstein.modules.php b/htdocs/includes/modules/commande/pdf_einstein.modules.php index 650554948b7..653e4ea679d 100644 --- a/htdocs/includes/modules/commande/pdf_einstein.modules.php +++ b/htdocs/includes/modules/commande/pdf_einstein.modules.php @@ -101,7 +101,7 @@ class pdf_einstein extends ModelePDFCommandes \param com Objet commande à générer \return int 1=ok, 0=ko */ - function write_pdf_file($com,$outputlangs='') + function write_file($com,$outputlangs='') { global $user,$langs,$conf; diff --git a/htdocs/includes/modules/facture/modules_facture.php b/htdocs/includes/modules/facture/modules_facture.php index b798205dbe0..fe09bf40a91 100644 --- a/htdocs/includes/modules/facture/modules_facture.php +++ b/htdocs/includes/modules/facture/modules_facture.php @@ -192,7 +192,7 @@ function facture_pdf_create($db, $id, $message='', $modele='', $outputlangs='') $obj = new $classname($db); $obj->message = $message; - if ($obj->write_pdf_file($id, $outputlangs) > 0) + if ($obj->write_file($id, $outputlangs) > 0) { // Succès de la création de la facture. On génère le fichier meta facture_meta_create($db, $id); diff --git a/htdocs/includes/modules/facture/pdf_crabe.modules.php b/htdocs/includes/modules/facture/pdf_crabe.modules.php index b6e0e68747f..6349b803011 100644 --- a/htdocs/includes/modules/facture/pdf_crabe.modules.php +++ b/htdocs/includes/modules/facture/pdf_crabe.modules.php @@ -101,7 +101,7 @@ class pdf_crabe extends ModelePDFFactures * \param fac Objet facture à générer (ou id si ancienne methode) * \return int 1=ok, 0=ko */ - function write_pdf_file($fac,$outputlangs='') + function write_file($fac,$outputlangs='') { global $user,$langs,$conf; diff --git a/htdocs/includes/modules/facture/pdf_huitre.modules.php b/htdocs/includes/modules/facture/pdf_huitre.modules.php index 4ca041c6932..263be0f4642 100644 --- a/htdocs/includes/modules/facture/pdf_huitre.modules.php +++ b/htdocs/includes/modules/facture/pdf_huitre.modules.php @@ -77,7 +77,7 @@ class pdf_huitre extends ModelePDFFactures * \param fac Objet facture à générer (ou id si ancienne methode) * \return int 1=ok, 0=ko */ - function write_pdf_file($fac,$outputlangs='') + function write_file($fac,$outputlangs='') { global $user,$langs,$conf; diff --git a/htdocs/includes/modules/facture/pdf_oursin.modules.php b/htdocs/includes/modules/facture/pdf_oursin.modules.php index b4758418c44..fd0debd0772 100644 --- a/htdocs/includes/modules/facture/pdf_oursin.modules.php +++ b/htdocs/includes/modules/facture/pdf_oursin.modules.php @@ -97,7 +97,7 @@ class pdf_oursin extends ModelePDFFactures * \remarks MAIN_INFO_CAPITAL * \remarks MAIN_INFO_TVAINTRA */ - function write_pdf_file($fac,$outputlangs='') + function write_file($fac,$outputlangs='') { global $user,$langs,$conf; diff --git a/htdocs/includes/modules/fichinter/modules_fichinter.php b/htdocs/includes/modules/fichinter/modules_fichinter.php index 6d28b64b3d6..3f47b65b3be 100644 --- a/htdocs/includes/modules/fichinter/modules_fichinter.php +++ b/htdocs/includes/modules/fichinter/modules_fichinter.php @@ -192,7 +192,7 @@ function fichinter_pdf_create($db, $id, $modele='', $outputlangs='') $obj = new $classname($db); - if ($obj->write_pdf_file($id,$outputlangs) > 0) + if ($obj->write_file($id,$outputlangs) > 0) { return 1; } diff --git a/htdocs/includes/modules/fichinter/pdf_soleil.modules.php b/htdocs/includes/modules/fichinter/pdf_soleil.modules.php index 48224f19f11..d1d63b2368e 100644 --- a/htdocs/includes/modules/fichinter/pdf_soleil.modules.php +++ b/htdocs/includes/modules/fichinter/pdf_soleil.modules.php @@ -1,6 +1,6 @@ - * Copyright (C) 2004-2005 Laurent Destailleur + * Copyright (C) 2004-2007 Laurent Destailleur * * 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 @@ -18,8 +18,6 @@ * or see http://www.gnu.org/ * * $Id$ - * $Source$ - * */ /** @@ -79,7 +77,7 @@ class pdf_soleil extends ModelePDFFicheinter \param fichinter Object fichinter \return int 1=ok, 0=ko */ - function write_pdf_file($fichinter,$outputlangs='') + function write_file($fichinter,$outputlangs='') { global $user,$langs,$conf,$mysoc; diff --git a/htdocs/includes/modules/propale/modules_propale.php b/htdocs/includes/modules/propale/modules_propale.php index 6bd61cc577b..dd13d554575 100644 --- a/htdocs/includes/modules/propale/modules_propale.php +++ b/htdocs/includes/modules/propale/modules_propale.php @@ -195,7 +195,7 @@ function propale_pdf_create($db, $id, $modele='', $outputlangs='') $obj = new $classname($db); - if ($obj->write_pdf_file($id, $outputlangs) > 0) + if ($obj->write_file($id, $outputlangs) > 0) { // on supprime l'image correspondant au preview propale_delete_preview($db, $id); diff --git a/htdocs/includes/modules/propale/pdf_propale_azur.modules.php b/htdocs/includes/modules/propale/pdf_propale_azur.modules.php index 115d1693a1a..6aee25b8304 100644 --- a/htdocs/includes/modules/propale/pdf_propale_azur.modules.php +++ b/htdocs/includes/modules/propale/pdf_propale_azur.modules.php @@ -99,7 +99,7 @@ class pdf_propale_azur extends ModelePDFPropales \param propale Objet propal à générer (ou id si ancienne methode) \return int 1=ok, 0=ko */ - function write_pdf_file($propale,$outputlangs='') + function write_file($propale,$outputlangs='') { global $user,$langs,$conf; diff --git a/htdocs/includes/modules/propale/pdf_propale_bleu.modules.php b/htdocs/includes/modules/propale/pdf_propale_bleu.modules.php index 5507e44b9c9..2e9cb81026a 100644 --- a/htdocs/includes/modules/propale/pdf_propale_bleu.modules.php +++ b/htdocs/includes/modules/propale/pdf_propale_bleu.modules.php @@ -77,7 +77,7 @@ class pdf_propale_bleu extends ModelePDFPropales \param propale Objet propal \return int 1=ok, 0=ko */ - function write_pdf_file($propale,$outputlangs='') + function write_file($propale,$outputlangs='') { global $user,$conf,$langs,$mysoc; diff --git a/htdocs/includes/modules/propale/pdf_propale_jaune.modules.php b/htdocs/includes/modules/propale/pdf_propale_jaune.modules.php index 38ca39bdd74..c237cede86a 100644 --- a/htdocs/includes/modules/propale/pdf_propale_jaune.modules.php +++ b/htdocs/includes/modules/propale/pdf_propale_jaune.modules.php @@ -78,7 +78,7 @@ class pdf_propale_jaune extends ModelePDFPropales \param propale Objet propal \return int 1=ok, 0=ko */ - function write_pdf_file($propale,$outputlangs='') + function write_file($propale,$outputlangs='') { global $user,$conf,$langs; diff --git a/htdocs/includes/modules/propale/pdf_propale_rouge.modules.php b/htdocs/includes/modules/propale/pdf_propale_rouge.modules.php index fc1614762c1..20b383d600b 100644 --- a/htdocs/includes/modules/propale/pdf_propale_rouge.modules.php +++ b/htdocs/includes/modules/propale/pdf_propale_rouge.modules.php @@ -81,7 +81,7 @@ class pdf_propale_rouge extends ModelePDFPropales \param propale Objet propal \return int 1=ok, 0=ko */ - function write_pdf_file($propale,$outputlangs='') + function write_file($propale,$outputlangs='') { global $user,$conf,$langs; diff --git a/htdocs/includes/modules/propale/pdf_propale_vert.modules.php b/htdocs/includes/modules/propale/pdf_propale_vert.modules.php index 3e0ab092784..7172aef6596 100644 --- a/htdocs/includes/modules/propale/pdf_propale_vert.modules.php +++ b/htdocs/includes/modules/propale/pdf_propale_vert.modules.php @@ -79,7 +79,7 @@ class pdf_propale_vert extends ModelePDFPropales \param propale Objet propal \return int 1=ok, 0=ko */ - function write_pdf_file($propale,$outputlangs='') + function write_file($propale,$outputlangs='') { global $user,$conf,$langs; diff --git a/htdocs/includes/modules/rapport/pdf_paiement.class.php b/htdocs/includes/modules/rapport/pdf_paiement.class.php index ceb02c14e5d..5af2fe89db5 100644 --- a/htdocs/includes/modules/rapport/pdf_paiement.class.php +++ b/htdocs/includes/modules/rapport/pdf_paiement.class.php @@ -166,7 +166,7 @@ class pdf_paiement extends FPDF \param month mois du rapport \param year annee du rapport */ - function write_pdf_file($_dir, $month, $year) + function write_file($_dir, $month, $year) { global $langs; @@ -218,7 +218,7 @@ class pdf_paiement extends FPDF $sql .= " AND date_format(p.datep, '%Y%m') = " . sprintf("%04d%02d",$year,$month); $sql .= " ORDER BY p.datep ASC, pf.fk_paiement ASC"; - dolibarr_syslog("pdf_paiement::write_pdf_file sql=".$sql); + dolibarr_syslog("pdf_paiement::write_file sql=".$sql); $result = $this->db->query($sql); if ($result) { diff --git a/htdocs/livraison/livraison.class.php b/htdocs/livraison/livraison.class.php index 1393b465ffe..9e4f0809225 100644 --- a/htdocs/livraison/livraison.class.php +++ b/htdocs/livraison/livraison.class.php @@ -1,7 +1,7 @@ * Copyright (C) 2005-2006 Regis Houssin - * Copyright (C) 2006 Laurent Destailleur + * Copyright (C) 2006-2007 Laurent Destailleur * Copyright (C) 2007 Franky Van Liedekerke * * This program is free software; you can redistribute it and/or modify @@ -19,7 +19,6 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * * $Id$ - * $Source$ */ /** @@ -207,7 +206,7 @@ class Livraison extends CommonObject * Lit un bon de livraison * */ - function fetch ($id) + function fetch($id) { global $conf; @@ -219,7 +218,6 @@ class Livraison extends CommonObject $sql .= " WHERE l.rowid = ".$id." AND c.rowid = l.fk_commande"; $result = $this->db->query($sql) ; - if ( $result ) { $obj = $this->db->fetch_object($result); diff --git a/htdocs/livraison/mods/modules_livraison.php b/htdocs/livraison/mods/modules_livraison.php index a3b16df32d9..f694c964636 100644 --- a/htdocs/livraison/mods/modules_livraison.php +++ b/htdocs/livraison/mods/modules_livraison.php @@ -180,7 +180,7 @@ function delivery_order_pdf_create($db, $deliveryid, $modele='', $outputlangs='' $obj = new $classname($db); - if ($obj->write_pdf_file($deliveryid,$outputlangs) > 0) + if ($obj->write_file($deliveryid,$outputlangs) > 0) { // on supprime l'image correspondant au preview delivery_order_delete_preview($db, $deliveryid); diff --git a/htdocs/livraison/mods/pdf/pdf_sirocco.modules.php b/htdocs/livraison/mods/pdf/pdf_sirocco.modules.php index 570b94e5674..05dca6dfe17 100644 --- a/htdocs/livraison/mods/pdf/pdf_sirocco.modules.php +++ b/htdocs/livraison/mods/pdf/pdf_sirocco.modules.php @@ -20,7 +20,6 @@ * or see http://www.gnu.org/ * * $Id$ - * $Source$ */ /** @@ -71,21 +70,37 @@ class pdf_sirocco extends ModelePDFDeliveryOrder /** \brief Fonction générant le bon de livraison sur le disque - \param id id du bon de livraison à générer - \return int 1=ok, 0=ko + \param delivery Object livraison à générer + \return int 1=ok, 0=ko */ - function write_pdf_file($id) + function write_file($delivery) { - global $user,$conf,$langs; - - $delivery = new Livraison($this->db); - if ($delivery->fetch($id)) - { - $deliveryref = sanitize_string($delivery->ref); - if ($conf->livraison->dir_output) - { - - $dir = $conf->livraison->dir_output . "/" . $deliveryref ; + global $user,$conf,$langs; + + $langs->load("main"); + $langs->load("bills"); + $langs->load("products"); + $langs->load("deliveries"); + + if ($conf->livraison->dir_output) + { + // If $delivery is id instead of object + if (! is_object($delivery)) + { + $id = $delivery; + $delivery = new Livraison($this->db); + $delivery->fetch($id); + $delivery->id = $id; + if ($result < 0) + { + dolibarr_print_error($db,$delivery->error); + } + } + + $deliveryref = sanitize_string($delivery->ref); + $dir = $conf->livraison->dir_output; + if (! eregi('specimen',$deliveryref)) $dir.= "/" . $deliveryref; + $file = $dir . "/" . $deliveryref . ".pdf"; if (! file_exists($dir)) { @@ -95,17 +110,17 @@ class pdf_sirocco extends ModelePDFDeliveryOrder return 0; } } - } - else - { - $this->error=$langs->transnoentities("ErrorConstantNotDefined","LIVRAISON_OUTPUTDIR"); + } + else + { + $this->error=$langs->transnoentities("ErrorConstantNotDefined","LIVRAISON_OUTPUTDIR"); return 0; - } + } - $file = $dir . "/" . $deliveryref . ".pdf"; + $file = $dir . "/" . $deliveryref . ".pdf"; - if (file_exists($dir)) - { + if (file_exists($dir)) + { // Protection et encryption du pdf if ($conf->global->PDF_SECURITY_ENCRYPTION) { @@ -243,7 +258,6 @@ class pdf_sirocco extends ModelePDFDeliveryOrder $pdf->Output($file); return 1; } - } } /* diff --git a/htdocs/livraison/mods/pdf/pdf_typhon.modules.php b/htdocs/livraison/mods/pdf/pdf_typhon.modules.php index 74a3a2b41d3..ca98bad92b1 100644 --- a/htdocs/livraison/mods/pdf/pdf_typhon.modules.php +++ b/htdocs/livraison/mods/pdf/pdf_typhon.modules.php @@ -19,7 +19,6 @@ * or see http://www.gnu.org/ * * $Id$ - * $Source$ */ /** @@ -110,24 +109,10 @@ class pdf_typhon extends ModelePDFDeliveryOrder /** \brief Fonction générant la commande sur le disque - \param id Id de la commande à générer + \param delivery Object livraison à générer \return int 1=ok, 0=ko - \remarks Variables utilisées - \remarks MAIN_INFO_SOCIETE_NOM - \remarks MAIN_INFO_ADRESSE - \remarks MAIN_INFO_CP - \remarks MAIN_INFO_VILLE - \remarks MAIN_INFO_TEL - \remarks MAIN_INFO_FAX - \remarks MAIN_INFO_WEB - \remarks MAIN_INFO_SIRET - \remarks MAIN_INFO_SIREN - \remarks MAIN_INFO_RCS - \remarks MAIN_INFO_CAPITAL - \remarks MAIN_INFO_TVAINTRA - \remarks MAIN_INFO_LOGO */ - function write_pdf_file($id) + function write_file($delivery) { global $user,$langs,$conf; @@ -138,16 +123,25 @@ class pdf_typhon extends ModelePDFDeliveryOrder if ($conf->livraison->dir_output) { - $delivery = new Livraison($this->db); - $delivery->fetch($id); - $delivery->id = $id; - $lignesdelivery = $delivery->fetch_lignes(); - + // If $delivery is id instead of object + if (! is_object($delivery)) + { + $id = $delivery; + $delivery = new Livraison($this->db); + $delivery->fetch($id); + $delivery->id = $id; + if ($result < 0) + { + dolibarr_print_error($db,$delivery->error); + } + } + $nblignes = sizeof($lignesdelivery); - $deliveryref = sanitize_string($delivery->ref); - $dir = $conf->livraison->dir_output . "/" . $deliveryref; - $file = $dir . "/" . $deliveryref . ".pdf"; + $deliveryref = sanitize_string($delivery->ref); + $dir = $conf->livraison->dir_output; + if (! eregi('specimen',$deliveryref)) $dir.= "/" . $deliveryref; + $file = $dir . "/" . $deliveryref . ".pdf"; if (! file_exists($dir)) {