26 require
'../main.inc.php';
27 require_once DOL_DOCUMENT_ROOT.
'/core/class/dolgraph.class.php';
28 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formother.class.php';
29 require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
30 require_once DOL_DOCUMENT_ROOT.
'/ticket/class/actions_ticket.class.php';
31 require_once DOL_DOCUMENT_ROOT.
'/ticket/class/ticketstats.class.php';
37 $hookmanager->initHooks(array(
'ticketsindex'));
40 $langs->loadLangs(array(
'companies',
'other',
'ticket'));
47 $msg_id =
GETPOST(
'msg_id',
'int');
49 $action =
GETPOST(
'action',
'aZ09');
53 $socid = $user->socid;
58 $nowyear = $nowarray[
'year'];
59 $year =
GETPOST(
'year',
'int') > 0 ?
GETPOST(
'year',
'int') : $nowyear;
60 $startyear = $year - (empty($conf->global->MAIN_STATS_GRAPHS_SHOW_N_YEARS) ? 2 : max(1, min(10, $conf->global->MAIN_STATS_GRAPHS_SHOW_N_YEARS)));
68 if (empty($user->rights->ticket->read) && empty($user->rights->knowledgemanagement->knowledgerecord->read)) {
90 llxHeader(
'', $langs->trans(
'TicketsIndex'),
'');
93 print
load_fiche_titre($langs->trans(
'TicketsIndex'), $resultboxes[
'selectboxlist'],
'ticket');
97 $filenamenb = $dir.
"/".$prefix.
"ticketinyear-".$endyear.
".png";
98 $fileurlnb = DOL_URL_ROOT.
'/viewimage.php?modulepart=ticket&file=ticketinyear-'.$endyear.
'.png';
101 $param_year =
'DOLUSERCOOKIE_ticket_by_status_year';
102 $param_shownb =
'DOLUSERCOOKIE_ticket_by_status_shownb';
103 $param_showtot =
'DOLUSERCOOKIE_ticket_by_status_showtot';
104 $autosetarray = preg_split(
"/[,;:]+/",
GETPOST(
'DOL_AUTOSET_COOKIE'));
105 if (in_array(
'DOLUSERCOOKIE_ticket_by_status', $autosetarray)) {
106 $endyear =
GETPOST($param_year,
'int');
107 $shownb =
GETPOST($param_shownb,
'alpha');
108 $showtot =
GETPOST($param_showtot,
'alpha');
109 } elseif (!empty($_COOKIE[
'DOLUSERCOOKIE_ticket_by_status'])) {
110 $tmparray = json_decode($_COOKIE[
'DOLUSERCOOKIE_ticket_by_status'],
true);
111 $endyear = $tmparray[
'year'];
112 $shownb = empty($tmparray[
'shownb']) ? 0 : $tmparray[
'shownb'];
113 $showtot = empty($tmparray[
'showtot']) ? 0 : $tmparray[
'showtot'];
115 if (empty($shownb) && empty($showtot)) {
120 if (empty($endyear)) {
121 $endyear = $nowarray[
'year'];
124 $startyear = $endyear - 1;
127 $WIDTH = (($shownb && $showtot) || !empty($conf->dol_optimize_smallscreen)) ?
'100%' :
'80%';
128 if (empty($conf->dol_optimize_smallscreen)) {
134 print
'<div class="clearboth"></div>';
135 print
'<div class="fichecenter fichecenterbis">';
137 print
'<div class="twocolumns">';
139 print
'<div class="firstcolumn fichehalfleft boxhalfleft" id="boxhalfleft">';
157 $sql =
"SELECT t.fk_statut, COUNT(t.fk_statut) as nb";
158 $sql .=
" FROM ".MAIN_DB_PREFIX.
"ticket as t";
159 if (empty($user->rights->societe->client->voir) && !$socid) {
160 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
162 $sql .=
' WHERE t.entity IN ('.getEntity(
'ticket').
')';
165 if (empty($user->rights->societe->client->voir) && !$socid) {
166 $sql .=
" AND t.fk_soc = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
170 if ($user->socid > 0) {
171 $sql .=
" AND t.fk_soc= ".((int) $user->socid);
174 if (!empty($conf->global->TICKET_LIMIT_VIEW_ASSIGNED_ONLY) && !$user->rights->ticket->manage) {
175 $sql .=
" AND t.fk_user_assign = ".((int) $user->id);
178 $sql .=
" GROUP BY t.fk_statut";
180 $result = $db->query($sql);
182 while ($objp = $db->fetch_object($result)) {
185 $tick[
'unread'] = $objp->nb;
187 if ($objp->fk_statut == Ticket::STATUS_READ) {
188 $tick[
'read'] = $objp->nb;
190 if ($objp->fk_statut == Ticket::STATUS_NEED_MORE_INFO) {
191 $tick[
'needmoreinfo'] = $objp->nb;
193 if ($objp->fk_statut == Ticket::STATUS_ASSIGNED) {
194 $tick[
'assigned'] = $objp->nb;
196 if ($objp->fk_statut == Ticket::STATUS_IN_PROGRESS) {
197 $tick[
'inprogress'] = $objp->nb;
199 if ($objp->fk_statut == Ticket::STATUS_WAITING) {
200 $tick[
'waiting'] = $objp->nb;
202 if ($objp->fk_statut == Ticket::STATUS_CLOSED) {
203 $tick[
'closed'] = $objp->nb;
205 if ($objp->fk_statut == Ticket::STATUS_CANCELED) {
206 $tick[
'canceled'] = $objp->nb;
210 include DOL_DOCUMENT_ROOT.
'/theme/'.$conf->theme.
'/theme_vars.inc.php';
212 $dataseries = array();
213 $colorseries = array();
215 $dataseries[] = array(
'label' => $langs->transnoentitiesnoconv($object->statuts_short[
Ticket::STATUS_NOT_READ]),
'data' => round($tick[
'unread']));
217 $dataseries[] = array(
'label' => $langs->transnoentitiesnoconv($object->statuts_short[Ticket::STATUS_READ]),
'data' => round($tick[
'read']));
218 $colorseries[Ticket::STATUS_READ] = $badgeStatus1;
219 $dataseries[] = array(
'label' => $langs->transnoentitiesnoconv($object->statuts_short[Ticket::STATUS_ASSIGNED]),
'data' => round($tick[
'assigned']));
220 $colorseries[Ticket::STATUS_ASSIGNED] = $badgeStatus3;
221 $dataseries[] = array(
'label' => $langs->transnoentitiesnoconv($object->statuts_short[Ticket::STATUS_IN_PROGRESS]),
'data' => round($tick[
'inprogress']));
222 $colorseries[Ticket::STATUS_IN_PROGRESS] = $badgeStatus4;
223 $dataseries[] = array(
'label' => $langs->transnoentitiesnoconv($object->statuts_short[Ticket::STATUS_WAITING]),
'data' => round($tick[
'waiting']));
224 $colorseries[Ticket::STATUS_WAITING] =
'-'.$badgeStatus4;
225 $dataseries[] = array(
'label' => $langs->transnoentitiesnoconv($object->statuts_short[Ticket::STATUS_NEED_MORE_INFO]),
'data' => round($tick[
'needmoreinfo']));
226 $colorseries[Ticket::STATUS_NEED_MORE_INFO] =
'-'.$badgeStatus3;
227 $dataseries[] = array(
'label' => $langs->transnoentitiesnoconv($object->statuts_short[Ticket::STATUS_CANCELED]),
'data' => round($tick[
'canceled']));
228 $colorseries[Ticket::STATUS_CANCELED] = $badgeStatus9;
229 $dataseries[] = array(
'label' => $langs->transnoentitiesnoconv($object->statuts_short[Ticket::STATUS_CLOSED]),
'data' => round($tick[
'closed']));
230 $colorseries[Ticket::STATUS_CLOSED] = $badgeStatus6;
235 $stringtoshow =
'<script type="text/javascript">
236 jQuery(document).ready(function() {
237 jQuery("#idsubimgDOLUSERCOOKIE_ticket_by_status").click(function() {
238 jQuery("#idfilterDOLUSERCOOKIE_ticket_by_status").toggle();
242 $stringtoshow .=
'<div class="center hideobject" id="idfilterDOLUSERCOOKIE_ticket_by_status">';
243 $stringtoshow .=
'<form class="flat formboxfilter" method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
244 $stringtoshow .=
'<input type="hidden" name="token" value="'.newToken().
'">';
245 $stringtoshow .=
'<input type="hidden" name="action" value="refresh">';
246 $stringtoshow .=
'<input type="hidden" name="DOL_AUTOSET_COOKIE" value="DOLUSERCOOKIE_ticket_by_status:year,shownb,showtot">';
247 $stringtoshow .= $langs->trans(
"Year").
' <input class="flat" size="4" type="text" name="'.$param_year.
'" value="'.$endyear.
'">';
248 $stringtoshow .=
'<input type="image" alt="'.$langs->trans(
"Refresh").
'" src="'.
img_picto($langs->trans(
"Refresh"),
'refresh.png',
'',
'', 1).
'">';
249 $stringtoshow .=
'</form>';
250 $stringtoshow .=
'</div>';
252 if (!empty($user->rights->ticket->read)) {
253 print
'<div class="div-table-responsive-no-min">';
254 print
'<table class="noborder centpercent">';
255 print
'<tr class="liste_titre"><th >'.$langs->trans(
"Statistics").
' '.$endyear.
' '.
img_picto(
'',
'filter.png',
'id="idsubimgDOLUSERCOOKIE_ticket_by_status" class="linkobject"').
'</th></tr>';
257 print
'<tr><td class="center">';
261 if (!empty($dataseries) && count($dataseries) > 1) {
263 foreach ($dataseries as $key => $value) {
264 $totalnb += $value[
'data'];
268 foreach ($dataseries as $key => $value) {
269 $data[] = array($value[
'label'], $value[
'data']);
272 $mesg = $px1->isGraphKo();
274 $px1->SetData($data);
275 $px1->SetDataColor(array_values($colorseries));
280 while ($i <= $endyear) {
284 $px1->setShowLegend(2);
285 $px1->SetType(array(
'pie'));
286 $px1->SetLegend($legend);
287 $px1->SetMaxValue($px1->GetCeilMaxValue());
289 $px1->SetHeight($HEIGHT);
290 $px1->SetYLabel($langs->trans(
"TicketStatByStatus"));
292 $px1->SetHorizTickIncrement(1);
293 $px1->SetCssPrefix(
"cssboxes");
294 $px1->mode =
'depth';
297 $px1->draw($filenamenb, $fileurlnb);
298 print $px1->show($totalnb ? 0 : 1);
307 if (!empty($user->rights->ticket->read)) {
309 $data = $stats->getNbByMonthWithPrevYear($endyear, $startyear);
314 print $resultboxes[
'boxlista'];
318 print
'<div class="secondcolumn fichehalfright boxhalfright" id="boxhalfright">';
320 if (!empty($user->rights->ticket->read)) {
327 $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, t.progress,";
328 $sql .=
" type.code as type_code, type.label as type_label,";
329 $sql .=
" category.code as category_code, category.label as category_label,";
330 $sql .=
" severity.code as severity_code, severity.label as severity_label";
331 $sql .=
" FROM ".MAIN_DB_PREFIX.
"ticket as t";
332 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_ticket_type as type ON type.code=t.type_code";
333 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_ticket_category as category ON category.code=t.category_code";
334 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_ticket_severity as severity ON severity.code=t.severity_code";
335 if (empty($user->rights->societe->client->voir) && !$socid) {
336 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
339 $sql .=
' WHERE t.entity IN ('.getEntity(
'ticket').
')';
340 $sql .=
" AND t.fk_statut=0";
341 if (empty($user->rights->societe->client->voir) && !$socid) {
342 $sql .=
" AND t.fk_soc = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
345 if ($user->socid > 0) {
346 $sql .=
" AND t.fk_soc= ".((int) $user->socid);
349 if (!empty($conf->global->TICKET_LIMIT_VIEW_ASSIGNED_ONLY) && !$user->rights->ticket->manage) {
350 $sql .=
" AND t.fk_user_assign = ".((int) $user->id);
353 $sql .= $db->order(
"t.datec",
"DESC");
354 $sql .= $db->plimit($max, 0);
357 $result = $db->query($sql);
359 $num = $db->num_rows($result);
363 $transRecordedType = $langs->trans(
"LatestNewTickets", $max);
365 print
'<div class="div-table-responsive-no-min">';
366 print
'<table class="noborder centpercent">';
367 print
'<tr class="liste_titre"><th colspan="5">'.$transRecordedType.
'</th>';
368 print
'<th class="right" colspan="2"><a href="'.DOL_URL_ROOT.
'/ticket/list.php?search_fk_statut[]='.
Ticket::STATUS_NOT_READ.
'">'.$langs->trans(
"FullList").
'</th>';
372 $objp = $db->fetch_object($result);
374 $object->id = $objp->rowid;
375 $object->ref = $objp->ref;
376 $object->track_id = $objp->track_id;
377 $object->fk_statut = $objp->fk_statut;
378 $object->progress = $objp->progress;
379 $object->subject = $objp->subject;
381 print
'<tr class="oddeven">';
384 print
'<td class="nowraponall">';
385 print $object->getNomUrl(1);
389 print
'<td class="left">';
394 print
'<td class="nowrap">';
395 print
'<a href="card.php?track_id='.$objp->track_id.
'">'.
dol_trunc($objp->subject, 30).
'</a>';
399 print
'<td class="nowrap tdoverflowmax100">';
400 $s = $langs->getLabelFromKey($db,
'TicketTypeShort'.$objp->type_code,
'c_ticket_type',
'code',
'label', $objp->type_code);
401 print
'<span title="'.dol_escape_htmltag($s).
'">'.$s.
'</span>';
405 print
'<td class="nowrap">';
406 if (!empty($obp->category_code)) {
407 $s = $langs->getLabelFromKey($db,
'TicketCategoryShort'.$objp->category_code,
'c_ticket_category',
'code',
'label', $objp->category_code);
408 print
'<span title="'.dol_escape_htmltag($s).
'">'.$s.
'</span>';
414 print
'<td class="nowrap">';
415 $s = $langs->getLabelFromKey($db,
'TicketSeverityShort'.$objp->severity_code,
'c_ticket_severity',
'code',
'label', $objp->severity_code);
416 print
'<span title="'.dol_escape_htmltag($s).
'">'.$s.
'</span>';
420 print
'<td class="nowraponall right">';
421 print $object->getLibStatut(5);
430 print
'<tr><td colspan="6"><span class="opacitymedium">'.$langs->trans(
'NoUnreadTicketsFound').
'</span></td></tr>';
442 print $resultboxes[
'boxlistb'];
449 print
'<div style="clear:both"></div>';
451 $parameters = array(
'user' => $user);
452 $reshook = $hookmanager->executeHooks(
'dashboardTickets', $parameters, $object);
static getDefaultGraphSizeForStats($direction, $defaultsize='')
getDefaultGraphSizeForStats
const STATUS_NOT_READ
Status.
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.
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($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
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.
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.
dol_getdate($timestamp, $fast=false, $forcetimezone='')
Return an array with locale date info.
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.