27require
'../../../main.inc.php';
28require_once DOL_DOCUMENT_ROOT.
'/core/class/dolgraph.class.php';
29require_once DOL_DOCUMENT_ROOT.
'/compta/deplacement/class/deplacementstats.class.php';
32$langs->loadLangs(array(
'trips',
'companies'));
37$userid =
GETPOST(
'userid',
'int');
if ($userid < 0) {
40$socid =
GETPOST(
'socid',
'int');
if ($socid < 0) {
46if ($user->socid > 0) {
48 $socid = $user->socid;
51 $socid = $user->socid;
56$childids = $user->getAllChildIds();
57$childids[] = $user->id;
59 if (!$user->hasRight(
'deplacement',
'readall') && !$user->hasRight(
'deplacement',
'lire_tous') && !in_array($userid, $childids)) {
82$title = $langs->trans(
"TripsAndExpensesStatistics");
83$dir = $conf->deplacement->dir_temp;
89$useridtofilter = $userid;
90if (empty($useridtofilter)) {
91 $useridtofilter = $childids;
92 if ($user->hasRight(
'deplacement',
'readall') || $user->hasRight(
'deplacement',
'lire_tous')) {
103$data = $stats->getNbByMonthWithPrevYear($endyear, $startyear);
106$filenamenb = $dir.
"/tripsexpensesnbinyear-".$year.
".png";
107$fileurlnb = DOL_URL_ROOT.
'/viewimage.php?modulepart=tripsexpensesstats&file=tripsexpensesnbinyear-'.$year.
'.png';
110$mesg = $px1->isGraphKo();
112 $px1->SetData($data);
115 while ($i <= $endyear) {
119 $px1->SetLegend($legend);
120 $px1->SetMaxValue($px1->GetCeilMaxValue());
121 $px1->SetWidth($WIDTH);
122 $px1->SetHeight($HEIGHT);
123 $px1->SetYLabel($langs->trans(
"Number"));
125 $px1->SetHorizTickIncrement(1);
126 $px1->mode =
'depth';
127 $px1->SetTitle($langs->trans(
"NumberByMonth"));
129 $px1->draw($filenamenb, $fileurlnb);
133$data = $stats->getAmountByMonthWithPrevYear($endyear, $startyear);
137$filenameamount = $dir.
"/tripsexpensesamountinyear-".$year.
".png";
138$fileurlamount = DOL_URL_ROOT.
'/viewimage.php?modulepart=tripsexpensesstats&file=tripsexpensesamountinyear-'.$year.
'.png';
141$mesg = $px2->isGraphKo();
143 $px2->SetData($data);
146 while ($i <= $endyear) {
150 $px2->SetLegend($legend);
151 $px2->SetMaxValue($px2->GetCeilMaxValue());
152 $px2->SetMinValue(min(0, $px2->GetFloorMinValue()));
153 $px2->SetWidth($WIDTH);
154 $px2->SetHeight($HEIGHT);
155 $px2->SetYLabel($langs->trans(
"Amount"));
157 $px2->SetHorizTickIncrement(1);
158 $px2->mode =
'depth';
159 $px2->SetTitle($langs->trans(
"AmountTotal"));
161 $px2->draw($filenameamount, $fileurlamount);
165$data = $stats->getAverageByMonthWithPrevYear($endyear, $startyear);
167if (!$user->hasRight(
'societe',
'client',
'voir') || $user->socid) {
168 $filename_avg = $dir.
'/ordersaverage-'.$user->id.
'-'.$year.
'.png';
169 if ($mode ==
'customer') {
170 $fileurl_avg = DOL_URL_ROOT.
'/viewimage.php?modulepart=orderstats&file=ordersaverage-'.$user->id.
'-'.$year.
'.png';
172 if ($mode ==
'supplier') {
173 $fileurl_avg = DOL_URL_ROOT.
'/viewimage.php?modulepart=orderstatssupplier&file=ordersaverage-'.$user->id.
'-'.$year.
'.png';
176 $filename_avg = $dir.
'/ordersaverage-'.$year.
'.png';
177 if ($mode ==
'customer') {
178 $fileurl_avg = DOL_URL_ROOT.
'/viewimage.php?modulepart=orderstats&file=ordersaverage-'.$year.
'.png';
180 if ($mode ==
'supplier') {
181 $fileurl_avg = DOL_URL_ROOT.
'/viewimage.php?modulepart=orderstatssupplier&file=ordersaverage-'.$year.
'.png';
186$mesg = $px3->isGraphKo();
188 $px3->SetData($data);
191 while ($i <= $endyear) {
195 $px3->SetLegend($legend);
196 $px3->SetYLabel($langs->trans(
"AmountAverage"));
197 $px3->SetMaxValue($px3->GetCeilMaxValue());
198 $px3->SetMinValue($px3->GetFloorMinValue());
199 $px3->SetWidth($WIDTH);
200 $px3->SetHeight($HEIGHT);
202 $px3->SetHorizTickIncrement(1);
203 $px3->mode =
'depth';
204 $px3->SetTitle($langs->trans(
"AmountAverage"));
206 $px3->draw($filename_avg, $fileurl_avg);
211$data = $stats->getAllByYear();
212$arrayyears = array();
213foreach ($data as $val) {
214 $arrayyears[$val[
'year']] = $val[
'year'];
216if (!count($arrayyears)) {
217 $arrayyears[$nowyear] = $nowyear;
223$head[$h][0] = DOL_URL_ROOT.
'/compta/deplacement/stats/index.php';
224$head[$h][1] = $langs->trans(
"ByMonthYear");
225$head[$h][2] =
'byyear';
233print
'<div class="fichecenter"><div class="fichethirdleft">';
237print
'<form name="stats" method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
238print
'<input type="hidden" name="token" value="'.newToken().
'">';
239print
'<input type="hidden" name="mode" value="'.$mode.
'">';
241print
'<table class="border centpercent">';
242print
'<tr class="liste_titre"><td class="liste_titre" colspan="2">'.$langs->trans(
"Filter").
'</td></tr>';
244print
'<tr><td>'.$langs->trans(
"ThirdParty").
'</td><td>';
245print
img_picto(
'',
'company',
'class="pictofixedwidth"');
246print $form->select_company($socid,
'socid',
'', 1, 1, 0, array(), 0,
'widthcentpercentminusx maxwidth300',
'');
249print
'<tr><td>'.$langs->trans(
"User").
'</td><td>';
251if (!$user->hasRight(
'deplacement',
'readall') && !$user->hasRight(
'deplacement',
'lire_tous')) {
252 $include =
'hierarchy';
254print
img_picto(
'',
'user',
'class="pictofixedwidth"');
255print $form->select_dolusers($userid,
'userid', 1,
'', 0, $include,
'', 0, 0, 0,
'', 0,
'',
'widthcentpercentminusx maxwidth300');
258print
'<tr><td>'.$langs->trans(
"Year").
'</td><td>';
259if (!in_array($year, $arrayyears)) {
260 $arrayyears[$year] = $year;
263print $form->selectarray(
'year', $arrayyears, $year, 0, 0, 0,
'', 0, 0, 0,
'',
'width75');
265print
'<tr><td align="center" colspan="2"><input type="submit" name="submit" class="button small" value="'.$langs->trans(
"Refresh").
'"></td></tr>';
270print
'<div class="div-table-responsive-no-min">';
271print
'<table class="border centpercent">';
273print
'<td class="center">'.$langs->trans(
"Year").
'</td>';
274print
'<td class="center">'.$langs->trans(
"Number").
'</td>';
275print
'<td class="center">'.$langs->trans(
"AmountTotal").
'</td>';
276print
'<td class="center">'.$langs->trans(
"AmountAverage").
'</td>';
280foreach ($data as $val) {
281 $year = $val[
'year'];
282 while ($year && $oldyear > $year + 1) {
285 print
'<td align="center"><a href="'.$_SERVER[
"PHP_SELF"].
'?year='.$oldyear.
'&mode='.$mode.
'">'.$oldyear.
'</a></td>';
286 print
'<td class="right">0</td>';
287 print
'<td class="right">0</td>';
288 print
'<td class="right">0</td>';
294 print
'<td align="center"><a href="'.$_SERVER[
"PHP_SELF"].
'?year='.$year.
'&mode='.$mode.
'">'.$year.
'</a></td>';
295 print
'<td class="right">'.$val[
'nb'].
'</td>';
296 print
'<td class="right">'.price(
price2num($val[
'total'],
'MT'), 1).
'</td>';
297 print
'<td class="right">'.price(
price2num($val[
'avg'],
'MT'), 1).
'</td>';
305print
'</div><div class="fichetwothirdright">';
309print
'<table class="border centpercent"><tr class="pair nohover"><td align="center">';
319print
'</td></tr></table>';
323print
'<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.
Classe permettant la gestion des stats des deplacements et notes de frais.
static getDefaultGraphSizeForStats($direction, $defaultsize='')
getDefaultGraphSizeForStats
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
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_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dol_now($mode='auto')
Return date for now.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
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.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.