Finished new module to manage expense reports !

Fix export to support corectly multicompany
This commit is contained in:
Laurent Destailleur
2015-02-22 13:16:49 +01:00
parent 6d1324b463
commit 2bc6ac4671
31 changed files with 1189 additions and 373 deletions

View File

@@ -0,0 +1,499 @@
<?php
/* Copyright (C) 2003-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2015 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004 Sebastien Di Cintio <sdicintio@ressource-toi.org>
* Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be>
* Copyright (C) 2005-2014 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2008 Raphael Bertrand (Resultic) <raphael.bertrand@resultic.fr>
* Copyright (C) 2011-2013 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2011-2013 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
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* \file htdocs/admin/expensereport.php
* \ingroup expensereport
* \brief Setup page of module ExpenseReport
*/
require '../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/expensereport.lib.php';
require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php';
$langs->load("admin");
$langs->load("errors");
$langs->load("trips");
$langs->load('other');
if (! $user->admin) accessforbidden();
$action = GETPOST('action','alpha');
$value = GETPOST('value','alpha');
$label = GETPOST('label','alpha');
$scandir = GETPOST('scandir','alpha');
$type='expensereport';
/*
* Actions
*/
if ($action == 'updateMask')
{
$maskconst=GETPOST('maskconst','alpha');
$maskvalue=GETPOST('maskvalue','alpha');
if ($maskconst) $res = dolibarr_set_const($db,$maskconst,$maskvalue,'chaine',0,'',$conf->entity);
if (! $res > 0) $error++;
if (! $error)
{
setEventMessage($langs->trans("SetupSaved"));
}
else
{
setEventMessage($langs->trans("Error"),'errors');
}
}
else if ($action == 'specimen') // For fiche inter
{
$modele= GETPOST('module','alpha');
$inter = new ExpenseReport($db);
$inter->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/expensereport/doc/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($inter,$langs) > 0)
{
header("Location: ".DOL_URL_ROOT."/document.php?modulepart=expensereport&file=SPECIMEN.pdf");
return;
}
else
{
setEventMessage($obj->error,'errors');
dol_syslog($obj->error, LOG_ERR);
}
}
else
{
setEventMessage($langs->trans("ErrorModuleNotFound"),'errors');
dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR);
}
}
// Define constants for submodules that contains parameters (forms with param1, param2, ... and value1, value2, ...)
if ($action == 'setModuleOptions')
{
$post_size=count($_POST);
$db->begin();
for($i=0;$i < $post_size;$i++)
{
if (array_key_exists('param'.$i,$_POST))
{
$param=GETPOST("param".$i,'alpha');
$value=GETPOST("value".$i,'alpha');
if ($param) $res = dolibarr_set_const($db,$param,$value,'chaine',0,'',$conf->entity);
if (! $res > 0) $error++;
}
}
if (! $error)
{
$db->commit();
setEventMessage($langs->trans("SetupSaved"));
}
else
{
$db->rollback();
setEventMessage($langs->trans("Error"),'errors');
}
}
// Activate a model
else if ($action == 'set')
{
$ret = addDocumentModel($value, $type, $label, $scandir);
}
else if ($action == 'del')
{
$ret = delDocumentModel($value, $type);
if ($ret > 0)
{
if ($conf->global->EXPENSEREPORT_ADDON_PDF == "$value") dolibarr_del_const($db, 'EXPENSEREPORT_ADDON_PDF',$conf->entity);
}
}
// Set default model
else if ($action == 'setdoc')
{
if (dolibarr_set_const($db, "EXPENSEREPORT_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->EXPENSEREPORT_ADDON_PDF = $value;
}
// On active le modele
$ret = delDocumentModel($value, $type);
if ($ret > 0)
{
$ret = addDocumentModel($value, $type, $label, $scandir);
}
}
else if ($action == 'setmod')
{
// TODO Verifier si module numerotation choisi peut etre active
// par appel methode canBeActivated
dolibarr_set_const($db, "EXPENSEREPORT_ADDON",$value,'chaine',0,'',$conf->entity);
}
else if ($action == 'set_EXPENSEREPORT_FREE_TEXT')
{
$freetext= GETPOST('EXPENSEREPORT_FREE_TEXT','alpha');
$res = dolibarr_set_const($db, "EXPENSEREPORT_FREE_TEXT",$freetext,'chaine',0,'',$conf->entity);
if (! $res > 0) $error++;
if (! $error)
{
setEventMessage($langs->trans("SetupSaved"));
}
else
{
setEventMessage($langs->trans("Error"),'errors');
}
}
else if ($action == 'set_EXPENSEREPORT_DRAFT_WATERMARK')
{
$draft= GETPOST('EXPENSEREPORT_DRAFT_WATERMARK','alpha');
$res = dolibarr_set_const($db, "EXPENSEREPORT_DRAFT_WATERMARK",trim($draft),'chaine',0,'',$conf->entity);
if (! $res > 0) $error++;
if (! $error)
{
setEventMessage($langs->trans("SetupSaved"));
}
else
{
setEventMessage($langs->trans("Error"),'errors');
}
}
/*
* View
*/
$dirmodels=array_merge(array('/'),(array) $conf->modules_parts['models']);
llxHeader();
$form=new Form($db);
$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
print_fiche_titre($langs->trans("ExpenseReportsSetup"),$linkback,'setup');
$head=expensereport_admin_prepare_head();
dol_fiche_head($head, 'expensereport', $langs->trans("ExpenseReports"), 0, 'trip');
// Interventions numbering model
/*
print_titre($langs->trans("FicheinterNumberingModules"));
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
print '<td width="100">'.$langs->trans("Name").'</td>';
print '<td>'.$langs->trans("Description").'</td>';
print '<td>'.$langs->trans("Example").'</td>';
print '<td align="center" width="60">'.$langs->trans("Status").'</td>';
print '<td align="center" width="80">'.$langs->trans("ShortInfo").'</td>';
print "</tr>\n";
clearstatcache();
foreach ($dirmodels as $reldir)
{
$dir = dol_buildpath($reldir."core/modules/fichinter/");
if (is_dir($dir))
{
$handle = opendir($dir);
if (is_resource($handle))
{
$var=true;
while (($file = readdir($handle))!==false)
{
if (preg_match('/^(mod_.*)\.php$/i',$file,$reg))
{
$file = $reg[1];
$classname = substr($file,4);
require_once $dir.$file.'.php';
$module = new $file;
if ($module->isEnabled())
{
// Show modules according to features level
if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue;
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue;
$var=!$var;
print '<tr '.$bc[$var].'><td>'.$module->nom."</td><td>\n";
print $module->info();
print '</td>';
// Show example of numbering model
print '<td class="nowrap">';
$tmp=$module->getExample();
if (preg_match('/^Error/',$tmp)) print '<div class="error">'.$langs->trans($tmp).'</div>';
elseif ($tmp=='NotConfigured') print $langs->trans($tmp);
else print $tmp;
print '</td>'."\n";
print '<td align="center">';
if ($conf->global->FICHEINTER_ADDON == $classname)
{
print img_picto($langs->trans("Activated"),'switch_on');
}
else
{
print '<a href="'.$_SERVER["PHP_SELF"].'?action=setmod&amp;value='.$classname.'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"),'switch_off').'</a>';
}
print '</td>';
$ficheinter=new Fichinter($db);
$ficheinter->initAsSpecimen();
// Info
$htmltooltip='';
$htmltooltip.=''.$langs->trans("Version").': <b>'.$module->getVersion().'</b><br>';
$nextval=$module->getNextValue($mysoc,$ficheinter);
if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval
$htmltooltip.=''.$langs->trans("NextValue").': ';
if ($nextval) {
if (preg_match('/^Error/',$nextval) || $nextval=='NotConfigured')
$nextval = $langs->trans($nextval);
$htmltooltip.=$nextval.'<br>';
} else {
$htmltooltip.=$langs->trans($module->error).'<br>';
}
}
print '<td align="center">';
print $form->textwithpicto('',$htmltooltip,1,0);
print '</td>';
print '</tr>';
}
}
}
closedir($handle);
}
}
}
print '</table><br>';
*/
/*
* Documents models for Interventions
*/
print_titre($langs->trans("TemplatePDFExpenseReports"));
// Defini tableau def des modeles
$type='expensereport';
$def = array();
$sql = "SELECT nom";
$sql.= " FROM ".MAIN_DB_PREFIX."document_model";
$sql.= " WHERE type = '".$type."'";
$sql.= " AND entity = ".$conf->entity;
$resql=$db->query($sql);
if ($resql)
{
$i = 0;
$num_rows=$db->num_rows($resql);
while ($i < $num_rows)
{
$array = $db->fetch_array($resql);
array_push($def, $array[0]);
$i++;
}
}
else
{
dol_print_error($db);
}
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
print '<td>'.$langs->trans("Name").'</td>';
print '<td>'.$langs->trans("Description").'</td>';
print '<td align="center" width="60">'.$langs->trans("Status")."</td>\n";
print '<td align="center" width="60">'.$langs->trans("Default")."</td>\n";
print '<td align="center" width="80">'.$langs->trans("ShortInfo").'</td>';
print '<td align="center" width="80">'.$langs->trans("Preview").'</td>';
print "</tr>\n";
clearstatcache();
$var=true;
foreach ($dirmodels as $reldir)
{
$dir = dol_buildpath($reldir."core/modules/expensereport/doc");
if (is_dir($dir))
{
$handle=opendir($dir);
if (is_resource($handle))
{
while (($file = readdir($handle))!==false)
{
$filelist[]=$file;
}
closedir($handle);
arsort($filelist);
foreach($filelist as $file)
{
if (preg_match('/\.modules\.php$/i',$file) && preg_match('/^(pdf_|doc_)/',$file))
{
if (file_exists($dir.'/'.$file))
{
$var=!$var;
$name = substr($file, 4, dol_strlen($file) -16);
$classname = substr($file, 0, dol_strlen($file) -12);
require_once $dir.'/'.$file;
$module = new $classname($db);
$modulequalified=1;
if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified=0;
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified=0;
if ($modulequalified)
{
print '<tr '.$bc[$var].'><td width="100">';
print (empty($module->name)?$name:$module->name);
print "</td><td>\n";
if (method_exists($module,'info')) print $module->info($langs);
else print $module->description;
print '</td>';
// Active
if (in_array($name, $def))
{
print "<td align=\"center\">\n";
print '<a href="'.$_SERVER["PHP_SELF"].'?action=del&amp;value='.$name.'&amp;scandir='.$module->scandir.'&amp;label='.urlencode($module->name).'">';
print img_picto($langs->trans("Enabled"),'switch_on');
print '</a>';
print "</td>";
}
else
{
print "<td align=\"center\">\n";
print '<a href="'.$_SERVER["PHP_SELF"].'?action=set&amp;value='.$name.'&amp;scandir='.$module->scandir.'&amp;label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"),'switch_off').'</a>';
print "</td>";
}
// Default
print "<td align=\"center\">";
if ($conf->global->EXPENSEREPORT_ADDON_PDF == "$name")
{
print img_picto($langs->trans("Default"),'on');
}
else
{
print '<a href="'.$_SERVER["PHP_SELF"].'?action=setdoc&amp;value='.$name.'&amp;scandir='.$module->scandir.'&amp;label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"),'off').'</a>';
}
print '</td>';
// Info
$htmltooltip = ''.$langs->trans("Name").': '.$module->name;
$htmltooltip.='<br>'.$langs->trans("Type").': '.($module->type?$module->type:$langs->trans("Unknown"));
$htmltooltip.='<br>'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur;
$htmltooltip.='<br><br><u>'.$langs->trans("FeaturesSupported").':</u>';
$htmltooltip.='<br>'.$langs->trans("Logo").': '.yn($module->option_logo,1,1);
$htmltooltip.='<br>'.$langs->trans("PaymentMode").': '.yn($module->option_modereg,1,1);
$htmltooltip.='<br>'.$langs->trans("PaymentConditions").': '.yn($module->option_condreg,1,1);
$htmltooltip.='<br>'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang,1,1);
$htmltooltip.='<br>'.$langs->trans("WatermarkOnDraftOrders").': '.yn($module->option_draft_watermark,1,1);
print '<td align="center">';
print $form->textwithpicto('',$htmltooltip,-1,0);
print '</td>';
// Preview
print '<td align="center">';
if ($module->type == 'pdf')
{
print '<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&module='.$name.'">'.img_object($langs->trans("Preview"),'intervention').'</a>';
}
else
{
print img_object($langs->trans("PreviewNotAvailable"),'generic');
}
print '</td>';
print '</tr>';
}
}
}
}
}
}
}
print '</table>';
dol_fiche_end();
llxFooter();
$db->close();

View File

@@ -440,11 +440,11 @@ class FormFile
} }
else if ($modulepart != 'agenda') else if ($modulepart != 'agenda')
{ {
// For normalized standard modules // For normalized standard modules
$file=dol_buildpath('/core/modules/'.$modulepart.'/modules_'.$modulepart.'.php',0); $file=dol_buildpath('/core/modules/'.$modulepart.'/modules_'.$modulepart.'.php',0);
if (file_exists($file)) if (file_exists($file))
{ {
$res=include_once $file; $res=include_once $file;
} }
// For normalized external modules // For normalized external modules
else else
@@ -458,7 +458,7 @@ class FormFile
$modellist=call_user_func($class.'::liste_modeles',$this->db); $modellist=call_user_func($class.'::liste_modeles',$this->db);
} }
else else
{ {
dol_print_error($this->db,'Bad value for modulepart'); dol_print_error($this->db,'Bad value for modulepart');
return -1; return -1;
} }

View File

@@ -59,3 +59,46 @@ function expensereport_prepare_head($object)
return $head; return $head;
} }
/**
* Return array head with list of tabs to view object informations.
*
* @return array head array with tabs
*/
function expensereport_admin_prepare_head()
{
global $langs, $conf, $user;
$h = 0;
$head = array();
$h = 0;
$head[$h][0] = DOL_URL_ROOT."/admin/expensereport.php";
$head[$h][1] = $langs->trans("ExpenseReports");
$head[$h][2] = 'expensereport';
$h++;
// Show more tabs from modules
// Entries must be declared in modules descriptor with line
// $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
// $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab
complete_head_from_modules($conf,$langs,null,$head,$h,'expensereport_admin');
/*$head[$h][0] = DOL_URL_ROOT.'/fichinter/admin/fichinter_extrafields.php';
$head[$h][1] = $langs->trans("ExtraFields");
$head[$h][2] = 'attributes';
$h++;
$head[$h][0] = DOL_URL_ROOT.'/fichinter/admin/fichinterdet_extrafields.php';
$head[$h][1] = $langs->trans("ExtraFieldsLines");
$head[$h][2] = 'attributesdet';
$h++;
*/
complete_head_from_modules($conf,$langs,null,$head,$h,'expensereport_admin','remove');
return $head;
}

