Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge branch 'develop' of ssh://git@github.com/Dolibarr/dolibarr.git …

…into develop
  • Loading branch information...
commit d30cd86dcdab0c4ee0a087c29980a2eb44eec1d2 2 parents a98439a + cd170db
@eldy eldy authored
Showing with 31 additions and 21 deletions.
  1. +31 −21 htdocs/admin/expedition.php
View
52 htdocs/admin/expedition.php
@@ -6,6 +6,7 @@
* Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com>
* Copyright (C) 2005-2011 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2011-2012 Juanjo Menent <jmenent@2byte.es>
+ * Copyright (C) 2011-2012 Philippe Grand <philippe.grand@atoo-net.com>
*
* 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
@@ -55,28 +56,36 @@
$exp = new Expedition($db);
$exp->initAsSpecimen();
- //$exp->fetch_commande();
- // Charge le modele
- $dir = "/core/modules/expedition/doc/";
- $file = "pdf_expedition_".$modele.".modules.php";
- $file = dol_buildpath($dir.$file);
- if (file_exists($file))
+ // Search template files
+ $file=''; $classname=''; $filefound=0;
+ $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);
+ if (file_exists($file))
+ {
+ $filefound=1;
+ $classname = "pdf_".$modele;
+ break;
+ }
+ }
+
+ if ($filefound)
{
- $classname = "pdf_expedition_".$modele;
require_once($file);
- $obj = new $classname($db);
+ $module = new $classname($db);
- if ($obj->write_file($exp,$langs) > 0)
+ if ($module->write_file($exp,$langs) > 0)
{
header("Location: ".DOL_URL_ROOT."/document.php?modulepart=expedition&file=SPECIMEN.pdf");
return;
}
else
{
- $mesg='<font class="error">'.$obj->error.'</font>';
- dol_syslog($obj->error, LOG_ERR);
+ $mesg='<font class="error">'.$module->error.'</font>';
+ dol_syslog($module->error, LOG_ERR);
}
}
else
@@ -298,8 +307,9 @@
* View
*/
-$form=new Form($db);
+$dirmodels=array_merge(array('/'),(array) $conf->modules_parts['models']);
+$form=new Form($db);
llxHeader("","");
@@ -349,9 +359,9 @@
clearstatcache();
-foreach ($conf->file->dol_document_root as $dirroot)
+foreach ($dirmodels as $reldir)
{
- $dir = $dirroot . "/core/modules/expedition/";
+ $dir = dol_buildpath($reldir."core/modules/expedition/");
if (is_dir($dir))
{
@@ -362,9 +372,10 @@
while (($file = readdir($handle))!==false)
{
- if (substr($file, 0, 15) == 'mod_expedition_' && substr($file, dol_strlen($file)-3, 3) == 'php')
+ if (preg_match('/^(mod_.*)\.php$/i',$file,$reg))
{
- $file = substr($file, 0, dol_strlen($file)-4);
+ $file = $reg[1];
+ $classname = substr($file,4);
require_once(DOL_DOCUMENT_ROOT ."/core/modules/expedition/".$file.".php");
@@ -482,15 +493,14 @@
clearstatcache();
-foreach ($conf->file->dol_document_root as $dirroot)
+$var=true;
+foreach ($dirmodels as $reldir)
{
- $dir = $dirroot . "/core/modules/expedition/doc/";
+ $dir = dol_buildpath($reldir."core/modules/expedition/doc/");
if (is_dir($dir))
{
$handle=opendir($dir);
- $var=true;
-
if (is_resource($handle))
{
while (($file = readdir($handle))!==false)
@@ -613,4 +623,4 @@
$db->close();
llxFooter();
-?>
+?>
Please sign in to comment.
Something went wrong with that request. Please try again.