28require
'../../main.inc.php';
29require_once DOL_DOCUMENT_ROOT.
'/core/class/dolgraph.class.php';
30require_once DOL_DOCUMENT_ROOT.
'/expensereport/class/expensereportstats.class.php';
33$langs->loadLangs(array(
'trips',
'companies'));
38$mode = GETPOSTISSET(
"mode") ?
GETPOST(
"mode",
'aZ09') :
'customer';
39$object_status =
GETPOST(
'object_status',
'intcomma');
48if ($user->socid > 0) {
50 $socid = $user->socid;
53 $socid = $user->socid;
71$title = $langs->trans(
"TripsAndExpensesStatistics");
72$dir = $conf->expensereport->dir_temp;
81if ($object_status !=
'' && $object_status >= -1) {
82 $stats->where .=
' AND e.fk_statut IN ('.$db->sanitize($db->escape($object_status)).
')';
88$data = $stats->getNbByMonthWithPrevYear($endyear, $startyear);
91$filenamenb = $dir.
"/tripsexpensesnbinyear-".$year.
".png";
92$fileurlnb = DOL_URL_ROOT.
'/viewimage.php?modulepart=tripsexpensesstats&file=tripsexpensesnbinyear-'.$year.
'.png';
95$mesg = $px1->isGraphKo();
100 while ($i <= $endyear) {
104 $px1->SetLegend($legend);
105 $px1->SetMaxValue($px1->GetCeilMaxValue());
106 $px1->SetWidth($WIDTH);
107 $px1->SetHeight($HEIGHT);
108 $px1->SetYLabel($langs->trans(
"Number"));
110 $px1->SetHorizTickIncrement(1);
111 $px1->mode =
'depth';
112 $px1->SetTitle($langs->trans(
"NumberByMonth"));
114 $px1->draw($filenamenb, $fileurlnb);
118$data = $stats->getAmountByMonthWithPrevYear($endyear, $startyear);
122$filenameamount = $dir.
"/tripsexpensesamountinyear-".$year.
".png";
123$fileurlamount = DOL_URL_ROOT.
'/viewimage.php?modulepart=tripsexpensesstats&file=tripsexpensesamountinyear-'.$year.
'.png';
126$mesg = $px2->isGraphKo();
128 $px2->SetData($data);
131 while ($i <= $endyear) {
135 $px2->SetLegend($legend);
136 $px2->SetMaxValue($px2->GetCeilMaxValue());
137 $px2->SetMinValue(min(0, $px2->GetFloorMinValue()));
138 $px2->SetWidth($WIDTH);
139 $px2->SetHeight($HEIGHT);
140 $px2->SetYLabel($langs->trans(
"Amount"));
142 $px2->SetHorizTickIncrement(1);
143 $px2->mode =
'depth';
144 $px2->SetTitle($langs->trans(
"AmountTotal"));
146 $px2->draw($filenameamount, $fileurlamount);
150$data = $stats->getAverageByMonthWithPrevYear($endyear, $startyear);
152if (!$user->hasRight(
'societe',
'client',
'voir')) {
153 $filename_avg = $dir.
'/ordersaverage-'.$user->id.
'-'.$year.
'.png';
154 if ($mode ==
'customer') {
155 $fileurl_avg = DOL_URL_ROOT.
'/viewimage.php?modulepart=orderstats&file=ordersaverage-'.$user->id.
'-'.$year.
'.png';
157 if ($mode ==
'supplier') {
158 $fileurl_avg = DOL_URL_ROOT.
'/viewimage.php?modulepart=orderstatssupplier&file=ordersaverage-'.$user->id.
'-'.$year.
'.png';
161 $filename_avg = $dir.
'/ordersaverage-'.$year.
'.png';
162 if ($mode ==
'customer') {
163 $fileurl_avg = DOL_URL_ROOT.
'/viewimage.php?modulepart=orderstats&file=ordersaverage-'.$year.
'.png';
165 if ($mode ==
'supplier') {
166 $fileurl_avg = DOL_URL_ROOT.
'/viewimage.php?modulepart=orderstatssupplier&file=ordersaverage-'.$year.
'.png';
171$mesg = $px3->isGraphKo();
173 $px3->SetData($data);
176 while ($i <= $endyear) {
180 $px3->SetLegend($legend);
181 $px3->SetYLabel($langs->trans(
"AmountAverage"));
182 $px3->SetMaxValue($px3->GetCeilMaxValue());
183 $px3->SetMinValue($px3->GetFloorMinValue());
184 $px3->SetWidth($WIDTH);
185 $px3->SetHeight($HEIGHT);
187 $px3->SetHorizTickIncrement(1);
188 $px3->mode =
'depth';
189 $px3->SetTitle($langs->trans(
"AmountAverage"));
191 $px3->draw($filename_avg, $fileurl_avg);
196$data = $stats->getAllByYear();
197$arrayyears = array();
198foreach ($data as $val) {
199 $arrayyears[$val[
'year']] = $val[
'year'];
201if (!count($arrayyears)) {
202 $arrayyears[$nowyear] = $nowyear;
208$head[$h][0] = DOL_URL_ROOT.
'/expensereport/stats/index.php';
209$head[$h][1] = $langs->trans(
"ByMonthYear");
210$head[$h][2] =
'byyear';
218print
'<div class="fichecenter"><div class="fichethirdleft">';
222print
'<form name="stats" method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
223print
'<input type="hidden" name="token" value="'.newToken().
'">';
224print
'<input type="hidden" name="mode" value="'.$mode.
'">';
226print
'<table class="noborder centpercent">';
227print
'<tr class="liste_titre"><td class="liste_titre" colspan="2">'.$langs->trans(
"Filter").
'</td></tr>';
235print
'<tr><td>'.$langs->trans(
"User").
'</td><td>';
237if (!$user->hasRight(
'expensereport',
'readall') && !$user->hasRight(
'expensereport',
'lire_tous')) {
238 $include =
'hierarchy';
240print
img_picto(
'',
'user',
'class="pictofixedwidth"');
241print $form->select_dolusers($userid,
'userid', 1,
'', 0, $include,
'', 0, 0, 0,
'', 0,
'',
'widthcentpercentminusx maxwidth300');
244print
'<tr><td class="left">'.$langs->trans(
"Status").
'</td><td class="left">';
245$liststatus = $tmpexpensereport->labelStatus;
246print $form->selectarray(
'object_status', $liststatus,
GETPOST(
'object_status',
'intcomma'), -4, 0, 0,
'', 1);
250print $form->textwithpicto($langs->trans(
"Year"), $langs->trans(
"DateValidation"));
252if (!in_array($year, $arrayyears)) {
253 $arrayyears[$year] = $year;
256print $form->selectarray(
'year', $arrayyears, $year, 0, 0, 0,
'', 0, 0, 0,
'',
'width75');
258print
'<tr><td class="center" colspan="2"><input type="submit" name="submit" class="button small" value="'.$langs->trans(
"Refresh").
'"></td></tr>';
263print
'<div class="div-table-responsive-no-min">';
264print
'<table class="noborder centpercent">';
265print
'<tr class="liste_titre" height="24">';
266print
'<td class="center">'.$langs->trans(
"Year").
'</td>';
267print
'<td class="right">'.$langs->trans(
"Number").
'</td>';
268print
'<td class="right">'.$langs->trans(
"AmountTotal").
'</td>';
269print
'<td class="right">'.$langs->trans(
"AmountAverage").
'</td>';
273foreach ($data as $val) {
274 $year = $val[
'year'];
275 while ($year && $oldyear > $year + 1) {
278 print
'<tr class="oddeven" height="24">';
279 print
'<td class="center"><a href="'.$_SERVER[
"PHP_SELF"].
'?year='.$oldyear.
'&mode='.$mode.
'">'.$oldyear.
'</a></td>';
280 print
'<td class="right">0</td>';
281 print
'<td class="right amount nowraponall">0</td>';
282 print
'<td class="right amount nowraponall">0</td>';
287 print
'<tr class="oddeven" height="24">';
288 print
'<td class="center"><a href="'.$_SERVER[
"PHP_SELF"].
'?year='.$year.
'&mode='.$mode.
'">'.$year.
'</a></td>';
289 print
'<td class="right">'.$val[
'nb'].
'</td>';
290 print
'<td class="right amount nowraponall">'.price(
price2num($val[
'total'],
'MT'), 1).
'</td>';
291 print
'<td class="right amount nowraponall">'.price(
price2num($val[
'avg'],
'MT'), 1).
'</td>';
299print
'</div><div class="fichetwothirdright">';
303print
'<table class="border centpercent"><tr class="pair nohover"><td class="center">';
313print
'</td></tr></table>';
317print
'<div class="clearboth"></div>';
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
Empty header.
static getDefaultGraphSizeForStats($direction, $defaultsize='')
getDefaultGraphSizeForStats
Class to manage Trips and Expenses.
Class to manage the statistics of the expensereports and expense notes.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0)
Show tabs of a record.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
dol_now($mode='auto')
Return date for now.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
complete_head_from_modules($conf, $langs, $object, &$head, &$h, $type, $mode='add', $filterorigmodule='')
Complete or removed entries into a head array (used to build tabs).
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
dol_mkdir($dir, $dataroot='', $newmask='')
Creation of a directory (this can create recursive subdir)
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.