27require
'../../main.inc.php';
35require_once DOL_DOCUMENT_ROOT.
'/ticket/class/actions_ticket.class.php';
36require_once DOL_DOCUMENT_ROOT.
'/ticket/class/ticketstats.class.php';
37require_once DOL_DOCUMENT_ROOT.
'/ticket/class/ticket.class.php';
38require_once DOL_DOCUMENT_ROOT.
'/core/class/dolgraph.class.php';
43$hookmanager->initHooks(array(
'ticketstats',
'globalcard'));
45if (!$user->hasRight(
'ticket',
'read')) {
49$object_status =
GETPOST(
'object_status',
'intcomma');
54if ($user->socid > 0) {
56 $socid = $user->socid;
60$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
71$langs->loadLangs(array(
'orders',
'companies',
'other',
'tickets'));
81$dir =
$conf->ticket->dir_temp;
83$title = $langs->trans(
"Statistics");
86llxHeader(
'', $title, $help_url,
'', 0, 0,
'',
'',
'',
'mod-ticket page-stats');
93 $params += [
'socid' => $socid];
95$url =
dolBuildUrl(DOL_URL_ROOT.
'/ticket/card.php', $params);
97$newcardbutton .= dolGetButtonTitle($langs->trans(
'ViewList'),
'',
'fa fa-bars imgforviewmode', DOL_URL_ROOT.
'/ticket/list.php?mode=common',
'', 1, array(
'morecss' =>
'reposition'));
98$newcardbutton .= dolGetButtonTitle($langs->trans(
'ViewKanban'),
'',
'fa fa-th-list imgforviewmode', DOL_URL_ROOT.
'/ticket/list.php?mode=kanban',
'', 1, array(
'morecss' =>
'reposition'));
99$newcardbutton .= dolGetButtonTitle($langs->trans(
'Statistics'),
'',
'fa fa-chart-bar imgforviewmode', DOL_URL_ROOT.
'/ticket/stats/index.php?mode=statistics&objecttype=ticket@ticket',
'', 2, array(
'morecss' =>
'reposition'));
100$newcardbutton .= dolGetButtonTitleSeparator();
101$newcardbutton .= dolGetButtonTitle($langs->trans(
'NewTicket'),
'',
'fa fa-plus-circle', $url,
'', $user->hasRight(
'ticket',
'write'));
103print_barre_liste($langs->trans(
'Tickets'), 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', 0, $langs->trans(
"Statistics"),
$object->picto, 0, $newcardbutton,
'', 0, 0, 0, 1);
107$stats =
new TicketStats(
$db, $socid, ($userid > 0 ? $userid : 0));
108if ($object_status !=
'' && $object_status >= -1) {
109 $stats->where .=
' AND fk_statut IN ('.$db->sanitize(
$db->escape($object_status)).
')';
114$data = $stats->getNbByMonthWithPrevYear($endyear, $startyear);
119if (!$user->hasRight(
'societe',
'client',
'voir')) {
120 $filenamenb = $dir.
'/ticketsnbinyear-'.$user->id.
'-'.$year.
'.png';
121 $fileurlnb = DOL_URL_ROOT.
'/viewimage.php?modulepart=ticketstats&file=ticketsnbinyear-'.$user->id.
'-'.$year.
'.png';
123 $filenamenb = $dir.
'/ticketsnbinyear-'.$year.
'.png';
124 $fileurlnb = DOL_URL_ROOT.
'/viewimage.php?modulepart=ticketstats&file=ticketsnbinyear-'.$year.
'.png';
128$mesg = $px1->isGraphKo();
130 $px1->SetData($data);
133 while ($i <= $endyear) {
137 $px1->SetLegend($legend);
138 $px1->SetMaxValue($px1->GetCeilMaxValue());
139 $px1->SetMinValue(min(0, $px1->GetFloorMinValue()));
140 $px1->SetWidth($WIDTH);
141 $px1->SetHeight($HEIGHT);
142 $px1->SetYLabel($langs->trans(
"NbOfTicket"));
144 $px1->SetHorizTickIncrement(1);
145 $px1->mode =
'depth';
146 $px1->SetTitle($langs->trans(
"NumberOfTicketsByMonth"));
148 $px1->draw($filenamenb, $fileurlnb);
152$data = $stats->getAmountByMonthWithPrevYear($endyear, $startyear);
157$data = $stats->getAllByYear();
158$arrayyears = array();
159foreach ($data as $val) {
160 if (!empty($val[
'year'])) {
161 $arrayyears[$val[
'year']] = $val[
'year'];
164if (!count($arrayyears)) {
165 $arrayyears[$nowyear] = $nowyear;
170$head[$h][0] = DOL_URL_ROOT.
'/ticket/stats/index.php';
171$head[$h][1] = $langs->trans(
"ByMonthYear");
172$head[$h][2] =
'byyear';
175$type =
'ticket_stats';
182print
'<div class="fichecenter"><div class="fichethirdleft">';
186print
'<form name="stats" method="POST" action="'.dolBuildUrl($_SERVER[
"PHP_SELF"]).
'">';
187print
'<input type="hidden" name="token" value="'.newToken().
'">';
189print
'<table class="noborder centpercent">';
190print
'<tr class="liste_titre"><td class="liste_titre" colspan="2">'.$langs->trans(
"Filter").
'</td></tr>';
192print
'<tr><td class="left">'.$langs->trans(
"ThirdParty").
'</td><td class="left">';
193print
img_picto(
'',
'company',
'class="pictofixedwidth"');
194print $form->select_company($socid,
'socid',
'', 1, 0, 0, array(), 0,
'widthcentpercentminusx maxwidth300',
'');
197print
'<tr><td class="left">'.$langs->trans(
"CreatedBy").
'</td><td class="left">';
198print
img_picto(
'',
'user',
'class="pictofixedwidth"');
199print $form->select_dolusers($userid,
'userid', 1,
null, 0,
'',
'',
'0', 0, 0,
'', 0,
'',
'widthcentpercentminusx maxwidth300');
201print
'<tr><td class="left">'.$langs->trans(
"Status").
'</td><td class="left">';
202$liststatus =
$object->fields[
'fk_statut'][
'arrayofkeyval'];
203print
img_picto(
'',
'status',
'class="pictofixedwidth"');
204print $form->selectarray(
'object_status', $liststatus,
GETPOST(
'object_status',
'intcomma'), -4, 0, 0,
'', 1);
207print
'<tr><td class="left">'.$langs->trans(
"Year").
'</td><td class="left">';
208if (!in_array($year, $arrayyears)) {
209 $arrayyears[$year] = $year;
211if (!in_array($nowyear, $arrayyears)) {
212 $arrayyears[$nowyear] = $nowyear;
215print
img_picto(
'',
'calendar',
'class="pictofixedwidth"');
216print $form->selectarray(
'year', $arrayyears, $year, 0, 0, 0,
'', 0, 0, 0,
'',
'width75');
218print
'<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" height="24">';
227print
'<td class="center">'.$langs->trans(
"Year").
'</td>';
228print
'<td class="right">'.$langs->trans(
"NbOfTickets").
'</td>';
229print
'<td class="right opacitylow">%</td>';
237foreach ($data as $val) {
238 $year = $val[
'year'];
239 while (!empty($year) && $oldyear > (
int) $year + 1) {
242 print
'<tr class="oddeven" height="24">';
243 print
'<td class="center"><a href="'.$_SERVER[
"PHP_SELF"].
'?year='.$oldyear.($socid > 0 ?
'&socid='.$socid :
'').($userid > 0 ?
'&userid='.$userid :
'').
'">'.$oldyear.
'</a></td>';
244 print
'<td class="right">0</td>';
245 print
'<td class="right"></td>';
254 print
'<tr class="oddeven" height="24">';
255 print
'<td class="center"><a href="'.$_SERVER[
"PHP_SELF"].
'?year='.$year.($socid > 0 ?
'&socid='.$socid :
'').($userid > 0 ?
'&userid='.$userid :
'').
'">'.$year.
'</a></td>';
256 print
'<td class="right">'.$val[
'nb'].
'</td>';
257 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>';
270print
'</div><div class="fichetwothirdright">';
274print
'<table class="border centpercent"><tr class="pair nohover"><td class="center">';
284print
'</td></tr></table>';
288print
'<div class="clearboth"></div>';
if(! $sortfield) if(! $sortorder) $object
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 the ticket stats.
dol_now($mode='gmt')
Return date for now.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
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.
dolBuildUrl($url, $params=[], $addtoken=false, $anchor='')
Return path of url.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
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)
Class to generate the form for creating a new ticket.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.