From 2dd4f080f0818d255cf4547d68df83d39d89f4ec Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 5 Apr 2010 01:01:28 +0000 Subject: [PATCH] New: Add statistics page for trips and expenses module --- ChangeLog | 1 + .../compta/deplacement/deplacement.class.php | 5 +- htdocs/compta/deplacement/fiche.php | 2 + .../stats/deplacementstats.class.php | 154 ++++++++++++++ htdocs/compta/deplacement/stats/index.php | 195 ++++++++++++++++++ htdocs/compta/deplacement/stats/month.php | 162 +++++++++++++++ htdocs/includes/menus/barre_left/eldy.lib.php | 1 + .../install/mysql/migration/2.8.0-2.9.0.sql | 4 +- .../install/mysql/tables/llx_deplacement.sql | 2 + htdocs/langs/en_US/main.lang | 1 + htdocs/langs/en_US/trips.lang | 1 + htdocs/langs/fr_FR/main.lang | 1 + htdocs/langs/fr_FR/trips.lang | 1 + htdocs/lib/datepicker.php | 3 - htdocs/lib/functions.lib.php | 8 +- htdocs/viewimage.php | 41 ++-- 16 files changed, 555 insertions(+), 27 deletions(-) create mode 100755 htdocs/compta/deplacement/stats/deplacementstats.class.php create mode 100755 htdocs/compta/deplacement/stats/index.php create mode 100755 htdocs/compta/deplacement/stats/month.php diff --git a/ChangeLog b/ChangeLog index 65cae46c29b..8f228b965ce 100644 --- a/ChangeLog +++ b/ChangeLog @@ -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. diff --git a/htdocs/compta/deplacement/deplacement.class.php b/htdocs/compta/deplacement/deplacement.class.php index bf016d8861f..53eb531f37a 100644 --- a/htdocs/compta/deplacement/deplacement.class.php +++ b/htdocs/compta/deplacement/deplacement.class.php @@ -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; diff --git a/htdocs/compta/deplacement/fiche.php b/htdocs/compta/deplacement/fiche.php index 8e1f7727deb..3d0e4914606 100644 --- a/htdocs/compta/deplacement/fiche.php +++ b/htdocs/compta/deplacement/fiche.php @@ -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) { diff --git a/htdocs/compta/deplacement/stats/deplacementstats.class.php b/htdocs/compta/deplacement/stats/deplacementstats.class.php new file mode 100755 index 00000000000..522ce737aa3 --- /dev/null +++ b/htdocs/compta/deplacement/stats/deplacementstats.class.php @@ -0,0 +1,154 @@ + + * Copyright (c) 2005-2008 Laurent Destailleur + * Copyright (C) 2005-2009 Regis Houssin + * + * 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 '
'; + 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 '
'; + 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); + } +} + +?> diff --git a/htdocs/compta/deplacement/stats/index.php b/htdocs/compta/deplacement/stats/index.php new file mode 100755 index 00000000000..9d758e16e19 --- /dev/null +++ b/htdocs/compta/deplacement/stats/index.php @@ -0,0 +1,195 @@ + + * Copyright (c) 2004-2010 Laurent Destailleur + * + * 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&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&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 ''; +print ''; +print '
'; + +// Show array +$data = $stats->getAllByYear(); + +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; + +$oldyear=0; +foreach ($data as $val) +{ + $year = $val['year']; + while ($year && $oldyear > $year+1) + { // If we have empty year + $oldyear--; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + } + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + $oldyear=$year; +} + +print '
'.$langs->trans("Year").''.$langs->trans("Number").''.$langs->trans("AmountTotal").''.$langs->trans("AmountAverage").'
'.$oldyear.'000
'.$year.''.$val['nb'].''.price(price2num($val['total'],'MT'),1).''.price(price2num($val['avg'],'MT'),1).'
'; + + +$db->close(); + +print '
'; + +// Show graphs +print '
'; +if ($mesg) { print $mesg; } +else { + print ''.$langs->trans('; + print "
\n"; + print ''.$langs->trans('; +} +print '
'; + +print '
'; + +llxFooter('$Date$ - $Revision$'); +?> diff --git a/htdocs/compta/deplacement/stats/month.php b/htdocs/compta/deplacement/stats/month.php new file mode 100755 index 00000000000..3eb63f00b83 --- /dev/null +++ b/htdocs/compta/deplacement/stats/month.php @@ -0,0 +1,162 @@ + + * Copyright (c) 2004-2010 Laurent Destailleur + * + * 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 = ''.img_previous().' '; +$mesg.= $langs->trans("Year")." $year"; +$mesg.= ' '.img_next().''; +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 ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print '
'.$langs->trans("NumberByMonth").''; +if ($mesg) { print $mesg; } +else { print ''; } +print '
'.$langs->trans("AmountTotal").''; +if ($mesg) { print $mesg; } +else { print ''; } +print '
'.$langs->trans("AmountAverage").''; +if ($mesg) { print $mesg; } +else { print ''; } +print '
'; + +$db->close(); + +llxFooter('$Date$ - $Revision$'); +?> diff --git a/htdocs/includes/menus/barre_left/eldy.lib.php b/htdocs/includes/menus/barre_left/eldy.lib.php index af2934c34b8..a7e96f879a4 100644 --- a/htdocs/includes/menus/barre_left/eldy.lib.php +++ b/htdocs/includes/menus/barre_left/eldy.lib.php @@ -452,6 +452,7 @@ function print_left_eldy_menu($db,$menu_array) $newmenu->add(DOL_URL_ROOT."/compta/deplacement/index.php?leftmenu=tripsandexpenses&mainmenu=accountancy", $langs->trans("TripsAndExpenses"), 0, $user->rights->deplacement->lire); if ($leftmenu=="tripsandexpenses") $newmenu->add(DOL_URL_ROOT."/compta/deplacement/fiche.php?action=create&leftmenu=tripsandexpenses&mainmenu=accountancy", $langs->trans("New"), 1, $user->rights->deplacement->creer); if ($leftmenu=="tripsandexpenses") $newmenu->add(DOL_URL_ROOT."/compta/deplacement/index.php?leftmenu=tripsandexpenses&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&mainmenu=accountancy", $langs->trans("Statistics"), 1, $user->rights->deplacement->lire); } // Taxes and social contributions diff --git a/htdocs/install/mysql/migration/2.8.0-2.9.0.sql b/htdocs/install/mysql/migration/2.8.0-2.9.0.sql index a5f9a0c556e..44c3ed1adbe 100755 --- a/htdocs/install/mysql/migration/2.8.0-2.9.0.sql +++ b/htdocs/install/mysql/migration/2.8.0-2.9.0.sql @@ -193,4 +193,6 @@ 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); \ No newline at end of file +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; diff --git a/htdocs/install/mysql/tables/llx_deplacement.sql b/htdocs/install/mysql/tables/llx_deplacement.sql index 96ca54bb44d..62aac07ef8f 100644 --- a/htdocs/install/mysql/tables/llx_deplacement.sql +++ b/htdocs/install/mysql/tables/llx_deplacement.sql @@ -1,6 +1,7 @@ -- ============================================================================ -- Copyright (C) 2003 Rodolphe Quiedeville -- Copyright (C) 2009 Regis Houssin +-- Copyright (C) 2010 Laurent Destailleur -- -- 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, diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index 572ba7e39e2..c31588d68d8 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -175,6 +175,7 @@ Action=Action About=About WelcomeString=We are %s, and you are connected as user %s Number=Number +NumberByMonth=Number by month Numero=Numero Limit=Limit Limits=Limits diff --git a/htdocs/langs/en_US/trips.lang b/htdocs/langs/en_US/trips.lang index 03a12f37a8d..1fc8e41ad3f 100644 --- a/htdocs/langs/en_US/trips.lang +++ b/htdocs/langs/en_US/trips.lang @@ -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 diff --git a/htdocs/langs/fr_FR/main.lang b/htdocs/langs/fr_FR/main.lang index 5ad1e2deedf..2bbb3fd9a59 100644 --- a/htdocs/langs/fr_FR/main.lang +++ b/htdocs/langs/fr_FR/main.lang @@ -174,6 +174,7 @@ DefaultModel=Modèle par défaut About=À propos WelcomeString=Nous sommes le %s, et vous êtes connecté(e) en tant que %s Number=Nombre +NumberByMonth=Nombre par mois Numero=Numéro Limit=Limite Limits=Limites diff --git a/htdocs/langs/fr_FR/trips.lang b/htdocs/langs/fr_FR/trips.lang index 3468b7d6e13..6d4a054197f 100644 --- a/htdocs/langs/fr_FR/trips.lang +++ b/htdocs/langs/fr_FR/trips.lang @@ -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 diff --git a/htdocs/lib/datepicker.php b/htdocs/lib/datepicker.php index d416192988b..d51ab75028d 100644 --- a/htdocs/lib/datepicker.php +++ b/htdocs/lib/datepicker.php @@ -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); diff --git a/htdocs/lib/functions.lib.php b/htdocs/lib/functions.lib.php index 0d309e0ab3a..3cd78eeaece 100644 --- a/htdocs/lib/functions.lib.php +++ b/htdocs/lib/functions.lib.php @@ -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) diff --git a/htdocs/viewimage.php b/htdocs/viewimage.php index 1beabbf55a5..8a86906cdc3 100644 --- a/htdocs/viewimage.php +++ b/htdocs/viewimage.php @@ -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"]:''; +//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('NOREQUIREAJAXL','1'); // Pour autre que companylogo, on charge environnement + info issus de logon comme le user -if (($modulepart == 'companylogo') && ! defined("NOLOGIN")) define("NOLOGIN",1); +if (($modulepart == 'companylogo') && ! defined("NOLOGIN")) define("NOLOGIN",'1'); -if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); -if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); -if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','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;