26 require
'../../main.inc.php';
27 require_once DOL_DOCUMENT_ROOT.
'/core/class/dolgraph.class.php';
28 require_once DOL_DOCUMENT_ROOT.
'/salaries/class/salariesstats.class.php';
31 $langs->loadLangs(array(
"salaries",
"companies",
"bills"));
36 $userid =
GETPOST(
'userid',
'int');
40 $socid =
GETPOST(
'socid',
'int');
47 $socid =
GETPOST(
"socid",
"int");
49 $socid = $user->socid;
53 $nowyear = strftime(
"%Y",
dol_now());
55 $startyear = $year - (empty($conf->global->MAIN_STATS_GRAPHS_SHOW_N_YEARS) ? 2 : max(1, min(10, $conf->global->MAIN_STATS_GRAPHS_SHOW_N_YEARS)));
68 $title = $langs->trans(
"SalariesStatistics");
69 $dir = $conf->salaries->dir_temp;
75 $useridtofilter = $userid;
77 if (empty($user->rights->salaries->readall) && empty($useridtofilter)) {
78 $useridtofilter = $user->getAllChildIds(1);
87 $data = $stats->getNbByMonthWithPrevYear($endyear, $startyear);
90 $filenamenb = $dir.
"/salariesnbinyear-".$year.
".png";
91 $fileurlnb = DOL_URL_ROOT.
'/viewimage.php?modulepart=salariesstats&file=salariesnbinyear-'.$year.
'.png';
94 $mesg = $px1->isGraphKo();
97 $i = $startyear; $legend = array();
98 while ($i <= $endyear) {
102 $px1->SetLegend($legend);
103 $px1->SetMaxValue($px1->GetCeilMaxValue());
104 $px1->SetWidth($WIDTH);
105 $px1->SetHeight($HEIGHT);
106 $px1->SetYLabel($langs->trans(
"Number"));
108 $px1->SetHorizTickIncrement(1);
109 $px1->mode =
'depth';
110 $px1->SetTitle($langs->trans(
"NumberByMonth"));
112 $px1->draw($filenamenb, $fileurlnb);
116 $data = $stats->getAmountByMonthWithPrevYear($endyear, $startyear);
120 $filenameamount = $dir.
"/salariesamountinyear-".$year.
".png";
121 $fileurlamount = DOL_URL_ROOT.
'/viewimage.php?modulepart=salariesstats&file=salariesamountinyear-'.$year.
'.png';
124 $mesg = $px2->isGraphKo();
126 $px2->SetData($data);
127 $i = $startyear; $legend = array();
128 while ($i <= $endyear) {
132 $px2->SetLegend($legend);
133 $px2->SetMaxValue($px2->GetCeilMaxValue());
134 $px2->SetMinValue(min(0, $px2->GetFloorMinValue()));
135 $px2->SetWidth($WIDTH);
136 $px2->SetHeight($HEIGHT);
137 $px2->SetYLabel($langs->trans(
"Amount"));
139 $px2->SetHorizTickIncrement(1);
140 $px2->mode =
'depth';
141 $px2->SetTitle($langs->trans(
"AmountTotal"));
143 $px2->draw($filenameamount, $fileurlamount);
147 $data = $stats->getAverageByMonthWithPrevYear($endyear, $startyear);
149 $filename_avg = $dir.
"/salariesaverageinyear-".$year.
".png";
150 $fileurl_avg = DOL_URL_ROOT.
'/viewimage.php?modulepart=salariesstats&file=salariesaverageinyear-'.$year.
'.png';
153 $mesg = $px3->isGraphKo();
155 $px3->SetData($data);
156 $i = $startyear; $legend = array();
157 while ($i <= $endyear) {
161 $px3->SetLegend($legend);
162 $px3->SetYLabel($langs->trans(
"AmountAverage"));
163 $px3->SetMaxValue($px3->GetCeilMaxValue());
164 $px3->SetMinValue($px3->GetFloorMinValue());
165 $px3->SetWidth($WIDTH);
166 $px3->SetHeight($HEIGHT);
168 $px3->SetHorizTickIncrement(1);
169 $px3->mode =
'depth';
170 $px3->SetTitle($langs->trans(
"AmountAverage"));
172 $px3->draw($filename_avg, $fileurl_avg);
177 $data = $stats->getAllByYear();
178 $arrayyears = array();
179 foreach ($data as $val) {
180 $arrayyears[$val[
'year']] = $val[
'year'];
182 if (!count($arrayyears)) {
183 $arrayyears[$nowyear] = $nowyear;
189 $head[$h][0] = DOL_URL_ROOT.
'/salaries/stats/index.php';
190 $head[$h][1] = $langs->trans(
"ByMonthYear");
191 $head[$h][2] =
'byyear';
199 print
'<div class="fichecenter"><div class="fichethirdleft">';
203 print
'<form name="stats" method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
204 print
'<input type="hidden" name="token" value="'.newToken().
'">';
206 print
'<table class="noborder centpercent">';
207 print
'<tr class="liste_titre"><td class="liste_titre" colspan="2">'.$langs->trans(
"Filter").
'</td></tr>';
209 print
'<tr><td>'.$langs->trans(
"Employee").
'</td><td>';
210 print
img_picto(
'',
'user',
'class="pictofixedwidth"');
211 print
$form->select_dolusers(($userid ? $userid : -1),
'userid', 1,
'', 0, empty($user->rights->salaries->readall) ?
'hierarchyme' :
'',
'', 0, 0, 0,
'', 0,
'',
'widthcentpercentminusx maxwidth300');
214 print
'<tr><td>'.$langs->trans(
"Year").
'</td><td>';
215 if (!in_array($year, $arrayyears)) {
216 $arrayyears[$year] = $year;
219 print
$form->selectarray(
'year', $arrayyears, $year, 0, 0, 0,
'', 0, 0, 0,
'',
'width75');
221 print
'<tr><td align="center" colspan="2"><input type="submit" name="submit" class="button small" value="'.$langs->trans(
"Refresh").
'"></td></tr>';
226 print
'<div class="div-table-responsive-no-min">';
227 print
'<table class="noborder centpercent">';
228 print
'<tr class="liste_titre" height="24">';
229 print
'<td class="center">'.$langs->trans(
"Year").
'</td>';
230 print
'<td class="right">'.$langs->trans(
"Number").
'</td>';
231 print
'<td class="right">'.$langs->trans(
"AmountTotal").
'</td>';
232 print
'<td class="right">'.$langs->trans(
"AmountAverage").
'</td>';
236 foreach ($data as $val) {
237 $year = $val[
'year'];
238 while ($year && $oldyear > $year + 1) {
242 print
'<tr class="oddeven" height="24">';
243 print
'<td align="center"><a href="'.$_SERVER[
"PHP_SELF"].
'?year='.$oldyear.
'">'.$oldyear.
'</a></td>';
244 print
'<td class="right">0</td>';
245 print
'<td class="right"><span class="amount">0</span></td>';
246 print
'<td class="right"><span class="amount">0</span></td>';
250 print
'<tr class="oddeven" height="24">';
251 print
'<td align="center"><a href="'.$_SERVER[
"PHP_SELF"].
'?year='.$year.
'">'.$year.
'</a></td>';
252 print
'<td class="right">'.$val[
'nb'].
'</td>';
253 print
'<td class="right"><span class="amount">'.price(
price2num($val[
'total'],
'MT'), 1).
'</span></td>';
254 print
'<td class="right"><span class="amount">'.price(
price2num($val[
'avg'],
'MT'), 1).
'</span></td>';
263 print
'</div><div class="fichetwothirdright">';
267 print
'<table class="border centpercent"><tr class="pair nohover"><td align="center">';
277 print
'</td></tr></table>';
280 print
'</div></div>';
281 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.
if($cancel &&!$id) if($action== 'add'&&!$cancel) if($action== 'delete') if($id) $form
Actions.
dol_mkdir($dir, $dataroot= '', $newmask= '')
Creation of a directory (this can create recursive subdir)
dol_now($mode= 'auto')
Return date for now.
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOCSRFCHECK')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
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 '...
img_picto($titlealt, $picto, $moreatt= '', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt= '', $morecss= '', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
restrictedArea($user, $features, $objectid=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.
dol_get_fiche_head($links=array(), $active= '', $title= '', $notab=0, $picto= '', $pictoisfullpath=0, $morehtmlright= '', $morecss= '', $limittoshow=0, $moretabssuffix= '')
Show tabs of a record.
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).