27require
'../main.inc.php';
28require_once DOL_DOCUMENT_ROOT.
'/core/class/dolgraph.class.php';
29require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formother.class.php';
30require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
31require_once DOL_DOCUMENT_ROOT.
'/ticket/class/actions_ticket.class.php';
32require_once DOL_DOCUMENT_ROOT.
'/ticket/class/ticketstats.class.php';
44$hookmanager->initHooks(array(
'ticketsindex'));
47$langs->loadLangs(array(
'companies',
'other',
'ticket'));
56$action =
GETPOST(
'action',
'aZ09');
60 $socid = $user->socid;
65$nowyear = $nowarray[
'year'];
75if (!$user->hasRight(
'ticket',
'read') && !$user->hasRight(
'knowledgemanagement',
'knowledgerecord',
'read')) {
97llxHeader(
'', $langs->trans(
'TicketsIndex'), $help_url,
'', 0, 0,
'',
'',
'',
'mod-ticket page-dashboard');
100print
load_fiche_titre($langs->trans(
'TicketsIndex'), $resultboxes[
'selectboxlist'],
'ticket');
105$filenamenb = $dir.
"/".$prefix.
"ticketinyear-".$endyear.
".png";
106$fileurlnb = DOL_URL_ROOT.
'/viewimage.php?modulepart=ticket&file=ticketinyear-'.$endyear.
'.png';
109$param_year =
'DOLUSERCOOKIE_ticket_by_status_year';
110$param_shownb =
'DOLUSERCOOKIE_ticket_by_status_shownb';
111$param_showtot =
'DOLUSERCOOKIE_ticket_by_status_showtot';
112$autosetarray = preg_split(
"/[,;:]+/",
GETPOST(
'DOL_AUTOSET_COOKIE'));
113if (in_array(
'DOLUSERCOOKIE_ticket_by_status', $autosetarray)) {
115 $shownb =
GETPOST($param_shownb,
'alpha');
116 $showtot =
GETPOST($param_showtot,
'alpha');
117} elseif (!empty($_COOKIE[
'DOLUSERCOOKIE_ticket_by_status'])) {
118 $tmparray = json_decode($_COOKIE[
'DOLUSERCOOKIE_ticket_by_status'],
true);
119 $endyear = $tmparray[
'year'];
120 $shownb = empty($tmparray[
'shownb']) ? 0 : $tmparray[
'shownb'];
121 $showtot = empty($tmparray[
'showtot']) ? 0 : $tmparray[
'showtot'];
123if (empty($shownb) && empty($showtot)) {
128if (empty($endyear)) {
129 $endyear = $nowarray[
'year'];
132$startyear = $endyear - 1;
135$WIDTH = (($shownb && $showtot) || !empty(
$conf->dol_optimize_smallscreen)) ?
'100%' :
'80%';
136if (empty(
$conf->dol_optimize_smallscreen)) {
142print
'<div class="clearboth"></div>';
143print
'<div class="fichecenter fichecenterbis">';
145print
'<div class="twocolumns">';
147print
'<div class="firstcolumn fichehalfleft boxhalfleft" id="boxhalfleft">';
165$sql =
"SELECT t.fk_statut, COUNT(t.fk_statut) as nb";
166$sql .=
" FROM ".MAIN_DB_PREFIX.
"ticket as t";
167if (!$user->hasRight(
'societe',
'client',
'voir')) {
168 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
170$sql .=
' WHERE t.entity IN ('.getEntity(
'ticket').
')';
173if (!$user->hasRight(
'societe',
'client',
'voir')) {
174 $sql .=
" AND t.fk_soc = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
178if ($user->socid > 0) {
179 $sql .=
" AND t.fk_soc= ".((int) $user->socid);
182 if (
getDolGlobalString(
'TICKET_LIMIT_VIEW_ASSIGNED_ONLY') && !$user->hasRight(
'ticket',
'manage')) {
183 $sql .=
" AND t.fk_user_assign = ".((int) $user->id);
186$sql .=
" GROUP BY t.fk_statut";
188$result = $db->query($sql);
190 while ($objp = $db->fetch_object($result)) {
192 if ($objp->fk_statut == Ticket::STATUS_NOT_READ) {
193 $tick[
'unread'] = $objp->nb;
195 if ($objp->fk_statut == Ticket::STATUS_READ) {
196 $tick[
'read'] = $objp->nb;
198 if ($objp->fk_statut == Ticket::STATUS_NEED_MORE_INFO) {
199 $tick[
'needmoreinfo'] = $objp->nb;
201 if ($objp->fk_statut == Ticket::STATUS_ASSIGNED) {
202 $tick[
'assigned'] = $objp->nb;
204 if ($objp->fk_statut == Ticket::STATUS_IN_PROGRESS) {
205 $tick[
'inprogress'] = $objp->nb;
207 if ($objp->fk_statut == Ticket::STATUS_WAITING) {
208 $tick[
'waiting'] = $objp->nb;
210 if ($objp->fk_statut == Ticket::STATUS_CLOSED) {
211 $tick[
'closed'] = $objp->nb;
213 if ($objp->fk_statut == Ticket::STATUS_CANCELED) {
214 $tick[
'canceled'] = $objp->nb;
218 include DOL_DOCUMENT_ROOT.
'/theme/'.
$conf->theme.
'/theme_vars.inc.php';
220 $dataseries = array();
221 $colorseries = array();
223 $dataseries[] = array(
'label' => $langs->transnoentitiesnoconv(
$object->labelStatusShort[Ticket::STATUS_NOT_READ]),
'data' => round($tick[
'unread']));
225 $dataseries[] = array(
'label' => $langs->transnoentitiesnoconv(
$object->labelStatusShort[Ticket::STATUS_READ]),
'data' => round($tick[
'read']));
226 $colorseries[Ticket::STATUS_READ] = $badgeStatus1;
227 $dataseries[] = array(
'label' => $langs->transnoentitiesnoconv(
$object->labelStatusShort[Ticket::STATUS_ASSIGNED]),
'data' => round($tick[
'assigned']));
228 $colorseries[Ticket::STATUS_ASSIGNED] = $badgeStatus3;
229 $dataseries[] = array(
'label' => $langs->transnoentitiesnoconv(
$object->labelStatusShort[Ticket::STATUS_IN_PROGRESS]),
'data' => round($tick[
'inprogress']));
230 $colorseries[Ticket::STATUS_IN_PROGRESS] = $badgeStatus4;
232 $dataseries[] = array(
'label' => $langs->transnoentitiesnoconv(
$object->labelStatusShort[Ticket::STATUS_WAITING]),
'data' => round($tick[
'waiting']));
233 $colorseries[Ticket::STATUS_WAITING] =
'-'.$badgeStatus4;
235 $dataseries[] = array(
'label' => $langs->transnoentitiesnoconv(
$object->labelStatusShort[Ticket::STATUS_NEED_MORE_INFO]),
'data' => round($tick[
'needmoreinfo']));
236 $colorseries[Ticket::STATUS_NEED_MORE_INFO] =
'-'.$badgeStatus3;
237 $dataseries[] = array(
'label' => $langs->transnoentitiesnoconv(
$object->labelStatusShort[Ticket::STATUS_CANCELED]),
'data' => round($tick[
'canceled']));
238 $colorseries[Ticket::STATUS_CANCELED] = $badgeStatus9;
239 $dataseries[] = array(
'label' => $langs->transnoentitiesnoconv(
$object->labelStatusShort[Ticket::STATUS_CLOSED]),
'data' => round($tick[
'closed']));
240 $colorseries[Ticket::STATUS_CLOSED] = $badgeStatus6;
245$stringtoshow =
'<script type="text/javascript">
246 jQuery(document).ready(function() {
247 jQuery("#idsubimgDOLUSERCOOKIE_ticket_by_status").click(function() {
248 jQuery("#idfilterDOLUSERCOOKIE_ticket_by_status").toggle();
252$stringtoshow .=
'<div class="center hideobject" id="idfilterDOLUSERCOOKIE_ticket_by_status">';
253$stringtoshow .=
'<form class="flat formboxfilter" method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
254$stringtoshow .=
'<input type="hidden" name="token" value="'.newToken().
'">';
255$stringtoshow .=
'<input type="hidden" name="action" value="refresh">';
256$stringtoshow .=
'<input type="hidden" name="DOL_AUTOSET_COOKIE" value="DOLUSERCOOKIE_ticket_by_status:year,shownb,showtot">';
257$stringtoshow .= $langs->trans(
"Year").
' <input class="flat" size="4" type="text" name="'.$param_year.
'" value="'.$endyear.
'">';
258$stringtoshow .=
'<input type="image" alt="'.$langs->trans(
"Refresh").
'" src="'.
img_picto($langs->trans(
"Refresh"),
'refresh.png',
'', 0, 1).
'">';
259$stringtoshow .=
'</form>';
260$stringtoshow .=
'</div>';
262if ($user->hasRight(
'ticket',
'read')) {
263 print
'<div class="div-table-responsive-no-min">';
264 print
'<table class="noborder centpercent">';
265 print
'<tr class="liste_titre"><th >'.$langs->trans(
"Statistics").
' '.$endyear.
' '.
img_picto(
'',
'filter.png',
'id="idsubimgDOLUSERCOOKIE_ticket_by_status" class="linkobject"').
'</th></tr>';
267 print
'<tr><td class="center">';
271 if (!empty($dataseries) && count($dataseries) > 1) {
273 foreach ($dataseries as $key => $value) {
274 $totalnb += $value[
'data'];
278 foreach ($dataseries as $key => $value) {
279 $data[] = array($value[
'label'], $value[
'data']);
282 $mesg = $px1->isGraphKo();
284 $px1->SetData($data);
285 $px1->SetDataColor(array_values($colorseries));
290 while ($i <= $endyear) {
294 $px1->setShowLegend(2);
295 $px1->SetType(array(
'pie'));
296 $px1->SetLegend($legend);
297 $px1->SetMaxValue($px1->GetCeilMaxValue());
299 $px1->SetHeight($HEIGHT);
300 $px1->SetYLabel($langs->trans(
"TicketStatByStatus"));
302 $px1->SetHorizTickIncrement(1);
303 $px1->SetCssPrefix(
"cssboxes");
304 $px1->mode =
'depth';
307 $px1->draw($filenamenb, $fileurlnb);
308 print $px1->show($totalnb ? 0 : 1);
317if ($user->hasRight(
'ticket',
'read')) {
319 $data = $stats->getNbByMonthWithPrevYear($endyear, $startyear);
324print $resultboxes[
'boxlista'];
328print
'<div class="secondcolumn fichehalfright boxhalfright" id="boxhalfright">';
330if ($user->hasRight(
'ticket',
'read')) {
335 $sql =
"SELECT t.rowid, t.ref, t.track_id, t.datec, t.subject, t.type_code, t.category_code, t.severity_code, t.fk_statut as status, t.progress,";
336 $sql .=
" type.code as type_code, type.label as type_label,";
337 $sql .=
" category.code as category_code, category.label as category_label,";
338 $sql .=
" severity.code as severity_code, severity.label as severity_label";
339 $sql .=
" FROM ".MAIN_DB_PREFIX.
"ticket as t";
340 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_ticket_type as type ON type.code=t.type_code";
341 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_ticket_category as category ON category.code=t.category_code";
342 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_ticket_severity as severity ON severity.code=t.severity_code";
343 if (!$user->hasRight(
'societe',
'client',
'voir')) {
344 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
347 $sql .=
' WHERE t.entity IN ('.getEntity(
'ticket').
')';
348 $sql .=
" AND t.fk_statut = 0";
349 if (!$user->hasRight(
'societe',
'client',
'voir')) {
350 $sql .=
" AND t.fk_soc = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
353 if ($user->socid > 0) {
354 $sql .=
" AND t.fk_soc= ".((int) $user->socid);
357 if (
getDolGlobalString(
'TICKET_LIMIT_VIEW_ASSIGNED_ONLY') && !$user->hasRight(
'ticket',
'manage')) {
358 $sql .=
" AND t.fk_user_assign = ".((int) $user->id);
361 $sql .= $db->order(
"t.datec",
"DESC");
362 $sql .= $db->plimit($max, 0);
365 $result = $db->query($sql);
367 $num = $db->num_rows($result);
371 $tmpmax =
getDolGlobalInt(
'MAIN_SIZE_SHORTLIST_LIMIT_LAST_MODIFIED_TICKETS', $max);
372 $transRecordedType = $langs->trans(
"LatestNewTickets", $tmpmax);
374 print
'<div class="div-table-responsive-no-min">';
375 print
'<table class="noborder centpercent">';
376 print
'<tr class="liste_titre"><th colspan="5">'.$transRecordedType;
377 print
'<a href="'.DOL_URL_ROOT.
'/ticket/list.php?search_fk_statut[]='.
Ticket::STATUS_NOT_READ.
'" title="'.$langs->trans(
"FullList").
'">';
378 print
'<span class="badge marginleftonlyshort">...</span>';
389 $objp = $db->fetch_object($result);
393 $object->track_id = $objp->track_id;
394 $object->status = $objp->status;
395 $object->progress = $objp->progress;
396 $object->subject = $objp->subject;
398 print
'<tr class="oddeven">';
401 print
'<td class="nowraponall">';
406 print
'<td class="center nowraponall">';
407 print
dol_print_date($db->jdate($objp->datec),
'dayhourreduceformat');
411 print
'<td class="nowrap tdoverflowmax150">';
416 print
'<td class="nowrap tdoverflowmax100">';
417 $s = $langs->getLabelFromKey($db,
'TicketTypeShort'.$objp->type_code,
'c_ticket_type',
'code',
'label', $objp->type_code);
418 print
'<span title="'.dol_escape_htmltag($s).
'">'.$s.
'</span>';
422 print
'<td class="nowrap">';
423 if (!empty($objp->category_code)) {
424 $s = $langs->getLabelFromKey($db,
'TicketCategoryShort'.$objp->category_code,
'c_ticket_category',
'code',
'label', $objp->category_code);
425 print
'<span title="'.dol_escape_htmltag($s).
'">'.$s.
'</span>';
431 print
'<td class="nowrap" title="'.$langs->trans(
"Priority").
'">';
432 $s = $langs->getLabelFromKey($db,
'TicketSeverityShort'.$objp->severity_code,
'c_ticket_severity',
'code',
'label', $objp->severity_code);
433 print
'<span title="'.dol_escape_htmltag($s).
'">'.$s.
'</span>';
437 print
'<td class="nowraponall right">';
438 print
$object->getLibStatut(5);
447 print
'<tr><td colspan="7"><span class="opacitymedium">'.$langs->trans(
'NoUnreadTicketsFound').
'</span></td></tr>';
459print $resultboxes[
'boxlistb'];
466print
'<div class="clearboth"></div>';
468$parameters = array(
'user' => $user);
469$reshook = $hookmanager->executeHooks(
'dashboardTickets', $parameters, $object);
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
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
const STATUS_NOT_READ
Status.
Class to manage the ticket stats.
dolSqlDateFilter($datefield, $day_date, $month_date, $year_date, $excludefirstand=0, $gm=false)
Generate a SQL string to make a filter into a range (for second of date until last second of date).
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
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_now($mode='auto')
Return date for now.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dolPrintHTMLForAttribute($s)
Return a string ready to be output on an HTML attribute (alt, title, data-html, .....
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dol_trunc($string, $size=40, $trunc='right', $stringencoding='UTF-8', $nodot=0, $display=0)
Truncate a string to a particular length adding '…' if string larger than length.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
dol_getdate($timestamp, $fast=false, $forcetimezone='')
Return an array with locale date info.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
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.