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';
38$hookmanager->initHooks(array(
'ticketsindex'));
41$langs->loadLangs(array(
'companies',
'other',
'ticket'));
50$action =
GETPOST(
'action',
'aZ09');
54 $socid = $user->socid;
59$nowyear = $nowarray[
'year'];
69if (!$user->hasRight(
'ticket',
'read') && !$user->hasRight(
'knowledgemanagement',
'knowledgerecord',
'read')) {
91llxHeader(
'', $langs->trans(
'TicketsIndex'), $help_url,
'', 0, 0,
'',
'',
'',
'mod-ticket page-dashboard');
94print
load_fiche_titre($langs->trans(
'TicketsIndex'), $resultboxes[
'selectboxlist'],
'ticket');
99$filenamenb = $dir.
"/".$prefix.
"ticketinyear-".$endyear.
".png";
100$fileurlnb = DOL_URL_ROOT.
'/viewimage.php?modulepart=ticket&file=ticketinyear-'.$endyear.
'.png';
103$param_year =
'DOLUSERCOOKIE_ticket_by_status_year';
104$param_shownb =
'DOLUSERCOOKIE_ticket_by_status_shownb';
105$param_showtot =
'DOLUSERCOOKIE_ticket_by_status_showtot';
106$autosetarray = preg_split(
"/[,;:]+/",
GETPOST(
'DOL_AUTOSET_COOKIE'));
107if (in_array(
'DOLUSERCOOKIE_ticket_by_status', $autosetarray)) {
109 $shownb =
GETPOST($param_shownb,
'alpha');
110 $showtot =
GETPOST($param_showtot,
'alpha');
111} elseif (!empty($_COOKIE[
'DOLUSERCOOKIE_ticket_by_status'])) {
112 $tmparray = json_decode($_COOKIE[
'DOLUSERCOOKIE_ticket_by_status'],
true);
113 $endyear = $tmparray[
'year'];
114 $shownb = empty($tmparray[
'shownb']) ? 0 : $tmparray[
'shownb'];
115 $showtot = empty($tmparray[
'showtot']) ? 0 : $tmparray[
'showtot'];
117if (empty($shownb) && empty($showtot)) {
122if (empty($endyear)) {
123 $endyear = $nowarray[
'year'];
126$startyear = $endyear - 1;
129$WIDTH = (($shownb && $showtot) || !empty($conf->dol_optimize_smallscreen)) ?
'100%' :
'80%';
130if (empty($conf->dol_optimize_smallscreen)) {
136print
'<div class="clearboth"></div>';
137print
'<div class="fichecenter fichecenterbis">';
139print
'<div class="twocolumns">';
141print
'<div class="firstcolumn fichehalfleft boxhalfleft" id="boxhalfleft">';
159$sql =
"SELECT t.fk_statut, COUNT(t.fk_statut) as nb";
160$sql .=
" FROM ".MAIN_DB_PREFIX.
"ticket as t";
161if (!$user->hasRight(
'societe',
'client',
'voir')) {
162 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
164$sql .=
' WHERE t.entity IN ('.getEntity(
'ticket').
')';
167if (!$user->hasRight(
'societe',
'client',
'voir')) {
168 $sql .=
" AND t.fk_soc = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
172if ($user->socid > 0) {
173 $sql .=
" AND t.fk_soc= ".((int) $user->socid);
176 if (
getDolGlobalString(
'TICKET_LIMIT_VIEW_ASSIGNED_ONLY') && !$user->hasRight(
'ticket',
'manage')) {
177 $sql .=
" AND t.fk_user_assign = ".((int) $user->id);
180$sql .=
" GROUP BY t.fk_statut";
182$result = $db->query($sql);
184 while ($objp = $db->fetch_object($result)) {
186 if ($objp->fk_statut == Ticket::STATUS_NOT_READ) {
187 $tick[
'unread'] = $objp->nb;
189 if ($objp->fk_statut == Ticket::STATUS_READ) {
190 $tick[
'read'] = $objp->nb;
192 if ($objp->fk_statut == Ticket::STATUS_NEED_MORE_INFO) {
193 $tick[
'needmoreinfo'] = $objp->nb;
195 if ($objp->fk_statut == Ticket::STATUS_ASSIGNED) {
196 $tick[
'assigned'] = $objp->nb;
198 if ($objp->fk_statut == Ticket::STATUS_IN_PROGRESS) {
199 $tick[
'inprogress'] = $objp->nb;
201 if ($objp->fk_statut == Ticket::STATUS_WAITING) {
202 $tick[
'waiting'] = $objp->nb;
204 if ($objp->fk_statut == Ticket::STATUS_CLOSED) {
205 $tick[
'closed'] = $objp->nb;
207 if ($objp->fk_statut == Ticket::STATUS_CANCELED) {
208 $tick[
'canceled'] = $objp->nb;
212 include DOL_DOCUMENT_ROOT.
'/theme/'.$conf->theme.
'/theme_vars.inc.php';
214 $dataseries = array();
215 $colorseries = array();
217 $dataseries[] = array(
'label' => $langs->transnoentitiesnoconv(
$object->labelStatusShort[Ticket::STATUS_NOT_READ]),
'data' => round($tick[
'unread']));
219 $dataseries[] = array(
'label' => $langs->transnoentitiesnoconv(
$object->labelStatusShort[Ticket::STATUS_READ]),
'data' => round($tick[
'read']));
220 $colorseries[Ticket::STATUS_READ] = $badgeStatus1;
221 $dataseries[] = array(
'label' => $langs->transnoentitiesnoconv(
$object->labelStatusShort[Ticket::STATUS_ASSIGNED]),
'data' => round($tick[
'assigned']));
222 $colorseries[Ticket::STATUS_ASSIGNED] = $badgeStatus3;
223 $dataseries[] = array(
'label' => $langs->transnoentitiesnoconv(
$object->labelStatusShort[Ticket::STATUS_IN_PROGRESS]),
'data' => round($tick[
'inprogress']));
224 $colorseries[Ticket::STATUS_IN_PROGRESS] = $badgeStatus4;
226 $dataseries[] = array(
'label' => $langs->transnoentitiesnoconv(
$object->labelStatusShort[Ticket::STATUS_WAITING]),
'data' => round($tick[
'waiting']));
227 $colorseries[Ticket::STATUS_WAITING] =
'-'.$badgeStatus4;
229 $dataseries[] = array(
'label' => $langs->transnoentitiesnoconv(
$object->labelStatusShort[Ticket::STATUS_NEED_MORE_INFO]),
'data' => round($tick[
'needmoreinfo']));
230 $colorseries[Ticket::STATUS_NEED_MORE_INFO] =
'-'.$badgeStatus3;
231 $dataseries[] = array(
'label' => $langs->transnoentitiesnoconv(
$object->labelStatusShort[Ticket::STATUS_CANCELED]),
'data' => round($tick[
'canceled']));
232 $colorseries[Ticket::STATUS_CANCELED] = $badgeStatus9;
233 $dataseries[] = array(
'label' => $langs->transnoentitiesnoconv(
$object->labelStatusShort[Ticket::STATUS_CLOSED]),
'data' => round($tick[
'closed']));
234 $colorseries[Ticket::STATUS_CLOSED] = $badgeStatus6;
239$stringtoshow =
'<script type="text/javascript">
240 jQuery(document).ready(function() {
241 jQuery("#idsubimgDOLUSERCOOKIE_ticket_by_status").click(function() {
242 jQuery("#idfilterDOLUSERCOOKIE_ticket_by_status").toggle();
246$stringtoshow .=
'<div class="center hideobject" id="idfilterDOLUSERCOOKIE_ticket_by_status">';
247$stringtoshow .=
'<form class="flat formboxfilter" method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
248$stringtoshow .=
'<input type="hidden" name="token" value="'.newToken().
'">';
249$stringtoshow .=
'<input type="hidden" name="action" value="refresh">';
250$stringtoshow .=
'<input type="hidden" name="DOL_AUTOSET_COOKIE" value="DOLUSERCOOKIE_ticket_by_status:year,shownb,showtot">';
251$stringtoshow .= $langs->trans(
"Year").
' <input class="flat" size="4" type="text" name="'.$param_year.
'" value="'.$endyear.
'">';
252$stringtoshow .=
'<input type="image" alt="'.$langs->trans(
"Refresh").
'" src="'.
img_picto($langs->trans(
"Refresh"),
'refresh.png',
'',
'', 1).
'">';
253$stringtoshow .=
'</form>';
254$stringtoshow .=
'</div>';
256if ($user->hasRight(
'ticket',
'read')) {
257 print
'<div class="div-table-responsive-no-min">';
258 print
'<table class="noborder centpercent">';
259 print
'<tr class="liste_titre"><th >'.$langs->trans(
"Statistics").
' '.$endyear.
' '.
img_picto(
'',
'filter.png',
'id="idsubimgDOLUSERCOOKIE_ticket_by_status" class="linkobject"').
'</th></tr>';
261 print
'<tr><td class="center">';
265 if (!empty($dataseries) && count($dataseries) > 1) {
267 foreach ($dataseries as $key => $value) {
268 $totalnb += $value[
'data'];
272 foreach ($dataseries as $key => $value) {
273 $data[] = array($value[
'label'], $value[
'data']);
276 $mesg = $px1->isGraphKo();
278 $px1->SetData($data);
279 $px1->SetDataColor(array_values($colorseries));
284 while ($i <= $endyear) {
288 $px1->setShowLegend(2);
289 $px1->SetType(array(
'pie'));
290 $px1->SetLegend($legend);
291 $px1->SetMaxValue($px1->GetCeilMaxValue());
293 $px1->SetHeight($HEIGHT);
294 $px1->SetYLabel($langs->trans(
"TicketStatByStatus"));
296 $px1->SetHorizTickIncrement(1);
297 $px1->SetCssPrefix(
"cssboxes");
298 $px1->mode =
'depth';
301 $px1->draw($filenamenb, $fileurlnb);
302 print $px1->show($totalnb ? 0 : 1);
311if ($user->hasRight(
'ticket',
'read')) {
313 $data = $stats->getNbByMonthWithPrevYear($endyear, $startyear);
318print $resultboxes[
'boxlista'];
322print
'<div class="secondcolumn fichehalfright boxhalfright" id="boxhalfright">';
324if ($user->hasRight(
'ticket',
'read')) {
329 $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,";
330 $sql .=
" type.code as type_code, type.label as type_label,";
331 $sql .=
" category.code as category_code, category.label as category_label,";
332 $sql .=
" severity.code as severity_code, severity.label as severity_label";
333 $sql .=
" FROM ".MAIN_DB_PREFIX.
"ticket as t";
334 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_ticket_type as type ON type.code=t.type_code";
335 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_ticket_category as category ON category.code=t.category_code";
336 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_ticket_severity as severity ON severity.code=t.severity_code";
337 if (!$user->hasRight(
'societe',
'client',
'voir')) {
338 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
341 $sql .=
' WHERE t.entity IN ('.getEntity(
'ticket').
')';
342 $sql .=
" AND t.fk_statut = 0";
343 if (!$user->hasRight(
'societe',
'client',
'voir')) {
344 $sql .=
" AND t.fk_soc = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
347 if ($user->socid > 0) {
348 $sql .=
" AND t.fk_soc= ".((int) $user->socid);
351 if (
getDolGlobalString(
'TICKET_LIMIT_VIEW_ASSIGNED_ONLY') && !$user->hasRight(
'ticket',
'manage')) {
352 $sql .=
" AND t.fk_user_assign = ".((int) $user->id);
355 $sql .= $db->order(
"t.datec",
"DESC");
356 $sql .= $db->plimit($max, 0);
359 $result = $db->query($sql);
361 $num = $db->num_rows($result);
365 $tmpmax =
getDolGlobalInt(
'MAIN_SIZE_SHORTLIST_LIMIT_LAST_MODIFIED_TICKETS', $max);
366 $transRecordedType = $langs->trans(
"LatestNewTickets", $tmpmax);
368 print
'<div class="div-table-responsive-no-min">';
369 print
'<table class="noborder centpercent">';
370 print
'<tr class="liste_titre"><th colspan="5">'.$transRecordedType;
371 print
'<a href="'.DOL_URL_ROOT.
'/ticket/list.php?search_fk_statut[]='.
Ticket::STATUS_NOT_READ.
'" title="'.$langs->trans(
"FullList").
'">';
372 print
'<span class="badge marginleftonlyshort">...</span>';
383 $objp = $db->fetch_object($result);
387 $object->track_id = $objp->track_id;
388 $object->status = $objp->status;
389 $object->progress = $objp->progress;
390 $object->subject = $objp->subject;
392 print
'<tr class="oddeven">';
395 print
'<td class="nowraponall">';
400 print
'<td class="center nowraponall">';
405 print
'<td class="nowrap">';
406 print
'<a href="card.php?track_id='.$objp->track_id.
'">'.
dol_trunc($objp->subject, 30).
'</a>';
410 print
'<td class="nowrap tdoverflowmax100">';
411 $s = $langs->getLabelFromKey($db,
'TicketTypeShort'.$objp->type_code,
'c_ticket_type',
'code',
'label', $objp->type_code);
412 print
'<span title="'.dol_escape_htmltag($s).
'">'.$s.
'</span>';
416 print
'<td class="nowrap">';
417 if (!empty($objp->category_code)) {
418 $s = $langs->getLabelFromKey($db,
'TicketCategoryShort'.$objp->category_code,
'c_ticket_category',
'code',
'label', $objp->category_code);
419 print
'<span title="'.dol_escape_htmltag($s).
'">'.$s.
'</span>';
425 print
'<td class="nowrap">';
426 $s = $langs->getLabelFromKey($db,
'TicketSeverityShort'.$objp->severity_code,
'c_ticket_severity',
'code',
'label', $objp->severity_code);
427 print
'<span title="'.dol_escape_htmltag($s).
'">'.$s.
'</span>';
431 print
'<td class="nowraponall right">';
432 print
$object->getLibStatut(5);
441 print
'<tr><td colspan="7"><span class="opacitymedium">'.$langs->trans(
'NoUnreadTicketsFound').
'</span></td></tr>';
453print $resultboxes[
'boxlistb'];
460print
'<div class="clearboth"></div>';
462$parameters = array(
'user' => $user);
463$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()
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.
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 dolibarr global constant string value.
dol_getdate($timestamp, $fast=false, $forcetimezone='')
Return an array with locale date info.
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.