Merge pull request #175 from grandoc/develop
Prepair to display receiptdocument within a custom place and uniformize ...
This commit is contained in:
commit
071cef15bf
@ -118,11 +118,11 @@ if ($action == 'specimen')
|
|||||||
$dirmodels=array_merge(array('/'),(array) $conf->modules_parts['models']);
|
$dirmodels=array_merge(array('/'),(array) $conf->modules_parts['models']);
|
||||||
foreach($dirmodels as $reldir)
|
foreach($dirmodels as $reldir)
|
||||||
{
|
{
|
||||||
$file=dol_buildpath($reldir."core/modules/expedition/doc/pdf_".$modele.".modules.php",0);
|
$file=dol_buildpath($reldir."core/modules/expedition/doc/pdf_expedition_".$modele.".modules.php",0);
|
||||||
if (file_exists($file))
|
if (file_exists($file))
|
||||||
{
|
{
|
||||||
$filefound=1;
|
$filefound=1;
|
||||||
$classname = "pdf_".$modele;
|
$classname = "pdf_expedition_".$modele;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -140,8 +140,8 @@ if ($action == 'specimen')
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$mesg='<font class="error">'.$obj->error.'</font>';
|
$mesg='<font class="error">'.$module->error.'</font>';
|
||||||
dol_syslog($obj->error, LOG_ERR);
|
dol_syslog($module->error, LOG_ERR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -339,10 +339,9 @@ foreach ($dirmodels as $reldir)
|
|||||||
|
|
||||||
while (($file = readdir($handle))!==false)
|
while (($file = readdir($handle))!==false)
|
||||||
{
|
{
|
||||||
if (preg_match('/^(mod_.*)\.php$/i',$file,$reg))
|
if (substr($file, 0, 15) == 'mod_expedition_' && substr($file, dol_strlen($file)-3, 3) == 'php')
|
||||||
{
|
{
|
||||||
$file = $reg[1];
|
$file = substr($file, 0, dol_strlen($file)-4);
|
||||||
$classname = substr($file,4);
|
|
||||||
|
|
||||||
require_once(DOL_DOCUMENT_ROOT ."/core/modules/expedition/".$file.".php");
|
require_once(DOL_DOCUMENT_ROOT ."/core/modules/expedition/".$file.".php");
|
||||||
|
|
||||||
@ -477,7 +476,7 @@ foreach ($dirmodels as $reldir)
|
|||||||
$classname = substr($file, 0, dol_strlen($file) - 12);
|
$classname = substr($file, 0, dol_strlen($file) - 12);
|
||||||
|
|
||||||
$var=!$var;
|
$var=!$var;
|
||||||
print "<tr $bc[$var]><td>";
|
print '<tr '.$bc[$var].'><td>';
|
||||||
print $name;
|
print $name;
|
||||||
print "</td><td>\n";
|
print "</td><td>\n";
|
||||||
require_once($dir.$file);
|
require_once($dir.$file);
|
||||||
@ -490,16 +489,9 @@ foreach ($dirmodels as $reldir)
|
|||||||
if (in_array($name, $def))
|
if (in_array($name, $def))
|
||||||
{
|
{
|
||||||
print "<td align=\"center\">\n";
|
print "<td align=\"center\">\n";
|
||||||
//if ($conf->global->EXPEDITION_ADDON_PDF != $name)
|
|
||||||
//{
|
|
||||||
print '<a href="'.$_SERVER["PHP_SELF"].'?action=del&value='.$name.'">';
|
print '<a href="'.$_SERVER["PHP_SELF"].'?action=del&value='.$name.'">';
|
||||||
print img_picto($langs->trans("Activated"),'switch_on');
|
print img_picto($langs->trans("Activated"),'switch_on');
|
||||||
print '</a>';
|
print '</a>';
|
||||||
//}
|
|
||||||
//else
|
|
||||||
//{
|
|
||||||
// print img_picto($langs->trans("Activated"),'switch_on');
|
|
||||||
//}
|
|
||||||
print "</td>";
|
print "</td>";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
@ -6,6 +6,7 @@
|
|||||||
* Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com>
|
* Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com>
|
||||||
* Copyright (C) 2005-2012 Regis Houssin <regis@dolibarr.fr>
|
* Copyright (C) 2005-2012 Regis Houssin <regis@dolibarr.fr>
|
||||||
* Copyright (C) 2011-2012 Juanjo Menent <jmenent@2byte.es>
|
* Copyright (C) 2011-2012 Juanjo Menent <jmenent@2byte.es>
|
||||||
|
* Copyright (C) 2011-2012 Philippe Grand <philippe.grand@atoo-net.com>
|
||||||
*
|
*
|
||||||
* 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
|
||||||
@ -38,6 +39,9 @@ if (!$user->admin) accessforbidden();
|
|||||||
|
|
||||||
$action = GETPOST('action','alpha');
|
$action = GETPOST('action','alpha');
|
||||||
$value = GETPOST('value','alpha');
|
$value = GETPOST('value','alpha');
|
||||||
|
$label = GETPOST('label','alpha');
|
||||||
|
$scandir = GETPOST('scandir','alpha');
|
||||||
|
$type='delivery';
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Actions
|
* Actions
|
||||||
@ -61,105 +65,6 @@ if ($action == 'updateMask')
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($action == 'specimen')
|
|
||||||
{
|
|
||||||
$modele=GETPOST('module','alpha');
|
|
||||||
|
|
||||||
$sending = new Livraison($db);
|
|
||||||
$sending->initAsSpecimen();
|
|
||||||
//$sending->fetch_commande();
|
|
||||||
|
|
||||||
// Charge le modele
|
|
||||||
$dir = DOL_DOCUMENT_ROOT . "/core/modules/livraison/pdf/";
|
|
||||||
$file = "pdf_".$modele.".modules.php";
|
|
||||||
if (file_exists($dir.$file))
|
|
||||||
{
|
|
||||||
$classname = "pdf_".$modele;
|
|
||||||
require_once($dir.$file);
|
|
||||||
|
|
||||||
$obj = new $classname($db);
|
|
||||||
|
|
||||||
if ($obj->write_file($sending,$langs) > 0)
|
|
||||||
{
|
|
||||||
header("Location: ".DOL_URL_ROOT."/document.php?modulepart=livraison&file=SPECIMEN.pdf");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$mesg='<font class="error">'.$obj->error.'</font>';
|
|
||||||
dol_syslog($obj->error, LOG_ERR);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$mesg='<font class="error">'.$langs->trans("ErrorModuleNotFound").'</font>';
|
|
||||||
dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($action == 'set')
|
|
||||||
{
|
|
||||||
$label = GETPOST('label','alpha');
|
|
||||||
$scandir = GETPOST('scandir','alpha');
|
|
||||||
|
|
||||||
$type='delivery';
|
|
||||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity, libelle, description)";
|
|
||||||
$sql.= " VALUES ('".$db->escape($value)."','".$type."',".$conf->entity.", ";
|
|
||||||
$sql.= ($label?"'".$db->escape($label)."'":'null').", ";
|
|
||||||
$sql.= (! empty($scandir)?"'".$db->escape($scandir)."'":"null");
|
|
||||||
$sql.= ")";
|
|
||||||
$resql=$db->query($sql);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($action == 'del')
|
|
||||||
{
|
|
||||||
$type='delivery';
|
|
||||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."document_model";
|
|
||||||
$sql.= " WHERE nom = '".$db->escape($value)."'";
|
|
||||||
$sql.= " AND type = '".$type."'";
|
|
||||||
$sql.= " AND entity = ".$conf->entity;
|
|
||||||
|
|
||||||
if ($db->query($sql))
|
|
||||||
{
|
|
||||||
if ($conf->global->LIVRAISON_ADDON_PDF == "$value") dolibarr_del_const($db, 'LIVRAISON_ADDON_PDF',$conf->entity);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($action == 'setdoc')
|
|
||||||
{
|
|
||||||
$label = GETPOST('label','alpha');
|
|
||||||
$scandir = GETPOST('scandir','alpha');
|
|
||||||
$db->begin();
|
|
||||||
|
|
||||||
if (dolibarr_set_const($db, "LIVRAISON_ADDON_PDF",$value,'chaine',0,'',$conf->entity))
|
|
||||||
{
|
|
||||||
$conf->global->LIVRAISON_ADDON_PDF = $value;
|
|
||||||
}
|
|
||||||
|
|
||||||
// On active le modele
|
|
||||||
$type='delivery';
|
|
||||||
$sql_del = "DELETE FROM ".MAIN_DB_PREFIX."document_model";
|
|
||||||
$sql_del.= " WHERE nom = '".$db->escape($value)."'";
|
|
||||||
$sql_del.= " AND type = '".$type."'";
|
|
||||||
$sql_del.= " AND entity = ".$conf->entity;
|
|
||||||
$result1=$db->query($sql_del);
|
|
||||||
|
|
||||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity, libelle, description)";
|
|
||||||
$sql.= " VALUES ('".$db->escape($value)."', '".$type."', ".$conf->entity.", ";
|
|
||||||
$sql.= ($label?"'".$db->escape($label)."'":'null').", ";
|
|
||||||
$sql.= (! empty($scandir)?"'".$db->escape($scandir)."'":"null");
|
|
||||||
$sql.= ")";
|
|
||||||
$result2=$db->query($sql);
|
|
||||||
if ($result1 && $result2)
|
|
||||||
{
|
|
||||||
$db->commit();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$db->rollback();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($action == 'set_DELIVERY_FREE_TEXT')
|
if ($action == 'set_DELIVERY_FREE_TEXT')
|
||||||
{
|
{
|
||||||
$free=GETPOST('DELIVERY_FREE_TEXT','alpha');
|
$free=GETPOST('DELIVERY_FREE_TEXT','alpha');
|
||||||
@ -177,6 +82,82 @@ if ($action == 'set_DELIVERY_FREE_TEXT')
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($action == 'specimen')
|
||||||
|
{
|
||||||
|
$modele=GETPOST('module','alpha');
|
||||||
|
|
||||||
|
$sending = new Livraison($db);
|
||||||
|
$sending->initAsSpecimen();
|
||||||
|
|
||||||
|
// 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/livraison/pdf/pdf_".$modele.".modules.php",0);
|
||||||
|
if (file_exists($file))
|
||||||
|
{
|
||||||
|
$filefound=1;
|
||||||
|
$classname = "pdf_".$modele;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($filefound)
|
||||||
|
{
|
||||||
|
require_once($file);
|
||||||
|
|
||||||
|
$module = new $classname($db);
|
||||||
|
|
||||||
|
if ($module->write_file($sending,$langs) > 0)
|
||||||
|
{
|
||||||
|
header("Location: ".DOL_URL_ROOT."/document.php?modulepart=livraison&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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($action == 'set')
|
||||||
|
{
|
||||||
|
$ret = addDocumentModel($value, $type, $label, $scandir);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($action == 'del')
|
||||||
|
{
|
||||||
|
$ret = delDocumentModel($value, $type);
|
||||||
|
if ($ret > 0)
|
||||||
|
{
|
||||||
|
if ($conf->global->LIVRAISON_ADDON_PDF == "$value") dolibarr_del_const($db, 'LIVRAISON_ADDON_PDF',$conf->entity);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($action == 'setdoc')
|
||||||
|
{
|
||||||
|
if (dolibarr_set_const($db, "LIVRAISON_ADDON_PDF",$value,'chaine',0,'',$conf->entity))
|
||||||
|
{
|
||||||
|
// La constante qui a ete lue en avant du nouveau set
|
||||||
|
// on passe donc par une variable pour avoir un affichage coherent
|
||||||
|
$conf->global->LIVRAISON_ADDON_PDF = $value;
|
||||||
|
}
|
||||||
|
|
||||||
|
// On active le modele
|
||||||
|
$ret = delDocumentModel($value, $type);
|
||||||
|
if ($ret > 0)
|
||||||
|
{
|
||||||
|
$ret = addDocumentModel($value, $type, $label, $scandir);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ($action == 'setmod')
|
if ($action == 'setmod')
|
||||||
{
|
{
|
||||||
// TODO Verifier si module numerotation choisi peut etre active
|
// TODO Verifier si module numerotation choisi peut etre active
|
||||||
@ -190,10 +171,12 @@ if ($action == 'setmod')
|
|||||||
* View
|
* View
|
||||||
*/
|
*/
|
||||||
|
|
||||||
$form=new Form($db);
|
$dirmodels=array_merge(array('/'),(array) $conf->modules_parts['models']);
|
||||||
|
|
||||||
llxHeader("","");
|
llxHeader("","");
|
||||||
|
|
||||||
|
$form=new Form($db);
|
||||||
|
|
||||||
$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
|
$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
|
||||||
print_fiche_titre($langs->trans("SendingsSetup"),$linkback,'setup');
|
print_fiche_titre($langs->trans("SendingsSetup"),$linkback,'setup');
|
||||||
print '<br>';
|
print '<br>';
|
||||||
@ -236,9 +219,9 @@ print '</tr>'."\n";
|
|||||||
|
|
||||||
clearstatcache();
|
clearstatcache();
|
||||||
|
|
||||||
foreach ($conf->file->dol_document_root as $dirroot)
|
foreach ($dirmodels as $reldir)
|
||||||
{
|
{
|
||||||
$dir = $dirroot . "/core/modules/livraison/";
|
$dir = dol_buildpath($reldir."core/modules/livraison/");
|
||||||
|
|
||||||
if (is_dir($dir))
|
if (is_dir($dir))
|
||||||
{
|
{
|
||||||
@ -365,9 +348,10 @@ print "</tr>\n";
|
|||||||
|
|
||||||
clearstatcache();
|
clearstatcache();
|
||||||
|
|
||||||
foreach ($conf->file->dol_document_root as $dirroot)
|
$var=true;
|
||||||
|
foreach ($dirmodels as $reldir)
|
||||||
{
|
{
|
||||||
$dir = $dirroot . "/core/modules/livraison/pdf/";
|
$dir = dol_buildpath($reldir."core/modules/livraison/pdf/");
|
||||||
|
|
||||||
if (is_dir($dir))
|
if (is_dir($dir))
|
||||||
{
|
{
|
||||||
@ -382,7 +366,8 @@ foreach ($conf->file->dol_document_root as $dirroot)
|
|||||||
$classname = substr($file, 0, dol_strlen($file) - 12);
|
$classname = substr($file, 0, dol_strlen($file) - 12);
|
||||||
|
|
||||||
$var=!$var;
|
$var=!$var;
|
||||||
print "<tr $bc[$var]><td>";
|
|
||||||
|
print '<tr '.$bc[$var].'><td>';
|
||||||
print $name;
|
print $name;
|
||||||
print "</td><td>\n";
|
print "</td><td>\n";
|
||||||
require_once($dir.$file);
|
require_once($dir.$file);
|
||||||
@ -395,16 +380,9 @@ foreach ($conf->file->dol_document_root as $dirroot)
|
|||||||
if (in_array($name, $def))
|
if (in_array($name, $def))
|
||||||
{
|
{
|
||||||
print "<td align=\"center\">\n";
|
print "<td align=\"center\">\n";
|
||||||
//if ($conf->global->LIVRAISON_ADDON_PDF != "$name")
|
|
||||||
//{
|
|
||||||
print '<a href="'.$_SERVER["PHP_SELF"].'?action=del&value='.$name.'&scandir='.$module->scandir.'&label='.urlencode($module->name).'">';
|
print '<a href="'.$_SERVER["PHP_SELF"].'?action=del&value='.$name.'&scandir='.$module->scandir.'&label='.urlencode($module->name).'">';
|
||||||
print img_picto($langs->trans("Enabled"),'switch_on');
|
print img_picto($langs->trans("Enabled"),'switch_on');
|
||||||
print '</a>';
|
print '</a>';
|
||||||
//}
|
|
||||||
//else
|
|
||||||
//{
|
|
||||||
// print img_picto($langs->trans("Enabled"),'switch_on');
|
|
||||||
//}
|
|
||||||
print "</td>";
|
print "</td>";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -447,10 +425,8 @@ foreach ($conf->file->dol_document_root as $dirroot)
|
|||||||
}
|
}
|
||||||
|
|
||||||
print '</table>';
|
print '</table>';
|
||||||
|
|
||||||
/*
|
/*
|
||||||
*
|
* Autres Options
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
print "<br>";
|
print "<br>";
|
||||||
print_titre($langs->trans("OtherOptions"));
|
print_titre($langs->trans("OtherOptions"));
|
||||||
|
|||||||
@ -2,6 +2,7 @@
|
|||||||
/* Copyright (C) 2005 Patrick Rouillon <patrick@rouillon.net>
|
/* Copyright (C) 2005 Patrick Rouillon <patrick@rouillon.net>
|
||||||
* Copyright (C) 2005-2011 Laurent Destailleur <eldy@users.sourceforge.net>
|
* Copyright (C) 2005-2011 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||||
* Copyright (C) 2005-2012 Regis Houssin <regis@dolibarr.fr>
|
* 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
|
* 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
|
||||||
@ -202,8 +203,15 @@ if ($id > 0 || ! empty($ref))
|
|||||||
|
|
||||||
print '<br>';
|
print '<br>';
|
||||||
|
|
||||||
// Contacts lines
|
// Select template for Contacts lines
|
||||||
|
if (file_exists(DOL_DOCUMENT_ROOT."/theme/".$conf->theme."/tpl/contacts.tpl.php"))
|
||||||
|
{
|
||||||
|
include(DOL_DOCUMENT_ROOT."/theme/".$conf->theme."/tpl/contacts.tpl.php");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
include(DOL_DOCUMENT_ROOT.'/core/tpl/contacts.tpl.php');
|
include(DOL_DOCUMENT_ROOT.'/core/tpl/contacts.tpl.php');
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
* Copyright (C) 2005-2011 Regis Houssin <regis@dolibarr.fr>
|
* Copyright (C) 2005-2011 Regis Houssin <regis@dolibarr.fr>
|
||||||
* Copyright (C) 2006 Andre Cianfarani <acianfa@free.fr>
|
* Copyright (C) 2006 Andre Cianfarani <acianfa@free.fr>
|
||||||
* Copyright (C) 2011 Juanjo Menent <jmenent@2byte.es>
|
* 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
|
* 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
|
||||||
@ -156,13 +156,8 @@ function expedition_pdf_create($db, $object, $modele, $outputlangs)
|
|||||||
|
|
||||||
$langs->load("sendings");
|
$langs->load("sendings");
|
||||||
|
|
||||||
// Increase limit for PDF build
|
$error=0;
|
||||||
$err=error_reporting();
|
|
||||||
error_reporting(0);
|
|
||||||
@set_time_limit(120);
|
|
||||||
error_reporting($err);
|
|
||||||
|
|
||||||
$dir = "/core/modules/expedition/";
|
|
||||||
$srctemplatepath='';
|
$srctemplatepath='';
|
||||||
|
|
||||||
// Positionne le modele sur le nom du modele a utiliser
|
// Positionne le modele sur le nom du modele a utiliser
|
||||||
@ -186,15 +181,18 @@ function expedition_pdf_create($db, $object, $modele, $outputlangs)
|
|||||||
$srctemplatepath=$tmp[1];
|
$srctemplatepath=$tmp[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Search template file
|
// Search template files
|
||||||
$file=''; $classname=''; $filefound=0;
|
$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)
|
foreach(array('doc','pdf') as $prefix)
|
||||||
{
|
{
|
||||||
$file = $prefix."_expedition_".$modele.".modules.php";
|
$file = $prefix."_expedition_".$modele.".modules.php";
|
||||||
|
|
||||||
// On verifie l'emplacement du modele
|
// On verifie l'emplacement du modele
|
||||||
$file = dol_buildpath($dir.'doc/'.$file);
|
$file=dol_buildpath($reldir."core/modules/expedition/doc/".$file,0);
|
||||||
|
|
||||||
if (file_exists($file))
|
if (file_exists($file))
|
||||||
{
|
{
|
||||||
$filefound=1;
|
$filefound=1;
|
||||||
@ -202,6 +200,8 @@ function expedition_pdf_create($db, $object, $modele, $outputlangs)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if ($filefound) break;
|
||||||
|
}
|
||||||
|
|
||||||
// Charge le modele
|
// Charge le modele
|
||||||
if ($filefound)
|
if ($filefound)
|
||||||
@ -215,7 +215,7 @@ function expedition_pdf_create($db, $object, $modele, $outputlangs)
|
|||||||
// We save charset_output to restore it because write_file can change it if needed for
|
// We save charset_output to restore it because write_file can change it if needed for
|
||||||
// output format that does not support UTF8.
|
// output format that does not support UTF8.
|
||||||
$sav_charset_output=$outputlangs->charset_output;
|
$sav_charset_output=$outputlangs->charset_output;
|
||||||
if ($obj->write_file($object, $outputlangs) > 0)
|
if ($obj->write_file($object, $outputlangs, $srctemplatepath) > 0)
|
||||||
{
|
{
|
||||||
$outputlangs->charset_output=$sav_charset_output;
|
$outputlangs->charset_output=$sav_charset_output;
|
||||||
|
|
||||||
|
|||||||
@ -3,6 +3,7 @@
|
|||||||
* 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) 2006-2011 Regis Houssin <regis@dolibarr.fr>
|
* Copyright (C) 2006-2011 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
|
* 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
|
||||||
@ -154,33 +155,62 @@ abstract class ModeleNumRefDeliveryOrder
|
|||||||
* @param Translate $outputlangs objet lang a utiliser pour traduction
|
* @param Translate $outputlangs objet lang a utiliser pour traduction
|
||||||
* @return int 0 if KO, 1 if OK
|
* @return int 0 if KO, 1 if OK
|
||||||
*/
|
*/
|
||||||
function delivery_order_pdf_create($db, $object, $model='', $outputlangs='')
|
function delivery_order_pdf_create($db, $object, $modele, $outputlangs='')
|
||||||
{
|
{
|
||||||
global $conf,$langs;
|
global $conf,$langs;
|
||||||
|
|
||||||
$langs->load("deliveries");
|
$langs->load("deliveries");
|
||||||
|
|
||||||
$dir = "/core/modules/livraison/pdf/";
|
$error=0;
|
||||||
|
|
||||||
|
$srctemplatepath='';
|
||||||
|
|
||||||
// Positionne modele sur le nom du modele de bon de livraison a utiliser
|
// Positionne modele sur le nom du modele de bon de livraison a utiliser
|
||||||
if (! dol_strlen($model))
|
if (! dol_strlen($modele))
|
||||||
{
|
{
|
||||||
if ($conf->global->LIVRAISON_ADDON_PDF)
|
if ($conf->global->LIVRAISON_ADDON_PDF)
|
||||||
{
|
{
|
||||||
$model = $conf->global->LIVRAISON_ADDON_PDF;
|
$modele = $conf->global->LIVRAISON_ADDON_PDF;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
print $langs->trans("Error")." ".$langs->trans("Error_LIVRAISON_ADDON_PDF_NotDefined");
|
$modele = 'typhon';
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Charge le modele
|
|
||||||
$file = "pdf_".$model.".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];
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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
|
// On verifie l'emplacement du modele
|
||||||
$file = dol_buildpath($dir.$file);
|
$file=dol_buildpath($reldir."core/modules/livraison/pdf/".$file,0);
|
||||||
if (file_exists($file))
|
if (file_exists($file))
|
||||||
{
|
{
|
||||||
$classname = "pdf_".$model;
|
$filefound=1;
|
||||||
|
$classname=$prefix.'_'.$modele;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($filefound) break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Charge le modele
|
||||||
|
if ($filefound)
|
||||||
|
{
|
||||||
require_once($file);
|
require_once($file);
|
||||||
|
|
||||||
$obj = new $classname($db);
|
$obj = new $classname($db);
|
||||||
|
|||||||
@ -1060,7 +1060,7 @@ class Expedition extends CommonObject
|
|||||||
|
|
||||||
// Initialise parametres
|
// Initialise parametres
|
||||||
$this->id=0;
|
$this->id=0;
|
||||||
$this->ref = 'SPECIMEN_SHIP';
|
$this->ref = 'SPECIMEN';
|
||||||
$this->specimen=1;
|
$this->specimen=1;
|
||||||
$this->statut = 1;
|
$this->statut = 1;
|
||||||
$this->livraison_id = 0;
|
$this->livraison_id = 0;
|
||||||
|
|||||||
@ -3,6 +3,7 @@
|
|||||||
* Copyright (C) 2005-2010 Regis Houssin <regis@dolibarr.fr>
|
* Copyright (C) 2005-2010 Regis Houssin <regis@dolibarr.fr>
|
||||||
* Copyright (C) 2006-2007 Laurent Destailleur <eldy@users.sourceforge.net>
|
* Copyright (C) 2006-2007 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||||
* Copyright (C) 2007 Franky Van Liedekerke <franky.van.liedekerke@telenet.be>
|
* Copyright (C) 2007 Franky Van Liedekerke <franky.van.liedekerke@telenet.be>
|
||||||
|
* Copyright (C) 2011-2012 Philippe Grand <philippe.grand@atoo-net.com>
|
||||||
*
|
*
|
||||||
* 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
|
||||||
@ -773,7 +774,7 @@ class Livraison extends CommonObject
|
|||||||
|
|
||||||
// Initialise parametres
|
// Initialise parametres
|
||||||
$this->id=0;
|
$this->id=0;
|
||||||
$this->ref = 'SPECIMEN_RECEIPT';
|
$this->ref = 'SPECIMEN';
|
||||||
$this->specimen=1;
|
$this->specimen=1;
|
||||||
$this->socid = 1;
|
$this->socid = 1;
|
||||||
$this->date_delivery = $now;
|
$this->date_delivery = $now;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user