View File

@@ -95,13 +95,13 @@ function getDoliDBInstance($type, $host, $user, $pass, $name, $port)
} }
/** /**
* Get entity to use * Get list of entity id to use
* *
* @param string $element Current element * @param string $element Current element
* @param int $shared 1=Return shared entities * @param int $shared 0=Return id of entity, 1=Return id entity + shared entities
* @return mixed Entity id(s) to use * @return mixed Entity id(s) to use
*/ */
function getEntity($element=false, $shared=false) function getEntity($element=false, $shared=0)
{ {
global $conf, $mc; global $conf, $mc;
@@ -112,12 +112,9 @@ function getEntity($element=false, $shared=false)
else else
{ {
$out=''; $out='';
$addzero = array('user', 'usergroup'); $addzero = array('user', 'usergroup');
if (in_array($element, $addzero)) $out.= '0,'; if (in_array($element, $addzero)) $out.= '0,';
$out.= $conf->entity; $out.= $conf->entity;
return $out; return $out;
} }
} }

View File

@@ -160,7 +160,7 @@ abstract class ModeleNumRefCommandes
* @param int $hidedesc Hide description * @param int $hidedesc Hide description
* @param int $hideref Hide ref * @param int $hideref Hide ref
* @return int 0 if KO, 1 if OK * @return int 0 if KO, 1 if OK
* @deprecated Use the new function generateDocument of Commande class * @deprecated Use the new function generateDocument of Commande class
*/ */
function commande_pdf_create(DoliDB $db, Commande $object, $modele, $outputlangs, $hidedetails=0, $hidedesc=0, $hideref=0) function commande_pdf_create(DoliDB $db, Commande $object, $modele, $outputlangs, $hidedetails=0, $hidedesc=0, $hideref=0)
{ {

View File

@@ -3,7 +3,7 @@
* *
* 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
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
@@ -19,10 +19,10 @@
/** /**
* \file htdocs/core/modules/expensereport/doc/pdf_standard.modules.php * \file htdocs/core/modules/expensereport/doc/pdf_standard.modules.php
* \ingroup expensereport * \ingroup expensereport
* \brief File of class to generate invoices from standard model * \brief File of class to generate expense report from standard model
*/ */
dol_include_once("/expensereport/core/modules/expensereport/modules_expensereport.php"); require_once DOL_DOCUMENT_ROOT.'/core/modules/expensereport/modules_expensereport.php';
require_once(DOL_DOCUMENT_ROOT."/product/class/product.class.php"); require_once(DOL_DOCUMENT_ROOT."/product/class/product.class.php");
require_once(DOL_DOCUMENT_ROOT."/core/lib/functions2.lib.php"); require_once(DOL_DOCUMENT_ROOT."/core/lib/functions2.lib.php");
require_once(DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php'); require_once(DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php');
@@ -34,9 +34,25 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
/** /**
* Classe permettant de generer les factures au modele Crabe * Classe permettant de generer les factures au modele Crabe
*/ */
class pdf_ extends ModeleExpenseReport class pdf_standard extends ModeleExpenseReport
{ {
var $emetteur; // Objet societe qui emet var $db;
var $name;
var $description;
var $type;
var $phpmin = array(4,3,0); // Minimum version of PHP required by module
var $version = 'dolibarr';
var $page_largeur;
var $page_hauteur;
var $format;
var $marge_gauche;
var $marge_droite;
var $marge_haute;
var $marge_basse;
var $emetteur; // Objet societe qui emet
/** /**
@@ -51,11 +67,11 @@ class pdf_ extends ModeleExpenseReport
$langs->load("main"); $langs->load("main");
$langs->load("trips"); $langs->load("trips");
$langs->load("project"); $langs->load("project");
$langs->load("expensereport@expensereport"); $langs->load("trips");
$this->db = $db; $this->db = $db;
$this->name = ""; $this->name = "";
$this->description = $langs->trans('PDFDescription'); $this->description = $langs->trans('PDFStandardExpenseReports');
// Dimension page pour format A4 // Dimension page pour format A4
$this->type = 'pdf'; $this->type = 'pdf';
@@ -85,17 +101,16 @@ class pdf_ extends ModeleExpenseReport
$this->emetteur=$mysoc; $this->emetteur=$mysoc;
if (empty($this->emetteur->country_code)) $this->emetteur->country_code=substr($langs->defaultlang,-2); // By default, if was not defined if (empty($this->emetteur->country_code)) $this->emetteur->country_code=substr($langs->defaultlang,-2); // By default, if was not defined
// Defini position des colonnes // Define position of columns
// Defini position des colonnes
$this->posxpiece=$this->marge_gauche+1; $this->posxpiece=$this->marge_gauche+1;
$this->posxdesc=20; $this->posxdesc=20;
$this->posxdate=85; $this->posxdate=85;
$this->posxtype=105; $this->posxtype=105;
$this->posxprojet=125; $this->posxprojet=125;
$this->posxtva=145; $this->posxtva=145;
$this->posxup=158; $this->posxup=162;
$this->posxqty=170; $this->posxqty=176;
$this->postotalttc=176; $this->postotalttc=186;
if ($this->page_largeur < 210) // To work with US executive format if ($this->page_largeur < 210) // To work with US executive format
{ {
$this->posxdate-=20; $this->posxdate-=20;
@@ -124,6 +139,7 @@ class pdf_ extends ModeleExpenseReport
* @param int $hidedetails Do not show line details * @param int $hidedetails Do not show line details
* @param int $hidedesc Do not show desc * @param int $hidedesc Do not show desc
* @param int $hideref Do not show ref * @param int $hideref Do not show ref
* @return int 1=OK, 0=KO
*/ */
function write_file($object,$outputlangs,$srctemplatepath='',$hidedetails=0,$hidedesc=0,$hideref=0) function write_file($object,$outputlangs,$srctemplatepath='',$hidedetails=0,$hidedesc=0,$hideref=0)
{ {
@@ -133,40 +149,27 @@ class pdf_ extends ModeleExpenseReport
// For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1'; if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1';
// Hack to use expensereport dir
$rootfordata = DOL_DATA_ROOT;
$rootforuser = DOL_DATA_ROOT;
// If multicompany module is enabled, we redefine the root of data
//if (! empty($this->multicompany->enabled) && ! empty($this->entity) && $this->entity > 1)
//{
// $rootfordata.='/'.$this->entity;
//}
$conf->expensereport->dir_output = $rootfordata.'/expensereport';
$conf->expensereport_->dir_output = $rootfordata.'/expensereport';
$outputlangs->load("main"); $outputlangs->load("main");
$outputlangs->load("dict"); $outputlangs->load("dict");
$outputlangs->load("trips"); $outputlangs->load("trips");
$outputlangs->load("project"); $outputlangs->load("project");
$outputlangs->load("expensereport@expensereport");
$default_font_size = pdf_getPDFFontSize($outputlangs); $nblignes = count($object->lines);
if ($conf->expensereport_->dir_output) if ($conf->expensereport->dir_output)
{ {
// Definition de l'objet $object (pour compatibilite ascendante) // Definition of $dir and $file
if (! is_object($object)) if ($object->specimen)
{ {
$id = $object; $dir = $conf->expensereport->dir_output;
$object = new ExpenseReport($db); $file = $dir . "/SPECIMEN.pdf";
$ret=$object->fetch($id,$user); }
else
{
$objectref = dol_sanitizeFileName($object->ref);
$dir = $conf->expensereport->dir_output . "/" . $objectref;
$file = $dir . "/" . $objectref . ".pdf";
} }
$objectref = dol_sanitizeFileName($object->ref_number);
$dir = $conf->expensereport_->dir_output . "/" . $objectref;
$file = $dir . "/" . $objectref . ".pdf";
if (! file_exists($dir)) if (! file_exists($dir))
{ {
@@ -181,10 +184,24 @@ class pdf_ extends ModeleExpenseReport
if (file_exists($dir)) if (file_exists($dir))
{ {
$nblignes = count($object->lines); // Add pdfgeneration hook
if (! is_object($hookmanager))
{
include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
$hookmanager=new HookManager($this->db);
}
$hookmanager->initHooks(array('pdfgeneration'));
$parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
global $action;
$reshook=$hookmanager->executeHooks('beforePDFCreation',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
// Create pdf instance // Create pdf instance
$pdf=pdf_getInstance($this->format); $pdf=pdf_getInstance($this->format);
$default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance
$heightforinfotot = 50; // Height reserved to output the info and total part
$heightforfreetext= (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT)?$conf->global->MAIN_PDF_FREETEXT_HEIGHT:5); // Height reserved to output the free text on last page
$heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin)
$pdf->SetAutoPageBreak(1,0);
if (class_exists('TCPDF')) if (class_exists('TCPDF'))
{ {
@@ -205,13 +222,12 @@ class pdf_ extends ModeleExpenseReport
$pdf->SetTitle($outputlangs->convToOutputCharset($object->ref_number)); $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref_number));
$pdf->SetSubject($outputlangs->transnoentities("Trips")); $pdf->SetSubject($outputlangs->transnoentities("Trips"));
$pdf->SetCreator(""); $pdf->SetCreator("Dolibarr ".DOL_VERSION);
$pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs))); $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
$pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref_number)." ".$outputlangs->transnoentities("Trips")); $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("Trips"));
if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false); if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
$pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right
$pdf->SetAutoPageBreak(1,0);
// Positionne $this->atleastonediscount si on a au moins une remise // Positionne $this->atleastonediscount si on a au moins une remise
for ($i = 0 ; $i < $nblignes ; $i++) for ($i = 0 ; $i < $nblignes ; $i++)
@@ -232,17 +248,29 @@ class pdf_ extends ModeleExpenseReport
$pdf->SetTextColor(0,0,0); $pdf->SetTextColor(0,0,0);
$tab_top = 95; $tab_top = 95;
$tab_top_newpage = 95; $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?95:10);
$tab_height = 110; $tab_height = 110;
$tab_height_newpage = 110; $tab_height_newpage = 110;
// Affiche notes // Affiche notes
if (! empty($object->note)) $notetoshow=empty($object->note_public)?'':$object->note_public;
if (! empty($conf->global->MAIN_ADD_SALE_REP_SIGNATURE_IN_NOTE))
{ {
$tab_top = 93; // Get first sale rep
if (is_object($object->thirdparty))
{
$salereparray=$object->thirdparty->getSalesRepresentatives($user);
$salerepobj=new User($this->db);
$salerepobj->fetch($salereparray[0]['id']);
if (! empty($salerepobj->signature)) $notetoshow=dol_concatdesc($notetoshow, $salerepobj->signature);
}
}
if ($notetoshow)
{
$tab_top = 95;
$pdf->SetFont('','', $default_font_size - 1); $pdf->SetFont('','', $default_font_size - 1);
$pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top, dol_htmlentitiesbr($object->note), 0, 1); $pdf->writeHTMLCell(190, 3, $this->posxpiece-1, $tab_top, dol_htmlentitiesbr($notetoshow), 0, 1);
$nexY = $pdf->GetY(); $nexY = $pdf->GetY();
$height_note=$nexY-$tab_top; $height_note=$nexY-$tab_top;
@@ -265,11 +293,20 @@ class pdf_ extends ModeleExpenseReport
// Loop on each lines // Loop on each lines
for ($i = 0 ; $i < $nblignes ; $i++) for ($i = 0 ; $i < $nblignes ; $i++)
{ {
$piece_comptable = $i +1;
$curY = $nexY; $curY = $nexY;
$pdf->SetFont('','', $default_font_size - 1); // Into loop to work with multipage $pdf->SetFont('','', $default_font_size - 1); // Into loop to work with multipage
$pdf->SetTextColor(0,0,0); $pdf->SetTextColor(0,0,0);
$piece_comptable = $i +1; $pdf->setTopMargin($tab_top_newpage);
$pdf->setPageOrientation('', 1, $heightforfooter+$heightforfreetext+$heightforinfotot); // The only function to edit the bottom margin of current page to set it.
$pageposbefore=$pdf->getPage();
// Description of product line
$curX = $this->posxdesc-1;
$showpricebeforepagebreak=1;
// Piece comptable // Piece comptable
$pdf->SetFont('','', $default_font_size - 1); $pdf->SetFont('','', $default_font_size - 1);
@@ -277,46 +314,50 @@ class pdf_ extends ModeleExpenseReport
// Comments // Comments
$pdf->SetFont('','', $default_font_size - 1); $pdf->SetFont('','', $default_font_size - 1);
$pdf->SetXY ($this->posxcomment, $curY); $pdf->SetXY($this->posxcomment, $curY);
$pdf->writeHTMLCell($this->posxdate-$this->posxdesc-1, 3, $this->posxdesc-1, $curY, $object->lignes[$i]->comments, 0, 1); $pdf->writeHTMLCell($this->posxdate-$this->posxdesc-1, 3, $this->posxdesc-1, $curY, $object->lines[$i]->comments, 0, 1);
//nexY //nexY
$nexY = $pdf->GetY(); $nexY = $pdf->GetY();
$pageposafter=$pdf->getPage();
$pdf->setPage($pageposbefore);
$pdf->setTopMargin($this->marge_haute);
$pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
// Date // Date
$pdf->SetFont('','', $default_font_size - 1); $pdf->SetFont('','', $default_font_size - 1);
$pdf->SetXY ($this->posxdate, $curY); $pdf->SetXY($this->posxdate, $curY);
$pdf->MultiCell($this->posxtype-$this->posxdate-1, 3,dol_print_date($object->lignes[$i]->date,"day",false,$outpulangs), 0, 'C'); $pdf->MultiCell($this->posxtype-$this->posxdate-1, 3,dol_print_date($object->lines[$i]->date,"day",false,$outpulangs), 0, 'C');
// Type // Type
$pdf->SetFont('','', $default_font_size - 1); $pdf->SetFont('','', $default_font_size - 1);
$pdf->SetXY ($this->posxtype, $curY); $pdf->SetXY($this->posxtype, $curY);
$pdf->MultiCell($this->posxprojet-$this->posxtype-1, 3,$outputlangs->transnoentities($object->lignes[$i]->type_fees_code), 0, 'C'); $pdf->MultiCell($this->posxprojet-$this->posxtype-1, 3,$outputlangs->transnoentities($object->lines[$i]->type_fees_code), 0, 'C');
// Projet // Projet
$pdf->SetFont('','', $default_font_size - 1); $pdf->SetFont('','', $default_font_size - 1);
$pdf->SetXY ($this->posxprojet, $curY); $pdf->SetXY($this->posxprojet, $curY);
$pdf->MultiCell($this->posxtva-$this->posxprojet-1, 3,$object->lignes[$i]->projet_ref, 0, 'C'); $pdf->MultiCell($this->posxtva-$this->posxprojet-1, 3,$object->lines[$i]->projet_ref, 0, 'C');
// TVA // VAT Rate
$pdf->SetFont('','', $default_font_size - 1); $pdf->SetFont('','', $default_font_size - 1);
$pdf->SetXY ($this->posxtva, $curY); $pdf->SetXY($this->posxtva, $curY);
$pdf->MultiCell($this->posxup-$this->posxtva-1, 3,vatrate($object->lignes[$i]->tva_taux,true), 0, 'R'); $pdf->MultiCell($this->posxup-$this->posxtva-1, 3,vatrate($object->lines[$i]->tva_taux,true), 0, 'R');
// UP // UP
$pdf->SetFont('','', $default_font_size - 1); $pdf->SetFont('','', $default_font_size - 1);
$pdf->SetXY ($this->posxup, $curY); $pdf->SetXY($this->posxup, $curY);
$pdf->MultiCell($this->posxqty-$this->posxup-1, 3,price($object->lignes[$i]->value_unit), 0, 'R'); $pdf->MultiCell($this->posxqty-$this->posxup-1, 3,price($object->lines[$i]->value_unit), 0, 'R');
// QTY // Quantity
$pdf->SetFont('','', $default_font_size - 1); $pdf->SetFont('','', $default_font_size - 1);
$pdf->SetXY ($this->posxqty, $curY); $pdf->SetXY($this->posxqty, $curY);
$pdf->MultiCell($this->postotalttc-$this->posxqty, 3,$object->lignes[$i]->qty, 0, 'C'); $pdf->MultiCell($this->postotalttc-$this->posxqty, 3,$object->lines[$i]->qty, 0, 'C');
// TotalTTC // TotalTTC
$pdf->SetFont('','', $default_font_size - 1); $pdf->SetFont('','', $default_font_size - 1);
$pdf->SetXY ($this->postotalttc-2, $curY); $pdf->SetXY($this->postotalttc-2, $curY);
$pdf->MultiCell(26, 3,price($object->lignes[$i]->total_ttc), 0, 'R'); $pdf->MultiCell($this->page_largeur-$this->marge_droite-$this->postotalttc, 3, price($object->lines[$i]->total_ttc), 0, 'R');
$nexY+=5; $nexY+=5;
@@ -338,38 +379,42 @@ class pdf_ extends ModeleExpenseReport
$nblineFollowDesc = 0; $nblineFollowDesc = 0;
} }
// Test if a new page is required $nexY+=2; // Passe espace entre les lignes
if ($pagenb == 1)
{
$tab_top_in_current_page=$tab_top;
$tab_height_in_current_page=$tab_height;
}
else
{
$tab_top_in_current_page=$tab_top_newpage;
$tab_height_in_current_page=$tab_height_newpage;
}
if (($nexY+$nblineFollowDesc) > ($tab_top_in_current_page+$tab_height_in_current_page) && $i < ($nblignes - 1))
{
if ($pagenb == 1):
$this->_tableau($pdf, $tab_top, $tab_height, $nexY, $outputlangs);
$nexY=$tab_top + $tab_height + 1;
else:
$this->_tableau($pdf, $tab_top_newpage, $tab_height_newpage, $nexY, $outputlangs);
$nexY=$tab_top_newpage + $tab_height_newpage + 1;
endif;
$this->_pagefoot($pdf,$object,$outputlangs);
// Detect if some page were added automatically and output _tableau for past pages
while ($pagenb < $pageposafter)
{
$pdf->setPage($pagenb);
if ($pagenb == 1)
{
$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
}
else
{
$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
}
$this->_pagefoot($pdf,$object,$outputlangs,1);
$pagenb++;
$pdf->setPage($pagenb);
$pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
}
if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak)
{
if ($pagenb == 1)
{
$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
}
else
{
$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
}
$this->_pagefoot($pdf,$object,$outputlangs,1);
// New page // New page
$pdf->AddPage(); $pdf->AddPage();
if (! empty($tplidx)) $pdf->useTemplate($tplidx);
$pagenb++; $pagenb++;
$this->_pagehead($pdf, $object, 0, $outputlangs); if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
$pdf->SetFont('','', $default_font_size - 1);
$pdf->MultiCell(0, 3, ''); // Set interline to 3
$pdf->SetTextColor(0,0,0);
$nexY = $tab_top_newpage + 7;
} }
} }
@@ -377,30 +422,30 @@ class pdf_ extends ModeleExpenseReport
// Show square // Show square
if ($pagenb == 1) if ($pagenb == 1)
{ {
$this->_tableau($pdf, $tab_top, $tab_height, $nexY, $outputlangs); $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0);
$bottomlasttab=$tab_top + $tab_height + 1; $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
} }
else else
{ {
$this->_tableau($pdf, $tab_top_newpage, $tab_height_newpage, $nexY, $outputlangs); $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0);
$bottomlasttab=$tab_top_newpage + $tab_height_newpage + 1; $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
} }
// Affiche zone totaux // Show total area box
$posy=$bottomlasttab+5;//$nexY+95; $posy=$bottomlasttab+5;//$nexY+95;
$pdf->SetXY(120, $posy); $pdf->SetXY(100, $posy);
$pdf->MultiCell(50, 5, $outputlangs->transnoentities("TotalHT"), 1, 'L'); $pdf->MultiCell(60, 5, $outputlangs->transnoentities("TotalHT"), 1, 'L');
$pdf->SetXY (170, $posy); $pdf->SetXY(160, $posy);
$pdf->MultiCell(30, 5, price($object->total_ht), 1, 'R'); $pdf->MultiCell($this->page_largeur - $this->marge_gauche - 160, 5, price($object->total_ht), 1, 'R');
$pdf->SetFillColor(248,248,248); $pdf->SetFillColor(248,248,248);
$posy+=5; $posy+=5;
$pdf->SetXY (120, $posy); $pdf->SetXY(100, $posy);
$pdf->SetFont('','B', 10); $pdf->SetFont('','B', 10);
$pdf->SetTextColor(0,0,60); $pdf->SetTextColor(0,0,60);
$pdf->MultiCell(50, 5, $outputlangs->transnoentities("TotalTTC"), 1,'L'); $pdf->MultiCell(60, 5, $outputlangs->transnoentities("TotalTTC"), 1,'L');
$pdf->SetXY (170, $posy); $pdf->SetXY(160, $posy);
$pdf->MultiCell(30, 5, price($object->total_ttc),1, 'R'); $pdf->MultiCell($this->page_largeur - $this->marge_gauche - 160, 5, price($object->total_ttc),1, 'R');
// Pied de page // Pied de page
$this->_pagefoot($pdf,$object,$outputlangs); $this->_pagefoot($pdf,$object,$outputlangs);
@@ -411,11 +456,6 @@ class pdf_ extends ModeleExpenseReport
$pdf->Output($file,'F'); $pdf->Output($file,'F');
// Add pdfgeneration hook // Add pdfgeneration hook
if (! is_object($hookmanager))
{
include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
$hookmanager=new HookManager($this->db);
}
$hookmanager->initHooks(array('pdfgeneration')); $hookmanager->initHooks(array('pdfgeneration'));
$parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs); $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
global $action; global $action;
@@ -434,7 +474,7 @@ class pdf_ extends ModeleExpenseReport
} }
else else
{ {
$this->error=$langs->trans("ErrorConstantNotDefined","DEPLACEMENT_OUTPUTDIR"); $this->error=$langs->trans("ErrorConstantNotDefined","EXPENSEREPORT_OUTPUTDIR");
return 0; return 0;
} }
$this->error=$langs->trans("ErrorUnknown"); $this->error=$langs->trans("ErrorUnknown");
@@ -468,9 +508,9 @@ class pdf_ extends ModeleExpenseReport
*/ */
// Filligrane brouillon // Filligrane brouillon
if($object->fk_c_expensereport_statuts==1) if ($object->fk_c_expensereport_statuts==1 && ! empty($conf->global->EXPENSEREPORT_FREE_TEXT))
{ {
pdf_watermark($pdf,$outputlangs,$this->page_hauteur,$this->page_largeur,'mm',"' - PREVIEW ONLY"); pdf_watermark($pdf,$outputlangs,$this->page_hauteur,$this->page_largeur,'mm',$conf->global->EXPENSEREPORT_FREE_TEXT);
} }
$pdf->SetTextColor(0,0,60); $pdf->SetTextColor(0,0,60);
@@ -504,48 +544,37 @@ class pdf_ extends ModeleExpenseReport
$pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L'); $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
} }
$pdf->SetFont('','B', $default_font_size + 6); $pdf->SetFont('','B', $default_font_size + 4);
$pdf->SetXY($posx,$posy); $pdf->SetXY($posx,$posy);
$pdf->SetTextColor(255,255,255); $pdf->SetTextColor(0,0,60);
$pdf->SetFillColor(193,219,62); $pdf->MultiCell($this->page_largeur-$this->marge_droite-$posx,6,$langs->trans("ExpenseReport"), 0, 'L');
$ref_text = explode($conf->global->NDF_EXPLODE_CHAR,$object->ref_number);
$ref_text = substr($ref_text[1],3,$conf->global->NDF_NUM_CAR_REF);
$pdf->MultiCell(110,6,"Note de frais ".$ref_text, 0, 'L', 1);
$pdf->SetFont('','', $default_font_size -1); $pdf->SetFont('','', $default_font_size -1);
// Réf complète // Réf complète
$posy+=8; $posy+=8;
$pdf->SetXY(100,$posy); $pdf->SetXY($posx,$posy);
$pdf->SetTextColor(0,0,60); $pdf->SetTextColor(0,0,60);
$pdf->MultiCell(100, 3, $outputlangs->transnoentities("Ref")." : " . $object->ref_number, '', 'L'); $pdf->MultiCell($this->page_largeur-$this->marge_droite-$posx, 3, $outputlangs->transnoentities("Ref")." : " . $object->ref, '', 'L');
// Date début période // Date début période
$posy+=5; $posy+=5;
$pdf->SetXY(100,$posy); $pdf->SetXY($posx,$posy);
$pdf->SetTextColor(0,0,60); $pdf->SetTextColor(0,0,60);
$pdf->MultiCell(100, 3, $outputlangs->transnoentities("DateStart")." : " . ($object->date_debut>0?$object->date_debut:dol_print_date($object->date_debut,"day",false,$outpulangs)), '', 'L'); $pdf->MultiCell($this->page_largeur-$this->marge_droite-$posx, 3, $outputlangs->transnoentities("DateStart")." : " . ($object->date_debut>0?dol_print_date($object->date_debut,"day",false,$outpulangs):''), '', 'L');
// Date fin période // Date fin période
$posy+=5; $posy+=5;
$pdf->SetXY(100,$posy); $pdf->SetXY($posx,$posy);
$pdf->SetTextColor(0,0,60); $pdf->SetTextColor(0,0,60);
$pdf->MultiCell(100, 3, $outputlangs->transnoentities("DateEnd")." : " . ($object->date_fin>0?dol_print_date($object->date_fin,"day",false,$outpulangs):''), '', 'L'); $pdf->MultiCell($this->page_largeur-$this->marge_droite-$posx, 3, $outputlangs->transnoentities("DateEnd")." : " . ($object->date_fin>0?dol_print_date($object->date_fin,"day",false,$outpulangs):''), '', 'L');
// Statut NDF // Statut NDF
$posy+=7; $posy+=6;
$pdf->SetXY(100,$posy); $pdf->SetXY($posx,$posy);
$pdf->SetFont('','B',20); $pdf->SetFont('','B',18);
$pdf->SetTextColor(111,81,124); $pdf->SetTextColor(111,81,124);
if(preg_match("#Pay#",$object->libelle_statut) && !preg_match("#A P#",$object->libelle_statut)): $pdf->MultiCell($this->page_largeur-$this->marge_droite-$posx, 3, $object->getLibStatut(0), '', 'R');
$pdf->MultiCell(100, 3,$outputlangs->convToOutputCharset("Payée"), '', 'L');
elseif(preg_match("#Annul#",$object->libelle_statut)):
$pdf->MultiCell(100, 3,$outputlangs->convToOutputCharset("Annulée"), '', 'L');
elseif(preg_match("#Refus#",$object->libelle_statut)):
$pdf->MultiCell(100, 3,$outputlangs->convToOutputCharset("Refusée"), '', 'L');
else:
$pdf->MultiCell(100, 3,$object->libelle_statut, '', 'L');
endif;
// Sender properties // Sender properties
$carac_emetteur = ''; $carac_emetteur = '';
@@ -596,64 +625,80 @@ class pdf_ extends ModeleExpenseReport
$pdf->SetFont('','B',8); $pdf->SetFont('','B',8);
$pdf->SetXY($posx,$posy-5); $pdf->SetXY($posx,$posy-5);
$pdf->MultiCell(80,5, $outputlangs->transnoentities("TripNDF")." :", 0, 'L'); $pdf->MultiCell(80,5, $outputlangs->transnoentities("TripNDF")." :", 0, 'L');
$pdf->rect($posx, $posy, 100, $hautcadre); $pdf->rect($posx, $posy, $this->page_largeur - $this->marge_gauche - $posx, $hautcadre);
// Informations for trip (dates and users workflow) // Informations for trip (dates and users workflow)
$userfee=new User($this->db); if ($object->fk_user_author > 0)
$userfee->fetch($object->fk_user_author); $posy+=3; {
$pdf->SetXY($posx+2,$posy); $userfee=new User($this->db);
$pdf->SetFont('','',10); $userfee->fetch($object->fk_user_author); $posy+=3;
$pdf->MultiCell(96,4,$outputlangs->transnoentities("AUTHOR")." : ".$outputlangs->convToOutputCharset($userfee->firstname)." ".$outputlangs->convToOutputCharset($userfee->lastname),0,'L'); $pdf->SetXY($posx+2,$posy);
$posy+=5; $pdf->SetFont('','',10);
$pdf->SetXY($posx+2,$posy); $pdf->MultiCell(96,4,$outputlangs->transnoentities("AUTHOR")." : ".dolGetFirstLastname($userfee->firstname,$userfee->lastname),0,'L');
$pdf->MultiCell(96,4,$outputlangs->transnoentities("DATE_SAVE")." : ".dol_print_date($object->date_create,"day",false,$outpulangs),0,'L'); $posy+=5;
$pdf->SetXY($posx+2,$posy);
$pdf->MultiCell(96,4,$outputlangs->transnoentities("DateCreation")." : ".dol_print_date($object->date_create,"day",false,$outpulangs),0,'L');
}
if($object->fk_c_expensereport_statuts<3): if ($object->fk_c_expensereport_statuts==99)
$userfee=new User($this->db); {
$userfee->fetch($object->fk_user_validator); $posy+=6; if ($object->fk_user_refuse > 0)
$pdf->SetXY($posx+2,$posy); {
$pdf->MultiCell(96,4,$outputlangs->transnoentities("VALIDATOR")." : ".$outputlangs->convToOutputCharset($userfee->firstname)." ".$outputlangs->convToOutputCharset($userfee->lastname),0,'L'); $userfee=new User($this->db);
elseif($object->fk_c_expensereport_statuts==99): $userfee->fetch($object->fk_user_refuse); $posy+=6;
$userfee=new User($this->db); $pdf->SetXY($posx+2,$posy);
$userfee->fetch($object->fk_user_refuse); $posy+=6; $pdf->MultiCell(96,4,$outputlangs->transnoentities("REFUSEUR")." : ".dolGetFirstLastname($userfee->firstname,$userfee->lastname),0,'L');
$pdf->SetXY($posx+2,$posy); $posy+=5;
$pdf->MultiCell(96,4,$outputlangs->transnoentities("REFUSEUR")." : ".$outputlangs->convToOutputCharset($userfee->firstname)." ".$outputlangs->convToOutputCharset($userfee->lastname),0,'L'); $pdf->SetXY($posx+2,$posy);
$posy+=5; $pdf->MultiCell(96,4,$outputlangs->transnoentities("MOTIF_REFUS")." : ".$outputlangs->convToOutputCharset($object->detail_refuse),0,'L');
$pdf->SetXY($posx+2,$posy); $posy+=5;
$pdf->MultiCell(96,4,$outputlangs->transnoentities("MOTIF_REFUS")." : ".$outputlangs->convToOutputCharset($object->detail_refuse),0,'L'); $pdf->SetXY($posx+2,$posy);
$posy+=5; $pdf->MultiCell(96,4,$outputlangs->transnoentities("DATE_REFUS")." : ".dol_print_date($object->date_refuse,"day",false,$outpulangs),0,'L');
$pdf->SetXY($posx+2,$posy); }
$pdf->MultiCell(96,4,$outputlangs->transnoentities("DATE_REFUS")." : ".dol_print_date($object->date_refuse,"day",false,$outpulangs),0,'L'); }
elseif($object->fk_c_expensereport_statuts==4): else if($object->fk_c_expensereport_statuts==4)
$userfee=new User($this->db); {
$userfee->fetch($object->fk_user_cancel); $posy+=6; if ($object->fk_user_cancel > 0)
$pdf->SetXY($posx+2,$posy); {
$pdf->MultiCell(96,4,$outputlangs->transnoentities("CANCEL_USER")." : ".$outputlangs->convToOutputCharset($userfee->firstname)." ".$outputlangs->convToOutputCharset($userfee->lastname),0,'L'); $userfee=new User($this->db);
$posy+=5; $userfee->fetch($object->fk_user_cancel); $posy+=6;
$pdf->SetXY($posx+2,$posy); $pdf->SetXY($posx+2,$posy);
$pdf->MultiCell(96,4,$outputlangs->transnoentities("MOTIF_CANCEL")." : ".$outputlangs->convToOutputCharset($object->detail_cancel),0,'L'); $pdf->MultiCell(96,4,$outputlangs->transnoentities("CANCEL_USER")." : ".dolGetFirstLastname($userfee->firstname,$userfee->lastname),0,'L');
$posy+=5; $posy+=5;
$pdf->SetXY($posx+2,$posy); $pdf->SetXY($posx+2,$posy);
$pdf->MultiCell(96,4,$outputlangs->transnoentities("DATE_CANCEL")." : ".dol_print_date($object->date_cancel,"day",false,$outpulangs),0,'L'); $pdf->MultiCell(96,4,$outputlangs->transnoentities("MOTIF_CANCEL")." : ".$outputlangs->convToOutputCharset($object->detail_cancel),0,'L');
else: $posy+=5;
$userfee=new User($this->db); $pdf->SetXY($posx+2,$posy);
$userfee->fetch($object->fk_user_validator); $posy+=6; $pdf->MultiCell(96,4,$outputlangs->transnoentities("DATE_CANCEL")." : ".dol_print_date($object->date_cancel,"day",false,$outpulangs),0,'L');
$pdf->SetXY($posx+2,$posy); }
$pdf->MultiCell(96,4,$outputlangs->transnoentities("VALIDOR")." : ".$outputlangs->convToOutputCharset($userfee->firstname)." ".$outputlangs->convToOutputCharset($userfee->lastname),0,'L'); }
$posy+=5; else
$pdf->SetXY($posx+2,$posy); {
$pdf->MultiCell(96,4,$outputlangs->transnoentities("DATE_VALIDE")." : ".dol_print_date($object->date_valide,"day",false,$outpulangs),0,'L'); if ($object->fk_user_approve > 0)
endif; {
$userfee=new User($this->db);
$userfee->fetch($object->fk_user_approve); $posy+=6;
$pdf->SetXY($posx+2,$posy);
$pdf->MultiCell(96,4,$outputlangs->transnoentities("VALIDOR")." : ".dolGetFirstLastname($userfee->firstname,$userfee->lastname),0,'L');
$posy+=5;
$pdf->SetXY($posx+2,$posy);
$pdf->MultiCell(96,4,$outputlangs->transnoentities("DateApprove")." : ".dol_print_date($object->date_approve,"day",false,$outpulangs),0,'L');
}
}
if($object->fk_c_expensereport_statuts==6): if($object->fk_c_expensereport_statuts==6)
$userfee=new User($this->db); {
$userfee->fetch($object->fk_user_paid); $posy+=6; if ($object->fk_user_paid > 0)
$pdf->SetXY($posx+2,$posy); {
$pdf->MultiCell(96,4,$outputlangs->transnoentities("AUTHORPAIEMENT")." : ".$outputlangs->convToOutputCharset($userfee->firstname)." ".$outputlangs->convToOutputCharset($userfee->lastname),0,'L'); $userfee=new User($this->db);
$posy+=5; $userfee->fetch($object->fk_user_paid); $posy+=6;
$pdf->SetXY($posx+2,$posy); $pdf->SetXY($posx+2,$posy);
$pdf->MultiCell(96,4,$outputlangs->transnoentities("DATE_PAIEMENT")." : ".dol_print_date($object->date_paiement,"day",false,$outpulangs),0,'L'); $pdf->MultiCell(96,4,$outputlangs->transnoentities("AUTHORPAIEMENT")." : ".dolGetFirstLastname($userfee->firstname,$userfee->lastname),0,'L');
endif; $posy+=5;
$pdf->SetXY($posx+2,$posy);
$pdf->MultiCell(96,4,$outputlangs->transnoentities("DATE_PAIEMENT")." : ".dol_print_date($object->date_paiement,"day",false,$outpulangs),0,'L');
}
}
} }
@@ -690,48 +735,48 @@ class pdf_ extends ModeleExpenseReport
$pdf->SetFont('','',8); $pdf->SetFont('','',8);
//Piece comptable //Piece comptable
$pdf->SetXY ($this->posxpiece-1, $tab_top+1); $pdf->SetXY($this->posxpiece-1, $tab_top+1);
$pdf->MultiCell($this->posxpiece-$this->posxpiece-1,1,$outputlangs->transnoentities("Piece"),'','L'); $pdf->MultiCell($this->posxdesc-$this->posxpiece-1,1,'','','R');
//Comments //Comments
$pdf->line($this->posxdesc-1, $tab_top, $this->posxdesc-1, $tab_top + $tab_height); $pdf->line($this->posxdesc-1, $tab_top, $this->posxdesc-1, $tab_top + $tab_height);
$pdf->SetXY ($this->posxdesc-1, $tab_top+1); $pdf->SetXY($this->posxdesc-1, $tab_top+1);
$pdf->MultiCell($this->posxdate-$this->posxdesc-1,1,$outputlangs->transnoentities("Description"),'','L'); $pdf->MultiCell($this->posxdate-$this->posxdesc-1,1,$outputlangs->transnoentities("Description"),'','L');
//Date //Date
$pdf->line($this->posxdate-1, $tab_top, $this->posxdate-1, $tab_top + $tab_height); $pdf->line($this->posxdate-1, $tab_top, $this->posxdate-1, $tab_top + $tab_height);
$pdf->SetXY ($this->posxdate-1, $tab_top+1); $pdf->SetXY($this->posxdate-1, $tab_top+1);
$pdf->MultiCell($this->posxtype-$this->posxdate-1,2, $outputlangs->transnoentities("Date"),'','C'); $pdf->MultiCell($this->posxtype-$this->posxdate-1,2, $outputlangs->transnoentities("Date"),'','C');
//Type //Type
$pdf->line($this->posxtype-1, $tab_top, $this->posxtype-1, $tab_top + $tab_height); $pdf->line($this->posxtype-1, $tab_top, $this->posxtype-1, $tab_top + $tab_height);
$pdf->SetXY ($this->posxtype-1, $tab_top+1); $pdf->SetXY($this->posxtype-1, $tab_top+1);
$pdf->MultiCell($this->posxprojet-$this->posxtype-1,2, $outputlangs->transnoentities("Type"),'','C'); $pdf->MultiCell($this->posxprojet-$this->posxtype-1,2, $outputlangs->transnoentities("Type"),'','C');
// Projet // Projet
$pdf->line($this->posxprojet-1, $tab_top, $this->posxprojet-1, $tab_top + $tab_height); $pdf->line($this->posxprojet-1, $tab_top, $this->posxprojet-1, $tab_top + $tab_height);
$pdf->SetXY ($this->posxprojet-1, $tab_top+1); $pdf->SetXY($this->posxprojet-1, $tab_top+1);
$pdf->MultiCell($this->posxtva-$this->posxprojet-1,2, $outputlangs->transnoentities("Project"),'','C'); $pdf->MultiCell($this->posxtva-$this->posxprojet-1,2, $outputlangs->transnoentities("Project"),'','C');
//TVA //TVA
$pdf->line($this->posxtva-1, $tab_top, $this->posxtva-1, $tab_top + $tab_height); $pdf->line($this->posxtva-1, $tab_top, $this->posxtva-1, $tab_top + $tab_height);
$pdf->SetXY ($this->posxtva-1, $tab_top+1); $pdf->SetXY($this->posxtva-1, $tab_top+1);
$pdf->MultiCell($this->posxup-$this->posxtva-1,2, $outputlangs->transnoentities("VAT"),'','C'); $pdf->MultiCell($this->posxup-$this->posxtva-1,2, $outputlangs->transnoentities("VAT"),'','C');
//PU //PU
$pdf->line($this->posxup-1, $tab_top, $this->posxup-1, $tab_top + $tab_height); $pdf->line($this->posxup-1, $tab_top, $this->posxup-1, $tab_top + $tab_height);
$pdf->SetXY ($this->posxup-1, $tab_top+1); $pdf->SetXY($this->posxup-1, $tab_top+1);
$pdf->MultiCell($this->posxqty-$this->posxup-1,2, $outputlangs->transnoentities("PU"),'','C'); $pdf->MultiCell($this->posxqty-$this->posxup-1,2, $outputlangs->transnoentities("UP"),'','C');
//QTY //QTY
$pdf->line($this->posxqty-1, $tab_top, $this->posxqty-1, $tab_top + $tab_height); $pdf->line($this->posxqty-1, $tab_top, $this->posxqty-1, $tab_top + $tab_height);
$pdf->SetXY ($this->posxqty-1, $tab_top+1); $pdf->SetXY($this->posxqty-1, $tab_top+1);
$pdf->MultiCell($this->postotalttc-$this->posxqty,2, $outputlangs->transnoentities("Q"),'','R'); $pdf->MultiCell($this->postotalttc-$this->posxqty,2, $outputlangs->transnoentities("Qty"),'','R');
//TOTALTTC //TOTALTTC
$pdf->line($this->postotalttc, $tab_top, $this->postotalttc, $tab_top + $tab_height); $pdf->line($this->postotalttc, $tab_top, $this->postotalttc, $tab_top + $tab_height);
$pdf->SetXY ($this->postotalttc-4, $tab_top+1); $pdf->SetXY($this->postotalttc-1, $tab_top+1);
$pdf->MultiCell(28,2, $outputlangs->transnoentities("TotalTTC"),'','R'); $pdf->MultiCell($this->page_largeur-$this->marge_droite-$this->postotalttc, 2, $outputlangs->transnoentities("TotalTTC"),'','R');
$pdf->SetTextColor(0,0,0); $pdf->SetTextColor(0,0,0);
} }
@@ -747,7 +792,8 @@ class pdf_ extends ModeleExpenseReport
*/ */
function _pagefoot(&$pdf,$object,$outputlangs,$hidefreetext=0) function _pagefoot(&$pdf,$object,$outputlangs,$hidefreetext=0)
{ {
return pdf_pagefoot($pdf,$outputlangs,'DEPLACEMENT_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur,$object,0,$hidefreetext); $showdetails=0;
return pdf_pagefoot($pdf,$outputlangs,'EXPENSEREPORT_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur,$object,$showdetails,$hidefreetext);
} }
} }

