first step to use fichinter within a custom place
This commit is contained in:
parent
8e745c88c5
commit
b3e55e179f
@ -6,7 +6,7 @@
|
||||
* Copyright (C) 2005-2012 Regis Houssin <regis@dolibarr.fr>
|
||||
* Copyright (C) 2008 Raphael Bertrand (Resultic) <raphael.bertrand@resultic.fr>
|
||||
* Copyright (C) 2011 Juanjo Menent <jmenent@2byte.es>
|
||||
* Copyright (C) 2011 Philippe Grand <philippe.grand@atoo-net.com>
|
||||
* Copyright (C) 2011-2012 Philippe Grand <philippe.grand@atoo-net.com>
|
||||
*
|
||||
* 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
|
||||
@ -106,18 +106,27 @@ if ($action == 'specimen')
|
||||
$inter = new Fichinter($db);
|
||||
$inter->initAsSpecimen();
|
||||
|
||||
// Charge le modele
|
||||
$dir = "/core/modules/fichinter/doc/";
|
||||
$file = "pdf_".$modele.".modules.php";
|
||||
$file = dol_buildpath($dir.$file);
|
||||
if (file_exists($file))
|
||||
// Search template files
|
||||
$file=''; $classname=''; $filefound=0;
|
||||
$dirmodels=array_merge(array('/'),(array) $conf->modules_parts['models']);
|
||||
foreach($dirmodels as $reldir)
|
||||
{
|
||||
$file=dol_buildpath($reldir."core/modules/fichinter/doc/pdf_".$modele.".modules.php",0);
|
||||
if (file_exists($file))
|
||||
{
|
||||
$filefound=1;
|
||||
$classname = "pdf_".$modele;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ($filefound)
|
||||
{
|
||||
$classname = "pdf_".$modele;
|
||||
require_once($file);
|
||||
|
||||
$obj = new $classname($db);
|
||||
$module = new $classname($db);
|
||||
|
||||
if ($obj->write_file($inter,$langs) > 0)
|
||||
if ($module->write_file($inter,$langs) > 0)
|
||||
{
|
||||
header("Location: ".DOL_URL_ROOT."/document.php?modulepart=ficheinter&file=SPECIMEN.pdf");
|
||||
return;
|
||||
@ -219,6 +228,8 @@ if ($action == 'setmod')
|
||||
* View
|
||||
*/
|
||||
|
||||
$dirmodels=array_merge(array('/'),(array) $conf->modules_parts['models']);
|
||||
|
||||
llxHeader();
|
||||
|
||||
$form=new Form($db);
|
||||
@ -242,9 +253,9 @@ print "</tr>\n";
|
||||
|
||||
clearstatcache();
|
||||
|
||||
foreach ($conf->file->dol_document_root as $dirroot)
|
||||
foreach ($dirmodels as $reldir)
|
||||
{
|
||||
$dir = $dirroot . "/core/modules/fichinter/";
|
||||
$dir = dol_buildpath($reldir."core/modules/fichinter/");
|
||||
|
||||
if (is_dir($dir))
|
||||
{
|
||||
@ -260,7 +271,7 @@ foreach ($conf->file->dol_document_root as $dirroot)
|
||||
$file = $reg[1];
|
||||
$classname = substr($file,4);
|
||||
|
||||
require_once($dir.$file.".php");
|
||||
require_once(DOL_DOCUMENT_ROOT ."/core/modules/fichinter/".$file.".php");
|
||||
|
||||
$module = new $file;
|
||||
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
/* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2005-2012 Regis Houssin <regis@dolibarr.fr>
|
||||
* Copyright (C) 2011-2012 Philippe Grand <philippe.grand@atoo-net.com>
|
||||
*
|
||||
* 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
|
||||
@ -44,7 +45,7 @@ abstract class ModelePDFFicheinter extends CommonDocGenerator
|
||||
* @param string $maxfilenamelength Max length of value to show
|
||||
* @return array List of templates
|
||||
*/
|
||||
static function liste_modeles($db,$maxfilenamelength=0)
|
||||
function liste_modeles($db,$maxfilenamelength=0)
|
||||
{
|
||||
global $conf;
|
||||
|
||||
@ -150,14 +151,16 @@ abstract class ModeleNumRefFicheinter
|
||||
* @param Translate $outputlangs objet lang a utiliser pour traduction
|
||||
* @return int 0 if KO, 1 if OK
|
||||
*/
|
||||
function fichinter_create($db, $object, $modele='', $outputlangs='')
|
||||
function fichinter_create($db, $object, $modele, $outputlangs, $hidedetails=0, $hidedesc=0, $hideref=0, $hookmanager=false)
|
||||
{
|
||||
global $conf,$langs;
|
||||
$langs->load("ficheinter");
|
||||
|
||||
$dir = "/core/modules/fichinter/doc/";
|
||||
$error=0;
|
||||
|
||||
// Positionne modele sur le nom du modele de facture a utiliser
|
||||
$srctemplatepath='';
|
||||
|
||||
// Positionne modele sur le nom du modele de fichinter a utiliser
|
||||
if (! dol_strlen($modele))
|
||||
{
|
||||
if ($conf->global->FICHEINTER_ADDON_PDF)
|
||||
@ -170,33 +173,70 @@ function fichinter_create($db, $object, $modele='', $outputlangs='')
|
||||
}
|
||||
}
|
||||
|
||||
// Charge le modele
|
||||
$file = "pdf_".$modele.".modules.php";
|
||||
// If selected modele is a filename template (then $modele="modelname:filename")
|
||||
$tmp=explode(':',$modele,2);
|
||||
if (! empty($tmp[1]))
|
||||
{
|
||||
$modele=$tmp[0];
|
||||
$srctemplatepath=$tmp[1];
|
||||
}
|
||||
|
||||
// On verifie l'emplacement du modele
|
||||
$file = dol_buildpath($dir.$file);
|
||||
|
||||
if (file_exists($file))
|
||||
// Search template files
|
||||
$file=''; $classname=''; $filefound=0;
|
||||
$dirmodels=array('/');
|
||||
if (is_array($conf->modules_parts['models'])) $dirmodels=array_merge($dirmodels,$conf->modules_parts['models']);
|
||||
foreach($dirmodels as $reldir)
|
||||
{
|
||||
foreach(array('doc','pdf') as $prefix)
|
||||
{
|
||||
$file = $prefix."_".$modele.".modules.php";
|
||||
|
||||
// On verifie l'emplacement du modele
|
||||
$file=dol_buildpath($reldir."core/modules/fichinter/doc/".$file,0);
|
||||
if (file_exists($file))
|
||||
{
|
||||
$filefound=1;
|
||||
$classname=$prefix.'_'.$modele;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ($filefound) break;
|
||||
}
|
||||
|
||||
// Charge le modele
|
||||
if ($filefound)
|
||||
{
|
||||
$classname = "pdf_".$modele;
|
||||
require_once($file);
|
||||
|
||||
$obj = new $classname($db);
|
||||
|
||||
dol_syslog("fichinter_create build PDF", LOG_DEBUG);
|
||||
|
||||
// We save charset_output to restore it because write_file can change it if needed for
|
||||
// output format that does not support UTF8.
|
||||
$sav_charset_output=$outputlangs->charset_output;
|
||||
if ($obj->write_file($object,$outputlangs) > 0)
|
||||
if ($obj->write_file($object, $outputlangs, $srctemplatepath, $hidedetails, $hidedesc, $hideref, $hookmanager) > 0)
|
||||
{
|
||||
$outputlangs->charset_output=$sav_charset_output;
|
||||
|
||||
// We delete old preview
|
||||
require_once(DOL_DOCUMENT_ROOT."/core/lib/files.lib.php");
|
||||
dol_delete_preview($object);
|
||||
|
||||
// Success in building document. We build meta file.
|
||||
dol_meta_create($object);
|
||||
|
||||
// Appel des triggers
|
||||
include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php");
|
||||
$interface=new Interfaces($db);
|
||||
$result=$interface->run_triggers('FICHEINTER_BUILDDOC',$object,$user,$langs,$conf);
|
||||
if ($result < 0) { $error++; $this->errors=$interface->errors; }
|
||||
// Fin appel triggers
|
||||
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
$outputlangs->charset_output=$sav_charset_output;
|
||||
dol_print_error($db,$obj->error);
|
||||
dol_print_error($db,"fichinter_pdf_create Error: ".$obj->error);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user