72 global $conf, $user, $langs;
74 $badgeStatus0 =
'#cbd3d3';
75 $badgeStatus1 =
'#bc9526';
76 $badgeStatus1b =
'#bc9526';
77 $badgeStatus2 =
'#9c9c26';
78 $badgeStatus3 =
'#bca52b';
79 $badgeStatus4 =
'#25a580';
80 $badgeStatus4b =
'#25a580';
81 $badgeStatus5 =
'#cad2d2';
82 $badgeStatus6 =
'#cad2d2';
83 $badgeStatus7 =
'#baa32b';
84 $badgeStatus8 =
'#993013';
85 $badgeStatus9 =
'#e7f0f0';
86 if (file_exists(DOL_DOCUMENT_ROOT .
'/theme/' . $conf->theme .
'/theme_vars.inc.php')) {
87 include DOL_DOCUMENT_ROOT .
'/theme/' . $conf->theme .
'/theme_vars.inc.php';
91 require_once DOL_DOCUMENT_ROOT.
"/ticket/class/ticket.class.php";
93 $text = $langs->trans(
"BoxTicketSeverity", $max);
94 $this->info_box_head = array(
99 $listofopplabel = array();
100 $listofoppcode = array();
101 $colorseriesstat = array();
102 if ($user->hasRight(
'ticket',
'read')) {
103 $sql =
"SELECT cts.rowid, cts.label, cts.code";
104 $sql .=
" FROM " . MAIN_DB_PREFIX .
"c_ticket_severity as cts";
105 $sql .=
" WHERE cts.active = 1";
106 $sql .= $this->db->order(
'cts.rowid',
'ASC');
107 $resql = $this->db->query($sql);
110 $num = $this->db->num_rows($resql);
113 $objp = $this->db->fetch_object($resql);
114 $listofoppcode[$objp->rowid] = $objp->code;
115 $listofopplabel[$objp->rowid] = $objp->label;
116 switch ($objp->code) {
118 $colorseriesstat[$objp->rowid] = $badgeStatus4;
121 $colorseriesstat[$objp->rowid] = $badgeStatus2;
124 $colorseriesstat[$objp->rowid] = $badgeStatus1;
127 $colorseriesstat[$objp->rowid] = $badgeStatus8;
138 $dataseries = array();
140 $sql =
"SELECT t.severity_code, COUNT(t.severity_code) as nb";
141 $sql .=
" FROM " . MAIN_DB_PREFIX .
"ticket as t";
142 $sql .=
" WHERE t.fk_statut <> 8";
143 $sql .=
" GROUP BY t.severity_code";
144 $resql = $this->db->query($sql);
146 $num = $this->db->num_rows($resql);
149 $objp = $this->db->fetch_object($resql);
150 $data[$objp->severity_code] = $objp->nb;
153 foreach ($listofoppcode as $rowid => $code) {
154 $dataseries[] = array(
155 'label' => $langs->getLabelFromKey($this->db,
'TicketSeverityShort' . $code,
'c_ticket_severity',
'code',
'label', $code),
156 'data' => (empty($data[$code]) ? 0 : $data[$code])
163 $stringtoprint .=
'<div class="div-table-responsive-no-min ">';
164 if (!empty($dataseries) && count($dataseries) > 0) {
165 include_once DOL_DOCUMENT_ROOT.
'/core/class/dolgraph.class.php';
167 $mesg = $px1->isGraphKo();
173 foreach ($dataseries as $value) {
174 $data[] = array($value[
'label'], $value[
'data']);
175 $totalnb += $value[
'data'];
178 $px1->SetData($data);
179 $px1->setShowLegend(0);
180 $px1->SetType(array(
'bars'));
181 $px1->SetLegend($legend);
182 $px1->SetMaxValue($px1->GetCeilMaxValue());
185 $px1->SetHorizTickIncrement(1);
186 $px1->SetCssPrefix(
"cssboxes");
187 $px1->mode =
'depth';
189 $px1->draw(
'idgraphticketseverity');
190 $stringtoprint .= $px1->show($totalnb ? 0 : 1);
192 $stringtoprint .=
'</div>';
193 $this->info_box_contents[][]=array(
194 'td' =>
'class="center"',
195 'text' => $stringtoprint
198 $this->info_box_contents[0][0] = array(
200 'text' =>
'<span class="opacitymedium">'.$langs->trans(
"BoxNoTicketSeverity").
'</span>'
204 $this->info_box_contents[0][0] = array(
206 'text' =>
'<span class="opacitymedium">'.$langs->trans(
"ReadPermissionNotAllowed").
'</span>',