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;
 
   69$title = $langs->trans(
"SalariesStatistics");
 
   70$dir = $conf->salaries->dir_temp;
 
   76$useridtofilter = $userid; 
 
   78if (!$user->hasRight(
'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();
 
  100  while ($i <= $endyear) {
 
  104  $px1->SetLegend($legend);
 
  105  $px1->SetMaxValue($px1->GetCeilMaxValue());
 
  106  $px1->SetWidth($WIDTH);
 
  107  $px1->SetHeight($HEIGHT);
 
  108  $px1->SetYLabel($langs->trans(
"Number"));
 
  110  $px1->SetHorizTickIncrement(1);
 
  111  $px1->mode = 
'depth';
 
  112  $px1->SetTitle($langs->trans(
"NumberByMonth"));
 
  114  $px1->draw($filenamenb, $fileurlnb);
 
  118$data = $stats->getAmountByMonthWithPrevYear($endyear, $startyear);
 
  122$filenameamount = $dir.
"/salariesamountinyear-".$year.
".png";
 
  123$fileurlamount = DOL_URL_ROOT.
'/viewimage.php?modulepart=salariesstats&file=salariesamountinyear-'.$year.
'.png';
 
  126$mesg = $px2->isGraphKo();
 
  128  $px2->SetData($data);
 
  131  while ($i <= $endyear) {
 
  135  $px2->SetLegend($legend);
 
  136  $px2->SetMaxValue($px2->GetCeilMaxValue());
 
  137  $px2->SetMinValue(min(0, $px2->GetFloorMinValue()));
 
  138  $px2->SetWidth($WIDTH);
 
  139  $px2->SetHeight($HEIGHT);
 
  140  $px2->SetYLabel($langs->trans(
"Amount"));
 
  142  $px2->SetHorizTickIncrement(1);
 
  143  $px2->mode = 
'depth';
 
  144  $px2->SetTitle($langs->trans(
"AmountTotal"));
 
  146  $px2->draw($filenameamount, $fileurlamount);
 
  150$data = $stats->getAverageByMonthWithPrevYear($endyear, $startyear);
 
  152$filename_avg = $dir.
"/salariesaverageinyear-".$year.
".png";
 
  153$fileurl_avg = DOL_URL_ROOT.
'/viewimage.php?modulepart=salariesstats&file=salariesaverageinyear-'.$year.
'.png';
 
  156$mesg = $px3->isGraphKo();
 
  158  $px3->SetData($data);
 
  161  while ($i <= $endyear) {
 
  165  $px3->SetLegend($legend);
 
  166  $px3->SetYLabel($langs->trans(
"AmountAverage"));
 
  167  $px3->SetMaxValue($px3->GetCeilMaxValue());
 
  168  $px3->SetMinValue($px3->GetFloorMinValue());
 
  169  $px3->SetWidth($WIDTH);
 
  170  $px3->SetHeight($HEIGHT);
 
  172  $px3->SetHorizTickIncrement(1);
 
  173  $px3->mode = 
'depth';
 
  174  $px3->SetTitle($langs->trans(
"AmountAverage"));
 
  176  $px3->draw($filename_avg, $fileurl_avg);
 
  181$data = $stats->getAllByYear();
 
  182$arrayyears = array();
 
  183foreach ($data as $val) {
 
  184  $arrayyears[$val[
'year']] = $val[
'year'];
 
  186if (!count($arrayyears)) {
 
  187  $arrayyears[$nowyear] = $nowyear;
 
  193$head[$h][0] = DOL_URL_ROOT.
'/salaries/stats/index.php';
 
  194$head[$h][1] = $langs->trans(
"ByMonthYear");
 
  195$head[$h][2] = 
'byyear';
 
  203print 
'<div class="fichecenter"><div class="fichethirdleft">';
 
  207print 
'<form name="stats" method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
 
  208print 
'<input type="hidden" name="token" value="'.newToken().
'">';
 
  210print 
'<table class="noborder centpercent">';
 
  211print 
'<tr class="liste_titre"><td class="liste_titre" colspan="2">'.$langs->trans(
"Filter").
'</td></tr>';
 
  213print 
'<tr><td>'.$langs->trans(
"Employee").
'</td><td>';
 
  214print 
img_picto(
'', 
'user', 
'class="pictofixedwidth"');
 
  215print $form->select_dolusers(($userid ? $userid : -1), 
'userid', 1, 
'', 0, !$user->hasRight(
'salaries', 
'readall') ? 
'hierarchyme' : 
'', 
'', 0, 0, 0, 
'', 0, 
'', 
'widthcentpercentminusx maxwidth300');
 
  218print 
'<tr><td>'.$langs->trans(
"Year").
'</td><td>';
 
  219if (!in_array($year, $arrayyears)) {
 
  220  $arrayyears[$year] = $year;
 
  223print $form->selectarray(
'year', $arrayyears, $year, 0, 0, 0, 
'', 0, 0, 0, 
'', 
'width75');
 
  225print 
'<tr><td align="center" colspan="2"><input type="submit" name="submit" class="button small" value="'.$langs->trans(
"Refresh").
'"></td></tr>';
 
  230print 
'<div class="div-table-responsive-no-min">';
 
  231print 
'<table class="noborder centpercent">';
 
  232print 
'<tr class="liste_titre" height="24">';
 
  233print 
'<td class="center">'.$langs->trans(
"Year").
'</td>';
 
  234print 
'<td class="right">'.$langs->trans(
"Number").
'</td>';
 
  235print 
'<td class="right">'.$langs->trans(
"AmountTotal").
'</td>';
 
  236print 
'<td class="right">'.$langs->trans(
"AmountAverage").
'</td>';
 
  240foreach ($data as $val) {
 
  241  $year = $val[
'year'];
 
  242  while ($year && $oldyear > $year + 1) {
 
  246    print 
'<tr class="oddeven" height="24">';
 
  247    print 
'<td align="center"><a href="'.$_SERVER[
"PHP_SELF"].
'?year='.$oldyear.
'">'.$oldyear.
'</a></td>';
 
  248    print 
'<td class="right">0</td>';
 
  249    print 
'<td class="right"><span class="amount">0</span></td>';
 
  250    print 
'<td class="right"><span class="amount">0</span></td>';
 
  254  print 
'<tr class="oddeven" height="24">';
 
  255  print 
'<td align="center"><a href="'.$_SERVER[
"PHP_SELF"].
'?year='.$year.
'">'.$year.
'</a></td>';
 
  256  print 
'<td class="right">'.$val[
'nb'].
'</td>';
 
  257  print 
'<td class="right"><span class="amount">'.price(
price2num($val[
'total'], 
'MT'), 1).
'</span></td>';
 
  258  print 
'<td class="right"><span class="amount">'.price(
price2num($val[
'avg'], 
'MT'), 1).
'</span></td>';
 
  267print 
'</div><div class="fichetwothirdright">';
 
  271print 
'<table class="border centpercent"><tr class="pair nohover"><td align="center">';
 
  281print 
'</td></tr></table>';
 
  285print 
'<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).
 
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.