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';
33 if (!$user->rights->ticket->read) {
37 $object_status =
GETPOST(
'object_status',
'intcomma');
39 $userid =
GETPOST(
'userid',
'int');
40 $socid =
GETPOST(
'socid',
'int');
42 if ($user->socid > 0) {
44 $socid = $user->socid;
47 $nowyear = strftime(
"%Y",
dol_now());
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(
'orders',
'companies',
'other',
'tickets'));
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) {
74 $stats->where .=
' AND fk_statut IN ('.$db->sanitize($db->escape($object_status)).
')';
79 $data = $stats->getNbByMonthWithPrevYear($endyear, $startyear);
85 if (empty($user->rights->societe->client->voir) || $user->socid) {
86 $filenamenb = $dir.
'/ticketsnbinyear-'.$user->id.
'-'.$year.
'.png';
87 $fileurlnb = DOL_URL_ROOT.
'/viewimage.php?modulepart=ticketstats&file=ticketsnbinyear-'.$user->id.
'-'.$year.
'.png';
89 $filenamenb = $dir.
'/ticketsnbinyear-'.$year.
'.png';
90 $fileurlnb = DOL_URL_ROOT.
'/viewimage.php?modulepart=ticketstats&file=ticketsnbinyear-'.$year.
'.png';
94 $mesg = $px1->isGraphKo();
97 $i = $startyear; $legend = array();
98 while ($i <= $endyear) {
102 $px1->SetLegend($legend);
103 $px1->SetMaxValue($px1->GetCeilMaxValue());
104 $px1->SetMinValue(min(0, $px1->GetFloorMinValue()));
105 $px1->SetWidth($WIDTH);
106 $px1->SetHeight($HEIGHT);
107 $px1->SetYLabel($langs->trans(
"NbOfTicket"));
109 $px1->SetHorizTickIncrement(1);
110 $px1->mode =
'depth';
111 $px1->SetTitle($langs->trans(
"NumberOfTicketsByMonth"));
113 $px1->draw($filenamenb, $fileurlnb);
117 $data = $stats->getAmountByMonthWithPrevYear($endyear, $startyear);
121 if (empty($user->rights->societe->client->voir) || $user->socid) {
122 $filenameamount = $dir.
'/ticketsamountinyear-'.$user->id.
'-'.$year.
'.png';
123 $fileurlamount = DOL_URL_ROOT.
'/viewimage.php?modulepart=ticketstats&file=ticketsamountinyear-'.$user->id.
'-'.$year.
'.png';
125 $filenameamount = $dir.
'/ticketsamountinyear-'.$year.
'.png';
126 $fileurlamount = DOL_URL_ROOT.
'/viewimage.php?modulepart=ticketstats&file=ticketsamountinyear-'.$year.
'.png';
130 $mesg = $px2->isGraphKo();
132 $px2->SetData($data);
133 $i = $startyear; $legend = array();
134 while ($i <= $endyear) {
138 $px2->SetLegend($legend);
139 $px2->SetMaxValue($px2->GetCeilMaxValue());
140 $px2->SetMinValue(min(0, $px2->GetFloorMinValue()));
141 $px2->SetWidth($WIDTH);
142 $px2->SetHeight($HEIGHT);
143 $px2->SetYLabel($langs->trans(
"AmountOfTickets"));
145 $px2->SetHorizTickIncrement(1);
146 $px2->mode =
'depth';
147 $px2->SetTitle($langs->trans(
"AmountOfTicketsByMonthHT"));
149 $px2->draw($filenameamount, $fileurlamount);
153 $data = $stats->getAverageByMonthWithPrevYear($endyear, $startyear);
155 if (empty($user->rights->societe->client->voir) || $user->socid) {
156 $filename_avg = $dir.
'/ticketsaverage-'.$user->id.
'-'.$year.
'.png';
157 $fileurl_avg = DOL_URL_ROOT.
'/viewimage.php?modulepart=ticketstats&file=ticketsaverage-'.$user->id.
'-'.$year.
'.png';
159 $filename_avg = $dir.
'/ticketsaverage-'.$year.
'.png';
160 $fileurl_avg = DOL_URL_ROOT.
'/viewimage.php?modulepart=ticketstats&file=ticketsaverage-'.$year.
'.png';
164 $mesg = $px3->isGraphKo();
166 $px3->SetData($data);
167 $i = $startyear; $legend = array();
168 while ($i <= $endyear) {
172 $px3->SetLegend($legend);
173 $px3->SetYLabel($langs->trans(
"AmountAverage"));
174 $px3->SetMaxValue($px3->GetCeilMaxValue());
175 $px3->SetMinValue($px3->GetFloorMinValue());
176 $px3->SetWidth($WIDTH);
177 $px3->SetHeight($HEIGHT);
179 $px3->SetHorizTickIncrement(1);
180 $px3->mode =
'depth';
181 $px3->SetTitle($langs->trans(
"AmountAverage"));
183 $px3->draw($filename_avg, $fileurl_avg);
189 $data = $stats->getAllByYear();
190 $arrayyears = array();
191 foreach ($data as $val) {
192 if (!empty($val[
'year'])) {
193 $arrayyears[$val[
'year']] = $val[
'year'];
196 if (!count($arrayyears)) {
197 $arrayyears[$nowyear] = $nowyear;
202 $head[$h][0] = DOL_URL_ROOT.
'/ticket/stats/index.php';
203 $head[$h][1] = $langs->trans(
"ByMonthYear");
204 $head[$h][2] =
'byyear';
207 $type =
'ticket_stats';
214 print
'<div class="fichecenter"><div class="fichethirdleft">';
218 print
'<form name="stats" method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
219 print
'<input type="hidden" name="token" value="'.newToken().
'">';
221 print
'<table class="noborder centpercent">';
222 print
'<tr class="liste_titre"><td class="liste_titre" colspan="2">'.$langs->trans(
"Filter").
'</td></tr>';
224 print
'<tr><td class="left">'.$langs->trans(
"ThirdParty").
'</td><td class="left">';
225 print
img_picto(
'',
'company',
'class="pictofixedwidth"');
226 print
$form->select_company($socid,
'socid',
'', 1, 0, 0, array(), 0,
'widthcentpercentminusx maxwidth300',
'');
229 print
'<tr><td class="left">'.$langs->trans(
"CreatedBy").
'</td><td class="left">';
230 print
img_picto(
'',
'user',
'class="pictofixedwidth"');
231 print
$form->select_dolusers($userid,
'userid', 1,
'', 0,
'',
'', 0, 0, 0,
'', 0,
'',
'widthcentpercentminusx maxwidth300');
233 print
'<tr><td class="left">'.$langs->trans(
"Status").
'</td><td class="left">';
234 $liststatus = $object->fields[
'fk_statut'][
'arrayofkeyval'];
235 print
$form->selectarray(
'object_status', $liststatus,
GETPOST(
'object_status',
'intcomma'), -4, 0, 0,
'', 1);
238 print
'<tr><td class="left">'.$langs->trans(
"Year").
'</td><td class="left">';
239 if (!in_array($year, $arrayyears)) {
240 $arrayyears[$year] = $year;
242 if (!in_array($nowyear, $arrayyears)) {
243 $arrayyears[$nowyear] = $nowyear;
246 print
$form->selectarray(
'year', $arrayyears, $year, 0, 0, 0,
'', 0, 0, 0,
'',
'width75');
248 print
'<tr><td class="center" colspan="2"><input type="submit" name="submit" class="button small" value="'.$langs->trans(
"Refresh").
'"></td></tr>';
254 print
'<div class="div-table-responsive-no-min">';
255 print
'<table class="noborder centpercent">';
256 print
'<tr class="liste_titre" height="24">';
257 print
'<td class="center">'.$langs->trans(
"Year").
'</td>';
258 print
'<td class="right">'.$langs->trans(
"NbOfTickets").
'</td>';
259 print
'<td class="right">%</td>';
267 foreach ($data as $val) {
268 $year = $val[
'year'];
269 while (!empty($year) && $oldyear > $year + 1) {
272 print
'<tr class="oddeven" height="24">';
273 print
'<td class="center"><a href="'.$_SERVER[
"PHP_SELF"].
'?year='.$oldyear.($socid > 0 ?
'&socid='.$socid :
'').($userid > 0 ?
'&userid='.$userid :
'').
'">'.$oldyear.
'</a></td>';
274 print
'<td class="right">0</td>';
275 print
'<td class="right"></td>';
284 print
'<tr class="oddeven" height="24">';
285 print
'<td class="center"><a href="'.$_SERVER[
"PHP_SELF"].
'?year='.$year.($socid > 0 ?
'&socid='.$socid :
'').($userid > 0 ?
'&userid='.$userid :
'').
'">'.$year.
'</a></td>';
286 print
'<td class="right">'.$val[
'nb'].
'</td>';
287 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>';
300 print
'</div><div class="fichetwothirdright">';
304 print
'<table class="border centpercent"><tr class="pair nohover"><td class="center">';
314 print
'</td></tr></table>';
317 print
'</div></div>';
318 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.
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.
img_picto($titlealt, $picto, $moreatt= '', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt= '', $morecss= '', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
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.
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).