New: Add statistics page for trips and expenses module

This commit is contained in:
Laurent Destailleur
2010-04-05 01:01:28 +00:00
parent b5bc6dac90
commit 2dd4f080f0
16 changed files with 555 additions and 27 deletions

View File

@@ -3,6 +3,7 @@ English Dolibarr ChangeLog
***** ChangeLog for 2.9 compared to 2.8 *****
For users:
- New: Add statistics on trips and expenses module.
- New: Can reopen a closed customer order.
- New: Add module externalsite to add a web site/tools inside
menu and a Dolibarr frame.

View File

@@ -48,7 +48,7 @@ class Deplacement extends CommonObject
var $note;
var $note_public;
var $socid;
var $statut=1; // 0=draft, 1=validated
var $statut; // 0=draft, 1=validated
var $fk_project;
/**
@@ -192,7 +192,7 @@ class Deplacement extends CommonObject
*/
function fetch($id)
{
$sql = "SELECT rowid, fk_user, type, km, fk_soc, dated, note, note_public, fk_projet";
$sql = "SELECT rowid, fk_user, type, fk_statut, km, fk_soc, dated, note, note_public, fk_projet";
$sql.= " FROM ".MAIN_DB_PREFIX."deplacement";
$sql.= " WHERE rowid = ".$id;
@@ -209,6 +209,7 @@ class Deplacement extends CommonObject
$this->socid = $obj->fk_soc;
$this->km = $obj->km;
$this->type = $obj->type;
$this->fk_statut = $obj->fk_statut;
$this->note = $obj->note;
$this->note_public = $obj->note_public;
$this->fk_project = $obj->fk_projet;

View File

@@ -23,7 +23,9 @@
* \brief Page to show a trip card
* \version $Id$
*/
require("../../main.inc.php");
require_once(DOL_DOCUMENT_ROOT."/compta/deplacement/deplacement.class.php");
require_once(DOL_DOCUMENT_ROOT."/html.formfile.class.php");
if ($conf->projet->enabled)
{

View File

@@ -0,0 +1,154 @@
<?php
/* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (c) 2005-2008 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2009 Regis Houssin <regis@dolibarr.fr>
*
* 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 2 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, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
/**
* \file htdocs/compta/deplacement/stats/deplacementstats.class.php
* \ingroup factures
* \brief Fichier de la classe de gestion des stats des deplacement et notes de frais
* \version $Id$
*/
include_once DOL_DOCUMENT_ROOT . "/stats.class.php";
include_once DOL_DOCUMENT_ROOT . "/compta/deplacement/deplacement.class.php";
/**
* \class DeplacementStats
* \brief Classe permettant la gestion des stats des deplacements et notes de frais
*/
class DeplacementStats extends Stats
{
var $db ;
var $socid;
var $where;
var $table_element;
var $field;
/**
* Constructor
*
* @param $DB Database handler
* @param $socid Id third party
* @return FactureStats
*/
function DeplacementStats($DB, $socid=0)
{
global $conf;
$this->db = $DB;
$object=new Deplacement($this->db);
$this->from = MAIN_DB_PREFIX.$object->table_element;
$this->field='km';
$this->socid = $socid;
$this->where = " fk_statut > 0";
$this->where.= " AND entity = ".$conf->entity;
if ($this->socid)
{
$this->where.=" AND fk_soc = ".$this->socid;
}
}
/**
* \brief Renvoie le nombre de facture par annee
* \return array Array of values
*/
function getNbByYear()
{
$sql = "SELECT YEAR(datef) as dm, count(*)";
$sql.= " FROM ".$this->from;
$sql.= " GROUP BY dm DESC";
$sql.= " WHERE ".$this->where;
return $this->_getNbByYear($sql);
}
/**
* \brief Renvoie le nombre de facture par mois pour une annee donnee
* \param year Year to scan
* \return array Array of values
*/
function getNbByMonth($year)
{
$sql = "SELECT MONTH(dated) as dm, count(*)";
$sql.= " FROM ".$this->from;
$sql.= " WHERE YEAR(dated) = ".$year;
$sql.= " AND ".$this->where;
$sql.= " GROUP BY dm DESC";
$res=$this->_getNbByMonth($year, $sql);
//var_dump($res);print '<br>';
return $res;
}
/**
* \brief Renvoie le montant de facture par mois pour une annee donnee
* \param year Year to scan
* \return array Array of values
*/
function getAmountByMonth($year)
{
$sql = "SELECT date_format(dated,'%m') as dm, sum(".$this->field.")";
$sql.= " FROM ".$this->from;
$sql.= " WHERE date_format(dated,'%Y') = ".$year;
$sql.= " AND ".$this->where;
$sql.= " GROUP BY dm DESC";
$res=$this->_getAmountByMonth($year, $sql);
//var_dump($res);print '<br>';
return $res;
}
/**
* \brief Return average amount
* \param year Year to scan
* \return array Array of values
*/
function getAverageByMonth($year)
{
$sql = "SELECT date_format(dated,'%m') as dm, avg(".$this->field.")";
$sql.= " FROM ".$this->from;
$sql.= " WHERE date_format(dated,'%Y') = ".$year;
$sql.= " AND ".$this->where;
$sql.= " GROUP BY dm DESC";
return $this->_getAverageByMonth($year, $sql);
}
/**
* \brief Return nb, total and average
* \return array Array of values
*/
function getAllByYear()
{
$sql = "SELECT date_format(dated,'%Y') as year, count(*) as nb, sum(".$this->field.") as total, avg(".$this->field.") as avg";
$sql.= " FROM ".$this->from;
$sql.= " WHERE ".$this->where;
$sql.= " GROUP BY year DESC";
return $this->_getAllByYear($sql);
}
}
?>

View File

@@ -0,0 +1,195 @@
<?php
/* Copyright (C) 2003-2006 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (c) 2004-2010 Laurent Destailleur <eldy@users.sourceforge.net>
*
* 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 2 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, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
/**
* \file htdocs/compta/deplacement/stats/index.php
* \ingroup deplacement
* \brief Page des stats deplacement et notes de frais
* \version $Id$
*/
require("../../../main.inc.php");
require_once(DOL_DOCUMENT_ROOT."/core/dolgraph.class.php");
require_once(DOL_DOCUMENT_ROOT."/compta/deplacement/stats/deplacementstats.class.php");
$langs->load("trips");
$WIDTH=500;
$HEIGHT=200;
// Securite acces client
if ($user->societe_id > 0)
{
$action = '';
$socid = $user->societe_id;
}
$year = strftime("%Y", time());
$startyear=$year-2;
$endyear=$year;
$mode='customer';
if (isset($_GET["mode"])) $mode=$_GET["mode"];
/*
* View
*/
llxHeader();
$title=$langs->trans("TripsAndExpensesStatistics");
$dir=$conf->deplacement->dir_temp;
print_fiche_titre($title, $mesg);
create_exdir($dir);
$stats = new DeplacementStats($db, $socid);
// Build graphic number of object
// $data = array(array('Lib',val1,val2,val3),...)
$data = $stats->getNbByMonthWithPrevYear($endyear,$startyear);
//var_dump($data);
$filenamenb = $dir."/tripsexpensesnbinyear-".$year.".png";
$fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=tripsexpensesstats&amp;file=tripsexpensesnbinyear-'.$year.'.png';
$px = new DolGraph();
$mesg = $px->isGraphKo();
if (! $mesg)
{
$px->SetData($data);
$px->SetPrecisionY(0);
$i=$startyear;
while ($i <= $endyear)
{
$legend[]=$i;
$i++;
}
$px->SetLegend($legend);
$px->SetMaxValue($px->GetCeilMaxValue());
$px->SetWidth($WIDTH);
$px->SetHeight($HEIGHT);
$px->SetYLabel($langs->trans("Number"));
$px->SetShading(3);
$px->SetHorizTickIncrement(1);
$px->SetPrecisionY(0);
$px->mode='depth';
$px->SetTitle($langs->trans("NumberByMonth"));
$px->draw($filenamenb);
}
// Build graphic amount of object
$data = $stats->getAmountByMonthWithPrevYear($endyear,$startyear);
//var_dump($data);
// $data = array(array('Lib',val1,val2,val3),...)
$filenameamount = $dir."/tripsexpensesamountinyear-".$year.".png";
$fileurlamount = DOL_URL_ROOT.'/viewimage.php?modulepart=tripsexpensesstats&amp;file=tripsexpensesamountinyear-'.$year.'.png';
$px = new DolGraph();
$mesg = $px->isGraphKo();
if (! $mesg)
{
$px->SetData($data);
$i=$startyear;
while ($i <= $endyear)
{
$legend[]=$i;
$i++;
}
$px->SetLegend($legend);
$px->SetMaxValue($px->GetCeilMaxValue());
$px->SetMinValue(min(0,$px->GetFloorMinValue()));
$px->SetWidth($WIDTH);
$px->SetHeight($HEIGHT);
$px->SetYLabel($langs->trans("Amount"));
$px->SetShading(3);
$px->SetHorizTickIncrement(1);
$px->SetPrecisionY(0);
$px->mode='depth';
$px->SetTitle($langs->trans("AmountTotal"));
$px->draw($filenameamount);
}
print '<table class="notopnoleftnopadd" width="100%"><tr>';
print '<td align="center" valign="top">';
// Show array
$data = $stats->getAllByYear();
print '<table class="border" width="100%">';
print '<tr height="24">';
print '<td align="center">'.$langs->trans("Year").'</td>';
print '<td align="center">'.$langs->trans("Number").'</td>';
print '<td align="center">'.$langs->trans("AmountTotal").'</td>';
print '<td align="center">'.$langs->trans("AmountAverage").'</td>';
print '</tr>';
$oldyear=0;
foreach ($data as $val)
{
$year = $val['year'];
while ($year && $oldyear > $year+1)
{ // If we have empty year
$oldyear--;
print '<tr height="24">';
print '<td align="center"><a href="month.php?year='.$oldyear.'&amp;mode='.$mode.'">'.$oldyear.'</a></td>';
print '<td align="right">0</td>';
print '<td align="right">0</td>';
print '<td align="right">0</td>';
print '</tr>';
}
print '<tr height="24">';
print '<td align="center"><a href="month.php?year='.$year.'&amp;mode='.$mode.'">'.$year.'</a></td>';
print '<td align="right">'.$val['nb'].'</td>';
print '<td align="right">'.price(price2num($val['total'],'MT'),1).'</td>';
print '<td align="right">'.price(price2num($val['avg'],'MT'),1).'</td>';
print '</tr>';
$oldyear=$year;
}
print '</table>';
$db->close();
print '</td>';
print '<td align="center" valign="top">';
// Show graphs
print '<table class="border" width="100%"><tr valign="top"><td align="center">';
if ($mesg) { print $mesg; }
else {
print '<img src="'.$fileurlnb.'" title="'.$langs->trans("Number").'" alt="'.$langs->trans("Number").'">';
print "<br>\n";
print '<img src="'.$fileurlamount.'" title="'.$langs->trans("Amount").'" alt="'.$langs->trans("Amount").'">';
}
print '</td></tr></table>';
print '</td></tr></table>';
llxFooter('$Date$ - $Revision$');
?>

View File

@@ -0,0 +1,162 @@
<?php
/* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (c) 2004-2010 Laurent Destailleur <eldy@users.sourceforge.net>
*
* 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 2 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, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
/**
* \file htdocs/compta/deplacement/stats/month.php
* \ingroup facture
* \brief Page des stats notes de frais par mois
* \version $Id$
*/
require("../../../main.inc.php");
require_once(DOL_DOCUMENT_ROOT."/core/dolgraph.class.php");
require_once(DOL_DOCUMENT_ROOT."/compta/deplacement/stats/deplacementstats.class.php");
$langs->load("trips");
$GRAPHWIDTH=500;
$GRAPHHEIGHT=200;
// Check security access
if ($user->societe_id > 0)
{
$action = '';
$socid = $user->societe_id;
}
$year = isset($_GET["year"])?$_GET["year"]:date("Y",time());
$mode='customer';
if (isset($_GET["mode"])) $mode=$_GET["mode"];
/*
* View
*/
llxHeader();
$title=$langs->trans("TripsAndExpensesStatistics");
$dir=$conf->deplacement->dir_temp;
$mesg = '<a href="month.php?year='.($year - 1).'&amp;mode='.$mode.'">'.img_previous().'</a> ';
$mesg.= $langs->trans("Year")." $year";
$mesg.= ' <a href="month.php?year='.($year + 1).'&amp;mode='.$mode.'">'.img_next().'</a>';
print_fiche_titre($title, $mesg);
create_exdir($dir);
$stats = new DeplacementStats($db, $socid);
$data = $stats->getNbByMonth($year);
$filename = $dir."/tripsexpensesnb-".$year.".png";
$fileurl = DOL_URL_ROOT.'/viewimage.php?modulepart=tripsexpensesstats&file=tripsexpensesnb-'.$year.'.png';
$px = new DolGraph();
$mesg = $px->isGraphKo();
if (! $mesg)
{
$px->SetData($data);
$px->SetMaxValue($px->GetCeilMaxValue());
$px->SetMinValue($px->GetFloorMinValue());
$px->SetWidth($GRAPHWIDTH);
$px->SetHeight($GRAPHHEIGHT);
$px->SetShading(3);
$px->SetHorizTickIncrement(1);
$px->SetPrecisionY(0);
$px->draw($filename);
}
$data = $stats->getAmountByMonth($year);
$filename_amount = $dir."/tripsexpensesamount-".$year.".png";
$fileurl_amount = DOL_URL_ROOT.'/viewimage.php?modulepart=tripsexpensesstats&file=tripsexpensesamount-'.$year.'.png';
$px = new DolGraph();
$mesg = $px->isGraphKo();
if (! $mesg)
{
$px->SetData($data);
$px->SetYLabel($langs->trans("AmountTotal"));
$px->SetMaxValue($px->GetCeilMaxValue());
$px->SetMinValue($px->GetFloorMinValue());
$px->SetWidth($GRAPHWIDTH);
$px->SetHeight($GRAPHHEIGHT);
$px->SetShading(3);
$px->SetHorizTickIncrement(1);
$px->SetPrecisionY(0);
$px->draw($filename_amount);
}
$res = $stats->getAverageByMonth($year);
$data = array();
for ($i = 1 ; $i < 13 ; $i++)
{
$data[$i-1] = array(ucfirst(substr(dol_print_date(dol_mktime(12,0,0,$i,1,$year),"%b"),0,3)), $res[$i]);
}
$filename_avg = $dir."/tripsexpensesaverage-".$year.".png";
$fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=tripsexpensesstats&file=tripsexpensesaverage-'.$year.'.png';
$px = new DolGraph();
$mesg = $px->isGraphKo();
if (! $mesg)
{
$px->SetData($data);
$px->SetYLabel($langs->trans("AmountAverage"));
$px->SetMaxValue($px->GetCeilMaxValue());
$px->SetMinValue($px->GetFloorMinValue());
$px->SetWidth($GRAPHWIDTH);
$px->SetHeight($GRAPHHEIGHT);
$px->SetShading(3);
$px->SetHorizTickIncrement(1);
$px->SetPrecisionY(0);
$px->draw($filename_avg);
}
print '<table class="border" width="100%">';
print '<tr><td align="center">'.$langs->trans("NumberByMonth").'</td>';
print '<td align="center">';
if ($mesg) { print $mesg; }
else { print '<img src="'.$fileurl.'">'; }
print '</td></tr>';
print '<tr><td align="center">'.$langs->trans("AmountTotal").'</td>';
print '<td align="center">';
if ($mesg) { print $mesg; }
else { print '<img src="'.$fileurl_amount.'">'; }
print '</td></tr>';
print '<tr><td align="center">'.$langs->trans("AmountAverage").'</td>';
print '<td align="center">';
if ($mesg) { print $mesg; }
else { print '<img src="'.$fileurl_avg.'">'; }
print '</td></tr></table>';
$db->close();
llxFooter('$Date$ - $Revision$');
?>

View File

@@ -452,6 +452,7 @@ function print_left_eldy_menu($db,$menu_array)
$newmenu->add(DOL_URL_ROOT."/compta/deplacement/index.php?leftmenu=tripsandexpenses&amp;mainmenu=accountancy", $langs->trans("TripsAndExpenses"), 0, $user->rights->deplacement->lire);
if ($leftmenu=="tripsandexpenses") $newmenu->add(DOL_URL_ROOT."/compta/deplacement/fiche.php?action=create&amp;leftmenu=tripsandexpenses&amp;mainmenu=accountancy", $langs->trans("New"), 1, $user->rights->deplacement->creer);
if ($leftmenu=="tripsandexpenses") $newmenu->add(DOL_URL_ROOT."/compta/deplacement/index.php?leftmenu=tripsandexpenses&amp;mainmenu=accountancy", $langs->trans("List"), 1, $user->rights->deplacement->lire);
if ($leftmenu=="tripsandexpenses") $newmenu->add(DOL_URL_ROOT."/compta/deplacement/stats/index.php?leftmenu=tripsandexpenses&amp;mainmenu=accountancy", $langs->trans("Statistics"), 1, $user->rights->deplacement->lire);
}
// Taxes and social contributions

View File

@@ -194,3 +194,5 @@ create table llx_element_milestone
ALTER TABLE llx_element_milestone ADD UNIQUE INDEX idx_element_milestone_idx1 (fk_element, elementtype, fk_milestone);
ALTER TABLE llx_element_milestone ADD INDEX idx_element_milestone_fk_milestone (fk_milestone);
ALTER TABLE llx_element_milestone ADD CONSTRAINT fk_element_milestone_fk_milestone FOREIGN KEY (fk_milestone) REFERENCES llx_milestone(rowid);
ALTER TABLE llx_deplacement ADD COLUMN fk_statut INTEGER DEFAULT 1 NOT NULL after type;

View File

@@ -1,6 +1,7 @@
-- ============================================================================
-- Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
-- Copyright (C) 2009 Regis Houssin <regis@dolibarr.fr>
-- Copyright (C) 2010 Laurent Destailleur <eldy@users.sourceforge.net>
--
-- 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
@@ -30,6 +31,7 @@ create table llx_deplacement
fk_user integer NOT NULL,
fk_user_author integer,
type varchar(12) NOT NULL,
fk_statut integer DEFAULT 1 NOT NULL,
km real,
fk_soc integer,
fk_projet integer DEFAULT 0,

View File

@@ -175,6 +175,7 @@ Action=Action
About=About
WelcomeString=<font class="body">We are </font>%s<font class="body">, and you are connected as user</font> %s
Number=Number
NumberByMonth=Number by month
Numero=Numero
Limit=Limit
Limits=Limits

View File

@@ -3,6 +3,7 @@ CHARSET=UTF-8
Trip=Trip
Trips=Trips
TripsAndExpenses=Trips and expenses
TripsAndExpensesStatistics=Trips and expenses statistics
TripCard=Trip card
AddTrip=Add trip
ListOfTrips=List of trips

View File

@@ -174,6 +174,7 @@ DefaultModel=Modèle par défaut
About=À propos
WelcomeString=<font class="body">Nous sommes le</font> %s<font class="body">, et vous êtes connecté(e) en tant que </font> %s
Number=Nombre
NumberByMonth=Nombre par mois
Numero=Numéro
Limit=Limite
Limits=Limites

View File

@@ -3,6 +3,7 @@ CHARSET=UTF-8
Trip=Déplacement
Trips=Déplacements
TripsAndExpenses=Note de frais
TripsAndExpensesStatistics=Statistiques notes de frais
TripId=Id note frais
TripCard=Fiche frais
AddTrip=Ajouter frais

View File

@@ -37,9 +37,6 @@ if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL',1);
if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU',1);
if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML',1);
// This is to make Dolibarr working with Plesk
set_include_path($_SERVER['DOCUMENT_ROOT'].'/htdocs');
require_once("../main.inc.php");
//var_dump($langs);

View File

@@ -1788,7 +1788,13 @@ function restrictedArea($user, $features='societe', $objectid=0, $dbtablename=''
*/
function accessforbidden($message='',$printheader=1,$printfooter=1,$showonlymessage=0)
{
global $user, $langs;
global $conf, $db, $user, $langs;
if (! is_object($langs))
{
include_once(DOL_DOCUMENT_ROOT.'/translate.class.php');
$langs=new Translate('',$conf);
}
$langs->load("other");
if ($printheader)

View File

@@ -26,24 +26,29 @@
* \version $Id$
*/
define('NOTOKENRENEWAL',1); // Disables token renewal
// Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP).
$action = isset($_GET["action"])?$_GET["action"]:'';
$original_file = isset($_GET["file"])?$_GET["file"]:'';
$modulepart = isset($_GET["modulepart"])?$_GET["modulepart"]:'';
$urlsource = isset($_GET["urlsource"])?$_GET["urlsource"]:'';
// Pour autre que companylogo, on charge environnement + info issus de logon comme le user
if (($modulepart == 'companylogo') && ! defined("NOLOGIN")) define("NOLOGIN",1);
//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1'); // Not disabled cause need to load personalized language
//if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); // Not disabled cause need to load personalized language
if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1');
if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1');
if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK','1');
if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1');
if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1');
if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1');
if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1');
if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAXL','1');
// Pour autre que companylogo, on charge environnement + info issus de logon comme le user
if (($modulepart == 'companylogo') && ! defined("NOLOGIN")) define("NOLOGIN",'1');
// C'est un wrapper, donc header vierge
function llxHeader() { }
require("./main.inc.php");
require_once(DOL_DOCUMENT_ROOT.'/lib/files.lib.php');
@@ -84,7 +89,6 @@ if ($modulepart)
// Wrapping pour les apercu factures
elseif ($modulepart == 'apercufacture')
{
$user->getrights('facture');
if ($user->rights->facture->lire)
{
$accessallowed=1;
@@ -95,7 +99,6 @@ if ($modulepart)
// Wrapping pour les apercu propal
elseif ($modulepart == 'apercupropal')
{
$user->getrights('propale');
if ($user->rights->propale->lire)
{
$accessallowed=1;
@@ -106,7 +109,6 @@ if ($modulepart)
// Wrapping pour les apercu commande
elseif ($modulepart == 'apercucommande')
{
$user->getrights('commande');
if ($user->rights->commande->lire)
{
$accessallowed=1;
@@ -117,7 +119,6 @@ if ($modulepart)
// Wrapping pour les apercu intervention
elseif ($modulepart == 'apercufichinter')
{
$user->getrights('ficheinter');
if ($user->rights->ficheinter->lire)
{
$accessallowed=1;
@@ -128,7 +129,6 @@ if ($modulepart)
// Wrapping pour les images des stats propales
elseif ($modulepart == 'propalstats')
{
$user->getrights('propale');
if ($user->rights->propale->lire)
{
$accessallowed=1;
@@ -139,7 +139,6 @@ if ($modulepart)
// Wrapping pour les images des stats commandes
elseif ($modulepart == 'orderstats')
{
$user->getrights('commande');
if ($user->rights->commande->lire)
{
$accessallowed=1;
@@ -148,7 +147,6 @@ if ($modulepart)
}
elseif ($modulepart == 'orderstatssupplier')
{
$user->getrights('fournisseur');
if ($user->rights->fournisseur->commande->lire)
{
$accessallowed=1;
@@ -159,7 +157,6 @@ if ($modulepart)
// Wrapping pour les images des stats factures
elseif ($modulepart == 'billstats')
{
$user->getrights('facture');
if ($user->rights->facture->lire)
{
$accessallowed=1;
@@ -168,7 +165,6 @@ if ($modulepart)
}
elseif ($modulepart == 'billstatssupplier')
{
$user->getrights('fourn');
if ($user->rights->fournisseur->facture->lire)
{
$accessallowed=1;
@@ -179,7 +175,6 @@ if ($modulepart)
// Wrapping pour les images des stats expeditions
elseif ($modulepart == 'expeditionstats')
{
$user->getrights('expedition');
if ($user->rights->expedition->lire)
{
$accessallowed=1;
@@ -187,10 +182,19 @@ if ($modulepart)
$original_file=$conf->expedition->dir_temp.'/'.$original_file;
}
// Wrapping pour les images des stats expeditions
elseif ($modulepart == 'tripsexpensesstats')
{
if ($user->rights->deplacement->lire)
{
$accessallowed=1;
}
$original_file=$conf->deplacement->dir_temp.'/'.$original_file;
}
// Wrapping pour les images des stats produits
elseif (preg_match('/^productstats_/i',$modulepart))
{
$user->getrights('produit');
if ($user->rights->produit->lire || $user->rights->service->lire)
{
$accessallowed=1;
@@ -201,7 +205,6 @@ if ($modulepart)
// Wrapping for products or services
elseif ($modulepart == 'product')
{
$user->getrights('produit');
if ($user->rights->produit->lire || $user->rights->service->lire)
{
$accessallowed=1;
@@ -212,7 +215,6 @@ if ($modulepart)
// Wrapping for categories
elseif ($modulepart == 'category')
{
$user->getrights('categorie');
if ($user->rights->categorie->lire)
{
$accessallowed=1;
@@ -223,7 +225,6 @@ if ($modulepart)
// Wrapping pour les prelevements
elseif ($modulepart == 'prelevement')
{
$user->getrights('prelevement');
if ($user->rights->prelevement->bons->lire) $accessallowed=1;
$original_file=$conf->prelevement->dir_output.'/receipts/'.$original_file;