Fix: Code was sharing loop for custom dir and loop for subdir modules.
The loop to manage customdir must be managed by the dol_buildpath so only loop on / + module dir must be done.
This commit is contained in:
parent
7e3cb90f5a
commit
51fb1b2385
@ -70,34 +70,27 @@ if ($action == 'specimen')
|
||||
|
||||
$commande = new Commande($db);
|
||||
$commande->initAsSpecimen();
|
||||
|
||||
// Check if there is external models to do asked by plugins
|
||||
if (is_array($conf->models_modules) && ! empty($conf->models_modules)) {
|
||||
$conf->file->dol_document_root = array_merge($conf->file->dol_document_root,$conf->models_modules);
|
||||
}
|
||||
|
||||
// Search template file
|
||||
|
||||
// Search template files
|
||||
$file=''; $classname=''; $filefound=0;
|
||||
foreach ($conf->file->dol_document_root as $dirroot)
|
||||
$dirmodels=array_merge(array('/'),$conf->models_modules);
|
||||
foreach($dirmodels as $reldir)
|
||||
{
|
||||
// Charge le modele
|
||||
$dir = $dirroot."/core/modules/commande/doc/";
|
||||
$file = $dir."pdf_".$modele.".modules.php";
|
||||
$file=dol_buildpath($reldir."core/modules/commande/doc/pdf_".$modele.".modules.php",0);
|
||||
if (file_exists($file))
|
||||
{
|
||||
$filefound=1;
|
||||
$classname = "pdf_".$modele;
|
||||
break;
|
||||
require_once($file);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ($filefound)
|
||||
{
|
||||
require_once($file);
|
||||
|
||||
|
||||
$module = new $classname($db);
|
||||
|
||||
|
||||
if ($module->write_file($commande,$langs) > 0)
|
||||
{
|
||||
header("Location: ".DOL_URL_ROOT."/document.php?modulepart=commande&file=SPECIMEN.pdf");
|
||||
|
||||
@ -69,19 +69,13 @@ if ($action == 'specimen')
|
||||
|
||||
$facture = new Facture($db);
|
||||
$facture->initAsSpecimen();
|
||||
|
||||
// Check if there is external models to do asked by plugins
|
||||
if (is_array($conf->models_modules) && ! empty($conf->models_modules)) {
|
||||
$conf->file->dol_document_root = array_merge($conf->file->dol_document_root,$conf->models_modules);
|
||||
}
|
||||
|
||||
// Search template file
|
||||
$file=''; $classname=''; $filefound=0;
|
||||
foreach ($conf->file->dol_document_root as $dirroot)
|
||||
{
|
||||
// Load template
|
||||
$dir = $dirroot."/core/modules/facture/doc/";
|
||||
$file = $dir."pdf_".$modele.".modules.php";
|
||||
|
||||
// Search template files
|
||||
$file=''; $classname=''; $filefound=0;
|
||||
$dirmodels=array_merge(array('/'),$conf->models_modules);
|
||||
foreach($dirmodels as $reldir)
|
||||
{
|
||||
$file=dol_buildpath($reldir."core/modules/facture/doc/pdf_".$modele.".modules.php",0);
|
||||
if (file_exists($file))
|
||||
{
|
||||
$filefound=1;
|
||||
@ -89,13 +83,13 @@ if ($action == 'specimen')
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ($filefound)
|
||||
{
|
||||
require_once($file);
|
||||
|
||||
|
||||
$module = new $classname($db);
|
||||
|
||||
|
||||
if ($module->write_file($facture,$langs) > 0)
|
||||
{
|
||||
header("Location: ".DOL_URL_ROOT."/document.php?modulepart=facture&file=SPECIMEN.pdf");
|
||||
|
||||
@ -69,18 +69,12 @@ if ($action == 'specimen')
|
||||
$propal = new Propal($db);
|
||||
$propal->initAsSpecimen();
|
||||
|
||||
// Check if there is external models to do asked by plugins
|
||||
if (is_array($conf->models_modules) && ! empty($conf->models_modules)) {
|
||||
$conf->file->dol_document_root = array_merge($conf->file->dol_document_root,$conf->models_modules);
|
||||
}
|
||||
|
||||
// Search template file
|
||||
// Search template files
|
||||
$file=''; $classname=''; $filefound=0;
|
||||
foreach ($conf->file->dol_document_root as $dirroot)
|
||||
$dirmodels=array_merge(array('/'),$conf->models_modules);
|
||||
foreach($dirmodels as $reldir)
|
||||
{
|
||||
// Charge le modele
|
||||
$dir = $dirroot."/core/modules/propale/doc/";
|
||||
$file = $dir."pdf_".$modele.".modules.php";
|
||||
$file=dol_buildpath($reldir."core/modules/propale/doc/pdf_".$modele.".modules.php",0);
|
||||
if (file_exists($file))
|
||||
{
|
||||
$filefound=1;
|
||||
@ -88,13 +82,13 @@ if ($action == 'specimen')
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ($filefound)
|
||||
{
|
||||
require_once($file);
|
||||
|
||||
|
||||
$module = new $classname($db);
|
||||
|
||||
|
||||
if ($module->write_file($propal,$langs) > 0)
|
||||
{
|
||||
header("Location: ".DOL_URL_ROOT."/document.php?modulepart=propal&file=SPECIMEN.pdf");
|
||||
|
||||
@ -158,7 +158,6 @@ function commande_pdf_create($db, $object, $modele, $outputlangs, $hidedetails=0
|
||||
|
||||
$error=0;
|
||||
|
||||
$dir = "/core/modules/commande/";
|
||||
$srctemplatepath='';
|
||||
|
||||
// Positionne le modele sur le nom du modele a utiliser
|
||||
@ -181,22 +180,18 @@ function commande_pdf_create($db, $object, $modele, $outputlangs, $hidedetails=0
|
||||
$modele=$tmp[0];
|
||||
$srctemplatepath=$tmp[1];
|
||||
}
|
||||
|
||||
// Check if there is external models to do asked by plugins
|
||||
if (is_array($conf->models_modules) && ! empty($conf->models_modules)) {
|
||||
$conf->file->dol_document_root = array_merge($conf->file->dol_document_root,$conf->models_modules);
|
||||
}
|
||||
|
||||
foreach ($conf->file->dol_document_root as $dirroot)
|
||||
{
|
||||
// Search template file
|
||||
$file=''; $classname=''; $filefound=0;
|
||||
|
||||
// Search template files
|
||||
$file=''; $classname=''; $filefound=0;
|
||||
$dirmodels=array_merge(array('/'),$conf->models_modules);
|
||||
foreach($dirmodels as $reldir)
|
||||
{
|
||||
foreach(array('doc','pdf') as $prefix)
|
||||
{
|
||||
$file = $prefix."_".$modele.".modules.php";
|
||||
|
||||
$file = $prefix."_".$modele.".modules.php";
|
||||
|
||||
// On verifie l'emplacement du modele
|
||||
$file = $dirroot.$dir.'doc/'.$file;
|
||||
$file=dol_buildpath($reldir."core/modules/commande/doc/".$file,0);
|
||||
if (file_exists($file))
|
||||
{
|
||||
$filefound=1;
|
||||
|
||||
@ -149,14 +149,13 @@ function facture_pdf_create($db, $object, $modele, $outputlangs, $hidedetails=0,
|
||||
$langs->load("bills");
|
||||
|
||||
$error=0;
|
||||
|
||||
|
||||
// Increase limit for PDF build
|
||||
$err=error_reporting();
|
||||
error_reporting(0);
|
||||
@set_time_limit(120);
|
||||
error_reporting($err);
|
||||
|
||||
$dir = "/core/modules/facture/";
|
||||
$srctemplatepath='';
|
||||
|
||||
// Positionne le modele sur le nom du modele a utiliser
|
||||
@ -179,22 +178,18 @@ function facture_pdf_create($db, $object, $modele, $outputlangs, $hidedetails=0,
|
||||
$modele=$tmp[0];
|
||||
$srctemplatepath=$tmp[1];
|
||||
}
|
||||
|
||||
// Check if there is external models to do asked by plugins
|
||||
if (is_array($conf->models_modules) && ! empty($conf->models_modules)) {
|
||||
$conf->file->dol_document_root = array_merge($conf->file->dol_document_root,$conf->models_modules);
|
||||
}
|
||||
|
||||
foreach ($conf->file->dol_document_root as $dirroot)
|
||||
{
|
||||
// Search template file
|
||||
$file=''; $classname=''; $filefound=0;
|
||||
|
||||
// Search template files
|
||||
$file=''; $classname=''; $filefound=0;
|
||||
$dirmodels=array_merge(array('/'),$conf->models_modules);
|
||||
foreach($dirmodels as $reldir)
|
||||
{
|
||||
foreach(array('doc','pdf') as $prefix)
|
||||
{
|
||||
$file = $prefix."_".$modele.".modules.php";
|
||||
|
||||
$file = $prefix."_".$modele.".modules.php";
|
||||
|
||||
// On verifie l'emplacement du modele
|
||||
$file = $dirroot.$dir.'doc/'.$file;
|
||||
$file=dol_buildpath($reldir."core/modules/facture/doc/".$file,0);
|
||||
if (file_exists($file))
|
||||
{
|
||||
$filefound=1;
|
||||
|
||||
@ -159,7 +159,6 @@ function propale_pdf_create($db, $object, $modele, $outputlangs, $hidedetails=0,
|
||||
|
||||
$error=0;
|
||||
|
||||
$dir = "/core/modules/propale/";
|
||||
$srctemplatepath='';
|
||||
|
||||
// Positionne le modele sur le nom du modele a utiliser
|
||||
@ -182,22 +181,18 @@ function propale_pdf_create($db, $object, $modele, $outputlangs, $hidedetails=0,
|
||||
$modele=$tmp[0];
|
||||
$srctemplatepath=$tmp[1];
|
||||
}
|
||||
|
||||
// Check if there is external models to do asked by plugins
|
||||
if (is_array($conf->models_modules) && ! empty($conf->models_modules)) {
|
||||
$conf->file->dol_document_root = array_merge($conf->file->dol_document_root,$conf->models_modules);
|
||||
}
|
||||
|
||||
// Search template file
|
||||
$file=''; $classname=''; $filefound=0;
|
||||
foreach ($conf->file->dol_document_root as $dirroot)
|
||||
{
|
||||
|
||||
// Search template files
|
||||
$file=''; $classname=''; $filefound=0;
|
||||
$dirmodels=array_merge(array('/'),$conf->models_modules);
|
||||
foreach($dirmodels as $reldir)
|
||||
{
|
||||
foreach(array('doc','pdf') as $prefix)
|
||||
{
|
||||
$file = $prefix."_".$modele.".modules.php";
|
||||
|
||||
$file = $prefix."_".$modele.".modules.php";
|
||||
|
||||
// On verifie l'emplacement du modele
|
||||
$file = $dirroot.$dir.'doc/'.$file;
|
||||
$file=dol_buildpath($reldir."core/modules/propale/doc/".$file,0);
|
||||
if (file_exists($file))
|
||||
{
|
||||
$filefound=1;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user