Fix: possibility to use models of external modules
This commit is contained in:
parent
07ee6208a9
commit
79c0369d66
@ -70,32 +70,48 @@ if ($action == 'specimen')
|
||||
|
||||
$commande = new Commande($db);
|
||||
$commande->initAsSpecimen();
|
||||
|
||||
// Charge le modele
|
||||
$dir = "/core/modules/commande/doc/";
|
||||
$file = "pdf_".$modele.".modules.php";
|
||||
$file = dol_buildpath($dir.$file);
|
||||
if (file_exists($file))
|
||||
|
||||
// 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)
|
||||
{
|
||||
// Charge le modele
|
||||
$dir = $dirroot."/core/modules/commande/doc/";
|
||||
$file = $dir."pdf_".$modele.".modules.php";
|
||||
if (file_exists($file))
|
||||
{
|
||||
$filefound=1;
|
||||
$classname = "pdf_".$modele;
|
||||
break;
|
||||
require_once($file);
|
||||
}
|
||||
}
|
||||
|
||||
if ($filefound)
|
||||
{
|
||||
$classname = "pdf_".$modele;
|
||||
require_once($file);
|
||||
|
||||
$obj = new $classname($db);
|
||||
|
||||
if ($obj->write_file($commande,$langs) > 0)
|
||||
|
||||
$module = new $classname($db);
|
||||
|
||||
if ($module->write_file($commande,$langs) > 0)
|
||||
{
|
||||
header("Location: ".DOL_URL_ROOT."/document.php?modulepart=commande&file=SPECIMEN.pdf");
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
$mesg='<div class="error">'.$obj->error.'</div>';
|
||||
dol_syslog($obj->error, LOG_ERR);
|
||||
$mesg='<font class="error">'.$module->error.'</font>';
|
||||
dol_syslog($module->error, LOG_ERR);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$mesg='<div class="error">'.$langs->trans("ErrorModuleNotFound").'</div>';
|
||||
$mesg='<font class="error">'.$langs->trans("ErrorModuleNotFound").'</font>';
|
||||
dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR);
|
||||
}
|
||||
}
|
||||
|
||||
@ -69,32 +69,48 @@ if ($action == 'specimen')
|
||||
|
||||
$facture = new Facture($db);
|
||||
$facture->initAsSpecimen();
|
||||
|
||||
// Load template
|
||||
$dir = DOL_DOCUMENT_ROOT . "/core/modules/facture/doc/";
|
||||
$file = "pdf_".$modele.".modules.php";
|
||||
if (file_exists($dir.$file))
|
||||
|
||||
// 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)
|
||||
{
|
||||
$classname = "pdf_".$modele;
|
||||
require_once($dir.$file);
|
||||
|
||||
$obj = new $classname($db);
|
||||
|
||||
if ($obj->write_file($facture,$langs) > 0)
|
||||
{
|
||||
header("Location: ".DOL_URL_ROOT."/document.php?modulepart=facture&file=SPECIMEN.pdf");
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
$mesg='<font class="error">'.$obj->error.'</font>';
|
||||
dol_syslog($obj->error, LOG_ERR);
|
||||
}
|
||||
// Load template
|
||||
$dir = $dirroot."/core/modules/facture/doc/";
|
||||
$file = $dir."pdf_".$modele.".modules.php";
|
||||
if (file_exists($file))
|
||||
{
|
||||
$filefound=1;
|
||||
$classname = "pdf_".$modele;
|
||||
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");
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
$mesg='<font class="error">'.$module->error.'</font>';
|
||||
dol_syslog($module->error, LOG_ERR);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$mesg='<font class="error">'.$langs->trans("ErrorModuleNotFound").'</font>';
|
||||
dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR);
|
||||
$mesg='<font class="error">'.$langs->trans("ErrorModuleNotFound").'</font>';
|
||||
dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -69,17 +69,32 @@ if ($action == 'specimen')
|
||||
$propal = new Propal($db);
|
||||
$propal->initAsSpecimen();
|
||||
|
||||
// Charge le modele
|
||||
$dir = "/core/modules/propale/doc/";
|
||||
$file = "pdf_".$modele.".modules.php";
|
||||
$file = dol_buildpath($dir.$file);
|
||||
if (file_exists($file))
|
||||
// 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)
|
||||
{
|
||||
// Charge le modele
|
||||
$dir = $dirroot."/core/modules/propale/doc/";
|
||||
$file = $dir."pdf_".$modele.".modules.php";
|
||||
if (file_exists($file))
|
||||
{
|
||||
$filefound=1;
|
||||
$classname = "pdf_".$modele;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ($filefound)
|
||||
{
|
||||
$classname = "pdf_".$modele;
|
||||
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");
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
/* Copyright (C) 2003-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com>
|
||||
* Copyright (C) 2005-2011 Regis Houssin <regis@dolibarr.fr>
|
||||
* Copyright (C) 2005-2012 Regis Houssin <regis@dolibarr.fr>
|
||||
* Copyright (C) 2006 Andre Cianfarani <acianfa@free.fr>
|
||||
* Copyright (C) 2012 Juanjo Menent <jmenent@2byte.es>
|
||||
*
|
||||
@ -181,23 +181,31 @@ function commande_pdf_create($db, $object, $modele, $outputlangs, $hidedetails=0
|
||||
$modele=$tmp[0];
|
||||
$srctemplatepath=$tmp[1];
|
||||
}
|
||||
|
||||
// Search template file
|
||||
$file=''; $classname=''; $filefound=0;
|
||||
foreach(array('doc','pdf') as $prefix)
|
||||
{
|
||||
$file = $prefix."_".$modele.".modules.php";
|
||||
|
||||
// On verifie l'emplacement du modele
|
||||
$file = dol_buildpath($dir.'doc/'.$file);
|
||||
|
||||
if (file_exists($file))
|
||||
{
|
||||
$filefound=1;
|
||||
$classname=$prefix.'_'.$modele;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// 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;
|
||||
foreach(array('doc','pdf') as $prefix)
|
||||
{
|
||||
$file = $prefix."_".$modele.".modules.php";
|
||||
|
||||
// On verifie l'emplacement du modele
|
||||
$file = $dirroot.$dir.'doc/'.$file;
|
||||
if (file_exists($file))
|
||||
{
|
||||
$filefound=1;
|
||||
$classname=$prefix.'_'.$modele;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ($filefound) break;
|
||||
}
|
||||
|
||||
// Charge le modele
|
||||
if ($filefound)
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
/* Copyright (C) 2003-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com>
|
||||
* Copyright (C) 2005-2011 Regis Houssin <regis@dolibarr.fr>
|
||||
* Copyright (C) 2005-2012 Regis Houssin <regis@dolibarr.fr>
|
||||
*
|
||||
* 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
|
||||
@ -179,23 +179,31 @@ function facture_pdf_create($db, $object, $modele, $outputlangs, $hidedetails=0,
|
||||
$modele=$tmp[0];
|
||||
$srctemplatepath=$tmp[1];
|
||||
}
|
||||
|
||||
// Search template file
|
||||
$file=''; $classname=''; $filefound=0;
|
||||
foreach(array('doc','pdf') as $prefix)
|
||||
{
|
||||
$file = $prefix."_".$modele.".modules.php";
|
||||
|
||||
// On verifie l'emplacement du modele
|
||||
$file = dol_buildpath($dir.'doc/'.$file);
|
||||
|
||||
if (file_exists($file))
|
||||
{
|
||||
$filefound=1;
|
||||
$classname=$prefix.'_'.$modele;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// 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;
|
||||
foreach(array('doc','pdf') as $prefix)
|
||||
{
|
||||
$file = $prefix."_".$modele.".modules.php";
|
||||
|
||||
// On verifie l'emplacement du modele
|
||||
$file = $dirroot.$dir.'doc/'.$file;
|
||||
if (file_exists($file))
|
||||
{
|
||||
$filefound=1;
|
||||
$classname=$prefix.'_'.$modele;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ($filefound) break;
|
||||
}
|
||||
|
||||
// Charge le modele
|
||||
if ($filefound)
|
||||
|
||||
@ -182,23 +182,31 @@ function propale_pdf_create($db, $object, $modele, $outputlangs, $hidedetails=0,
|
||||
$modele=$tmp[0];
|
||||
$srctemplatepath=$tmp[1];
|
||||
}
|
||||
|
||||
// Search template file
|
||||
$file=''; $classname=''; $filefound=0;
|
||||
foreach(array('doc','pdf') as $prefix)
|
||||
{
|
||||
$file = $prefix."_".$modele.".modules.php";
|
||||
|
||||
// On verifie l'emplacement du modele
|
||||
$file = dol_buildpath($dir.'doc/'.$file);
|
||||
|
||||
if (file_exists($file))
|
||||
{
|
||||
$filefound=1;
|
||||
$classname=$prefix.'_'.$modele;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// 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)
|
||||
{
|
||||
foreach(array('doc','pdf') as $prefix)
|
||||
{
|
||||
$file = $prefix."_".$modele.".modules.php";
|
||||
|
||||
// On verifie l'emplacement du modele
|
||||
$file = $dirroot.$dir.'doc/'.$file;
|
||||
if (file_exists($file))
|
||||
{
|
||||
$filefound=1;
|
||||
$classname=$prefix.'_'.$modele;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ($filefound) break;
|
||||
}
|
||||
|
||||
// Charge le modele
|
||||
if ($filefound)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user