View File

@@ -49,62 +49,20 @@ class ModeleExpenseReport extends CommonDocGenerator
} }
function expensereport_pdf_create($db, $id, $message, $modele, $outputlangs) /**
* expensereport_pdf_create
*
* @param DoliDB $db Database handler
* @param Object $object Object order
* @param string $modele Force le modele a utiliser ('' to not force)
* @param Translate $outputlangs objet lang a utiliser pour traduction
* @param int $hidedetails Hide details of lines
* @param int $hidedesc Hide description
* @param int $hideref Hide ref
* @return int 0 if KO, 1 if OK
* @return number
*/
function expensereport_pdf_create(DoliDB $db, ExpenseReport $object, $message, $modele, $outputlangs, $hidedetails=0, $hidedesc=0, $hideref=0)
{ {
global $conf,$langs; return $object->generateDocument($modele, $outputlangs, $hidedetails, $hidedesc, $hideref);
$langs->load("trips");
// Increase limit for PDF build
$err=error_reporting();
error_reporting(0);
@set_time_limit(120);
error_reporting($err);
$dir = dol_buildpath('/expensereport/core/modules/expensereport/');
// Positionne modele sur le nom du modele a utiliser
if (! strlen($modele))
{
if ($conf->global->DEPLACEMENT_ADDON_PDF)
{
$modele = $conf->global->DEPLACEMENT_ADDON_PDF;
}
else
{
print $langs->trans("Error")." ".$langs->trans("Error_DEPLACEMENT_ADDON_PDF_NotDefined");
return 0;
}
}
// Charge le modele
$file = "pdf_".$modele.".modules.php";
if (file_exists($dir.$file))
{
$classname = "pdf_".$modele;
require_once($dir.$file);
$obj = new $classname($db);
$obj->message = $message;
// 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($id, $outputlangs) > 0)
{
$outputlangs->charset_output=$sav_charset_output;
return 1;
}
else
{
$outputlangs->charset_output=$sav_charset_output;
dol_print_error($db,"expensereport_pdf_create Error: ".$obj->error);
return -1;
}
}
else
{
dol_print_error('',$langs->trans("Error")." ".$langs->trans("ErrorFileDoesNotExists",$dir.$file));
return -1;
}
} }

