Debug module ticket

This commit is contained in:
Laurent Destailleur 2019-06-19 12:53:28 +02:00
parent 7afcdb46eb
commit f9cc120d75
4 changed files with 39 additions and 36 deletions

View File

@ -229,7 +229,7 @@ class DolGraph
/** /**
* Set width * Set width
* *
* @param int $w Width * @param int|string $w Width (Example: 320 or '100%')
* @return boolean|null True * @return boolean|null True
*/ */
public function SetWidth($w) public function SetWidth($w)

View File

@ -99,6 +99,7 @@ class modTicket extends DolibarrModules
$this->conflictwith = array(); // List of module class names as string this module is in conflict with $this->conflictwith = array(); // List of module class names as string this module is in conflict with
$this->phpmin = array(5,4); // Minimum version of PHP required by module $this->phpmin = array(5,4); // Minimum version of PHP required by module
$this->langfiles = array("ticket"); $this->langfiles = array("ticket");
// Constants // Constants
// List of particular constants to add when module is enabled // List of particular constants to add when module is enabled
// (key, 'chaine', value, desc, visible, 'current' or 'allentities', deleteonunactive) // (key, 'chaine', value, desc, visible, 'current' or 'allentities', deleteonunactive)

View File

@ -133,6 +133,7 @@ TicketsIndex=Ticket - home
TicketList=List of tickets TicketList=List of tickets
TicketAssignedToMeInfos=This page display ticket list created by or assigned to current user TicketAssignedToMeInfos=This page display ticket list created by or assigned to current user
NoTicketsFound=No ticket found NoTicketsFound=No ticket found
NoUnreadTicketsFound=No unread ticket found
TicketViewAllTickets=View all tickets TicketViewAllTickets=View all tickets
TicketViewNonClosedOnly=View only open tickets TicketViewNonClosedOnly=View only open tickets
TicketStatByStatus=Tickets by status TicketStatByStatus=Tickets by status

View File

