25 require
'../../main.inc.php';
26 require_once DOL_DOCUMENT_ROOT.
'/core/class/dolgraph.class.php';
27 require_once DOL_DOCUMENT_ROOT.
'/salaries/class/salariesstats.class.php';
30 $langs->loadLangs(array(
"salaries",
"companies"));
35 $userid =
GETPOST(
'userid',
'int');
if ($userid < 0) $userid = 0;
36 $socid =
GETPOST(
'socid',
'int');
if ($socid < 0) $socid = 0;
40 $socid =
GETPOST(
"socid",
"int");
41 if ($user->socid) $socid = $user->socid;
44 $nowyear = strftime(
"%Y",
dol_now());
47 $startyear = $year - 1;
55 $form =
new Form($db);
60 $title = $langs->trans(
"SalariesStatistics");
61 $dir = $conf->salaries->dir_temp;
67 $useridtofilter = $userid;
75 $data = $stats->getNbByMonthWithPrevYear($endyear, $startyear);
78 $filenamenb = $dir.
"/salariesnbinyear-".$year.
".png";
79 $fileurlnb = DOL_URL_ROOT.
'/viewimage.php?modulepart=salariesstats&file=salariesnbinyear-'.$year.
'.png';
82 $mesg = $px1->isGraphKo();
86 $i = $startyear; $legend = array();
87 while ($i <= $endyear)
92 $px1->SetLegend($legend);
93 $px1->SetMaxValue($px1->GetCeilMaxValue());
94 $px1->SetWidth($WIDTH);
95 $px1->SetHeight($HEIGHT);
96 $px1->SetYLabel($langs->trans(
"Number"));
98 $px1->SetHorizTickIncrement(1);
100 $px1->SetTitle($langs->trans(
"NumberByMonth"));
102 $px1->draw($filenamenb, $fileurlnb);
106 $data = $stats->getAmountByMonthWithPrevYear($endyear, $startyear);
110 $filenameamount = $dir.
"/salariesamountinyear-".$year.
".png";
111 $fileurlamount = DOL_URL_ROOT.
'/viewimage.php?modulepart=salariesstats&file=salariesamountinyear-'.$year.
'.png';
114 $mesg = $px2->isGraphKo();
117 $px2->SetData($data);
118 $i = $startyear; $legend = array();
119 while ($i <= $endyear)
124 $px2->SetLegend($legend);
125 $px2->SetMaxValue($px2->GetCeilMaxValue());
126 $px2->SetMinValue(min(0, $px2->GetFloorMinValue()));
127 $px2->SetWidth($WIDTH);
128 $px2->SetHeight($HEIGHT);
129 $px2->SetYLabel($langs->trans(
"Amount"));
131 $px2->SetHorizTickIncrement(1);
132 $px2->mode =
'depth';
133 $px2->SetTitle($langs->trans(
"AmountTotal"));
135 $px2->draw($filenameamount, $fileurlamount);
139 $data = $stats->getAverageByMonthWithPrevYear($endyear, $startyear);
141 $filename_avg = $dir.
"/salariesaverageinyear-".$year.
".png";
142 $fileurl_avg = DOL_URL_ROOT.
'/viewimage.php?modulepart=salariesstats&file=salariesaverageinyear-'.$year.
'.png';
145 $mesg = $px3->isGraphKo();
148 $px3->SetData($data);
149 $i = $startyear; $legend = array();
150 while ($i <= $endyear)
155 $px3->SetLegend($legend);
156 $px3->SetYLabel($langs->trans(
"AmountAverage"));
157 $px3->SetMaxValue($px3->GetCeilMaxValue());
158 $px3->SetMinValue($px3->GetFloorMinValue());
159 $px3->SetWidth($WIDTH);
160 $px3->SetHeight($HEIGHT);
162 $px3->SetHorizTickIncrement(1);
163 $px3->mode =
'depth';
164 $px3->SetTitle($langs->trans(
"AmountAverage"));
166 $px3->draw($filename_avg, $fileurl_avg);
171 $data = $stats->getAllByYear();
172 $arrayyears = array();
173 foreach ($data as $val) {
174 $arrayyears[$val[
'year']] = $val[
'year'];
176 if (!count($arrayyears)) $arrayyears[$nowyear] = $nowyear;
181 $head[$h][0] = DOL_URL_ROOT.
'/salaries/stats/index.php';
182 $head[$h][1] = $langs->trans(
"ByMonthYear");
183 $head[$h][2] =
'byyear';
191 print '<div class="fichecenter"><div class="fichethirdleft">';
195 print
'<form name="stats" method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
196 print
'<input type="hidden" name="token" value="'.newToken().
'">';
198 print
'<table class="noborder centpercent">';
199 print
'<tr class="liste_titre"><td class="liste_titre" colspan="2">'.$langs->trans(
"Filter").
'</td></tr>';
201 print
'<tr><td>'.$langs->trans(
"User").
'</td><td>';
202 print $form->select_dolusers($userid,
'userid', 1,
'', 0,
'',
'', 0, 0, 0,
'', 0,
'',
'maxwidth300');
205 print
'<tr><td>'.$langs->trans(
"Year").
'</td><td>';
206 if (!in_array($year, $arrayyears)) $arrayyears[$year] = $year;
208 print $form->selectarray(
'year', $arrayyears, $year, 0);
210 print
'<tr><td align="center" colspan="2"><input type="submit" name="submit" class="button" value="'.$langs->trans(
"Refresh").
'"></td></tr>';
215 print
'<div class="div-table-responsive-no-min">';
216 print
'<table class="noborder centpercent">';
217 print
'<tr class="liste_titre" height="24">';
218 print
'<td class="center">'.$langs->trans(
"Year").
'</td>';
219 print
'<td class="right">'.$langs->trans(
"Number").
'</td>';
220 print
'<td class="right">'.$langs->trans(
"AmountTotal").
'</td>';
221 print
'<td class="right">'.$langs->trans(
"AmountAverage").
'</td>';
225 foreach ($data as $val)
227 $year = $val[
'year'];
228 while ($year && $oldyear > $year + 1)
233 print
'<tr class="oddeven" height="24">';
234 print
'<td align="center"><a href="'.$_SERVER[
"PHP_SELF"].
'?year='.$oldyear.
'">'.$oldyear.
'</a></td>';
235 print
'<td class="right">0</td>';
236 print
'<td class="right">0</td>';
237 print
'<td class="right">0</td>';
241 print
'<tr class="oddeven" height="24">';
242 print
'<td align="center"><a href="'.$_SERVER[
"PHP_SELF"].
'?year='.$year.
'">'.$year.
'</a></td>';
243 print
'<td class="right">'.$val[
'nb'].
'</td>';
244 print
'<td class="right">'.price(
price2num($val[
'total'],
'MT'), 1).
'</td>';
245 print
'<td class="right">'.price(
price2num($val[
'avg'],
'MT'), 1).
'</td>';
254 print
'</div><div class="fichetwothirdright"><div class="ficheaddleft">';
258 print
'<table class="border centpercent"><tr class="pair nohover"><td align="center">';
259 if ($mesg) { print $mesg; }
else {
266 print
'</td></tr></table>';
269 print
'</div></div></div>';
270 print
'<div style="clear:both"></div>';
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_now($mode= 'auto')
Return date for now.
Classe permettant la gestion des stats des salaires.
load_fiche_titre($titre, $morehtmlright= '', $picto= 'generic', $pictoisfullpath=0, $id= '', $morecssontable= '', $morehtmlcenter= '')
Load a title with picto.
price2num($amount, $rounding= '', $option=0)
Function that return a number with universal decimal format (decimal separator is '...
restrictedArea($user, $features, $objectid=0, $tableandshare= '', $feature2= '', $dbt_keyfield= 'fk_soc', $dbt_select= 'rowid', $isdraft=0)
Check permissions of a user to show a page and an object.
dol_get_fiche_head($links=array(), $active= '', $title= '', $notab=0, $picto= '', $pictoisfullpath=0, $morehtmlright= '', $morecss= '', $limittoshow=0, $moretabssuffix= '')
Show tabs of a record.
print
Draft customers invoices.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
static getDefaultGraphSizeForStats($direction, $defaultsize= '')
getDefaultGraphSizeForStats
complete_head_from_modules($conf, $langs, $object, &$head, &$h, $type, $mode= 'add')
Complete or removed entries into a head array (used to build tabs).
dol_mkdir($dir, $dataroot= '', $newmask=null)
Creation of a directory (this can create recursive subdir)