View File

@@ -393,7 +393,7 @@ class modAgenda extends DolibarrModules
$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'socpeople as sp on ac.fk_contact = sp.rowid'; $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'socpeople as sp on ac.fk_contact = sp.rowid';
$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'societe as s on ac.fk_soc = s.rowid'; $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'societe as s on ac.fk_soc = s.rowid';
$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as co on s.fk_pays = co.rowid'; $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as co on s.fk_pays = co.rowid';
$this->export_sql_end[$r] .=' Where ac.entity = '.$conf->entity; $this->export_sql_end[$r] .=' WHERE ac.entity IN ('.getEntity('agenda',1).')';
$this->export_sql_end[$r] .=' ORDER BY ac.datep'; $this->export_sql_end[$r] .=' ORDER BY ac.datep';
} }

View File

@@ -157,7 +157,7 @@ class modBanque extends DolibarrModules
$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX."bank_url as bu ON (bu.fk_bank = b.rowid AND bu.type = 'company')"; $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX."bank_url as bu ON (bu.fk_bank = b.rowid AND bu.type = 'company')";
$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'societe as s ON bu.url_id = s.rowid'; $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'societe as s ON bu.url_id = s.rowid';
$this->export_sql_end[$r] .=' WHERE ba.rowid = b.fk_account'; $this->export_sql_end[$r] .=' WHERE ba.rowid = b.fk_account';
$this->export_sql_end[$r] .=' AND ba.entity = '.$conf->entity; $this->export_sql_end[$r] .=' AND ba.entity IN ('.getEntity('bank',1).')';
$this->export_sql_order[$r] =' ORDER BY b.datev, b.num_releve'; $this->export_sql_order[$r] =' ORDER BY b.datev, b.num_releve';
$r++; $r++;
@@ -184,7 +184,7 @@ class modBanque extends DolibarrModules
$this->export_sql_end[$r] .=' WHERE ba.rowid = b.fk_account AND bch.rowid = b.fk_bordereau and bch.fk_bank_account=ba.rowid'; $this->export_sql_end[$r] .=' WHERE ba.rowid = b.fk_account AND bch.rowid = b.fk_bordereau and bch.fk_bank_account=ba.rowid';
$this->export_sql_end[$r] .=" AND b.fk_type = 'CHQ'"; $this->export_sql_end[$r] .=" AND b.fk_type = 'CHQ'";
$this->export_sql_end[$r] .=' AND p.fk_paiement = 7'; $this->export_sql_end[$r] .=' AND p.fk_paiement = 7';
$this->export_sql_end[$r] .=' AND ba.entity = '.$conf->entity; $this->export_sql_end[$r] .=' AND ba.entity IN ('.getEntity('bank',1).')';
$this->export_sql_order[$r] =' ORDER BY b.datev, b.num_releve'; $this->export_sql_order[$r] =' ORDER BY b.datev, b.num_releve';
} }

