25 require
'../../../main.inc.php';
26 require_once DOL_DOCUMENT_ROOT.
'/core/class/dolgraph.class.php';
27 require_once DOL_DOCUMENT_ROOT.
'/core/lib/project.lib.php';
28 require_once DOL_DOCUMENT_ROOT.
'/projet/class/taskstats.class.php';
31 if (!$user->rights->projet->lire)
38 $userid =
GETPOST(
'userid',
'int');
39 $socid =
GETPOST(
'socid',
'int');
44 $socid = $user->socid;
46 $nowyear = strftime(
"%Y",
dol_now());
49 $startyear = $year - 1;
53 $langs->loadlangs(array(
'companies',
'projects'));
60 $form =
new Form($db);
62 $includeuserlist = array();
67 $title = $langs->trans(
"TasksStatistics");
68 $dir = $conf->projet->dir_output.
'/temp';
76 if (!empty($userid) && $userid != -1) $stats_tasks->userid = $userid;
77 if (!empty($socid) && $socid != -1) $stats_tasks->socid = $socid;
78 if (!empty($year)) $stats_tasks->year = $year;
84 $data = $stats_tasks->getNbByMonthWithPrevYear($endyear, $startyear);
87 $filenamenb = $conf->project->dir_output.
"/stats/tasknbprevyear-".$year.
".png";
88 $fileurlnb = DOL_URL_ROOT.
'/viewimage.php?modulepart=taskstats&file=tasknbprevyear-'.$year.
'.png';
91 $mesg = $px1->isGraphKo();
95 $i = $startyear; $legend = array();
96 while ($i <= $endyear)
101 $px1->SetLegend($legend);
102 $px1->SetMaxValue($px1->GetCeilMaxValue());
103 $px1->SetWidth($WIDTH);
104 $px1->SetHeight($HEIGHT);
105 $px1->SetYLabel($langs->trans(
"ProjectNbTask"));
107 $px1->SetHorizTickIncrement(1);
108 $px1->mode =
'depth';
109 $px1->SetTitle($langs->trans(
"ProjectNbTaskByMonth"));
111 $px1->draw($filenamenb, $fileurlnb);
116 $stats_tasks->year = 0;
117 $data_all_year = $stats_tasks->getAllByYear();
119 if (!empty($year)) $stats_tasks->year = $year;
120 $arrayyears = array();
121 foreach ($data_all_year as $val) {
122 $arrayyears[$val[
'year']] = $val[
'year'];
124 if (!count($arrayyears)) $arrayyears[$nowyear] = $nowyear;
129 $head[$h][0] = DOL_URL_ROOT.
'/projet/tasks/stats/index.php?mode='.$mode;
130 $head[$h][1] = $langs->trans(
"ByMonthYear");
131 $head[$h][2] =
'byyear';
139 print '<div class="fichecenter"><div class="fichethirdleft">';
141 print
'<form name="stats" method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
142 print
'<input type="hidden" name="token" value="'.newToken().
'">';
144 print
'<table class="noborder centpercent">';
145 print
'<tr class="liste_titre"><td class="liste_titre" colspan="2">'.$langs->trans(
"Filter").
'</td></tr>';
156 print
'<tr><td>'.$langs->trans(
"Year").
'</td><td>';
157 if (!in_array($year, $arrayyears)) $arrayyears[$year] = $year;
158 if (!in_array($nowyear, $arrayyears)) $arrayyears[$nowyear] = $nowyear;
160 print $form->selectarray(
'year', $arrayyears, $year, 0);
162 print
'<tr><td class="center" colspan="2"><input type="submit" name="submit" class="button" value="'.$langs->trans(
"Refresh").
'"></td></tr>';
168 print
'<div class="div-table-responsive-no-min">';
169 print
'<table class="noborder centpercent">';
170 print
'<tr class="liste_titre" height="24">';
171 print
'<td>'.$langs->trans(
"Year").
'</td>';
172 print
'<td class="right">'.$langs->trans(
"NbOfTasks").
'</td>';
176 foreach ($data_all_year as $val)
178 $year = $val[
'year'];
179 while ($year && $oldyear > $year + 1)
183 print
'<tr class="oddeven" height="24">';
184 print
'<td><a href="'.$_SERVER[
"PHP_SELF"].
'?year='.$oldyear.
'&mode='.$mode.($socid > 0 ?
'&socid='.$socid :
'').($userid > 0 ?
'&userid='.$userid :
'').
'">'.$oldyear.
'</a></td>';
185 print
'<td class="right">0</td>';
189 print
'<tr class="oddeven" height="24">';
190 print
'<td><a href="'.$_SERVER[
"PHP_SELF"].
'?year='.$year.
'&mode='.$mode.($socid > 0 ?
'&socid='.$socid :
'').($userid > 0 ?
'&userid='.$userid :
'').
'">'.$year.
'</a></td>';
191 print
'<td class="right">'.$val[
'nb'].
'</td>';
199 print
'</div><div class="fichetwothirdright"><div class="ficheaddleft">';
201 $stringtoshow .=
'<table class="border centpercent"><tr class="pair nohover"><td class="center">';
202 if ($mesg) { print $mesg; }
else {
203 $stringtoshow .= $px1->show();
204 $stringtoshow .=
"<br>\n";
206 $stringtoshow .=
'</td></tr></table>';
211 print
'</div></div></div>';
212 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.
load_fiche_titre($titre, $morehtmlright= '', $picto= 'generic', $pictoisfullpath=0, $id= '', $morecssontable= '', $morehtmlcenter= '')
Load a title with picto.
accessforbidden($message= '', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program Calling this function terminate execution ...
Class to manage statistics on project tasks.
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.
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)