66 global
$conf, $user, $langs;
68 $badgeStatus0 =
'#cbd3d3';
69 $badgeStatus1 =
'#bc9526';
70 $badgeStatus1b =
'#bc9526';
71 $badgeStatus2 =
'#9c9c26';
72 $badgeStatus3 =
'#bca52b';
73 $badgeStatus4 =
'#25a580';
74 $badgeStatus4b =
'#25a580';
75 $badgeStatus5 =
'#cad2d2';
76 $badgeStatus6 =
'#cad2d2';
77 $badgeStatus7 =
'#baa32b';
78 $badgeStatus8 =
'#993013';
79 $badgeStatus9 =
'#e7f0f0';
81 if ($theme_vars_file) {
82 include $theme_vars_file;
86 require_once DOL_DOCUMENT_ROOT.
"/ticket/class/ticket.class.php";
88 $text = $langs->trans(
"BoxTicketSeverity", $max);
89 $this->info_box_head = array(
94 $listofopplabel = array();
95 $listofoppcode = array();
96 $colorseriesstat = array();
97 if ($user->hasRight(
'ticket',
'read')) {
98 $sql =
"SELECT cts.rowid, cts.label, cts.code";
99 $sql .=
" FROM " . MAIN_DB_PREFIX .
"c_ticket_severity as cts";
100 $sql .=
" WHERE cts.entity IN (".getEntity(
'c_ticket_severity').
")";
101 $sql .=
" AND cts.active = 1";
102 $sql .= $this->db->order(
'cts.rowid',
'ASC');
103 $resql = $this->db->query($sql);
106 $num = $this->db->num_rows($resql);
109 $objp = $this->db->fetch_object($resql);
110 $listofoppcode[$objp->rowid] = $objp->code;
111 $listofopplabel[$objp->rowid] = $objp->label;
112 switch ($objp->code) {
114 $colorseriesstat[$objp->rowid] = $badgeStatus4;
117 $colorseriesstat[$objp->rowid] = $badgeStatus2;
120 $colorseriesstat[$objp->rowid] = $badgeStatus1;
123 $colorseriesstat[$objp->rowid] = $badgeStatus8;
131 dol_print_error($this->db);
134 $dataseries = array();
136 $sql =
"SELECT t.severity_code, COUNT(t.severity_code) as nb";
137 $sql .=
" FROM " . MAIN_DB_PREFIX .
"ticket as t";
138 $sql .=
" WHERE t.entity IN (".getEntity(
'ticket').
")";
139 $sql .=
" AND t.fk_statut <> 8";
140 $sql .=
" GROUP BY t.severity_code";
141 $resql = $this->db->query($sql);
143 $num = $this->db->num_rows($resql);
146 $objp = $this->db->fetch_object($resql);
147 $data[$objp->severity_code] = $objp->nb;
150 foreach ($listofoppcode as $rowid => $code) {
151 $dataseries[] = array(
152 'label' => $langs->getLabelFromKey($this->db,
'TicketSeverityShort' . $code,
'c_ticket_severity',
'code',
'label', $code),
153 'data' => (empty($data[$code]) ? 0 : $data[$code])
157 dol_print_error($this->db);
160 $stringtoprint .=
'<div class="div-table-responsive-no-min ">';
161 if (!empty($dataseries) && count($dataseries) > 0) {
162 include_once DOL_DOCUMENT_ROOT.
'/core/class/dolgraph.class.php';
164 $mesg = $px1->isGraphKo();
170 foreach ($dataseries as $value) {
171 $data[] = array($value[
'label'], $value[
'data']);
172 $totalnb += $value[
'data'];
175 $px1->SetData($data);
176 $px1->setShowLegend(0);
177 $px1->SetType(array(
'bars'));
178 $px1->SetLegend($legend);
179 $px1->SetMaxValue($px1->GetCeilMaxValue());
182 $px1->SetHorizTickIncrement(1);
183 $px1->SetCssPrefix(
"cssboxes");
184 $px1->mode =
'depth';
186 $px1->draw(
'idgraphticketseverity');
187 $stringtoprint .= $px1->show($totalnb ? 0 : 1);
189 $stringtoprint .=
'</div>';
190 $this->info_box_contents[][] = array(
191 'td' =>
'class="center"',
192 'text' => $stringtoprint
195 $this->info_box_contents[0][0] = array(
197 'text' =>
'<span class="opacitymedium">'.$langs->trans(
"BoxNoTicketSeverity").
'</span>'
201 $this->info_box_contents[0][0] = array(
203 'text' =>
'<span class="opacitymedium">'.$langs->trans(
"ReadPermissionNotAllowed").
'</span>',