View File

@@ -122,7 +122,7 @@ class modCategorie extends DolibarrModules
$this->export_sql_start[$r]='SELECT DISTINCT '; $this->export_sql_start[$r]='SELECT DISTINCT ';
$this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'categorie as u, '.MAIN_DB_PREFIX.'categorie_fournisseur as cf, '.MAIN_DB_PREFIX.'societe as s LEFT JOIN '.MAIN_DB_PREFIX.'c_typent as t ON s.fk_typent = t.id LEFT JOIN '.MAIN_DB_PREFIX.'c_country as c ON s.fk_pays = c.rowid LEFT JOIN '.MAIN_DB_PREFIX.'c_effectif as ce ON s.fk_effectif = ce.id LEFT JOIN '.MAIN_DB_PREFIX.'c_forme_juridique as cfj ON s.fk_forme_juridique = cfj.code'; $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'categorie as u, '.MAIN_DB_PREFIX.'categorie_fournisseur as cf, '.MAIN_DB_PREFIX.'societe as s LEFT JOIN '.MAIN_DB_PREFIX.'c_typent as t ON s.fk_typent = t.id LEFT JOIN '.MAIN_DB_PREFIX.'c_country as c ON s.fk_pays = c.rowid LEFT JOIN '.MAIN_DB_PREFIX.'c_effectif as ce ON s.fk_effectif = ce.id LEFT JOIN '.MAIN_DB_PREFIX.'c_forme_juridique as cfj ON s.fk_forme_juridique = cfj.code';
$this->export_sql_end[$r] .=' WHERE u.rowid = cf.fk_categorie AND cf.fk_societe = s.rowid'; $this->export_sql_end[$r] .=' WHERE u.rowid = cf.fk_categorie AND cf.fk_societe = s.rowid';
$this->export_sql_end[$r] .=' AND u.entity = '.$conf->entity; $this->export_sql_end[$r] .=' AND u.entity IN ('.getEntity('category',1).')';
$this->export_sql_end[$r] .=' AND u.type = 1'; // Supplier categories $this->export_sql_end[$r] .=' AND u.type = 1'; // Supplier categories
$r++; $r++;
@@ -137,7 +137,7 @@ class modCategorie extends DolibarrModules
$this->export_sql_start[$r]='SELECT DISTINCT '; $this->export_sql_start[$r]='SELECT DISTINCT ';
$this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'categorie as u, '.MAIN_DB_PREFIX.'categorie_societe as cf, '.MAIN_DB_PREFIX.'societe as s LEFT JOIN '.MAIN_DB_PREFIX.'c_typent as t ON s.fk_typent = t.id LEFT JOIN '.MAIN_DB_PREFIX.'c_country as c ON s.fk_pays = c.rowid LEFT JOIN '.MAIN_DB_PREFIX.'c_effectif as ce ON s.fk_effectif = ce.id LEFT JOIN '.MAIN_DB_PREFIX.'c_forme_juridique as cfj ON s.fk_forme_juridique = cfj.code'; $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'categorie as u, '.MAIN_DB_PREFIX.'categorie_societe as cf, '.MAIN_DB_PREFIX.'societe as s LEFT JOIN '.MAIN_DB_PREFIX.'c_typent as t ON s.fk_typent = t.id LEFT JOIN '.MAIN_DB_PREFIX.'c_country as c ON s.fk_pays = c.rowid LEFT JOIN '.MAIN_DB_PREFIX.'c_effectif as ce ON s.fk_effectif = ce.id LEFT JOIN '.MAIN_DB_PREFIX.'c_forme_juridique as cfj ON s.fk_forme_juridique = cfj.code';
$this->export_sql_end[$r] .=' WHERE u.rowid = cf.fk_categorie AND cf.fk_societe = s.rowid'; $this->export_sql_end[$r] .=' WHERE u.rowid = cf.fk_categorie AND cf.fk_societe = s.rowid';
$this->export_sql_end[$r] .=' AND u.entity = '.$conf->entity; $this->export_sql_end[$r] .=' AND u.entity IN ('.getEntity('category',1).')';
$this->export_sql_end[$r] .=' AND u.type = 2'; // Customer/Prospect categories $this->export_sql_end[$r] .=' AND u.type = 2'; // Customer/Prospect categories
$r++; $r++;
@@ -152,7 +152,7 @@ class modCategorie extends DolibarrModules
$this->export_sql_start[$r]='SELECT DISTINCT '; $this->export_sql_start[$r]='SELECT DISTINCT ';
$this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'categorie as u, '.MAIN_DB_PREFIX.'categorie_product as cp, '.MAIN_DB_PREFIX.'product as p'; $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'categorie as u, '.MAIN_DB_PREFIX.'categorie_product as cp, '.MAIN_DB_PREFIX.'product as p';
$this->export_sql_end[$r] .=' WHERE u.rowid = cp.fk_categorie AND cp.fk_product = p.rowid'; $this->export_sql_end[$r] .=' WHERE u.rowid = cp.fk_categorie AND cp.fk_product = p.rowid';
$this->export_sql_end[$r] .=' AND u.entity = '.$conf->entity; $this->export_sql_end[$r] .=' AND u.entity IN ('.getEntity('category',1).')';
$this->export_sql_end[$r] .=' AND u.type = 0'; // Supplier categories $this->export_sql_end[$r] .=' AND u.type = 0'; // Supplier categories
$r++; $r++;
@@ -167,8 +167,8 @@ class modCategorie extends DolibarrModules
$this->export_sql_start[$r]='SELECT DISTINCT '; $this->export_sql_start[$r]='SELECT DISTINCT ';
$this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'categorie as u, '.MAIN_DB_PREFIX.'categorie_member as cp, '.MAIN_DB_PREFIX.'adherent as p'; $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'categorie as u, '.MAIN_DB_PREFIX.'categorie_member as cp, '.MAIN_DB_PREFIX.'adherent as p';
$this->export_sql_end[$r] .=' WHERE u.rowid = cp.fk_categorie AND cp.fk_member = p.rowid'; $this->export_sql_end[$r] .=' WHERE u.rowid = cp.fk_categorie AND cp.fk_member = p.rowid';
$this->export_sql_end[$r] .=' AND u.entity = '.$conf->entity; $this->export_sql_end[$r] .=' AND u.entity IN ('.getEntity('category',1).')';
$this->export_sql_end[$r] .=' AND u.type = 3'; // Supplier categories $this->export_sql_end[$r] .=' AND u.type = 3'; // Member categories
$r++; $r++;
$this->export_code[$r]='category_'.$r; $this->export_code[$r]='category_'.$r;
@@ -232,7 +232,7 @@ class modCategorie extends DolibarrModules
$this->export_sql_start[$r] = 'SELECT DISTINCT '; $this->export_sql_start[$r] = 'SELECT DISTINCT ';
$this->export_sql_end[$r] = ' FROM ' . MAIN_DB_PREFIX . 'categorie as u, '.MAIN_DB_PREFIX . 'categorie_contact as cp, '.MAIN_DB_PREFIX . 'socpeople as p'; $this->export_sql_end[$r] = ' FROM ' . MAIN_DB_PREFIX . 'categorie as u, '.MAIN_DB_PREFIX . 'categorie_contact as cp, '.MAIN_DB_PREFIX . 'socpeople as p';
$this->export_sql_end[$r] .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'c_country as country ON p.fk_pays = country.rowid'; $this->export_sql_end[$r] .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'c_country as country ON p.fk_pays = country.rowid';
$this->export_sql_end[$r] .= ' WHERE u.rowid = cp.fk_categorie AND cp.fk_socpeople = p.rowid AND u.entity = ' . $conf->entity; $this->export_sql_end[$r] .= ' WHERE u.rowid = cp.fk_categorie AND cp.fk_socpeople = p.rowid AND u.entity IN ('.getEntity('category',1).')';
$this->export_sql_end[$r] .= ' AND u.type = 4'; // contact categories $this->export_sql_end[$r] .= ' AND u.type = 4'; // contact categories
// Imports // Imports

View File

@@ -192,7 +192,7 @@ class modCommande extends DolibarrModules
$this->export_sql_end[$r] .=' , '.MAIN_DB_PREFIX.'commandedet as cd'; $this->export_sql_end[$r] .=' , '.MAIN_DB_PREFIX.'commandedet as cd';
$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product as p on cd.fk_product = p.rowid'; $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product as p on cd.fk_product = p.rowid';
$this->export_sql_end[$r] .=' WHERE c.fk_soc = s.rowid AND c.rowid = cd.fk_commande'; $this->export_sql_end[$r] .=' WHERE c.fk_soc = s.rowid AND c.rowid = cd.fk_commande';
$this->export_sql_end[$r] .=' AND c.entity = '.$conf->entity; $this->export_sql_end[$r] .=' AND c.entity IN ('.getEntity('commande',1).')';
} }

View File

@@ -162,7 +162,7 @@ class modContrat extends DolibarrModules
$this->export_sql_end[$r] .=' '.MAIN_DB_PREFIX.'contratdet as cod'; $this->export_sql_end[$r] .=' '.MAIN_DB_PREFIX.'contratdet as cod';
$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product as p on (cod.fk_product = p.rowid)'; $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product as p on (cod.fk_product = p.rowid)';
$this->export_sql_end[$r] .=' WHERE co.fk_soc = s.rowid and co.rowid = cod.fk_contrat'; $this->export_sql_end[$r] .=' WHERE co.fk_soc = s.rowid and co.rowid = cod.fk_contrat';
$this->export_sql_end[$r] .=' AND co.entity = '.$conf->entity; $this->export_sql_end[$r] .=' AND co.entity IN ('.getEntity('contract',1).')';
} }

View File

