25 require
'../../main.inc.php';
26 require_once DOL_DOCUMENT_ROOT.
'/ticket/class/actions_ticket.class.php';
27 require_once DOL_DOCUMENT_ROOT.
'/ticket/class/ticketstats.class.php';
28 require_once DOL_DOCUMENT_ROOT.
'/ticket/class/ticket.class.php';
29 require_once DOL_DOCUMENT_ROOT.
'/core/class/dolgraph.class.php';
34 if (!$user->rights->ticket->read) {
38 $object_status =
GETPOST(
'object_status',
'intcomma');
40 $userid =
GETPOST(
'userid',
'int');
41 $socid =
GETPOST(
'socid',
'int');
43 if ($user->socid > 0) {
45 $socid = $user->socid;
50 $startyear = $year - (empty($conf->global->MAIN_STATS_GRAPHS_SHOW_N_YEARS) ? 2 : max(1, min(10, $conf->global->MAIN_STATS_GRAPHS_SHOW_N_YEARS)));
54 $langs->loadLangs(array(
'orders',
'companies',
'other',
'tickets'));
64 $title = $langs->trans(
"Statistics");
65 $dir = $conf->ticket->dir_temp;
73 $stats =
new TicketStats($db, $socid, ($userid > 0 ? $userid : 0));
74 if ($object_status !=
'' && $object_status >= -1) {
75 $stats->where .=
' AND fk_statut IN ('.$db->sanitize($db->escape($object_status)).
')';
80 $data = $stats->getNbByMonthWithPrevYear($endyear, $startyear);
86 if (empty($user->rights->societe->client->voir) || $user->socid) {
87 $filenamenb = $dir.
'/ticketsnbinyear-'.$user->id.
'-'.$year.
'.png';
88 $fileurlnb = DOL_URL_ROOT.
'/viewimage.php?modulepart=ticketstats&file=ticketsnbinyear-'.$user->id.
'-'.$year.
'.png';
90 $filenamenb = $dir.
'/ticketsnbinyear-'.$year.
'.png';
91 $fileurlnb = DOL_URL_ROOT.
'/viewimage.php?modulepart=ticketstats&file=ticketsnbinyear-'.$year.
'.png';
95 $mesg = $px1->isGraphKo();
98 $i = $startyear; $legend = array();
99 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 (empty($user->rights->societe->client->voir) || $user->socid) {
123 $filenameamount = $dir.
'/ticketsamountinyear-'.$user->id.
'-'.$year.
'.png';
124 $fileurlamount = DOL_URL_ROOT.
'/viewimage.php?modulepart=ticketstats&file=ticketsamountinyear-'.$user->id.
'-'.$year.
'.png';
126 $filenameamount = $dir.
'/ticketsamountinyear-'.$year.
'.png';
127 $fileurlamount = DOL_URL_ROOT.
'/viewimage.php?modulepart=ticketstats&file=ticketsamountinyear-'.$year.
'.png';
131 $mesg = $px2->isGraphKo();
133 $px2->SetData($data);
134 $i = $startyear; $legend = array();
135 while ($i <= $endyear) {
139 $px2->SetLegend($legend);
140 $px2->SetMaxValue($px2->GetCeilMaxValue());
141 $px2->SetMinValue(min(0, $px2->GetFloorMinValue()));
142 $px2->SetWidth($WIDTH);
143 $px2->SetHeight($HEIGHT);
144 $px2->SetYLabel($langs->trans(
"AmountOfTickets"));
146 $px2->SetHorizTickIncrement(1);
147 $px2->mode =
'depth';
148 $px2->SetTitle($langs->trans(
"AmountOfTicketsByMonthHT"));
150 $px2->draw($filenameamount, $fileurlamount);
154 $data = $stats->getAverageByMonthWithPrevYear($endyear, $startyear);
156 if (empty($user->rights->societe->client->voir) || $user->socid) {
157 $filename_avg = $dir.
'/ticketsaverage-'.$user->id.
'-'.$year.
'.png';
158 $fileurl_avg = DOL_URL_ROOT.
'/viewimage.php?modulepart=ticketstats&file=ticketsaverage-'.$user->id.
'-'.$year.
'.png';
160 $filename_avg = $dir.
'/ticketsaverage-'.$year.
'.png';
161 $fileurl_avg = DOL_URL_ROOT.
'/viewimage.php?modulepart=ticketstats&file=ticketsaverage-'.$year.
'.png';
165 $mesg = $px3->isGraphKo();
167 $px3->SetData($data);
168 $i = $startyear; $legend = array();
169 while ($i <= $endyear) {
173 $px3->SetLegend($legend);
174 $px3->SetYLabel($langs->trans(
"AmountAverage"));
175 $px3->SetMaxValue($px3->GetCeilMaxValue());
176 $px3->SetMinValue($px3->GetFloorMinValue());
177 $px3->SetWidth($WIDTH);
178 $px3->SetHeight($HEIGHT);
180 $px3->SetHorizTickIncrement(1);
181 $px3->mode =
'depth';
182 $px3->SetTitle($langs->trans(
"AmountAverage"));
184 $px3->draw($filename_avg, $fileurl_avg);
190 $data = $stats->getAllByYear();
191 $arrayyears = array();
192 foreach ($data as $val) {
193 if (!empty($val[
'year'])) {
194 $arrayyears[$val[
'year']] = $val[
'year'];
197 if (!count($arrayyears)) {
198 $arrayyears[$nowyear] = $nowyear;
203 $head[$h][0] = DOL_URL_ROOT.
'/ticket/stats/index.php';
204 $head[$h][1] = $langs->trans(
"ByMonthYear");
205 $head[$h][2] =
'byyear';
208 $type =
'ticket_stats';
215 print
'<div class="fichecenter"><div class="fichethirdleft">';
219 print
'<form name="stats" method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
220 print
'<input type="hidden" name="token" value="'.newToken().
'">';
222 print
'<table class="noborder centpercent">';
223 print
'<tr class="liste_titre"><td class="liste_titre" colspan="2">'.$langs->trans(
"Filter").
'</td></tr>';
225 print
'<tr><td class="left">'.$langs->trans(
"ThirdParty").
'</td><td class="left">';
226 print
img_picto(
'',
'company',
'class="pictofixedwidth"');
227 print
$form->select_company($socid,
'socid',
'', 1, 0, 0, array(), 0,
'widthcentpercentminusx maxwidth300',
'');
230 print
'<tr><td class="left">'.$langs->trans(
"CreatedBy").
'</td><td class="left">';
231 print
img_picto(
'',
'user',
'class="pictofixedwidth"');
232 print
$form->select_dolusers($userid,
'userid', 1,
'', 0,
'',
'', 0, 0, 0,
'', 0,
'',
'widthcentpercentminusx maxwidth300');
234 print
'<tr><td class="left">'.$langs->trans(
"Status").
'</td><td class="left">';
235 $liststatus = $object->fields[
'fk_statut'][
'arrayofkeyval'];
236 print
$form->selectarray(
'object_status', $liststatus,
GETPOST(
'object_status',
'intcomma'), -4, 0, 0,
'', 1);
239 print
'<tr><td class="left">'.$langs->trans(
"Year").
'</td><td class="left">';
240 if (!in_array($year, $arrayyears)) {
241 $arrayyears[$year] = $year;
243 if (!in_array($nowyear, $arrayyears)) {
244 $arrayyears[$nowyear] = $nowyear;
247 print
$form->selectarray(
'year', $arrayyears, $year, 0, 0, 0,
'', 0, 0, 0,
'',
'width75');
249 print
'<tr><td class="center" colspan="2"><input type="submit" name="submit" class="button small" value="'.$langs->trans(
"Refresh").
'"></td></tr>';
255 print
'<div class="div-table-responsive-no-min">';
256 print
'<table class="noborder centpercent">';
257 print
'<tr class="liste_titre" height="24">';
258 print
'<td class="center">'.$langs->trans(
"Year").
'</td>';
259 print
'<td class="right">'.$langs->trans(
"NbOfTickets").
'</td>';
260 print
'<td class="right">%</td>';
268 foreach ($data as $val) {
269 $year = $val[
'year'];
270 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="'.((isset($val[
'nb_diff']) && $val[
'nb_diff'] >= 0) ?
'color: green;' :
'color: red;').
'">'.round(isset($val[
'nb_diff']) ? $val[
'nb_diff'] : 0).
'</td>';
301 print
'</div><div class="fichetwothirdright">';
305 print
'<table class="border centpercent"><tr class="pair nohover"><td class="center">';
315 print
'</td></tr></table>';
318 print
'</div></div>';
319 print
'<div style="clear:both"></div>';
static getDefaultGraphSizeForStats($direction, $defaultsize='')
getDefaultGraphSizeForStats
Classe permettant la gestion des stats des deplacements et notes de frais.
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.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
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)
Class to generate the form for creating a new ticket.
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.