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

This commit is contained in:
Laurent Destailleur 2012-04-04 21:45:07 +02:00
commit d30cd86dcd

View File

@ -6,6 +6,7 @@
* Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com> * Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com>
* Copyright (C) 2005-2011 Regis Houssin <regis@dolibarr.fr> * Copyright (C) 2005-2011 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2011-2012 Juanjo Menent <jmenent@2byte.es> * 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 * 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 * it under the terms of the GNU General Public License as published by
@ -55,28 +56,36 @@ if ($action == 'specimen')
$exp = new Expedition($db); $exp = new Expedition($db);
$exp->initAsSpecimen(); $exp->initAsSpecimen();
//$exp->fetch_commande();
// Charge le modele // Search template files
$dir = "/core/modules/expedition/doc/"; $file=''; $classname=''; $filefound=0;
$file = "pdf_expedition_".$modele.".modules.php"; $dirmodels=array_merge(array('/'),(array) $conf->modules_parts['models']);
$file = dol_buildpath($dir.$file); foreach($dirmodels as $reldir)
if (file_exists($file)) {
$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); 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"); header("Location: ".DOL_URL_ROOT."/document.php?modulepart=expedition&file=SPECIMEN.pdf");
return; return;
} }
else else
{ {
$mesg='<font class="error">'.$obj->error.'</font>'; $mesg='<font class="error">'.$module->error.'</font>';
dol_syslog($obj->error, LOG_ERR); dol_syslog($module->error, LOG_ERR);
} }
} }
else else
@ -298,8 +307,9 @@ if ($action == 'set_SHIPPING_FREE_TEXT')
* View * View
*/ */
$form=new Form($db); $dirmodels=array_merge(array('/'),(array) $conf->modules_parts['models']);
$form=new Form($db);
llxHeader("",""); llxHeader("","");
@ -349,9 +359,9 @@ print "</tr>\n";
clearstatcache(); 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)) if (is_dir($dir))
{ {
@ -362,9 +372,10 @@ foreach ($conf->file->dol_document_root as $dirroot)
while (($file = readdir($handle))!==false) 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"); require_once(DOL_DOCUMENT_ROOT ."/core/modules/expedition/".$file.".php");
@ -482,15 +493,14 @@ print "</tr>\n";
clearstatcache(); 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)) if (is_dir($dir))
{ {
$handle=opendir($dir); $handle=opendir($dir);
$var=true;
if (is_resource($handle)) if (is_resource($handle))
{ {
while (($file = readdir($handle))!==false) while (($file = readdir($handle))!==false)
@ -613,4 +623,4 @@ dol_htmloutput_mesg($mesg);
$db->close(); $db->close();
llxFooter(); llxFooter();
?> ?>