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 = new Commande($db);
|
||||||
$commande->initAsSpecimen();
|
$commande->initAsSpecimen();
|
||||||
|
|
||||||
// Check if there is external models to do asked by plugins
|
// Search template files
|
||||||
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;
|
$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
|
$file=dol_buildpath($reldir."core/modules/commande/doc/pdf_".$modele.".modules.php",0);
|
||||||
$dir = $dirroot."/core/modules/commande/doc/";
|
|
||||||
$file = $dir."pdf_".$modele.".modules.php";
|
|
||||||
if (file_exists($file))
|
if (file_exists($file))
|
||||||
{
|
{
|
||||||
$filefound=1;
|
$filefound=1;
|
||||||
$classname = "pdf_".$modele;
|
$classname = "pdf_".$modele;
|
||||||
break;
|
break;
|
||||||
require_once($file);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($filefound)
|
if ($filefound)
|
||||||
{
|
{
|
||||||
require_once($file);
|
require_once($file);
|
||||||
|
|
||||||
$module = new $classname($db);
|
$module = new $classname($db);
|
||||||
|
|
||||||
if ($module->write_file($commande,$langs) > 0)
|
if ($module->write_file($commande,$langs) > 0)
|
||||||
{
|
{
|
||||||
header("Location: ".DOL_URL_ROOT."/document.php?modulepart=commande&file=SPECIMEN.pdf");
|
header("Location: ".DOL_URL_ROOT."/document.php?modulepart=commande&file=SPECIMEN.pdf");
|
||||||
|
|||||||
@ -69,19 +69,13 @@ if ($action == 'specimen')
|
|||||||
|
|
||||||
$facture = new Facture($db);
|
$facture = new Facture($db);
|
||||||
$facture->initAsSpecimen();
|
$facture->initAsSpecimen();
|
||||||
|
|
||||||
// Check if there is external models to do asked by plugins
|
// Search template files
|
||||||
if (is_array($conf->models_modules) && ! empty($conf->models_modules)) {
|
$file=''; $classname=''; $filefound=0;
|
||||||
$conf->file->dol_document_root = array_merge($conf->file->dol_document_root,$conf->models_modules);
|
$dirmodels=array_merge(array('/'),$conf->models_modules);
|
||||||
}
|
foreach($dirmodels as $reldir)
|
||||||
|
{
|
||||||
// Search template file
|
$file=dol_buildpath($reldir."core/modules/facture/doc/pdf_".$modele.".modules.php",0);
|
||||||
$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";
|
|
||||||
if (file_exists($file))
|
if (file_exists($file))
|
||||||
{
|
{
|
||||||
$filefound=1;
|
$filefound=1;
|
||||||
@ -89,13 +83,13 @@ if ($action == 'specimen')
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($filefound)
|
if ($filefound)
|
||||||
{
|
{
|
||||||
require_once($file);
|
require_once($file);
|
||||||
|
|
||||||
$module = new $classname($db);
|
$module = new $classname($db);
|
||||||
|
|
||||||
if ($module->write_file($facture,$langs) > 0)
|
if ($module->write_file($facture,$langs) > 0)
|
||||||
{
|
{
|
||||||
header("Location: ".DOL_URL_ROOT."/document.php?modulepart=facture&file=SPECIMEN.pdf");
|
header("Location: ".DOL_URL_ROOT."/document.php?modulepart=facture&file=SPECIMEN.pdf");
|
||||||
|
|||||||
@ -69,18 +69,12 @@ if ($action == 'specimen')
|
|||||||
$propal = new Propal($db);
|
$propal = new Propal($db);
|
||||||
$propal->initAsSpecimen();
|
$propal->initAsSpecimen();
|
||||||
|
|
||||||
// Check if there is external models to do asked by plugins
|
// Search template files
|
||||||
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;
|
$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
|
$file=dol_buildpath($reldir."core/modules/propale/doc/pdf_".$modele.".modules.php",0);
|
||||||
$dir = $dirroot."/core/modules/propale/doc/";
|
|
||||||
$file = $dir."pdf_".$modele.".modules.php";
|
|
||||||
if (file_exists($file))
|
if (file_exists($file))
|
||||||
{
|
{
|
||||||
$filefound=1;
|
$filefound=1;
|
||||||
@ -88,13 +82,13 @@ if ($action == 'specimen')
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($filefound)
|
if ($filefound)
|
||||||
{
|
{
|
||||||
require_once($file);
|
require_once($file);
|
||||||
|
|
||||||
$module = new $classname($db);
|
$module = new $classname($db);
|
||||||
|
|
||||||
if ($module->write_file($propal,$langs) > 0)
|
if ($module->write_file($propal,$langs) > 0)
|
||||||
{
|
{
|
||||||
header("Location: ".DOL_URL_ROOT."/document.php?modulepart=propal&file=SPECIMEN.pdf");
|
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;
|
$error=0;
|
||||||
|
|
||||||
$dir = "/core/modules/commande/";
|
|
||||||
$srctemplatepath='';
|
$srctemplatepath='';
|
||||||
|
|
||||||
// Positionne le modele sur le nom du modele a utiliser
|
// 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];
|
$modele=$tmp[0];
|
||||||
$srctemplatepath=$tmp[1];
|
$srctemplatepath=$tmp[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if there is external models to do asked by plugins
|
// Search template files
|
||||||
if (is_array($conf->models_modules) && ! empty($conf->models_modules)) {
|
$file=''; $classname=''; $filefound=0;
|
||||||
$conf->file->dol_document_root = array_merge($conf->file->dol_document_root,$conf->models_modules);
|
$dirmodels=array_merge(array('/'),$conf->models_modules);
|
||||||
}
|
foreach($dirmodels as $reldir)
|
||||||
|
{
|
||||||
foreach ($conf->file->dol_document_root as $dirroot)
|
|
||||||
{
|
|
||||||
// Search template file
|
|
||||||
$file=''; $classname=''; $filefound=0;
|
|
||||||
foreach(array('doc','pdf') as $prefix)
|
foreach(array('doc','pdf') as $prefix)
|
||||||
{
|
{
|
||||||
$file = $prefix."_".$modele.".modules.php";
|
$file = $prefix."_".$modele.".modules.php";
|
||||||
|
|
||||||
// On verifie l'emplacement du modele
|
// 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))
|
if (file_exists($file))
|
||||||
{
|
{
|
||||||
$filefound=1;
|
$filefound=1;
|
||||||
|
|||||||
@ -149,14 +149,13 @@ function facture_pdf_create($db, $object, $modele, $outputlangs, $hidedetails=0,
|
|||||||
$langs->load("bills");
|
$langs->load("bills");
|
||||||
|
|
||||||
$error=0;
|
$error=0;
|
||||||
|
|
||||||
// Increase limit for PDF build
|
// Increase limit for PDF build
|
||||||
$err=error_reporting();
|
$err=error_reporting();
|
||||||
error_reporting(0);
|
error_reporting(0);
|
||||||
@set_time_limit(120);
|
@set_time_limit(120);
|
||||||
error_reporting($err);
|
error_reporting($err);
|
||||||
|
|
||||||
$dir = "/core/modules/facture/";
|
|
||||||
$srctemplatepath='';
|
$srctemplatepath='';
|
||||||
|
|
||||||
// Positionne le modele sur le nom du modele a utiliser
|
// 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];
|
$modele=$tmp[0];
|
||||||
$srctemplatepath=$tmp[1];
|
$srctemplatepath=$tmp[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if there is external models to do asked by plugins
|
// Search template files
|
||||||
if (is_array($conf->models_modules) && ! empty($conf->models_modules)) {
|
$file=''; $classname=''; $filefound=0;
|
||||||
$conf->file->dol_document_root = array_merge($conf->file->dol_document_root,$conf->models_modules);
|
$dirmodels=array_merge(array('/'),$conf->models_modules);
|
||||||
}
|
foreach($dirmodels as $reldir)
|
||||||
|
{
|
||||||
foreach ($conf->file->dol_document_root as $dirroot)
|
|
||||||
{
|
|
||||||
// Search template file
|
|
||||||
$file=''; $classname=''; $filefound=0;
|
|
||||||
foreach(array('doc','pdf') as $prefix)
|
foreach(array('doc','pdf') as $prefix)
|
||||||
{
|
{
|
||||||
$file = $prefix."_".$modele.".modules.php";
|
$file = $prefix."_".$modele.".modules.php";
|
||||||
|
|
||||||
// On verifie l'emplacement du modele
|
// 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))
|
if (file_exists($file))
|
||||||
{
|
{
|
||||||
$filefound=1;
|
$filefound=1;
|
||||||
|
|||||||
@ -159,7 +159,6 @@ function propale_pdf_create($db, $object, $modele, $outputlangs, $hidedetails=0,
|
|||||||
|
|
||||||
$error=0;
|
$error=0;
|
||||||
|
|
||||||
$dir = "/core/modules/propale/";
|
|
||||||
$srctemplatepath='';
|
$srctemplatepath='';
|
||||||
|
|
||||||
// Positionne le modele sur le nom du modele a utiliser
|
// 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];
|
$modele=$tmp[0];
|
||||||
$srctemplatepath=$tmp[1];
|
$srctemplatepath=$tmp[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if there is external models to do asked by plugins
|
// Search template files
|
||||||
if (is_array($conf->models_modules) && ! empty($conf->models_modules)) {
|
$file=''; $classname=''; $filefound=0;
|
||||||
$conf->file->dol_document_root = array_merge($conf->file->dol_document_root,$conf->models_modules);
|
$dirmodels=array_merge(array('/'),$conf->models_modules);
|
||||||
}
|
foreach($dirmodels as $reldir)
|
||||||
|
{
|
||||||
// Search template file
|
|
||||||
$file=''; $classname=''; $filefound=0;
|
|
||||||
foreach ($conf->file->dol_document_root as $dirroot)
|
|
||||||
{
|
|
||||||
foreach(array('doc','pdf') as $prefix)
|
foreach(array('doc','pdf') as $prefix)
|
||||||
{
|
{
|
||||||
$file = $prefix."_".$modele.".modules.php";
|
$file = $prefix."_".$modele.".modules.php";
|
||||||
|
|
||||||
// On verifie l'emplacement du modele
|
// 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))
|
if (file_exists($file))
|
||||||
{
|
{
|
||||||
$filefound=1;
|
$filefound=1;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user