@@ -124,7 +124,7 @@ class modDeplacement extends DolibarrModules
$this->export_sql_end[$r] .=', '.MAIN_DB_PREFIX.'deplacement as d'; $this->export_sql_end[$r] .=', '.MAIN_DB_PREFIX.'deplacement as d';
$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'societe as s ON d.fk_soc = s.rowid'; $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'societe as s ON d.fk_soc = s.rowid';
$this->export_sql_end[$r] .=' WHERE d.fk_user = u.rowid'; $this->export_sql_end[$r] .=' WHERE d.fk_user = u.rowid';
$this->export_sql_end[$r] .=' AND d.entity = '.$conf->entity; $this->export_sql_end[$r] .=' AND d.entity IN ('.getEntity('deplacement',1).')';
} }

View File

@@ -229,7 +229,7 @@ class modExpedition extends DolibarrModules
$this->export_sql_end[$r] .=' '.MAIN_DB_PREFIX.'expeditiondet as ed, '.MAIN_DB_PREFIX.'commandedet as cd'; $this->export_sql_end[$r] .=' '.MAIN_DB_PREFIX.'expeditiondet as ed, '.MAIN_DB_PREFIX.'commandedet as cd';
$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product as p on cd.fk_product = p.rowid'; $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product as p on cd.fk_product = p.rowid';
$this->export_sql_end[$r] .=' WHERE c.fk_soc = s.rowid AND c.rowid = ed.fk_expedition AND ed.fk_origin_line = cd.rowid'; $this->export_sql_end[$r] .=' WHERE c.fk_soc = s.rowid AND c.rowid = ed.fk_expedition AND ed.fk_origin_line = cd.rowid';
$this->export_sql_end[$r] .=' AND c.entity = '.$conf->entity; $this->export_sql_end[$r] .=' AND c.entity IN ('.getEntity('shipment',1).')';
} }

View File

@@ -4,7 +4,7 @@
* *
* 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
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
@@ -14,7 +14,6 @@
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
* or see http://www.gnu.org/
*/ */
/** /**
@@ -50,8 +49,6 @@ class modExpenseReport extends DolibarrModules
// Id for module (must be unique). // Id for module (must be unique).
// Use here a free id (See in Home -> System information -> Dolibarr for list of used modules id). // Use here a free id (See in Home -> System information -> Dolibarr for list of used modules id).
$this->numero = 770; $this->numero = 770;
// Key text used to identify module (for permissions, menus, etc...)
$this->rights_class = 'deplacement';
// Family can be 'crm','financial','hr','projects','products','ecm','technic','other' // Family can be 'crm','financial','hr','projects','products','ecm','technic','other'
// It is used to group modules in module setup page // It is used to group modules in module setup page
@@ -83,21 +80,29 @@ class modExpenseReport extends DolibarrModules
//$this->style_sheet = '/mymodule/mymodule.css.php'; //$this->style_sheet = '/mymodule/mymodule.css.php';
// Config pages. Put here list of php page names stored in admmin directory used to setup module. // Config pages. Put here list of php page names stored in admmin directory used to setup module.
$this->config_page_url = array(); $this->config_page_url = array('expensereport.php');
// Dependencies // Dependencies
$this->depends = array(); // List of modules id that must be enabled if this module is enabled $this->depends = array(); // List of modules id that must be enabled if this module is enabled
// $this->conflictwith = array("modDeplacement"); // $this->conflictwith = array("modDeplacement");
$this->requiredby = array(); // List of modules id to disable if this one is disabled $this->requiredby = array(); // List of modules id to disable if this one is disabled
$this->phpmin = array(4,3); // Minimum version of PHP required by module $this->phpmin = array(4,3); // Minimum version of PHP required by module
$this->need_dolibarr_version = array(3,0); // Minimum version of Dolibarr required by module $this->need_dolibarr_version = array(3,7); // Minimum version of Dolibarr required by module
$this->langfiles = array("companies","trips","deplacement@deplacement"); $this->langfiles = array("companies","trips");
// Constants // Constants
// Example: $this->const=array(0=>array('MYMODULE_MYNEWCONST1','chaine','myvalue','This is a constant to add',0), // Example: $this->const=array(0=>array('MYMODULE_MYNEWCONST1','chaine','myvalue','This is a constant to add',0),
// 1=>array('MYMODULE_MYNEWCONST2','chaine','myvalue','This is another constant to add',0) ); // 1=>array('MYMODULE_MYNEWCONST2','chaine','myvalue','This is another constant to add',0) );
// 2=>array('MAIN_MODULE_MYMODULE_NEEDSMARTY','chaine',1,'Constant to say module need smarty',0) // 2=>array('MAIN_MODULE_MYMODULE_NEEDSMARTY','chaine',1,'Constant to say module need smarty',0)
$this->const = array(); // List of particular constants to add when module is enabled (key, 'chaine', value, desc, visible, 0 or 'allentities') $this->const = array(); // List of particular constants to add when module is enabled (key, 'chaine', value, desc, visible, 0 or 'allentities')
$r=0;
$this->const[$r][0] = "EXPENSEREPORT_ADDON_PDF";
$this->const[$r][1] = "chaine";
$this->const[$r][2] = "standard";
$this->const[$r][3] = 'Name of manager to build PDF expense reports documents';
$this->const[$r][4] = 0;
$r++;
// Array to add new pages in new tabs // Array to add new pages in new tabs
$this->tabs = array(); $this->tabs = array();
@@ -195,19 +200,21 @@ class modExpenseReport extends DolibarrModules
$r=0; $r=0;
$r++; $r++;
$this->export_code[$r]='trips_'.$r; $this->export_code[$r]='expensereport_'.$r;
$this->export_label[$r]='ListTripsAndExpenses'; $this->export_label[$r]='ListTripsAndExpenses';
$this->export_icon[$r]='trip';
$this->export_permission[$r]=array(array("expensereport","export")); $this->export_permission[$r]=array(array("expensereport","export"));
$this->export_fields_array[$r]=array('d.rowid'=>"TripId",'d.type'=>"Type",'d.km'=>"FeesKilometersOrAmout",'d.note'=>'NotePrivate','d.note_public'=>'NotePublic','s.nom'=>'ThirdParty','u.lastname'=>'Lastname','u.firstname'=>'Firstname','d.dated'=>"Date"); $this->export_fields_array[$r]=array('d.rowid'=>"TripId",'d.ref'=>'Ref','d.date_debut'=>'DateStart','d.date_fin'=>'DateEnd','d.date_create'=>'DateCreation','d.date_approve'=>'DateApprove','d.total_ht'=>"TotalHT",'d.total_tva'=>'TotalVAT','d.total_ttc'=>'TotalTTC','d.note_private'=>'NotePrivate','d.note_public'=>'NotePublic','u.lastname'=>'Lastname','u.firstname'=>'Firstname','u.login'=>"Login",'ed.rowid'=>'LineId','tf.code'=>'Type','ed.date'=>'Date','ed.fk_c_tva'=>'VATRate','ed.total_ht'=>'TotalHT','ed.total_tva'=>'TotalVAT','ed.total_ttc'=>'TotalTTC','ed.comments'=>'Comment','p.rowid'=>'ProjectId','p.ref'=>'Ref');
$this->export_entities_array[$r]=array('d.rowid'=>"Trip",'d.type'=>"Trip",'d.km'=>"Trip",'d.note'=>'Trip','d.note_public'=>'Trip','s.nom'=>'company','u.lastname'=>'user','u.firstname'=>'user','d.dated'=>"Date"); $this->export_entities_array[$r]=array('u.lastname'=>'user','u.firstname'=>'user','u.login'=>'user','ed.rowid'=>'expensereport_line','ed.date'=>'expensereport_line','ed.fk_c_tva'=>'expensereport_line','ed.total_ht'=>'expensereport_line','ed.total_tva'=>'expensereport_line','ed.total_ttc'=>'expensereport_line','ed.comments'=>'expensereport_line','tf.code'=>'expensereport_line','p.project_ref'=>'expensereport_line','p.rowid'=>'project','p.ref'=>'project');
$this->export_alias_array[$r]=array('d.rowid'=>"idtrip",'d.type'=>"type",'d.km'=>"km",'d.note'=>'note','d.note_public'=>'note_public','s.nom'=>'companyname','u.lastname'=>'name','u.firstname'=>'firstname','d.dated'=>'date'); $this->export_alias_array[$r]=array('d.rowid'=>"idtrip",'d.type'=>"type",'d.note_private'=>'note_private','d.note_public'=>'note_public','u.lastname'=>'name','u.firstname'=>'firstname','u.login'=>'login');
$this->export_dependencies_array[$r]=array('expensereport_line'=>'ed.rowid','type_fees'=>'tf.rowid'); // To add unique key if we ask a field of a child to avoid the DISTINCT to discard them
$this->export_sql_start[$r]='SELECT DISTINCT '; $this->export_sql_start[$r]='SELECT DISTINCT ';
$this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'user as u'; $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'expensereport as d, '.MAIN_DB_PREFIX.'user as u,';
$this->export_sql_end[$r] .=', '.MAIN_DB_PREFIX.'expensereport as d'; $this->export_sql_end[$r] .=' '.MAIN_DB_PREFIX.'expensereport_det as ed LEFT JOIN '.MAIN_DB_PREFIX.'c_type_fees as tf ON ed.fk_c_type_fees = tf.id';
$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'societe as s ON d.fk_soc = s.rowid'; $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'projet as p ON ed.fk_projet = p.rowid';
$this->export_sql_end[$r] .=' WHERE d.fk_user = u.rowid'; $this->export_sql_end[$r] .=' WHERE ed.fk_expensereport = d.rowid AND d.fk_user_author = u.rowid';
$this->export_sql_end[$r] .=' AND d.entity = '.$conf->entity; $this->export_sql_end[$r] .=' AND d.entity IN ('.getEntity('expensereport',1).')';

View File

@@ -228,7 +228,7 @@ class modFacture extends DolibarrModules
$this->export_sql_end[$r] .=' , '.MAIN_DB_PREFIX.'facturedet as fd'; $this->export_sql_end[$r] .=' , '.MAIN_DB_PREFIX.'facturedet as fd';
$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product as p on (fd.fk_product = p.rowid)'; $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product as p on (fd.fk_product = p.rowid)';
$this->export_sql_end[$r] .=' WHERE f.fk_soc = s.rowid AND f.rowid = fd.fk_facture'; $this->export_sql_end[$r] .=' WHERE f.fk_soc = s.rowid AND f.rowid = fd.fk_facture';
$this->export_sql_end[$r] .=' AND f.entity = '.$conf->entity; $this->export_sql_end[$r] .=' AND f.entity IN ('.getEntity('facture',1).')';
$r++; $r++;
$this->export_code[$r]=$this->rights_class.'_'.$r; $this->export_code[$r]=$this->rights_class.'_'.$r;
@@ -284,7 +284,7 @@ class modFacture extends DolibarrModules
$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'paiement_facture as pf ON pf.fk_facture = f.rowid'; $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'paiement_facture as pf ON pf.fk_facture = f.rowid';
$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'paiement as p ON pf.fk_paiement = p.rowid'; $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'paiement as p ON pf.fk_paiement = p.rowid';
$this->export_sql_end[$r] .=' WHERE f.fk_soc = s.rowid'; $this->export_sql_end[$r] .=' WHERE f.fk_soc = s.rowid';
$this->export_sql_end[$r] .=' AND f.entity = '.$conf->entity; $this->export_sql_end[$r] .=' AND f.entity IN ('.getEntity('facture',1).')';
$r++; $r++;
} }

View File

@@ -147,7 +147,7 @@ class modFicheinter extends DolibarrModules
$this->export_sql_start[$r]='SELECT DISTINCT '; $this->export_sql_start[$r]='SELECT DISTINCT ';
$this->export_sql_end[$r] =' FROM ('.MAIN_DB_PREFIX.'fichinter as f, '.MAIN_DB_PREFIX.'fichinterdet as fd, '.MAIN_DB_PREFIX.'societe as s)'; $this->export_sql_end[$r] =' FROM ('.MAIN_DB_PREFIX.'fichinter as f, '.MAIN_DB_PREFIX.'fichinterdet as fd, '.MAIN_DB_PREFIX.'societe as s)';
$this->export_sql_end[$r] .=' WHERE f.fk_soc = s.rowid AND f.rowid = fd.fk_fichinter'; $this->export_sql_end[$r] .=' WHERE f.fk_soc = s.rowid AND f.rowid = fd.fk_fichinter';
$this->export_sql_end[$r] .=' AND f.entity = '.$conf->entity; $this->export_sql_end[$r] .=' AND f.entity IN ('.getEntity('intervention',1).')';
$r++; $r++;
} }

View File

@@ -297,7 +297,7 @@ class modFournisseur extends DolibarrModules
$this->export_sql_end[$r] .=' , '.MAIN_DB_PREFIX.'facture_fourn_det as fd'; $this->export_sql_end[$r] .=' , '.MAIN_DB_PREFIX.'facture_fourn_det as fd';
$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product as p on (fd.fk_product = p.rowid)'; $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product as p on (fd.fk_product = p.rowid)';
$this->export_sql_end[$r] .=' WHERE f.fk_soc = s.rowid AND f.rowid = fd.fk_facture_fourn'; $this->export_sql_end[$r] .=' WHERE f.fk_soc = s.rowid AND f.rowid = fd.fk_facture_fourn';
$this->export_sql_end[$r] .=' AND f.entity = '.$conf->entity; $this->export_sql_end[$r] .=' AND f.entity IN ('.getEntity('supplier_invoice',1).')';
$r++; $r++;
$this->export_code[$r]=$this->rights_class.'_'.$r; $this->export_code[$r]=$this->rights_class.'_'.$r;
@@ -351,7 +351,7 @@ class modFournisseur extends DolibarrModules
$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'paiementfourn_facturefourn as pf ON pf.fk_facturefourn = f.rowid'; $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'paiementfourn_facturefourn as pf ON pf.fk_facturefourn = f.rowid';
$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'paiementfourn as p ON pf.fk_paiementfourn = p.rowid'; $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'paiementfourn as p ON pf.fk_paiementfourn = p.rowid';
$this->export_sql_end[$r] .=' WHERE f.fk_soc = s.rowid'; $this->export_sql_end[$r] .=' WHERE f.fk_soc = s.rowid';
$this->export_sql_end[$r] .=' AND f.entity = '.$conf->entity; $this->export_sql_end[$r] .=' AND f.entity IN ('.getEntity('supplier_invoice',1).')';
$r++; $r++;
$this->export_code[$r]=$this->rights_class.'_'.$r; $this->export_code[$r]=$this->rights_class.'_'.$r;
@@ -369,7 +369,7 @@ class modFournisseur extends DolibarrModules
$this->export_sql_end[$r] .=' '.MAIN_DB_PREFIX.'commande_fournisseur as f, '.MAIN_DB_PREFIX.'commande_fournisseurdet as fd'; $this->export_sql_end[$r] .=' '.MAIN_DB_PREFIX.'commande_fournisseur as f, '.MAIN_DB_PREFIX.'commande_fournisseurdet as fd';
$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product as p on (fd.fk_product = p.rowid)'; $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product as p on (fd.fk_product = p.rowid)';
$this->export_sql_end[$r] .=' WHERE f.fk_soc = s.rowid AND f.rowid = fd.fk_commande'; $this->export_sql_end[$r] .=' WHERE f.fk_soc = s.rowid AND f.rowid = fd.fk_commande';
$this->export_sql_end[$r] .=' AND f.entity = '.$conf->entity; $this->export_sql_end[$r] .=' AND f.entity IN ('.getEntity('supplier_order',1).')';
} }

View File

@@ -289,7 +289,7 @@ class modProjet extends DolibarrModules
$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX."projet_task_time as ptt ON pt.rowid = ptt.fk_task,"; $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX."projet_task_time as ptt ON pt.rowid = ptt.fk_task,";
$this->export_sql_end[$r] .=' '.MAIN_DB_PREFIX.'societe as s'; $this->export_sql_end[$r] .=' '.MAIN_DB_PREFIX.'societe as s';
$this->export_sql_end[$r] .=' WHERE p.fk_soc = s.rowid'; $this->export_sql_end[$r] .=' WHERE p.fk_soc = s.rowid';
$this->export_sql_end[$r] .=' AND p.entity = '.$conf->entity; $this->export_sql_end[$r] .=' AND p.entity IN ('.getEntity('project',1).')';
} }

View File

@@ -186,7 +186,7 @@ class modPropale extends DolibarrModules
$this->export_sql_end[$r] .=', '.MAIN_DB_PREFIX.'propaldet as cd'; $this->export_sql_end[$r] .=', '.MAIN_DB_PREFIX.'propaldet as cd';
$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product as p on (cd.fk_product = p.rowid)'; $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product as p on (cd.fk_product = p.rowid)';
$this->export_sql_end[$r] .=' WHERE c.fk_soc = s.rowid AND c.rowid = cd.fk_propal'; $this->export_sql_end[$r] .=' WHERE c.fk_soc = s.rowid AND c.rowid = cd.fk_propal';
$this->export_sql_end[$r] .=' AND c.entity = '.$conf->entity; $this->export_sql_end[$r] .=' AND c.entity IN ('.getEntity('propal',1).')';
} }

View File

@@ -132,21 +132,7 @@ class modSalaries extends DolibarrModules
// Exports // Exports
//-------- //--------
$r=0; $r=0;
/*
$r++;
$this->export_code[$r]=$this->rights_class.'_'.$r;
$this->export_label[$r]='Payment of salaries';
$this->export_permission[$r]=array(array("tax","charges","export"));
$this->export_fields_array[$r]=array('cc.libelle'=>"Type",'c.rowid'=>"IdSocialContribution",'c.libelle'=>"Label",'c.date_ech'=>'DateDue','c.periode'=>'Period','c.amount'=>"AmountExpected","c.paye"=>"Status",'p.rowid'=>'PaymentId','p.datep'=>'DatePayment','p.amount'=>'AmountPayment','p.num_paiement'=>'Numero');
$this->export_TypeFields_array[$r]=array('cc.libelle'=>"List:c_chargesociales:libelle:id",'c.libelle'=>"Text",'c.date_ech'=>'Date','c.periode'=>'Period','c.amount'=>"Number","c.paye"=>"Boolean",'p.datep'=>'Date','p.amount'=>'Number','p.num_paiement'=>'Number');
$this->export_entities_array[$r]=array('cc.libelle'=>"tax_type",'c.rowid'=>"tax",'c.libelle'=>'tax','c.date_ech'=>'tax','c.periode'=>'tax','c.amount'=>"tax","c.paye"=>"tax",'p.rowid'=>'payment','p.datep'=>'payment','p.amount'=>'payment','p.num_paiement'=>'payment');
$this->export_sql_start[$r]='SELECT DISTINCT ';
$this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'c_chargesociales as cc, '.MAIN_DB_PREFIX.'chargesociales as c';
$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'paiementcharge as p ON p.fk_charge = c.rowid';
$this->export_sql_end[$r] .=' WHERE c.fk_type = cc.id';
$this->export_sql_end[$r] .=' AND c.entity = '.$conf->entity;
*/
} }

