Qual: Uniformize code for document generation of shipments.
Prepare usage of odt templates.
This commit is contained in:
parent
a0e701da3d
commit
9f889b0439
@ -58,7 +58,7 @@ if ($action == 'specimen')
|
||||
//$exp->fetch_commande();
|
||||
|
||||
// Charge le modele
|
||||
$dir = DOL_DOCUMENT_ROOT . "/core/modules/expedition/pdf/";
|
||||
$dir = DOL_DOCUMENT_ROOT . "/core/modules/expedition/doc/";
|
||||
$file = "pdf_expedition_".$modele.".modules.php";
|
||||
if (file_exists($dir.$file))
|
||||
{
|
||||
@ -483,7 +483,7 @@ clearstatcache();
|
||||
|
||||
foreach ($conf->file->dol_document_root as $dirroot)
|
||||
{
|
||||
$dir = $dirroot . "/core/modules/expedition/pdf/";
|
||||
$dir = $dirroot . "/core/modules/expedition/doc/";
|
||||
|
||||
if (is_dir($dir))
|
||||
{
|
||||
|
||||
@ -247,7 +247,7 @@ class FormFile
|
||||
if (is_array($genallowed)) $modellist=$genallowed;
|
||||
else
|
||||
{
|
||||
include_once(DOL_DOCUMENT_ROOT.'/core/modules/expedition/pdf/ModelePdfExpedition.class.php');
|
||||
include_once(DOL_DOCUMENT_ROOT.'/core/modules/expedition/doc/ModelePdfExpedition.class.php');
|
||||
$modellist=ModelePDFExpedition::liste_modeles($this->db);
|
||||
}
|
||||
}
|
||||
|
||||
@ -19,7 +19,7 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file htdocs/core/modules/expedition/pdf/ModelePdfExpedition.class.php
|
||||
* \file htdocs/core/modules/expedition/doc/ModelePdfExpedition.class.php
|
||||
* \ingroup shipping
|
||||
* \brief Fichier contenant la classe mere de generation des expeditions
|
||||
*/
|
||||
@ -65,46 +65,60 @@ abstract class ModelePdfExpedition extends CommonDocGenerator
|
||||
function expedition_pdf_create($db, $object, $modele, $outputlangs)
|
||||
{
|
||||
global $conf,$langs;
|
||||
|
||||
$langs->load("sendings");
|
||||
|
||||
$dir = "/core/modules/expedition/pdf/";
|
||||
$modelisok=0;
|
||||
// Increase limit for PDF build
|
||||
$err=error_reporting();
|
||||
error_reporting(0);
|
||||
@set_time_limit(120);
|
||||
error_reporting($err);
|
||||
|
||||
// Positionne modele sur le nom du modele de commande a utiliser
|
||||
$file = "pdf_expedition_".$modele.".modules.php";
|
||||
$dir = "/core/modules/expedition/";
|
||||
$srctemplatepath='';
|
||||
|
||||
// On verifie l'emplacement du modele
|
||||
$file = dol_buildpath($dir.$file);
|
||||
|
||||
if ($modele && file_exists($file)) $modelisok=1;
|
||||
|
||||
// Si model pas encore bon
|
||||
if (! $modelisok)
|
||||
// Positionne le modele sur le nom du modele a utiliser
|
||||
if (! dol_strlen($modele))
|
||||
{
|
||||
if ($conf->global->EXPEDITION_ADDON_PDF) $modele = $conf->global->EXPEDITION_ADDON_PDF;
|
||||
$file = "pdf_expedition_".$modele.".modules.php";
|
||||
// On verifie l'emplacement du modele
|
||||
$file = dol_buildpath($dir.$file);
|
||||
if (file_exists($file)) $modelisok=1;
|
||||
}
|
||||
if (! empty($conf->global->EXPEDITION_ADDON_PDF))
|
||||
{
|
||||
$modele = $conf->global->EXPEDITION_ADDON_PDF;
|
||||
}
|
||||
else
|
||||
{
|
||||
$modele = 'rouget';
|
||||
}
|
||||
}
|
||||
|
||||
// Si model pas encore bon
|
||||
if (! $modelisok)
|
||||
// If selected modele is a filename template (then $modele="modelname:filename")
|
||||
$tmp=explode(':',$modele,2);
|
||||
if (! empty($tmp[1]))
|
||||
{
|
||||
$liste=ModelePDFExpedition::liste_modeles($db);
|
||||
$modele=key($liste); // Renvoie premiere valeur de cle trouve dans le tableau
|
||||
$file = "pdf_expedition_".$modele.".modules.php";
|
||||
// On verifie l'emplacement du modele
|
||||
$file = dol_buildpath($dir.$file);
|
||||
if (file_exists($file)) $modelisok=1;
|
||||
$modele=$tmp[0];
|
||||
$srctemplatepath=$tmp[1];
|
||||
}
|
||||
|
||||
// Search template file
|
||||
$file=''; $classname=''; $filefound=0;
|
||||
foreach(array('doc','pdf') as $prefix)
|
||||
{
|
||||
$file = $prefix."_expedition_".$modele.".modules.php";
|
||||
|
||||
// On verifie l'emplacement du modele
|
||||
$file = dol_buildpath($dir.'doc/'.$file);
|
||||
|
||||
if (file_exists($file))
|
||||
{
|
||||
$filefound=1;
|
||||
$classname=$prefix.'_expedition_'.$modele;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Charge le modele
|
||||
if ($modelisok)
|
||||
if ($filefound)
|
||||
{
|
||||
dol_syslog("expedition_pdf_create ".$modele);
|
||||
$classname = "pdf_expedition_".$modele;
|
||||
require_once($file);
|
||||
require_once($file);
|
||||
|
||||
$obj = new $classname($db);
|
||||
|
||||
@ -132,16 +146,9 @@ function expedition_pdf_create($db, $object, $modele, $outputlangs)
|
||||
}
|
||||
else
|
||||
{
|
||||
if (! $conf->global->EXPEDITION_ADDON_PDF)
|
||||
{
|
||||
print $langs->trans("Error")." ".$langs->trans("Error_EXPEDITION_ADDON_PDF_NotDefined");
|
||||
}
|
||||
else
|
||||
{
|
||||
print $langs->trans("Error")." ".$langs->trans("ErrorFileDoesNotExists",$dir.$file);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
dol_print_error('',$langs->trans("Error")." ".$langs->trans("ErrorFileDoesNotExists",$dir.$file));
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
@ -19,12 +19,12 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file htdocs/core/modules/expedition/pdf/pdf_expedition_merou.modules.php
|
||||
* \file htdocs/core/modules/expedition/doc/pdf_expedition_merou.modules.php
|
||||
* \ingroup expedition
|
||||
* \brief Fichier de la classe permettant de generer les bordereaux envoi au modele Merou
|
||||
*/
|
||||
|
||||
require_once DOL_DOCUMENT_ROOT."/core/modules/expedition/pdf/ModelePdfExpedition.class.php";
|
||||
require_once DOL_DOCUMENT_ROOT."/core/modules/expedition/doc/ModelePdfExpedition.class.php";
|
||||
require_once DOL_DOCUMENT_ROOT."/contact/class/contact.class.php";
|
||||
require_once(DOL_DOCUMENT_ROOT."/core/lib/company.lib.php");
|
||||
require_once(DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php');
|
||||
@ -19,12 +19,12 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file htdocs/core/modules/expedition/pdf/pdf_expedition_rouget.modules.php
|
||||
* \file htdocs/core/modules/expedition/doc/pdf_expedition_rouget.modules.php
|
||||
* \ingroup expedition
|
||||
* \brief Fichier de la classe permettant de generer les bordereaux envoi au modele Rouget
|
||||
*/
|
||||
|
||||
require_once DOL_DOCUMENT_ROOT."/core/modules/expedition/pdf/ModelePdfExpedition.class.php";
|
||||
require_once DOL_DOCUMENT_ROOT."/core/modules/expedition/doc/ModelePdfExpedition.class.php";
|
||||
require_once(DOL_DOCUMENT_ROOT."/core/lib/company.lib.php");
|
||||
require_once(DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php');
|
||||
|
||||
@ -1754,7 +1754,7 @@ function migrate_modeles($db,$langs,$conf)
|
||||
|
||||
if (! empty($conf->expedition->enabled))
|
||||
{
|
||||
include_once(DOL_DOCUMENT_ROOT.'/core/modules/expedition/pdf/ModelePdfExpedition.class.php');
|
||||
include_once(DOL_DOCUMENT_ROOT.'/core/modules/expedition/doc/ModelePdfExpedition.class.php');
|
||||
$modellist=ModelePDFExpedition::liste_modeles($db);
|
||||
if (count($modellist)==0)
|
||||
{
|
||||
|
||||
@ -43,15 +43,15 @@ require_once dirname(__FILE__).'/../../htdocs/core/modules/propale/pdf_propale_a
|
||||
require_once dirname(__FILE__).'/../../htdocs/core/modules/propale/pdf_propale_jaune.modules.php';
|
||||
require_once dirname(__FILE__).'/../../htdocs/core/modules/project/pdf/pdf_baleine.modules.php';
|
||||
require_once dirname(__FILE__).'/../../htdocs/core/modules/fichinter/pdf_soleil.modules.php';
|
||||
require_once dirname(__FILE__).'/../../htdocs/core/modules/expedition/pdf/pdf_expedition_merou.modules.php';
|
||||
require_once dirname(__FILE__).'/../../htdocs/core/modules/expedition/pdf/pdf_expedition_rouget.modules.php';
|
||||
require_once dirname(__FILE__).'/../../htdocs/core/modules/expedition/doc/pdf_expedition_merou.modules.php';
|
||||
require_once dirname(__FILE__).'/../../htdocs/core/modules/expedition/doc/pdf_expedition_rouget.modules.php';
|
||||
// Mother classes of pdf generators
|
||||
require_once dirname(__FILE__).'/../../htdocs/core/modules/facture/modules_facture.php';
|
||||
require_once dirname(__FILE__).'/../../htdocs/core/modules/commande/modules_commande.php';
|
||||
require_once dirname(__FILE__).'/../../htdocs/core/modules/propale/modules_propale.php';
|
||||
require_once dirname(__FILE__).'/../../htdocs/core/modules/project/modules_project.php';
|
||||
require_once dirname(__FILE__).'/../../htdocs/core/modules/fichinter/modules_fichinter.php';
|
||||
require_once dirname(__FILE__).'/../../htdocs/core/modules/expedition/pdf/ModelePdfExpedition.class.php';
|
||||
require_once dirname(__FILE__).'/../../htdocs/core/modules/expedition/doc/ModelePdfExpedition.class.php';
|
||||
|
||||
if (empty($user->id))
|
||||
{
|
||||
|
||||
Loading…
Reference in New Issue
Block a user