62 global $conf, $user, $langs;
64 $badgeStatus0 =
'#cbd3d3';
65 $badgeStatus1 =
'#bc9526';
66 $badgeStatus1b =
'#bc9526';
67 $badgeStatus2 =
'#9c9c26';
68 $badgeStatus3 =
'#bca52b';
69 $badgeStatus4 =
'#25a580';
70 $badgeStatus4b =
'#25a580';
71 $badgeStatus5 =
'#cad2d2';
72 $badgeStatus6 =
'#cad2d2';
73 $badgeStatus7 =
'#baa32b';
74 $badgeStatus8 =
'#993013';
75 $badgeStatus9 =
'#e7f0f0';
76 if (file_exists(DOL_DOCUMENT_ROOT .
'/theme/' . $conf->theme .
'/theme_vars.inc.php')) {
77 include DOL_DOCUMENT_ROOT .
'/theme/' . $conf->theme .
'/theme_vars.inc.php';
81 require_once DOL_DOCUMENT_ROOT.
"/ticket/class/ticket.class.php";
83 $text = $langs->trans(
"BoxTicketSeverity", $max);
84 $this->info_box_head = array(
89 $listofopplabel = array();
90 $listofoppcode = array();
91 $colorseriesstat = array();
92 if ($user->hasRight(
'ticket',
'read')) {
93 $sql =
"SELECT cts.rowid, cts.label, cts.code";
94 $sql .=
" FROM " . MAIN_DB_PREFIX .
"c_ticket_severity as cts";
95 $sql .=
" WHERE cts.active = 1";
96 $sql .= $this->db->order(
'cts.rowid',
'ASC');
97 $resql = $this->db->query($sql);
100 $num = $this->db->num_rows($resql);
103 $objp = $this->db->fetch_object($resql);
104 $listofoppcode[$objp->rowid] = $objp->code;
105 $listofopplabel[$objp->rowid] = $objp->label;
106 switch ($objp->code) {
108 $colorseriesstat[$objp->rowid] = $badgeStatus4;
111 $colorseriesstat[$objp->rowid] = $badgeStatus2;
114 $colorseriesstat[$objp->rowid] = $badgeStatus1;
117 $colorseriesstat[$objp->rowid] = $badgeStatus8;
128 $dataseries = array();
130 $sql =
"SELECT t.severity_code, COUNT(t.severity_code) as nb";
131 $sql .=
" FROM " . MAIN_DB_PREFIX .
"ticket as t";
132 $sql .=
" WHERE t.fk_statut <> 8";
133 $sql .=
" GROUP BY t.severity_code";
134 $resql = $this->db->query($sql);
136 $num = $this->db->num_rows($resql);
139 $objp = $this->db->fetch_object($resql);
140 $data[$objp->severity_code] = $objp->nb;
143 foreach ($listofoppcode as $rowid => $code) {
144 $dataseries[] = array(
145 'label' => $langs->getLabelFromKey($this->db,
'TicketSeverityShort' . $code,
'c_ticket_severity',
'code',
'label', $code),
146 'data' => (empty($data[$code]) ? 0 : $data[$code])
153 $stringtoprint .=
'<div class="div-table-responsive-no-min ">';
154 if (!empty($dataseries) && count($dataseries) > 0) {
155 include_once DOL_DOCUMENT_ROOT.
'/core/class/dolgraph.class.php';
157 $mesg = $px1->isGraphKo();
163 foreach ($dataseries as $value) {
164 $data[] = array($value[
'label'], $value[
'data']);
165 $totalnb += $value[
'data'];
168 $px1->SetData($data);
169 $px1->setShowLegend(0);
170 $px1->SetType(array(
'bars'));
171 $px1->SetLegend($legend);
172 $px1->SetMaxValue($px1->GetCeilMaxValue());
175 $px1->SetHorizTickIncrement(1);
176 $px1->SetCssPrefix(
"cssboxes");
177 $px1->mode =
'depth';
179 $px1->draw(
'idgraphticketseverity');
180 $stringtoprint .= $px1->show($totalnb ? 0 : 1);
182 $stringtoprint .=
'</div>';
183 $this->info_box_contents[][]=array(
184 'td' =>
'class="center"',
185 'text' => $stringtoprint
188 $this->info_box_contents[0][0] = array(
190 'text' =>
'<span class="opacitymedium">'.$langs->trans(
"BoxNoTicketSeverity").
'</span>'
194 $this->info_box_contents[0][0] = array(
196 'text' =>
'<span class="opacitymedium">'.$langs->trans(
"ReadPermissionNotAllowed").
'</span>',