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) {
39 $userid =
GETPOST(
'userid',
'int');
40 $socid =
GETPOST(
'socid',
'int');
42 if ($user->socid > 0) {
44 $socid = $user->socid;
46 $nowyear = strftime(
"%Y",
dol_now());
48 $startyear = $year - (empty($conf->global->MAIN_STATS_GRAPHS_SHOW_N_YEARS) ? 2 : max(1, min(10, $conf->global->MAIN_STATS_GRAPHS_SHOW_N_YEARS)));
52 $langs->loadlangs(array(
'companies',
'projects'));
61 $includeuserlist = array();
66 $title = $langs->trans(
"TasksStatistics");
67 $dir = $conf->project->dir_output.
'/temp';
75 if (!empty($userid) && $userid != -1) {
76 $stats_tasks->userid = $userid;
78 if (!empty($socid) && $socid != -1) {
79 $stats_tasks->socid = $socid;
82 $stats_tasks->year = $year;
89 $data = $stats_tasks->getNbByMonthWithPrevYear($endyear, $startyear);
92 $filenamenb = $conf->project->dir_output.
"/stats/tasknbprevyear-".$year.
".png";
93 $fileurlnb = DOL_URL_ROOT.
'/viewimage.php?modulepart=taskstats&file=tasknbprevyear-'.$year.
'.png';
96 $mesg = $px1->isGraphKo();
99 $i = $startyear; $legend = array();
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(
"ProjectNbTask"));
110 $px1->SetHorizTickIncrement(1);
111 $px1->mode =
'depth';
112 $px1->SetTitle($langs->trans(
"ProjectNbTaskByMonth"));
114 $px1->draw($filenamenb, $fileurlnb);
119 $stats_tasks->year = 0;
120 $data_all_year = $stats_tasks->getAllByYear();
123 $stats_tasks->year = $year;
125 $arrayyears = array();
126 foreach ($data_all_year as $val) {
127 $arrayyears[$val[
'year']] = $val[
'year'];
129 if (!count($arrayyears)) {
130 $arrayyears[$nowyear] = $nowyear;
136 $head[$h][0] = DOL_URL_ROOT.
'/projet/tasks/stats/index.php';
137 $head[$h][1] = $langs->trans(
"ByMonthYear");
138 $head[$h][2] =
'byyear';
146 print
'<div class="fichecenter"><div class="fichethirdleft">';
148 print
'<form name="stats" method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
149 print
'<input type="hidden" name="token" value="'.newToken().
'">';
151 print
'<table class="noborder centpercent">';
152 print
'<tr class="liste_titre"><td class="liste_titre" colspan="2">'.$langs->trans(
"Filter").
'</td></tr>';
163 print
'<tr><td>'.$langs->trans(
"Year").
'</td><td>';
164 if (!in_array($year, $arrayyears)) {
165 $arrayyears[$year] = $year;
167 if (!in_array($nowyear, $arrayyears)) {
168 $arrayyears[$nowyear] = $nowyear;
171 print
$form->selectarray(
'year', $arrayyears, $year, 0, 0, 0,
'', 0, 0, 0,
'',
'width75');
173 print
'<tr><td class="center" colspan="2"><input type="submit" name="submit" class="button small" value="'.$langs->trans(
"Refresh").
'"></td></tr>';
181 print
'<div class="div-table-responsive-no-min">';
182 print
'<table class="noborder centpercent">';
183 print
'<tr class="liste_titre">';
184 print
'<td>'.$langs->trans(
"Year").
'</td>';
185 print
'<td class="right">'.$langs->trans(
"NbOfTasks").
'</td>';
189 foreach ($data_all_year as $val) {
190 $year = $val[
'year'];
191 while ($year && $oldyear > $year + 1) {
194 print
'<tr class="oddeven">';
195 print
'<td><a href="'.$_SERVER[
"PHP_SELF"].
'?year='.$oldyear.($socid > 0 ?
'&socid='.$socid :
'').($userid > 0 ?
'&userid='.$userid :
'').
'">'.$oldyear.
'</a></td>';
196 print
'<td class="right">0</td>';
200 print
'<tr class="oddeven">';
201 print
'<td><a href="'.$_SERVER[
"PHP_SELF"].
'?year='.$year.($socid > 0 ?
'&socid='.$socid :
'').($userid > 0 ?
'&userid='.$userid :
'').
'">'.$year.
'</a></td>';
202 print
'<td class="right">'.$val[
'nb'].
'</td>';
210 print
'</div><div class="fichetwothirdright">';
212 $stringtoshow =
'<table class="border centpercent"><tr class="pair nohover"><td class="center">';
216 $stringtoshow .= $px1->show();
217 $stringtoshow .=
"<br>\n";
219 $stringtoshow .=
'</td></tr></table>';
224 print
'</div></div>';
226 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.
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.
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).