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';
80 if (file_exists(DOL_DOCUMENT_ROOT .
'/theme/' .
$conf->theme .
'/theme_vars.inc.php')) {
81 include DOL_DOCUMENT_ROOT .
'/theme/' .
$conf->theme .
'/theme_vars.inc.php';
85 require_once DOL_DOCUMENT_ROOT.
"/ticket/class/ticket.class.php";
87 $text = $langs->trans(
"BoxTicketSeverity", $max);
88 $this->info_box_head = array(
93 $listofopplabel = array();
94 $listofoppcode = array();
95 $colorseriesstat = array();
96 if ($user->hasRight(
'ticket',
'read')) {
97 $sql =
"SELECT cts.rowid, cts.label, cts.code";
98 $sql .=
" FROM " . MAIN_DB_PREFIX .
"c_ticket_severity as cts";
99 $sql .=
" WHERE cts.entity IN (".getEntity(
'c_ticket_severity').
")";
100 $sql .=
" AND cts.active = 1";
101 $sql .= $this->db->order(
'cts.rowid',
'ASC');
102 $resql = $this->db->query($sql);
105 $num = $this->db->num_rows($resql);
108 $objp = $this->db->fetch_object($resql);
109 $listofoppcode[$objp->rowid] = $objp->code;
110 $listofopplabel[$objp->rowid] = $objp->label;
111 switch ($objp->code) {
113 $colorseriesstat[$objp->rowid] = $badgeStatus4;
116 $colorseriesstat[$objp->rowid] = $badgeStatus2;
119 $colorseriesstat[$objp->rowid] = $badgeStatus1;
122 $colorseriesstat[$objp->rowid] = $badgeStatus8;
133 $dataseries = array();
135 $sql =
"SELECT t.severity_code, COUNT(t.severity_code) as nb";
136 $sql .=
" FROM " . MAIN_DB_PREFIX .
"ticket as t";
137 $sql .=
" WHERE t.entity IN (".getEntity(
'ticket').
")";
138 $sql .=
" AND t.fk_statut <> 8";
139 $sql .=
" GROUP BY t.severity_code";
140 $resql = $this->db->query($sql);
142 $num = $this->db->num_rows($resql);
145 $objp = $this->db->fetch_object($resql);
146 $data[$objp->severity_code] = $objp->nb;
149 foreach ($listofoppcode as $rowid => $code) {
150 $dataseries[] = array(
151 'label' => $langs->getLabelFromKey($this->db,
'TicketSeverityShort' . $code,
'c_ticket_severity',
'code',
'label', $code),
152 'data' => (empty($data[$code]) ? 0 : $data[$code])
159 $stringtoprint .=
'<div class="div-table-responsive-no-min ">';
160 if (!empty($dataseries) && count($dataseries) > 0) {
161 include_once DOL_DOCUMENT_ROOT.
'/core/class/dolgraph.class.php';
163 $mesg = $px1->isGraphKo();
169 foreach ($dataseries as $value) {
170 $data[] = array($value[
'label'], $value[
'data']);
171 $totalnb += $value[
'data'];
174 $px1->SetData($data);
175 $px1->setShowLegend(0);
176 $px1->SetType(array(
'bars'));
177 $px1->SetLegend($legend);
178 $px1->SetMaxValue($px1->GetCeilMaxValue());
181 $px1->SetHorizTickIncrement(1);
182 $px1->SetCssPrefix(
"cssboxes");
183 $px1->mode =
'depth';
185 $px1->draw(
'idgraphticketseverity');
186 $stringtoprint .= $px1->show($totalnb ? 0 : 1);
188 $stringtoprint .=
'</div>';
189 $this->info_box_contents[][] = array(
190 'td' =>
'class="center"',
191 'text' => $stringtoprint
194 $this->info_box_contents[0][0] = array(
196 'text' =>
'<span class="opacitymedium">'.$langs->trans(
"BoxNoTicketSeverity").
'</span>'
200 $this->info_box_contents[0][0] = array(
202 'text' =>
'<span class="opacitymedium">'.$langs->trans(
"ReadPermissionNotAllowed").
'</span>',