26 require
'../../../main.inc.php';
27 require_once DOL_DOCUMENT_ROOT.
'/core/class/dolgraph.class.php';
28 require_once DOL_DOCUMENT_ROOT.
'/core/lib/project.lib.php';
29 require_once DOL_DOCUMENT_ROOT.
'/projet/class/taskstats.class.php';
32 if (!$user->rights->projet->lire) {
40 $userid =
GETPOST(
'userid',
'int');
41 $socid =
GETPOST(
'socid',
'int');
43 if ($user->socid > 0) {
45 $socid = $user->socid;
49 $startyear = $year - (empty($conf->global->MAIN_STATS_GRAPHS_SHOW_N_YEARS) ? 2 : max(1, min(10, $conf->global->MAIN_STATS_GRAPHS_SHOW_N_YEARS)));
53 $langs->loadlangs(array(
'companies',
'projects'));
62 $includeuserlist = array();
67 $title = $langs->trans(
"TasksStatistics");
68 $dir = $conf->project->dir_output.
'/temp';
76 if (!empty($userid) && $userid != -1) {
77 $stats_tasks->userid = $userid;
79 if (!empty($socid) && $socid != -1) {
80 $stats_tasks->socid = $socid;
83 $stats_tasks->year = $year;
90 $data = $stats_tasks->getNbByMonthWithPrevYear($endyear, $startyear);
93 $filenamenb = $conf->project->dir_output.
"/stats/tasknbprevyear-".$year.
".png";
94 $fileurlnb = DOL_URL_ROOT.
'/viewimage.php?modulepart=taskstats&file=tasknbprevyear-'.$year.
'.png';
97 $mesg = $px1->isGraphKo();
100 $i = $startyear; $legend = array();
101 while ($i <= $endyear) {
105 $px1->SetLegend($legend);
106 $px1->SetMaxValue($px1->GetCeilMaxValue());
107 $px1->SetWidth($WIDTH);
108 $px1->SetHeight($HEIGHT);
109 $px1->SetYLabel($langs->trans(
"ProjectNbTask"));
111 $px1->SetHorizTickIncrement(1);
112 $px1->mode =
'depth';
113 $px1->SetTitle($langs->trans(
"ProjectNbTaskByMonth"));
115 $px1->draw($filenamenb, $fileurlnb);
120 $stats_tasks->year = 0;
121 $data_all_year = $stats_tasks->getAllByYear();
124 $stats_tasks->year = $year;
126 $arrayyears = array();
127 foreach ($data_all_year as $val) {
128 $arrayyears[$val[
'year']] = $val[
'year'];
130 if (!count($arrayyears)) {
131 $arrayyears[$nowyear] = $nowyear;
137 $head[$h][0] = DOL_URL_ROOT.
'/projet/tasks/stats/index.php';
138 $head[$h][1] = $langs->trans(
"ByMonthYear");
139 $head[$h][2] =
'byyear';
147 print
'<div class="fichecenter"><div class="fichethirdleft">';
149 print
'<form name="stats" method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
150 print
'<input type="hidden" name="token" value="'.newToken().
'">';
152 print
'<table class="noborder centpercent">';
153 print
'<tr class="liste_titre"><td class="liste_titre" colspan="2">'.$langs->trans(
"Filter").
'</td></tr>';
164 print
'<tr><td>'.$langs->trans(
"Year").
'</td><td>';
165 if (!in_array($year, $arrayyears)) {
166 $arrayyears[$year] = $year;
168 if (!in_array($nowyear, $arrayyears)) {
169 $arrayyears[$nowyear] = $nowyear;
172 print
$form->selectarray(
'year', $arrayyears, $year, 0, 0, 0,
'', 0, 0, 0,
'',
'width75');
174 print
'<tr><td class="center" colspan="2"><input type="submit" name="submit" class="button small" value="'.$langs->trans(
"Refresh").
'"></td></tr>';
182 print
'<div class="div-table-responsive-no-min">';
183 print
'<table class="noborder centpercent">';
184 print
'<tr class="liste_titre">';
185 print
'<td>'.$langs->trans(
"Year").
'</td>';
186 print
'<td class="right">'.$langs->trans(
"NbOfTasks").
'</td>';
190 foreach ($data_all_year as $val) {
191 $year = $val[
'year'];
192 while ($year && $oldyear > $year + 1) {
195 print
'<tr class="oddeven">';
196 print
'<td><a href="'.$_SERVER[
"PHP_SELF"].
'?year='.$oldyear.($socid > 0 ?
'&socid='.$socid :
'').($userid > 0 ?
'&userid='.$userid :
'').
'">'.$oldyear.
'</a></td>';
197 print
'<td class="right">0</td>';
201 print
'<tr class="oddeven">';
202 print
'<td><a href="'.$_SERVER[
"PHP_SELF"].
'?year='.$year.($socid > 0 ?
'&socid='.$socid :
'').($userid > 0 ?
'&userid='.$userid :
'').
'">'.$year.
'</a></td>';
203 print
'<td class="right">'.$val[
'nb'].
'</td>';
211 print
'</div><div class="fichetwothirdright">';
213 $stringtoshow =
'<table class="border centpercent"><tr class="pair nohover"><td class="center">';
217 $stringtoshow .= $px1->show();
218 $stringtoshow .=
"<br>\n";
220 $stringtoshow .=
'</td></tr></table>';
225 print
'</div></div>';
227 print
'<div style="clear:both"></div>';
static getDefaultGraphSizeForStats($direction, $defaultsize='')
getDefaultGraphSizeForStats
Class to manage statistics on project tasks.
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
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='')
Show tabs of a record.
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.
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).
dol_mkdir($dir, $dataroot='', $newmask='')
Creation of a directory (this can create recursive subdir)
if(!defined('NOTOKENRENEWAL')) if(!defined('NOLOGIN')) if(!defined('NOCSRFCHECK')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) if(!defined('NOIPCHECK')) if(!defined('NOBROWSERNOTIF')) llxHeader()
Header empty.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.