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