29require
'../../main.inc.php';
30require_once DOL_DOCUMENT_ROOT.
'/core/class/dolgraph.class.php';
31require_once DOL_DOCUMENT_ROOT.
'/salaries/class/salariesstats.class.php';
42$langs->loadLangs(array(
"salaries",
"companies",
"bills"));
60 $socid = $user->socid;
79$title = $langs->trans(
"SalariesStatistics");
80$dir =
$conf->salaries->dir_temp;
86$useridtofilter = $userid;
88if (!$user->hasRight(
'salaries',
'readall') && empty($useridtofilter)) {
89 $useridtofilter = $user->getAllChildIds(1);
98$data = $stats->getNbByMonthWithPrevYear($endyear, $startyear);
101$filenamenb = $dir.
"/salariesnbinyear-".$year.
".png";
102$fileurlnb = DOL_URL_ROOT.
'/viewimage.php?modulepart=salariesstats&file=salariesnbinyear-'.$year.
'.png';
105$mesg = $px1->isGraphKo();
107 $px1->SetData($data);
110 while ($i <= $endyear) {
114 $px1->SetLegend($legend);
115 $px1->SetMaxValue($px1->GetCeilMaxValue());
116 $px1->SetWidth($WIDTH);
117 $px1->SetHeight($HEIGHT);
118 $px1->SetYLabel($langs->trans(
"Number"));
120 $px1->SetHorizTickIncrement(1);
121 $px1->mode =
'depth';
122 $px1->SetTitle($langs->trans(
"NumberByMonth"));
124 $px1->draw($filenamenb, $fileurlnb);
128$data = $stats->getAmountByMonthWithPrevYear($endyear, $startyear);
132$filenameamount = $dir.
"/salariesamountinyear-".$year.
".png";
133$fileurlamount = DOL_URL_ROOT.
'/viewimage.php?modulepart=salariesstats&file=salariesamountinyear-'.$year.
'.png';
136$mesg = $px2->isGraphKo();
138 $px2->SetData($data);
141 while ($i <= $endyear) {
145 $px2->SetLegend($legend);
146 $px2->SetMaxValue($px2->GetCeilMaxValue());
147 $px2->SetMinValue(min(0, $px2->GetFloorMinValue()));
148 $px2->SetWidth($WIDTH);
149 $px2->SetHeight($HEIGHT);
150 $px2->SetYLabel($langs->trans(
"Amount"));
152 $px2->SetHorizTickIncrement(1);
153 $px2->mode =
'depth';
154 $px2->SetTitle($langs->trans(
"AmountTotal"));
156 $px2->draw($filenameamount, $fileurlamount);
160$data = $stats->getAverageByMonthWithPrevYear($endyear, $startyear);
162$filename_avg = $dir.
"/salariesaverageinyear-".$year.
".png";
163$fileurl_avg = DOL_URL_ROOT.
'/viewimage.php?modulepart=salariesstats&file=salariesaverageinyear-'.$year.
'.png';
166$mesg = $px3->isGraphKo();
168 $px3->SetData($data);
171 while ($i <= $endyear) {
175 $px3->SetLegend($legend);
176 $px3->SetYLabel($langs->trans(
"AmountAverage"));
177 $px3->SetMaxValue($px3->GetCeilMaxValue());
178 $px3->SetMinValue($px3->GetFloorMinValue());
179 $px3->SetWidth($WIDTH);
180 $px3->SetHeight($HEIGHT);
182 $px3->SetHorizTickIncrement(1);
183 $px3->mode =
'depth';
184 $px3->SetTitle($langs->trans(
"AmountAverage"));
186 $px3->draw($filename_avg, $fileurl_avg);
191$data = $stats->getAllByYear();
192$arrayyears = array();
193foreach ($data as $val) {
194 $arrayyears[$val[
'year']] = $val[
'year'];
196if (!count($arrayyears)) {
197 $arrayyears[$nowyear] = $nowyear;
203$head[$h][0] = DOL_URL_ROOT.
'/salaries/stats/index.php';
204$head[$h][1] = $langs->trans(
"ByMonthYear");
205$head[$h][2] =
'byyear';
213print
'<div class="fichecenter"><div class="fichethirdleft">';
217print
'<form name="stats" method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
218print
'<input type="hidden" name="token" value="'.newToken().
'">';
220print
'<table class="noborder centpercent">';
221print
'<tr class="liste_titre"><td class="liste_titre" colspan="2">'.$langs->trans(
"Filter").
'</td></tr>';
223print
'<tr><td>'.$langs->trans(
"Employee").
'</td><td>';
224print
img_picto(
'',
'user',
'class="pictofixedwidth"');
225print $form->select_dolusers(($userid ? $userid : -1),
'userid', 1,
'', 0, !$user->hasRight(
'salaries',
'readall') ?
'hierarchyme' :
'',
'', 0, 0, 0,
'', 0,
'',
'widthcentpercentminusx maxwidth300');
228print
'<tr><td>'.$langs->trans(
"Year").
'</td><td>';
229if (!in_array($year, $arrayyears)) {
230 $arrayyears[$year] = $year;
233print $form->selectarray(
'year', $arrayyears, $year, 0, 0, 0,
'', 0, 0, 0,
'',
'width75');
235print
'<tr><td align="center" colspan="2"><input type="submit" name="submit" class="button small" value="'.$langs->trans(
"Refresh").
'"></td></tr>';
240print
'<div class="div-table-responsive-no-min">';
241print
'<table class="noborder centpercent">';
242print
'<tr class="liste_titre" height="24">';
243print
'<td class="center">'.$langs->trans(
"Year").
'</td>';
244print
'<td class="right">'.$langs->trans(
"Number").
'</td>';
245print
'<td class="right">'.$langs->trans(
"AmountTotal").
'</td>';
246print
'<td class="right">'.$langs->trans(
"AmountAverage").
'</td>';
250foreach ($data as $val) {
251 $year = $val[
'year'];
252 while ($year && $oldyear > (
int) $year + 1) {
256 print
'<tr class="oddeven" height="24">';
257 print
'<td align="center"><a href="'.$_SERVER[
"PHP_SELF"].
'?year='.$oldyear.
'">'.$oldyear.
'</a></td>';
258 print
'<td class="right">0</td>';
259 print
'<td class="right"><span class="amount">0</span></td>';
260 print
'<td class="right"><span class="amount">0</span></td>';
264 print
'<tr class="oddeven" height="24">';
265 print
'<td align="center"><a href="'.$_SERVER[
"PHP_SELF"].
'?year='.$year.
'">'.$year.
'</a></td>';
266 print
'<td class="right">'.$val[
'nb'].
'</td>';
267 print
'<td class="right"><span class="amount">'.price(
price2num($val[
'total'],
'MT'), 1).
'</span></td>';
268 print
'<td class="right"><span class="amount">'.price(
price2num($val[
'avg'],
'MT'), 1).
'</span></td>';
277print
'</div><div class="fichetwothirdright">';
281print
'<table class="border centpercent"><tr class="pair nohover"><td align="center">';
291print
'</td></tr></table>';
295print
'<div class="clearboth"></div>';
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 salary statistics.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
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)
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).
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.