View File

@@ -131,7 +131,7 @@ class modStock extends DolibarrModules
$this->export_sql_start[$r]='SELECT DISTINCT '; $this->export_sql_start[$r]='SELECT DISTINCT ';
$this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'product as p, '.MAIN_DB_PREFIX.'product_stock as ps, '.MAIN_DB_PREFIX.'entrepot as e'; $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'product as p, '.MAIN_DB_PREFIX.'product_stock as ps, '.MAIN_DB_PREFIX.'entrepot as e';
$this->export_sql_end[$r] .=' WHERE p.rowid = ps.fk_product AND ps.fk_entrepot = e.rowid'; $this->export_sql_end[$r] .=' WHERE p.rowid = ps.fk_product AND ps.fk_entrepot = e.rowid';
$this->export_sql_end[$r] .=' AND e.entity = '.$conf->entity; $this->export_sql_end[$r] .=' AND e.entity IN ('.getEntity('stock',1).')';
// Imports // Imports

View File

@@ -133,7 +133,7 @@ class modTax extends DolibarrModules
$this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'c_chargesociales as cc, '.MAIN_DB_PREFIX.'chargesociales as c'; $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'c_chargesociales as cc, '.MAIN_DB_PREFIX.'chargesociales as c';
$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'paiementcharge as p ON p.fk_charge = c.rowid'; $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'paiementcharge as p ON p.fk_charge = c.rowid';
$this->export_sql_end[$r] .=' WHERE c.fk_type = cc.id'; $this->export_sql_end[$r] .=' WHERE c.fk_type = cc.id';
$this->export_sql_end[$r] .=' AND c.entity = '.$conf->entity; $this->export_sql_end[$r] .=' AND c.entity IN ('.getEntity('tax',1).')';
} }

View File

@@ -220,7 +220,7 @@ class modUser extends DolibarrModules
} }
$this->export_sql_start[$r]='SELECT DISTINCT '; $this->export_sql_start[$r]='SELECT DISTINCT ';
$this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'user as u'; $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'user as u';
$this->export_sql_end[$r] .=' WHERE u.entity IN (0,'.$conf->entity.')'; $this->export_sql_end[$r] .=' WHERE u.entity IN ('.getEntity('user',1).')';
} }

View File

