27require
'../../main.inc.php';
28require_once DOL_DOCUMENT_ROOT.
'/core/class/dolgraph.class.php';
29require_once DOL_DOCUMENT_ROOT.
'/salaries/class/salariesstats.class.php';
32$langs->loadLangs(array(
"salaries",
"companies",
"bills"));
37$userid =
GETPOST(
'userid',
'int');
41$socid =
GETPOST(
'socid',
'int');
48$socid =
GETPOST(
"socid",
"int");
50 $socid = $user->socid;
56$startyear = $year - (empty($conf->global->MAIN_STATS_GRAPHS_SHOW_N_YEARS) ? 2 : max(1, min(10, $conf->global->MAIN_STATS_GRAPHS_SHOW_N_YEARS)));
69$title = $langs->trans(
"SalariesStatistics");
70$dir = $conf->salaries->dir_temp;
76$useridtofilter = $userid;
78if (empty($user->rights->salaries->readall) && empty($useridtofilter)) {
79 $useridtofilter = $user->getAllChildIds(1);
88$data = $stats->getNbByMonthWithPrevYear($endyear, $startyear);
91$filenamenb = $dir.
"/salariesnbinyear-".$year.
".png";
92$fileurlnb = DOL_URL_ROOT.
'/viewimage.php?modulepart=salariesstats&file=salariesnbinyear-'.$year.
'.png';
95$mesg = $px1->isGraphKo();
98 $i = $startyear; $legend = array();
99 while ($i <= $endyear) {
103 $px1->SetLegend($legend);
104 $px1->SetMaxValue($px1->GetCeilMaxValue());
105 $px1->SetWidth($WIDTH);
106 $px1->SetHeight($HEIGHT);
107 $px1->SetYLabel($langs->trans(
"Number"));
109 $px1->SetHorizTickIncrement(1);
110 $px1->mode =
'depth';
111 $px1->SetTitle($langs->trans(
"NumberByMonth"));
113 $px1->draw($filenamenb, $fileurlnb);
117$data = $stats->getAmountByMonthWithPrevYear($endyear, $startyear);
121$filenameamount = $dir.
"/salariesamountinyear-".$year.
".png";
122$fileurlamount = DOL_URL_ROOT.
'/viewimage.php?modulepart=salariesstats&file=salariesamountinyear-'.$year.
'.png';
125$mesg = $px2->isGraphKo();
127 $px2->SetData($data);
128 $i = $startyear; $legend = array();
129 while ($i <= $endyear) {
133 $px2->SetLegend($legend);
134 $px2->SetMaxValue($px2->GetCeilMaxValue());
135 $px2->SetMinValue(min(0, $px2->GetFloorMinValue()));
136 $px2->SetWidth($WIDTH);
137 $px2->SetHeight($HEIGHT);
138 $px2->SetYLabel($langs->trans(
"Amount"));
140 $px2->SetHorizTickIncrement(1);
141 $px2->mode =
'depth';
142 $px2->SetTitle($langs->trans(
"AmountTotal"));
144 $px2->draw($filenameamount, $fileurlamount);
148$data = $stats->getAverageByMonthWithPrevYear($endyear, $startyear);
150$filename_avg = $dir.
"/salariesaverageinyear-".$year.
".png";
151$fileurl_avg = DOL_URL_ROOT.
'/viewimage.php?modulepart=salariesstats&file=salariesaverageinyear-'.$year.
'.png';
154$mesg = $px3->isGraphKo();
156 $px3->SetData($data);
157 $i = $startyear; $legend = array();
158 while ($i <= $endyear) {
162 $px3->SetLegend($legend);
163 $px3->SetYLabel($langs->trans(
"AmountAverage"));
164 $px3->SetMaxValue($px3->GetCeilMaxValue());
165 $px3->SetMinValue($px3->GetFloorMinValue());
166 $px3->SetWidth($WIDTH);
167 $px3->SetHeight($HEIGHT);
169 $px3->SetHorizTickIncrement(1);
170 $px3->mode =
'depth';
171 $px3->SetTitle($langs->trans(
"AmountAverage"));
173 $px3->draw($filename_avg, $fileurl_avg);
178$data = $stats->getAllByYear();
179$arrayyears = array();
180foreach ($data as $val) {
181 $arrayyears[$val[
'year']] = $val[
'year'];
183if (!count($arrayyears)) {
184 $arrayyears[$nowyear] = $nowyear;
190$head[$h][0] = DOL_URL_ROOT.
'/salaries/stats/index.php';
191$head[$h][1] = $langs->trans(
"ByMonthYear");
192$head[$h][2] =
'byyear';
200print
'<div class="fichecenter"><div class="fichethirdleft">';
204print
'<form name="stats" method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
205print
'<input type="hidden" name="token" value="'.newToken().
'">';
207print
'<table class="noborder centpercent">';
208print
'<tr class="liste_titre"><td class="liste_titre" colspan="2">'.$langs->trans(
"Filter").
'</td></tr>';
210print
'<tr><td>'.$langs->trans(
"Employee").
'</td><td>';
211print
img_picto(
'',
'user',
'class="pictofixedwidth"');
212print $form->select_dolusers(($userid ? $userid : -1),
'userid', 1,
'', 0, empty($user->rights->salaries->readall) ?
'hierarchyme' :
'',
'', 0, 0, 0,
'', 0,
'',
'widthcentpercentminusx maxwidth300');
215print
'<tr><td>'.$langs->trans(
"Year").
'</td><td>';
216if (!in_array($year, $arrayyears)) {
217 $arrayyears[$year] = $year;
220print $form->selectarray(
'year', $arrayyears, $year, 0, 0, 0,
'', 0, 0, 0,
'',
'width75');
222print
'<tr><td align="center" colspan="2"><input type="submit" name="submit" class="button small" value="'.$langs->trans(
"Refresh").
'"></td></tr>';
227print
'<div class="div-table-responsive-no-min">';
228print
'<table class="noborder centpercent">';
229print
'<tr class="liste_titre" height="24">';
230print
'<td class="center">'.$langs->trans(
"Year").
'</td>';
231print
'<td class="right">'.$langs->trans(
"Number").
'</td>';
232print
'<td class="right">'.$langs->trans(
"AmountTotal").
'</td>';
233print
'<td class="right">'.$langs->trans(
"AmountAverage").
'</td>';
237foreach ($data as $val) {
238 $year = $val[
'year'];
239 while ($year && $oldyear > $year + 1) {
243 print
'<tr class="oddeven" height="24">';
244 print
'<td align="center"><a href="'.$_SERVER[
"PHP_SELF"].
'?year='.$oldyear.
'">'.$oldyear.
'</a></td>';
245 print
'<td class="right">0</td>';
246 print
'<td class="right"><span class="amount">0</span></td>';
247 print
'<td class="right"><span class="amount">0</span></td>';
251 print
'<tr class="oddeven" height="24">';
252 print
'<td align="center"><a href="'.$_SERVER[
"PHP_SELF"].
'?year='.$year.
'">'.$year.
'</a></td>';
253 print
'<td class="right">'.$val[
'nb'].
'</td>';
254 print
'<td class="right"><span class="amount">'.price(
price2num($val[
'total'],
'MT'), 1).
'</span></td>';
255 print
'<td class="right"><span class="amount">'.price(
price2num($val[
'avg'],
'MT'), 1).
'</span></td>';
264print
'</div><div class="fichetwothirdright">';
268print
'<table class="border centpercent"><tr class="pair nohover"><td align="center">';
278print
'</td></tr></table>';
282print
'<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
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.
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).
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.