29require
'../../main.inc.php';
30require_once DOL_DOCUMENT_ROOT.
'/core/class/dolgraph.class.php';
31require_once DOL_DOCUMENT_ROOT.
'/expensereport/class/expensereportstats.class.php';
42$langs->loadLangs(array(
'trips',
'companies'));
47$hookmanager->initHooks(array(
'expensereportstats',
'globalcard'));
49$mode = GETPOSTISSET(
"mode") ?
GETPOST(
"mode",
'aZ09') :
'customer';
50$object_status =
GETPOST(
'object_status',
'intcomma');
60if ($user->socid > 0) {
62 $socid = $user->socid;
65 $socid = $user->socid;
70$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
89$title = $langs->trans(
"TripsAndExpensesStatistics");
90$dir =
$conf->expensereport->dir_temp;
99if ($object_status !=
'' && $object_status >= -1) {
100 $stats->where .=
' AND e.fk_statut IN ('.$db->sanitize($db->escape($object_status)).
')';
106$data = $stats->getNbByMonthWithPrevYear($endyear, $startyear);
109$filenamenb = $dir.
"/tripsexpensesnbinyear-".$year.
".png";
110$fileurlnb = DOL_URL_ROOT.
'/viewimage.php?modulepart=tripsexpensesstats&file=tripsexpensesnbinyear-'.$year.
'.png';
113$mesg = $px1->isGraphKo();
115 $px1->SetData($data);
118 while ($i <= $endyear) {
122 $px1->SetLegend($legend);
123 $px1->SetMaxValue($px1->GetCeilMaxValue());
124 $px1->SetWidth($WIDTH);
125 $px1->SetHeight($HEIGHT);
126 $px1->SetYLabel($langs->trans(
"Number"));
128 $px1->SetHorizTickIncrement(1);
129 $px1->mode =
'depth';
130 $px1->SetTitle($langs->trans(
"NumberByMonth"));
132 $px1->draw($filenamenb, $fileurlnb);
136$data = $stats->getAmountByMonthWithPrevYear($endyear, $startyear);
140$filenameamount = $dir.
"/tripsexpensesamountinyear-".$year.
".png";
141$fileurlamount = DOL_URL_ROOT.
'/viewimage.php?modulepart=tripsexpensesstats&file=tripsexpensesamountinyear-'.$year.
'.png';
144$mesg = $px2->isGraphKo();
146 $px2->SetData($data);
149 while ($i <= $endyear) {
153 $px2->SetLegend($legend);
154 $px2->SetMaxValue($px2->GetCeilMaxValue());
155 $px2->SetMinValue(min(0, $px2->GetFloorMinValue()));
156 $px2->SetWidth($WIDTH);
157 $px2->SetHeight($HEIGHT);
158 $px2->SetYLabel($langs->trans(
"Amount"));
160 $px2->SetHorizTickIncrement(1);
161 $px2->mode =
'depth';
162 $px2->SetTitle($langs->trans(
"AmountTotal"));
164 $px2->draw($filenameamount, $fileurlamount);
168$data = $stats->getAverageByMonthWithPrevYear($endyear, $startyear);
171if (!$user->hasRight(
'societe',
'client',
'voir')) {
172 $filename_avg = $dir.
'/ordersaverage-'.$user->id.
'-'.$year.
'.png';
173 if ($mode ==
'customer') {
174 $fileurl_avg = DOL_URL_ROOT.
'/viewimage.php?modulepart=orderstats&file=ordersaverage-'.$user->id.
'-'.$year.
'.png';
176 if ($mode ==
'supplier') {
177 $fileurl_avg = DOL_URL_ROOT.
'/viewimage.php?modulepart=orderstatssupplier&file=ordersaverage-'.$user->id.
'-'.$year.
'.png';
180 $filename_avg = $dir.
'/ordersaverage-'.$year.
'.png';
181 if ($mode ==
'customer') {
182 $fileurl_avg = DOL_URL_ROOT.
'/viewimage.php?modulepart=orderstats&file=ordersaverage-'.$year.
'.png';
184 if ($mode ==
'supplier') {
185 $fileurl_avg = DOL_URL_ROOT.
'/viewimage.php?modulepart=orderstatssupplier&file=ordersaverage-'.$year.
'.png';
190$mesg = $px3->isGraphKo();
191if (!$mesg && $fileurl_avg !==
null) {
192 $px3->SetData($data);
195 while ($i <= $endyear) {
199 $px3->SetLegend($legend);
200 $px3->SetYLabel($langs->trans(
"AmountAverage"));
201 $px3->SetMaxValue($px3->GetCeilMaxValue());
202 $px3->SetMinValue((
int) $px3->GetFloorMinValue());
203 $px3->SetWidth($WIDTH);
204 $px3->SetHeight($HEIGHT);
206 $px3->SetHorizTickIncrement(1);
207 $px3->mode =
'depth';
208 $px3->SetTitle($langs->trans(
"AmountAverage"));
210 $px3->draw($filename_avg, $fileurl_avg);
215$data = $stats->getAllByYear();
216$arrayyears = array();
217foreach ($data as $val) {
218 $arrayyears[$val[
'year']] = $val[
'year'];
220if (!count($arrayyears)) {
221 $arrayyears[$nowyear] = $nowyear;
227$head[$h][0] = DOL_URL_ROOT.
'/expensereport/stats/index.php';
228$head[$h][1] = $langs->trans(
"ByMonthYear");
229$head[$h][2] =
'byyear';
237print
'<div class="fichecenter"><div class="fichethirdleft">';
241print
'<form name="stats" method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
242print
'<input type="hidden" name="token" value="'.newToken().
'">';
243print
'<input type="hidden" name="mode" value="'.$mode.
'">';
245print
'<table class="noborder centpercent">';
246print
'<tr class="liste_titre"><td class="liste_titre" colspan="2">'.$langs->trans(
"Filter").
'</td></tr>';
254print
'<tr><td>'.$langs->trans(
"User").
'</td><td>';
256if (!$user->hasRight(
'expensereport',
'readall') && !$user->hasRight(
'expensereport',
'lire_tous')) {
257 $include =
'hierarchy';
259print
img_picto(
'',
'user',
'class="pictofixedwidth"');
260print $form->select_dolusers($userid,
'userid', 1,
null, 0, $include,
'',
'', 0, 0,
'', 0,
'',
'widthcentpercentminusx maxwidth300');
263print
'<tr><td class="left">'.$langs->trans(
"Status").
'</td><td class="left">';
264$liststatus = $tmpexpensereport->labelStatus;
265print $form->selectarray(
'object_status', $liststatus,
GETPOST(
'object_status',
'intcomma'), -4, 0, 0,
'', 1);
269print $form->textwithpicto($langs->trans(
"Year"), $langs->trans(
"DateValidation"));
271if (!in_array($year, $arrayyears)) {
272 $arrayyears[$year] = $year;
275print $form->selectarray(
'year', $arrayyears, $year, 0, 0, 0,
'', 0, 0, 0,
'',
'width75');
277print
'<tr><td class="center" colspan="2"><input type="submit" name="submit" class="button small" value="'.$langs->trans(
"Refresh").
'"></td></tr>';
282print
'<div class="div-table-responsive-no-min">';
283print
'<table class="noborder centpercent">';
284print
'<tr class="liste_titre" height="24">';
285print
'<td class="center">'.$langs->trans(
"Year").
'</td>';
286print
'<td class="right">'.$langs->trans(
"Number").
'</td>';
287print
'<td class="right">'.$langs->trans(
"AmountTotal").
'</td>';
288print
'<td class="right">'.$langs->trans(
"AmountAverage").
'</td>';
292foreach ($data as $val) {
293 $year = $val[
'year'];
294 while ($year && $oldyear > (
int) $year + 1) {
297 print
'<tr class="oddeven" height="24">';
298 print
'<td class="center"><a href="'.$_SERVER[
"PHP_SELF"].
'?year='.$oldyear.
'&mode='.$mode.
'">'.$oldyear.
'</a></td>';
299 print
'<td class="right">0</td>';
300 print
'<td class="right amount nowraponall">0</td>';
301 print
'<td class="right amount nowraponall">0</td>';
306 print
'<tr class="oddeven" height="24">';
307 print
'<td class="center"><a href="'.$_SERVER[
"PHP_SELF"].
'?year='.$year.
'&mode='.$mode.
'">'.$year.
'</a></td>';
308 print
'<td class="right">'.$val[
'nb'].
'</td>';
309 print
'<td class="right amount nowraponall">'.price(
price2num($val[
'total'],
'MT'), 1).
'</td>';
310 print
'<td class="right amount nowraponall">'.price(
price2num($val[
'avg'],
'MT'), 1).
'</td>';
318print
'</div><div class="fichetwothirdright">';
322print
'<table class="border centpercent"><tr class="pair nohover"><td class="center">';
332print
'</td></tr></table>';
336print
'<div class="clearboth"></div>';
$id
Support class for third parties, contacts, members, users or resources.
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
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.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
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, $morecssdiv='')
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 a Dolibarr global constant string value.
dol_mkdir($dir, $dataroot='', $newmask='')
Creation of a directory (this can create recursive subdir)
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
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.