@@ -33,8 +33,8 @@ require_once(DOL_DOCUMENT_ROOT."/projet/class/project.class.php");
require_once(DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'); require_once(DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php');
require_once(DOL_DOCUMENT_ROOT."/core/lib/expensereport.lib.php"); require_once(DOL_DOCUMENT_ROOT."/core/lib/expensereport.lib.php");
require_once(DOL_DOCUMENT_ROOT."/core/lib/price.lib.php"); require_once(DOL_DOCUMENT_ROOT."/core/lib/price.lib.php");
dol_include_once('/expensereport/core/modules/expensereport/modules_expensereport.php'); require_once(DOL_DOCUMENT_ROOT."/core/modules/expensereport/modules_expensereport.php");
dol_include_once("/expensereport/class/expensereport.class.php"); require_once(DOL_DOCUMENT_ROOT."/expensereport/class/expensereport.class.php");
$langs->load("trips"); $langs->load("trips");
@@ -68,13 +68,17 @@ if (! empty($conf->multicompany->enabled) && ! empty($conf->entity) && $conf->en
$rootfordata.='/'.$conf->entity; $rootfordata.='/'.$conf->entity;
} }
$conf->expensereport->dir_output = $rootfordata.'/expensereport'; $conf->expensereport->dir_output = $rootfordata.'/expensereport';
$conf->expensereport->dir_output = $rootfordata.'/expensereport';
// Define $urlwithroot // Define $urlwithroot
$urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root)); $urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root));
$urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file $urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file
//$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current //$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current
// PDF
$hidedetails = (GETPOST('hidedetails', 'int') ? GETPOST('hidedetails', 'int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 1 : 0));
$hidedesc = (GETPOST('hidedesc', 'int') ? GETPOST('hidedesc', 'int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC) ? 1 : 0));
$hideref = (GETPOST('hideref', 'int') ? GETPOST('hideref', 'int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF) ? 1 : 0));
/* /*
@@ -83,7 +87,7 @@ $urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain
if ($cancel) $action=''; if ($cancel) $action='';
if ($action == 'confirm_delete' && $_GET["confirm"] == "yes" && $id > 0 && $user->rights->expensereport->supprimer) if ($action == 'confirm_delete' && GETPOST("confirm") == "yes" && $id > 0 && $user->rights->expensereport->supprimer)
{ {
$object = new ExpenseReport($db); $object = new ExpenseReport($db);
$result=$object->delete($id); $result=$object->delete($id);
@@ -171,6 +175,27 @@ if ($action == "confirm_save" && GETPOST("confirm") == "yes" && $id > 0 && $user
$object = new ExpenseReport($db); $object = new ExpenseReport($db);
$object->fetch($id); $object->fetch($id);
$result = $object->setValidate($user); $result = $object->setValidate($user);
if ($result > 0)
{
// Define output language
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
{
$outputlangs = $langs;
$newlang = '';
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id')) $newlang = GETPOST('lang_id','alpha');
if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang;
if (! empty($newlang)) {
$outputlangs = new Translate("", $conf);
$outputlangs->setDefaultLang($newlang);
}
$model=$object->modelpdf;
$ret = $object->fetch($id); // Reload to get new records
$object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
}
}
if ($result > 0 && $object->fk_user_validator > 0) if ($result > 0 && $object->fk_user_validator > 0)
{ {
$langs->load("mails"); $langs->load("mails");
@@ -252,6 +277,27 @@ if ($action == "confirm_save_from_refuse" && GETPOST("confirm") == "yes" && $id
$object = new ExpenseReport($db); $object = new ExpenseReport($db);
$object->fetch($id); $object->fetch($id);
$result = $object->set_save_from_refuse($user); $result = $object->set_save_from_refuse($user);
if ($result > 0)
{
// Define output language
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
{
$outputlangs = $langs;
$newlang = '';
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id')) $newlang = GETPOST('lang_id','alpha');
if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang;
if (! empty($newlang)) {
$outputlangs = new Translate("", $conf);
$outputlangs->setDefaultLang($newlang);
}
$model=$object->modelpdf;
$ret = $object->fetch($id); // Reload to get new records
$object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
}
}
if ($result > 0) if ($result > 0)
{ {
// Send mail // Send mail
@@ -283,7 +329,7 @@ if ($action == "confirm_save_from_refuse" && GETPOST("confirm") == "yes" && $id
// Génération du pdf avant attachement // Génération du pdf avant attachement
$object->setDocModel($user,""); $object->setDocModel($user,"");
$resultPDF = expensereport_pdf_create($db,$id,'',"",$langs); $resultPDF = expensereport_pdf_create($db,$object,'',"",$langs);
if($resultPDF): if($resultPDF):
// ATTACHMENT // ATTACHMENT
@@ -329,6 +375,27 @@ if ($action == "confirm_approve" && GETPOST("confirm") == "yes" && $id > 0 && $u
$object->fetch($id); $object->fetch($id);
$result = $object->setApproved($user); $result = $object->setApproved($user);
if ($result > 0)
{
// Define output language
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
{
$outputlangs = $langs;
$newlang = '';
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id')) $newlang = GETPOST('lang_id','alpha');
if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang;
if (! empty($newlang)) {
$outputlangs = new Translate("", $conf);
$outputlangs->setDefaultLang($newlang);
}
$model=$object->modelpdf;
$ret = $object->fetch($id); // Reload to get new records
$object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
}
}
if ($result > 0) if ($result > 0)
{ {
if (! empty($conf->global->DEPLACEMENT_TO_CLEAN)) if (! empty($conf->global->DEPLACEMENT_TO_CLEAN))
@@ -360,7 +427,7 @@ if ($action == "confirm_approve" && GETPOST("confirm") == "yes" && $id > 0 && $u
// Génération du pdf avant attachement // Génération du pdf avant attachement
$object->setDocModel($user,""); $object->setDocModel($user,"");
$resultPDF = expensereport_pdf_create($db,$id,'',"",$langs); $resultPDF = expensereport_pdf_create($db,$object,'',"",$langs);
if($resultPDF): if($resultPDF):
// ATTACHMENT // ATTACHMENT
@@ -412,6 +479,27 @@ if ($action == "confirm_refuse" && GETPOST('confirm')=="yes" && $id > 0 && $user
$object->fetch($id); $object->fetch($id);
$result = $object->setDeny($user,GETPOST('detail_refuse')); $result = $object->setDeny($user,GETPOST('detail_refuse'));
if ($result > 0)
{
// Define output language
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
{
$outputlangs = $langs;
$newlang = '';
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id')) $newlang = GETPOST('lang_id','alpha');
if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang;
if (! empty($newlang)) {
$outputlangs = new Translate("", $conf);
$outputlangs->setDefaultLang($newlang);
}
$model=$object->modelpdf;
$ret = $object->fetch($id); // Reload to get new records
$object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
}
}
if ($result > 0) if ($result > 0)
{ {
if (! empty($conf->global->DEPLACEMENT_TO_CLEAN)) if (! empty($conf->global->DEPLACEMENT_TO_CLEAN))
@@ -477,6 +565,26 @@ if ($action == "confirm_cancel" && GETPOST('confirm')=="yes" && GETPOST('detail_
{ {
$result = $object->set_cancel($user,GETPOST('detail_cancel')); $result = $object->set_cancel($user,GETPOST('detail_cancel'));
if ($result > 0)
{
// Define output language
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
{
$outputlangs = $langs;
$newlang = '';
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id')) $newlang = GETPOST('lang_id','alpha');
if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang;
if (! empty($newlang)) {
$outputlangs = new Translate("", $conf);
$outputlangs->setDefaultLang($newlang);
}
$model=$object->modelpdf;
$ret = $object->fetch($id); // Reload to get new records
$object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
}
}
if ($result > 0) if ($result > 0)
{ {
if (! empty($conf->global->DEPLACEMENT_TO_CLEAN)) if (! empty($conf->global->DEPLACEMENT_TO_CLEAN))
@@ -541,6 +649,27 @@ if ($action == "confirm_paid" && GETPOST('confirm')=="yes" && $id > 0 && $user->
$object->fetch($id); $object->fetch($id);
$result = $object->setPaid($user); $result = $object->setPaid($user);
if ($result > 0)
{
// Define output language
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
{
$outputlangs = $langs;
$newlang = '';
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id')) $newlang = GETPOST('lang_id','alpha');
if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang;
if (! empty($newlang)) {
$outputlangs = new Translate("", $conf);
$outputlangs->setDefaultLang($newlang);
}
$model=$object->modelpdf;
$ret = $object->fetch($id); // Reload to get new records
$object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
}
}
if ($result > 0) if ($result > 0)
{ {
if (! empty($conf->global->DEPLACEMENT_TO_CLEAN)) if (! empty($conf->global->DEPLACEMENT_TO_CLEAN))
@@ -569,7 +698,7 @@ if ($action == "confirm_paid" && GETPOST('confirm')=="yes" && $id > 0 && $user->
// Génération du pdf avant attachement // Génération du pdf avant attachement
$object->setDocModel($user,""); $object->setDocModel($user,"");
$resultPDF = expensereport_pdf_create($db,$id,'',"",$langs); $resultPDF = expensereport_pdf_create($db,$object,'',"",$langs);
// PREPARE SEND // PREPARE SEND
$mailfile = new CMailFile($subject,$emailTo,$emailFrom,$message); $mailfile = new CMailFile($subject,$emailTo,$emailFrom,$message);
@@ -638,6 +767,27 @@ if ($action == "confirm_brouillonner" && GETPOST('confirm')=="yes" && $id > 0 &&
if ($user->id == $object->fk_user_author || $user->id == $object->fk_user_valid) if ($user->id == $object->fk_user_author || $user->id == $object->fk_user_valid)
{ {
$result = $object->setStatut(0); $result = $object->setStatut(0);
if ($result > 0)
{
// Define output language
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
{
$outputlangs = $langs;
$newlang = '';
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id')) $newlang = GETPOST('lang_id','alpha');
if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang;
if (! empty($newlang)) {
$outputlangs = new Translate("", $conf);
$outputlangs->setDefaultLang($newlang);
}
$model=$object->modelpdf;
$ret = $object->fetch($id); // Reload to get new records
$object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
}
}
if ($result > 0) if ($result > 0)
{ {
header("Location: ".$_SEVER["PHP_SELF"]."?id=".$id); header("Location: ".$_SEVER["PHP_SELF"]."?id=".$id);
@@ -746,7 +896,7 @@ if ($action == "addline")
$action=''; $action='';
} }
if ($action == 'confirm_delete_line' && $_POST["confirm"] == "yes") if ($action == 'confirm_delete_line' && GETPOST("confirm") == "yes")
{ {
$object = new ExpenseReport($db); $object = new ExpenseReport($db);
$object->fetch($id); $object->fetch($id);
@@ -759,6 +909,26 @@ if ($action == 'confirm_delete_line' && $_POST["confirm"] == "yes")
$result=$object->deleteline($_GET["rowid"]); $result=$object->deleteline($_GET["rowid"]);
if ($result >= 0) if ($result >= 0)
{ {
if ($result > 0)
{
// Define output language
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
{
$outputlangs = $langs;
$newlang = '';
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id')) $newlang = GETPOST('lang_id','alpha');
if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang;
if (! empty($newlang)) {
$outputlangs = new Translate("", $conf);
$outputlangs->setDefaultLang($newlang);
}
$model=$object->modelpdf;
$ret = $object->fetch($id); // Reload to get new records
$object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
}
}
$object->update_totaux_del($object_ligne->total_ht,$object_ligne->total_tva); $object->update_totaux_del($object_ligne->total_ht,$object_ligne->total_tva);
header("Location: ".$_SERVER["PHP_SELF"]."?id=".$_GET['id']); header("Location: ".$_SERVER["PHP_SELF"]."?id=".$_GET['id']);
exit; exit;
@@ -801,6 +971,26 @@ if ($action == "updateligne" )
$result = $object->updateline($rowid, $type_fees_id, $projet_id, $c_tva, $comments, $qty, $value_unit, $date, $object_id); $result = $object->updateline($rowid, $type_fees_id, $projet_id, $c_tva, $comments, $qty, $value_unit, $date, $object_id);
if ($result >= 0) if ($result >= 0)
{ {
if ($result > 0)
{
// Define output language
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
{
$outputlangs = $langs;
$newlang = '';
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id')) $newlang = GETPOST('lang_id','alpha');
if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang;
if (! empty($newlang)) {
$outputlangs = new Translate("", $conf);
$outputlangs->setDefaultLang($newlang);
}
$model=$object->modelpdf;
$ret = $object->fetch($id); // Reload to get new records
$object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
}
}
$object->recalculer($object_id); $object->recalculer($object_id);
header("Location: ".$_SERVER["PHP_SELF"]."?id=".$object_id); header("Location: ".$_SERVER["PHP_SELF"]."?id=".$object_id);
exit; exit;
@@ -812,20 +1002,6 @@ if ($action == "updateligne" )
} }
} }
if ($action == "recalc" && $id > 0)
{
$object = new ExpenseReport($db);
$object->fetch($id);
if($object->recalculer($id) > 0)
{
header("Location: ".$_SERVER["PHP_SELF"]."?id=".$_GET['id']);
exit;
}
else
{
setEventMessages($object->error, $object->errors, 'errors');
}
}
/* /*
* Generer ou regenerer le document PDF * Generer ou regenerer le document PDF
@@ -846,7 +1022,7 @@ if ($action == 'builddoc') // En get ou en post
$outputlangs = new Translate("",$conf); $outputlangs = new Translate("",$conf);
$outputlangs->setDefaultLang($_REQUEST['lang_id']); $outputlangs->setDefaultLang($_REQUEST['lang_id']);
} }
$result=expensereport_pdf_create($db, $depl->id, '', $depl->modelpdf, $outputlangs); $result=expensereport_pdf_create($db, $depl, '', $depl->modelpdf, $outputlangs);
if ($result <= 0) if ($result <= 0)
{ {
dol_print_error($db,$result); dol_print_error($db,$result);

View File

@@ -24,7 +24,8 @@ class ExpenseReport extends CommonObject
var $date_fin; var $date_fin;
var $fk_user_validator; var $fk_user_validator;
var $fk_c_expensereport_statuts; // -- 1=brouillon, 2=validé (attente approb), 4=annulé, 5=approuvé, 6=payed, 99=refusé var $status;
var $fk_c_expensereport_statuts; // -- 1=draft, 2=validated (attente approb), 4=canceled, 5=approved, 6=payed, 99=denied
var $fk_c_paiement; var $fk_c_paiement;
var $user_author_infos; var $user_author_infos;
@@ -467,6 +468,67 @@ class ExpenseReport extends CommonObject
} }
/**
* Initialise an instance with random values.
* Used to build previews or test instances.
* id must be 0 if object instance is a specimen.
*
* @return void
*/
function initAsSpecimen()
{
global $user,$langs,$conf;
$now=dol_now();
// Initialise parametres
$this->id=0;
$this->ref = 'SPECIMEN';
$this->specimen=1;
$this->date_create = $now;
$this->date_debut = $now;
$this->date_fin = $now;
$this->date_approve = $now;
$this->status = 5;
$this->fk_c_expensereport_statuts = 5;
$this->fk_user_author = $user->id;
$this->fk_user_valid = $user->id;
$this->fk_user_approve = $user->id;
$this->fk_user_validator = $user->id;
$this->note_private='Private note';
$this->note_public='SPECIMEN';
$nbp = 5;
$xnbp = 0;
while ($xnbp < $nbp)
{
$line=new ExpenseReportLine($this->db);
$line->comments=$langs->trans("Comment")." ".$xnbp;
$line->date=($now-3600*(1+$xnbp));
$line->total_ht=100;
$line->total_tva=20;
$line->total_ttc=120;
$line->qty=1;
$line->fk_c_tva=20;
$line->tva_taux=20;
$line->value_unit=120;
$line->fk_expensereport=0;
$line->type_fees_code='TRA';
$line->projet_ref = 'ABC';
$this->lines[$xnbp]=$line;
$xnbp++;
$this->total_ht+=$line->total_ht;
$this->total_tva+=$line->total_tva;
$this->total_ttc+=$line->total_ttc;
}
}
/** /**
* fetch_line_by_project * fetch_line_by_project
* *
@@ -1302,6 +1364,41 @@ class ExpenseReport extends CommonObject
return -1; return -1;
} }
} }
/**
* Create a document onto disk accordign to template module.
*
* @param string $modele Force le mnodele a utiliser ('' to not force)
* @param Translate $outputlangs objet lang a utiliser pour traduction
* @param int $hidedetails Hide details of lines
* @param int $hidedesc Hide description
* @param int $hideref Hide ref
* @return int 0 if KO, 1 if OK
*/
public function generateDocument($modele, $outputlangs, $hidedetails=0, $hidedesc=0, $hideref=0)
{
global $conf,$langs;
$langs->load("trips");
// Positionne le modele sur le nom du modele a utiliser
if (! dol_strlen($modele))
{
if (! empty($conf->global->EXPENSEREPORT_ADDON_PDF))
{
$modele = $conf->global->EXPENSEREPORT_ADDON_PDF;
}
else
{
$modele = 'standard';
}
}
$modelpath = "core/modules/expensereport/doc/";
return $this->commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref);
}
} }

View File

@@ -60,7 +60,9 @@ $entitytoicon = array(
'warehouse' => 'stock', 'warehouse' => 'stock',
'category' => 'category', 'category' => 'category',
'shipment' => 'sending', 'shipment' => 'sending',
'shipment_line'=> 'sending' 'shipment_line'=> 'sending',
'expensereport'=> 'trip',
'expensereport_line'=> 'trip'
); );
// Translation code // Translation code
@@ -95,7 +97,9 @@ $entitytolang = array(
'project' => 'Projects', 'project' => 'Projects',
'projecttask' => 'Tasks', 'projecttask' => 'Tasks',
'task_time' => 'TaskTimeSpent', 'task_time' => 'TaskTimeSpent',
'action' => 'Action' 'action' => 'Action',
'expensereport'=> 'ExpenseReport',
'expensereport_line'=> 'ExpenseReportLine',
); );
$array_selected=isset($_SESSION["export_selected_fields"])?$_SESSION["export_selected_fields"]:array(); $array_selected=isset($_SESSION["export_selected_fields"])?$_SESSION["export_selected_fields"]:array();

View File

@@ -148,7 +148,7 @@ CREATE TABLE llx_expensereport (
fk_user_paid integer DEFAULT NULL, fk_user_paid integer DEFAULT NULL,
fk_c_expensereport_statuts integer NOT NULL, -- 1=brouillon, 2=validé (attente approb), 4=annulé, 5=approuvé, 6=payed, 99=refusé fk_c_expensereport_statuts integer NOT NULL, -- 1=brouillon, 2=validé (attente approb), 4=annulé, 5=approuvé, 6=payed, 99=refusé
fk_c_paiement integer DEFAULT NULL, fk_c_paiement integer DEFAULT NULL,
note text, note_public text,
note_private text, note_private text,
detail_refuse varchar(255) DEFAULT NULL, detail_refuse varchar(255) DEFAULT NULL,
detail_cancel varchar(255) DEFAULT NULL, detail_cancel varchar(255) DEFAULT NULL,

View File

@@ -46,7 +46,7 @@ CREATE TABLE llx_expensereport (
fk_user_paid integer DEFAULT NULL, fk_user_paid integer DEFAULT NULL,
fk_c_expensereport_statuts integer NOT NULL, -- 1=brouillon, 2=validé (attente approb), 4=annulé, 5=approuvé, 6=payed, 99=refusé fk_c_expensereport_statuts integer NOT NULL, -- 1=brouillon, 2=validé (attente approb), 4=annulé, 5=approuvé, 6=payed, 99=refusé
fk_c_paiement integer DEFAULT NULL, fk_c_paiement integer DEFAULT NULL,
note text, note_public text,
note_private text, note_private text,
detail_refuse varchar(255) DEFAULT NULL, detail_refuse varchar(255) DEFAULT NULL,
detail_cancel varchar(255) DEFAULT NULL, detail_cancel varchar(255) DEFAULT NULL,

View File

@@ -1581,3 +1581,5 @@ SortOrder=Sort order
Format=Format Format=Format
TypePaymentDesc=0:Customer payment type, 1:Supplier payment type, 2:Both customers and suppliers payment type TypePaymentDesc=0:Customer payment type, 1:Supplier payment type, 2:Both customers and suppliers payment type
IncludePath=Include path (defined into variable %s) IncludePath=Include path (defined into variable %s)
ExpenseReportsSetup=Setup of module Expense Reports
TemplatePDFExpenseReports=Document templates to generate expense report document

View File

@@ -27,10 +27,10 @@ AnyOtherInThisListCanValidate=Person to inform for validation.
TripSociete=Information company TripSociete=Information company
TripSalarie=Informations user TripSalarie=Informations user
TripNDF=Informations expense report TripNDF=Informations expense report
DeleteLine=Delete a ligne of the expense report DeleteLine=Delete a ligne of the expense report
ConfirmDeleteLine=Are you sure you want to delete this line ? ConfirmDeleteLine=Are you sure you want to delete this line ?
PDFStandardExpenseReports=Standard template to generate a PDF document for expense report
ExpenseReportLine=Expense report line
TF_OTHER=Other TF_OTHER=Other
TF_TRANSPORTATION=Transportation TF_TRANSPORTATION=Transportation
TF_LUNCH=Lunch TF_LUNCH=Lunch
@@ -67,10 +67,11 @@ MOTIF_REFUS=Reason
MOTIF_CANCEL=Reason MOTIF_CANCEL=Reason
DATE_REFUS=Deny date DATE_REFUS=Deny date
DATE_CANCEL=Cancelation date DATE_SAVE=Validation date
DATE_VALIDE=Validation date DATE_VALIDE=Validation date
DateApprove=Approving date
DATE_CANCEL=Cancelation date
DATE_PAIEMENT=Payment date DATE_PAIEMENT=Payment date
DATE_SAVE=Recording date
Deny=Deny Deny=Deny
TO_PAID=Pay TO_PAID=Pay