diff --git a/htdocs/admin/expedition.php b/htdocs/admin/expedition.php
index aa9259226ab..3d0fac4c72b 100644
--- a/htdocs/admin/expedition.php
+++ b/htdocs/admin/expedition.php
@@ -118,11 +118,11 @@ if ($action == 'specimen')
$dirmodels=array_merge(array('/'),(array) $conf->modules_parts['models']);
foreach($dirmodels as $reldir)
{
- $file=dol_buildpath($reldir."core/modules/expedition/doc/pdf_".$modele.".modules.php",0);
+ $file=dol_buildpath($reldir."core/modules/expedition/doc/pdf_expedition_".$modele.".modules.php",0);
if (file_exists($file))
{
$filefound=1;
- $classname = "pdf_".$modele;
+ $classname = "pdf_expedition_".$modele;
break;
}
}
@@ -339,10 +339,9 @@ foreach ($dirmodels as $reldir)
while (($file = readdir($handle))!==false)
{
- if (preg_match('/^(mod_.*)\.php$/i',$file,$reg))
+ if (substr($file, 0, 15) == 'mod_expedition_' && substr($file, dol_strlen($file)-3, 3) == 'php')
{
- $file = $reg[1];
- $classname = substr($file,4);
+ $file = substr($file, 0, dol_strlen($file)-4);
require_once(DOL_DOCUMENT_ROOT ."/core/modules/expedition/".$file.".php");
@@ -477,7 +476,7 @@ foreach ($dirmodels as $reldir)
$classname = substr($file, 0, dol_strlen($file) - 12);
$var=!$var;
- print "
| ";
+ print ' |
| ';
print $name;
print " | \n";
require_once($dir.$file);
@@ -489,17 +488,10 @@ foreach ($dirmodels as $reldir)
// Active
if (in_array($name, $def))
{
- print " | \n";
- //if ($conf->global->EXPEDITION_ADDON_PDF != $name)
- //{
- print '';
- print img_picto($langs->trans("Activated"),'switch_on');
- print '';
- //}
- //else
- //{
- // print img_picto($langs->trans("Activated"),'switch_on');
- //}
+ print " | \n";
+ print '';
+ print img_picto($langs->trans("Activated"),'switch_on');
+ print '';
print " | ";
}
else
diff --git a/htdocs/core/modules/expedition/modules_expedition.php b/htdocs/core/modules/expedition/modules_expedition.php
index f239178236e..b06872d3e0d 100644
--- a/htdocs/core/modules/expedition/modules_expedition.php
+++ b/htdocs/core/modules/expedition/modules_expedition.php
@@ -5,7 +5,7 @@
* Copyright (C) 2005-2011 Regis Houssin
* Copyright (C) 2006 Andre Cianfarani
* Copyright (C) 2011 Juanjo Menent
- * Copyright (C) 2011 Philippe Grand
+ * Copyright (C) 2011-2012 Philippe Grand
*
* 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
@@ -156,13 +156,8 @@ function expedition_pdf_create($db, $object, $modele, $outputlangs)
$langs->load("sendings");
- // Increase limit for PDF build
- $err=error_reporting();
- error_reporting(0);
- @set_time_limit(120);
- error_reporting($err);
+ $error=0;
- $dir = "/core/modules/expedition/";
$srctemplatepath='';
// Positionne le modele sur le nom du modele a utiliser
@@ -180,28 +175,33 @@ function expedition_pdf_create($db, $object, $modele, $outputlangs)
// If selected modele is a filename template (then $modele="modelname:filename")
$tmp=explode(':',$modele,2);
- if (! empty($tmp[1]))
- {
- $modele=$tmp[0];
- $srctemplatepath=$tmp[1];
- }
+ if (! empty($tmp[1]))
+ {
+ $modele=$tmp[0];
+ $srctemplatepath=$tmp[1];
+ }
- // Search template file
+ // Search template files
$file=''; $classname=''; $filefound=0;
- foreach(array('doc','pdf') as $prefix)
+ $dirmodels=array('/');
+ if (is_array($conf->modules_parts['models'])) $dirmodels=array_merge($dirmodels,$conf->modules_parts['models']);
+ foreach($dirmodels as $reldir)
{
- $file = $prefix."_expedition_".$modele.".modules.php";
+ foreach(array('doc','pdf') as $prefix)
+ {
+ $file = $prefix."_expedition_".$modele.".modules.php";
- // On verifie l'emplacement du modele
- $file = dol_buildpath($dir.'doc/'.$file);
-
- if (file_exists($file))
- {
- $filefound=1;
- $classname=$prefix.'_expedition_'.$modele;
- break;
- }
- }
+ // On verifie l'emplacement du modele
+ $file=dol_buildpath($reldir."core/modules/expedition/doc/".$file,0);
+ if (file_exists($file))
+ {
+ $filefound=1;
+ $classname=$prefix.'_expedition_'.$modele;
+ break;
+ }
+ }
+ if ($filefound) break;
+ }
// Charge le modele
if ($filefound)
@@ -215,7 +215,7 @@ function expedition_pdf_create($db, $object, $modele, $outputlangs)
// We save charset_output to restore it because write_file can change it if needed for
// output format that does not support UTF8.
$sav_charset_output=$outputlangs->charset_output;
- if ($obj->write_file($object, $outputlangs) > 0)
+ if ($obj->write_file($object, $outputlangs, $srctemplatepath) > 0)
{
$outputlangs->charset_output=$sav_charset_output;
@@ -238,4 +238,4 @@ function expedition_pdf_create($db, $object, $modele, $outputlangs)
return -1;
}
}
-?>
+?>
\ No newline at end of file