24 require
'../../main.inc.php';
25 require_once DOL_DOCUMENT_ROOT.
'/ticket/class/actions_ticket.class.php';
26 require_once DOL_DOCUMENT_ROOT.
'/ticket/class/ticketstats.class.php';
27 require_once DOL_DOCUMENT_ROOT.
'/ticket/class/ticket.class.php';
28 require_once DOL_DOCUMENT_ROOT.
'/core/class/dolgraph.class.php';
35 $object_status =
GETPOST(
'object_status',
'intcomma');
37 $userid =
GETPOST(
'userid',
'int');
38 $socid =
GETPOST(
'socid',
'int');
43 $socid = $user->socid;
46 $nowyear = strftime(
"%Y",
dol_now());
49 $startyear = $year - 1;
53 $langs->loadLangs(array(
'orders',
'companies',
'other',
'tickets'));
60 $form =
new Form($db);
63 $title = $langs->trans(
"Statistics");
64 $dir = $conf->ticket->dir_temp;
72 $stats =
new TicketStats($db, $socid, ($userid > 0 ? $userid : 0));
73 if ($object_status !=
'' && $object_status >= -1) $stats->where .=
' AND fk_statut IN ('.$db->sanitize($db->escape($object_status)).
')';
77 $data = $stats->getNbByMonthWithPrevYear($endyear, $startyear);
83 if (!$user->rights->societe->client->voir || $user->socid)
85 $filenamenb = $dir.
'/ticketsnbinyear-'.$user->id.
'-'.$year.
'.png';
86 $fileurlnb = DOL_URL_ROOT.
'/viewimage.php?modulepart=ticketstats&file=ticketsnbinyear-'.$user->id.
'-'.$year.
'.png';
88 $filenamenb = $dir.
'/ticketsnbinyear-'.$year.
'.png';
89 $fileurlnb = DOL_URL_ROOT.
'/viewimage.php?modulepart=ticketstats&file=ticketsnbinyear-'.$year.
'.png';
93 $mesg = $px1->isGraphKo();
97 $i = $startyear; $legend = array();
98 while ($i <= $endyear)
103 $px1->SetLegend($legend);
104 $px1->SetMaxValue($px1->GetCeilMaxValue());
105 $px1->SetMinValue(min(0, $px1->GetFloorMinValue()));
106 $px1->SetWidth($WIDTH);
107 $px1->SetHeight($HEIGHT);
108 $px1->SetYLabel($langs->trans(
"NbOfTicket"));
110 $px1->SetHorizTickIncrement(1);
111 $px1->mode =
'depth';
112 $px1->SetTitle($langs->trans(
"NumberOfTicketsByMonth"));
114 $px1->draw($filenamenb, $fileurlnb);
118 $data = $stats->getAmountByMonthWithPrevYear($endyear, $startyear);
122 if (!$user->rights->societe->client->voir || $user->socid)
124 $filenameamount = $dir.
'/ticketsamountinyear-'.$user->id.
'-'.$year.
'.png';
125 $fileurlamount = DOL_URL_ROOT.
'/viewimage.php?modulepart=ticketstats&file=ticketsamountinyear-'.$user->id.
'-'.$year.
'.png';
127 $filenameamount = $dir.
'/ticketsamountinyear-'.$year.
'.png';
128 $fileurlamount = DOL_URL_ROOT.
'/viewimage.php?modulepart=ticketstats&file=ticketsamountinyear-'.$year.
'.png';
132 $mesg = $px2->isGraphKo();
135 $px2->SetData($data);
136 $i = $startyear; $legend = array();
137 while ($i <= $endyear)
142 $px2->SetLegend($legend);
143 $px2->SetMaxValue($px2->GetCeilMaxValue());
144 $px2->SetMinValue(min(0, $px2->GetFloorMinValue()));
145 $px2->SetWidth($WIDTH);
146 $px2->SetHeight($HEIGHT);
147 $px2->SetYLabel($langs->trans(
"AmountOfTickets"));
149 $px2->SetHorizTickIncrement(1);
150 $px2->mode =
'depth';
151 $px2->SetTitle($langs->trans(
"AmountOfTicketsByMonthHT"));
153 $px2->draw($filenameamount, $fileurlamount);
157 $data = $stats->getAverageByMonthWithPrevYear($endyear, $startyear);
159 if (!$user->rights->societe->client->voir || $user->socid)
161 $filename_avg = $dir.
'/ticketsaverage-'.$user->id.
'-'.$year.
'.png';
162 $fileurl_avg = DOL_URL_ROOT.
'/viewimage.php?modulepart=ticketstats&file=ticketsaverage-'.$user->id.
'-'.$year.
'.png';
164 $filename_avg = $dir.
'/ticketsaverage-'.$year.
'.png';
165 $fileurl_avg = DOL_URL_ROOT.
'/viewimage.php?modulepart=ticketstats&file=ticketsaverage-'.$year.
'.png';
169 $mesg = $px3->isGraphKo();
172 $px3->SetData($data);
173 $i = $startyear; $legend = array();
174 while ($i <= $endyear)
179 $px3->SetLegend($legend);
180 $px3->SetYLabel($langs->trans(
"AmountAverage"));
181 $px3->SetMaxValue($px3->GetCeilMaxValue());
182 $px3->SetMinValue($px3->GetFloorMinValue());
183 $px3->SetWidth($WIDTH);
184 $px3->SetHeight($HEIGHT);
186 $px3->SetHorizTickIncrement(1);
187 $px3->mode =
'depth';
188 $px3->SetTitle($langs->trans(
"AmountAverage"));
190 $px3->draw($filename_avg, $fileurl_avg);
196 $data = $stats->getAllByYear();
197 $arrayyears = array();
198 foreach ($data as $val) {
199 if (!empty($val[
'year'])) {
200 $arrayyears[$val[
'year']] = $val[
'year'];
203 if (!count($arrayyears)) $arrayyears[$nowyear] = $nowyear;
207 $head[$h][0] = DOL_URL_ROOT.
'/ticket/stats/index.php';
208 $head[$h][1] = $langs->trans(
"ByMonthYear");
209 $head[$h][2] =
'byyear';
212 $type =
'ticket_stats';
219 print '<div class="fichecenter"><div class="fichethirdleft">';
223 print
'<form name="stats" method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
224 print
'<input type="hidden" name="token" value="'.newToken().
'">';
226 print
'<table class="noborder centpercent">';
227 print
'<tr class="liste_titre"><td class="liste_titre" colspan="2">'.$langs->trans(
"Filter").
'</td></tr>';
229 print
'<tr><td class="left">'.$langs->trans(
"ThirdParty").
'</td><td class="left">';
230 print $form->select_company($socid,
'socid',
'', 1, 0, 0, array(), 0,
'',
'style="width: 95%"');
233 print
'<tr><td class="left">'.$langs->trans(
"CreatedBy").
'</td><td class="left">';
234 print $form->select_dolusers($userid,
'userid', 1,
'', 0,
'',
'', 0, 0, 0,
'', 0,
'',
'maxwidth300');
236 print
'<tr><td class="left">'.$langs->trans(
"Status").
'</td><td class="left">';
237 $liststatus = $object->fields[
'fk_statut'][
'arrayofkeyval'];
238 print $form->selectarray(
'object_status', $liststatus,
GETPOST(
'object_status',
'intcomma'), -4, 0, 0,
'', 1);
241 print
'<tr><td class="left">'.$langs->trans(
"Year").
'</td><td class="left">';
242 if (!in_array($year, $arrayyears)) $arrayyears[$year] = $year;
243 if (!in_array($nowyear, $arrayyears)) $arrayyears[$nowyear] = $nowyear;
245 print $form->selectarray(
'year', $arrayyears, $year, 0);
247 print
'<tr><td class="center" colspan="2"><input type="submit" name="submit" class="button" value="'.$langs->trans(
"Refresh").
'"></td></tr>';
253 print
'<div class="div-table-responsive-no-min">';
254 print
'<table class="noborder centpercent">';
255 print
'<tr class="liste_titre" height="24">';
256 print
'<td class="center">'.$langs->trans(
"Year").
'</td>';
257 print
'<td class="right">'.$langs->trans(
"NbOfTickets").
'</td>';
258 print
'<td class="right">%</td>';
266 foreach ($data as $val)
268 $year = $val[
'year'];
269 while (!empty($year) && $oldyear > $year + 1)
273 print
'<tr class="oddeven" height="24">';
274 print
'<td class="center"><a href="'.$_SERVER[
"PHP_SELF"].
'?year='.$oldyear.($socid > 0 ?
'&socid='.$socid :
'').($userid > 0 ?
'&userid='.$userid :
'').
'">'.$oldyear.
'</a></td>';
275 print
'<td class="right">0</td>';
276 print
'<td class="right"></td>';
285 print
'<tr class="oddeven" height="24">';
286 print
'<td class="center"><a href="'.$_SERVER[
"PHP_SELF"].
'?year='.$year.($socid > 0 ?
'&socid='.$socid :
'').($userid > 0 ?
'&userid='.$userid :
'').
'">'.$year.
'</a></td>';
287 print
'<td class="right">'.$val[
'nb'].
'</td>';
288 print
'<td class="right" style="'.(($val[
'nb_diff'] >= 0) ?
'color: green;' :
'color: red;').
'">'.round($val[
'nb_diff']).
'</td>';
301 print
'</div><div class="fichetwothirdright"><div class="ficheaddleft">';
305 print
'<table class="border centpercent"><tr class="pair nohover"><td class="center">';
306 if ($mesg) { print $mesg; }
else {
313 print
'</td></tr></table>';
316 print
'</div></div></div>';
317 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.
Classe permettant la gestion des stats des deplacements et notes de frais.
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 ...
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.
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).
dol_mkdir($dir, $dataroot= '', $newmask=null)
Creation of a directory (this can create recursive subdir)