@ -24,6 +24,7 @@ require '../main.inc.php';
require_once DOL_DOCUMENT_ROOT . '/ticket/class/actions_ticket.class.php'; require_once DOL_DOCUMENT_ROOT . '/ticket/class/actions_ticket.class.php';
require_once DOL_DOCUMENT_ROOT . '/ticket/class/ticketstats.class.php'; require_once DOL_DOCUMENT_ROOT . '/ticket/class/ticketstats.class.php';
require_once DOL_DOCUMENT_ROOT . '/core/class/dolgraph.class.php'; require_once DOL_DOCUMENT_ROOT . '/core/class/dolgraph.class.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php';
// Load translation files required by the page // Load translation files required by the page
$langs->loadLangs(array('companies', 'other', 'ticket')); $langs->loadLangs(array('companies', 'other', 'ticket'));
@ -102,8 +103,8 @@ if (empty($endyear)) {
} }
$startyear = $endyear - 1; $startyear = $endyear - 1;
$WIDTH = (($shownb && $showtot) || !empty($conf->dol_optimize_smallscreen)) ? '256' : '320'; $WIDTH = (($shownb && $showtot) || !empty($conf->dol_optimize_smallscreen)) ? '100%' : '80%';
$HEIGHT = '192'; $HEIGHT = '228';
print '<div class="fichecenter"><div class="fichethirdleft">'; print '<div class="fichecenter"><div class="fichethirdleft">';
@ -120,16 +121,14 @@ $tick = array(
'closed' => 0, 'closed' => 0,
'deleted' => 0, 'deleted' => 0,
); );
$total = 0;
$sql = "SELECT t.fk_statut, COUNT(t.fk_statut) as nb"; $sql = "SELECT t.fk_statut, COUNT(t.fk_statut) as nb";
$sql .= " FROM " . MAIN_DB_PREFIX . "ticket as t"; $sql .= " FROM " . MAIN_DB_PREFIX . "ticket as t";
if (!$user->rights->societe->client->voir && !$socid) { if (!$user->rights->societe->client->voir && !$socid) {
$sql .= ", " . MAIN_DB_PREFIX . "societe_commerciaux as sc"; $sql .= ", " . MAIN_DB_PREFIX . "societe_commerciaux as sc";
} }
$sql .= ' WHERE t.entity IN (' . getEntity('ticket') . ')';
$sql .= ' WHERE t.entity IN (' . getEntity('ticket', 1) . ')'; $sql .= dolSqlDateFilter('datec', 0, 0, $endyear);
$sql .= " AND t.fk_statut IS NOT NULL";
$sql .= " AND date_format(datec,'%Y') = '" . $endyear . "'";
if (!$user->rights->societe->client->voir && !$socid) { if (!$user->rights->societe->client->voir && !$socid) {
$sql .= " AND t.fk_soc = sc.fk_soc AND sc.fk_user = " . $user->id; $sql .= " AND t.fk_soc = sc.fk_soc AND sc.fk_user = " . $user->id;
} }
@ -149,44 +148,41 @@ $result = $db->query($sql);
if ($result) { if ($result) {
while ($objp = $db->fetch_object($result)) { while ($objp = $db->fetch_object($result)) {
$found = 0; $found = 0;
if ($objp->fk_statut == 0) { if ($objp->fk_statut == Ticket::STATUS_NOT_READ) {
$tick['unread'] = $objp->nb; $tick['unread'] = $objp->nb;
} }
if ($objp->fk_statut == 1) { if ($objp->fk_statut == Ticket::STATUS_READ) {
$tick['read'] = $objp->nb; $tick['read'] = $objp->nb;
} }
if ($objp->fk_statut == 3) { if ($objp->fk_statut == Ticket::STATUS_NEED_MORE_INFO) {
$tick['answered'] = $objp->nb; $tick['needmoreinfo'] = $objp->nb;
} }
if ($objp->fk_statut == 4) { if ($objp->fk_statut == Ticket::STATUS_ASSIGNED) {
$tick['assigned'] = $objp->nb; $tick['assigned'] = $objp->nb;
} }
if ($objp->fk_statut == 5) { if ($objp->fk_statut == Ticket::STATUS_IN_PROGRESS) {
$tick['inprogress'] = $objp->nb; $tick['inprogress'] = $objp->nb;
} }
if ($objp->fk_statut == 6) { if ($objp->fk_statut == Ticket::STATUS_WAITING) {
$tick['waiting'] = $objp->nb; $tick['waiting'] = $objp->nb;
} }
if ($objp->fk_statut == 8) { if ($objp->fk_statut == Ticket::STATUS_CLOSED) {
$tick['closed'] = $objp->nb; $tick['closed'] = $objp->nb;
} }
if ($objp->fk_statut == 9) { if ($objp->fk_statut == Ticket::STATUS_CANCELED) {
$tick['deleted'] = $objp->nb; $tick['canceled'] = $objp->nb;
} }
} }
if ((round($tick['unread']) ? 1 : 0) +(round($tick['read']) ? 1 : 0) +(round($tick['answered']) ? 1 : 0) +(round($tick['assigned']) ? 1 : 0) +(round($tick['inprogress']) ? 1 : 0) +(round($tick['waiting']) ? 1 : 0) +(round($tick['closed']) ? 1 : 0) +(round($tick['deleted']) ? 1 : 0) >= 2 $dataseries = array();
) { $dataseries[] = array('label' => $langs->trans("Unread"), 'data' => round($tick['unread']));
$dataseries = array(); $dataseries[] = array('label' => $langs->trans("Read"), 'data' => round($tick['read']));
$dataseries[] = array('label' => $langs->trans("Unread"), 'data' => round($tick['unread'])); $dataseries[] = array('label' => $langs->trans("NeedMoreInformation"), 'data' => round($tick['needmoreinfo']));
$dataseries[] = array('label' => $langs->trans("Read"), 'data' => round($tick['read'])); $dataseries[] = array('label' => $langs->trans("Assigned"), 'data' => round($tick['assigned']));
$dataseries[] = array('label' => $langs->trans("Answered"), 'data' => round($tick['answered'])); $dataseries[] = array('label' => $langs->trans("InProgress"), 'data' => round($tick['inprogress']));
$dataseries[] = array('label' => $langs->trans("Assigned"), 'data' => round($tick['assigned'])); $dataseries[] = array('label' => $langs->trans("Waiting"), 'data' => round($tick['waiting']));
$dataseries[] = array('label' => $langs->trans("InProgress"), 'data' => round($tick['inprogress'])); $dataseries[] = array('label' => $langs->trans("Closed"), 'data' => round($tick['closed']));
$dataseries[] = array('label' => $langs->trans("Waiting"), 'data' => round($tick['waiting'])); $dataseries[] = array('label' => $langs->trans("Canceled"), 'data' => round($tick['canceled']));
$dataseries[] = array('label' => $langs->trans("Closed"), 'data' => round($tick['closed']));
$dataseries[] = array('label' => $langs->trans("Deleted"), 'data' => round($tick['deleted']));
}
} else { } else {
dol_print_error($db); dol_print_error($db);
} }
@ -210,11 +206,17 @@ $stringtoshow .= '</div>';
print '<table class="noborder" width="100%">'; print '<table class="noborder" width="100%">';
print '<tr class="liste_titre"><th >' . $langs->trans("Statistics") . ' ' . img_picto('', 'filter.png', 'id="idsubimgDOLUSERCOOKIE_ticket_by_status" class="linkobject"') . '</th></tr>'; print '<tr class="liste_titre"><th >' . $langs->trans("Statistics") . ' ' . img_picto('', 'filter.png', 'id="idsubimgDOLUSERCOOKIE_ticket_by_status" class="linkobject"') . '</th></tr>';
print '<tr><td>'; print '<tr><td class="center">';
print $stringtoshow;
// don't display graph if no series // don't display graph if no series
if (! empty($dataseries) && count($dataseries) > 1) { if (! empty($dataseries) && count($dataseries) > 1) {
$data = array(); $totalnb=0;
foreach ($dataseries as $key => $value) {
$totalnb += $value['data'];
}
$data = array();
foreach ($dataseries as $key => $value) { foreach ($dataseries as $key => $value) {
$data[] = array($value['label'], $value['data']); $data[] = array($value['label'], $value['data']);
} }
@ -244,10 +246,9 @@ if (! empty($dataseries) && count($dataseries) > 1) {
//$px1->SetTitle($langs->trans("TicketStatByStatus")); //$px1->SetTitle($langs->trans("TicketStatByStatus"));
$px1->draw($filenamenb, $fileurlnb); $px1->draw($filenamenb, $fileurlnb);
print $px1->show(); print $px1->show($totalnb?0:1);
} }
} }
print $stringtoshow;
print '</td></tr>'; print '</td></tr>';
print '</table>'; print '</table>';
@ -303,7 +304,7 @@ if ($result) {
print '<div class="div-table-responsive-no-min">'; print '<div class="div-table-responsive-no-min">';
print '<table class="noborder" width="100%">'; print '<table class="noborder" width="100%">';
print '<tr class="liste_titre"><th colspan="5">' . $transRecordedType . '</th>'; print '<tr class="liste_titre"><th colspan="5">' . $transRecordedType . '</th>';
print '<th class="right" colspan="2"><a href="'.DOL_URL_ROOT.'/ticket/list.php">'.$langs->trans("FullList").'</th>'; 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>';
print '</tr>'; print '</tr>';
if ($num > 0) { if ($num > 0) {
@ -359,7 +360,7 @@ if ($result) {
$db->free(); $db->free();
} else { } else {
print '<tr><td colspan="6" class="opacitymedium">' . $langs->trans('NoTicketsFound') . '</td></tr>'; print '<tr><td colspan="6" class="opacitymedium">' . $langs->trans('NoUnreadTicketsFound') . '</td></tr>';
} }
print "</table>"; print "</table>";