28require
'../../../main.inc.php';
29require_once DOL_DOCUMENT_ROOT.
'/core/class/dolgraph.class.php';
30require_once DOL_DOCUMENT_ROOT.
'/core/lib/project.lib.php';
31require_once DOL_DOCUMENT_ROOT.
'/projet/class/taskstats.class.php';
42if (!$user->hasRight(
'projet',
'lire')) {
50$mode =
GETPOST(
'mode',
'alpha');
52$contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'projectlist';
57if ($user->socid > 0) {
59 $socid = $user->socid;
67$langs->loadlangs(array(
'companies',
'projects'));
76$includeuserlist = array();
79llxHeader(
'', $langs->trans(
'Tasks'),
'',
'', 0, 0,
'',
'',
'',
'mod-project project-tasks page-stats');
81$title = $langs->trans(
"TasksStatistics");
82$dir =
$conf->project->dir_output.
'/temp';
87$massactionbutton =
'';
89$nbtotalofrecords = $langs->trans(
"Statistics");
95$newcardbutton .= dolGetButtonTitle($langs->trans(
'ViewList'),
'',
'fa fa-bars imgforviewmode', DOL_URL_ROOT.
'/projet/tasks/list.php?mode=common'.preg_replace(
'/(&|\?)*mode=[^&]+/',
'', $param),
'', ($mode ==
'common' ? 2 : 1), array(
'morecss' =>
'reposition'));
96$newcardbutton .= dolGetButtonTitle($langs->trans(
'ViewKanban'),
'',
'fa fa-th-list imgforviewmode', DOL_URL_ROOT.
'/projet/tasks/list.php?mode=kanban'.preg_replace(
'/(&|\?)*mode=[^&]+/',
'', $param),
'', ($mode ==
'kanban' ? 2 : 1), array(
'morecss' =>
'reposition'));
97$newcardbutton .= dolGetButtonTitle($langs->trans(
'Statistics'),
'',
'fa fa-chart-bar imgforviewmode', DOL_URL_ROOT.
'/projet/tasks/stats/index.php?mode=statistics&contextpage='.$contextpage.preg_replace(
'/(&|\?)*(mode|groupby)=[^&]+/',
'', $param),
'', 2, array(
'morecss' =>
'reposition'));
98$newcardbutton .= dolGetButtonTitleSeparator();
99$newcardbutton .= dolGetButtonTitle($langs->trans(
'NewTask'),
'',
'fa fa-plus-circle', DOL_URL_ROOT.
'/projet/tasks.php?action=create&backtopage='.urlencode(DOL_URL_ROOT.
'/projet/tasks/list.php'),
'', $user->hasRight(
'projet',
'creer'));
104if ($user->hasRight(
'projet',
'all',
'lire') && !$socid) {
105 $htmltooltip .= $langs->trans(
"TasksOnProjectsDesc");
107 $htmltooltip .= $langs->trans(
"TasksOnProjectsPublicDesc");
110print_barre_liste($form->textwithpicto($title, $htmltooltip), $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords,
'projecttask', 0, $newcardbutton,
'', $limit, 0, 0, 1);
116if (!empty($userid) && $userid != -1) {
117 $stats_tasks->userid = $userid;
119if (!empty($socid) && $socid != -1) {
120 $stats_tasks->socid = $socid;
123 $stats_tasks->year = $year;
130$data = $stats_tasks->getNbByMonthWithPrevYear($endyear, $startyear);
133$filenamenb =
$conf->project->dir_output.
"/stats/tasknbprevyear-".$year.
".png";
134$fileurlnb = DOL_URL_ROOT.
'/viewimage.php?modulepart=taskstats&file=tasknbprevyear-'.$year.
'.png';
137$mesg = $px1->isGraphKo();
139 $px1->SetData($data);
142 while ($i <= $endyear) {
146 $px1->SetLegend($legend);
147 $px1->SetMaxValue($px1->GetCeilMaxValue());
148 $px1->SetWidth($WIDTH);
149 $px1->SetHeight($HEIGHT);
150 $px1->SetYLabel($langs->trans(
"ProjectNbTask"));
152 $px1->SetHorizTickIncrement(1);
153 $px1->mode =
'depth';
154 $px1->SetTitle($langs->trans(
"ProjectNbTaskByMonth"));
156 $px1->draw($filenamenb, $fileurlnb);
161$stats_tasks->year = 0;
162$data_all_year = $stats_tasks->getAllByYear();
165 $stats_tasks->year = $year;
167$arrayyears = array();
168foreach ($data_all_year as $val) {
169 $arrayyears[$val[
'year']] = $val[
'year'];
171if (!count($arrayyears)) {
172 $arrayyears[$nowyear] = $nowyear;
178$head[$h][0] = DOL_URL_ROOT.
'/projet/tasks/stats/index.php';
179$head[$h][1] = $langs->trans(
"ByMonthYear");
180$head[$h][2] =
'byyear';
188print
'<div class="fichecenter"><div class="fichethirdleft">';
190print
'<form name="stats" method="POST" action="'.dolBuildUrl($_SERVER[
"PHP_SELF"]).
'">';
191print
'<input type="hidden" name="token" value="'.newToken().
'">';
193print
'<table class="noborder centpercent">';
194print
'<tr class="liste_titre"><td class="liste_titre" colspan="2">'.$langs->trans(
"Filter").
'</td></tr>';
205print
'<tr><td>'.$langs->trans(
"Year").
'</td><td>';
206if (!in_array($year, $arrayyears)) {
207 $arrayyears[$year] = $year;
209if (!in_array($nowyear, $arrayyears)) {
210 $arrayyears[$nowyear] = $nowyear;
213print
img_picto(
'',
'calendar',
'class="pictofixedwidth"');
214print $form->selectarray(
'year', $arrayyears, $year, 0, 0, 0,
'', 0, 0, 0,
'',
'width75');
216print
'<tr><td class="center" colspan="2"><input type="submit" name="submit" class="button small" value="'.$langs->trans(
"Refresh").
'"></td></tr>';
224print
'<div class="div-table-responsive-no-min">';
225print
'<table class="noborder centpercent">';
226print
'<tr class="liste_titre">';
227print
'<td>'.$langs->trans(
"Year").
'</td>';
228print
'<td class="right">'.$langs->trans(
"NbOfTasks").
'</td>';
232foreach ($data_all_year as $val) {
233 $year = $val[
'year'];
234 while ($year && $oldyear > (
int) $year + 1) {
237 print
'<tr class="oddeven">';
238 print
'<td><a href="'.$_SERVER[
"PHP_SELF"].
'?year='.$oldyear.($socid > 0 ?
'&socid='.$socid :
'').($userid > 0 ?
'&userid='.$userid :
'').
'">'.$oldyear.
'</a></td>';
239 print
'<td class="right">0</td>';
243 print
'<tr class="oddeven">';
244 print
'<td><a href="'.$_SERVER[
"PHP_SELF"].
'?year='.$year.($socid > 0 ?
'&socid='.$socid :
'').($userid > 0 ?
'&userid='.$userid :
'').
'">'.$year.
'</a></td>';
245 print
'<td class="right">'.$val[
'nb'].
'</td>';
253print
'</div><div class="fichetwothirdright">';
255$stringtoshow =
'<table class="border centpercent"><tr class="pair nohover"><td class="center">';
259 $stringtoshow .= $px1->show();
260 $stringtoshow .=
"<br>\n";
262$stringtoshow .=
'</td></tr></table>';
269print
'<div class="clearboth"></div>';
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
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 statistics on project tasks.
dol_now($mode='gmt')
Return date for now.
print_barre_liste($title, $page, $file, $options='', $sortfield='', $sortorder='', $morehtmlcenter='', $num=-1, $totalnboflines='', $picto='generic', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limit=-1, $selectlimitsuffix=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow='')
Print a title with navigation controls for pagination.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
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, $morecssdiv='')
Show tabs of a record.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false, $decorate=0)
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)
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.