67 global $conf, $user, $langs;
68 global $theme_datacolor, $badgeStatus8;
70 require_once DOL_DOCUMENT_ROOT.
"/core/lib/functions2.lib.php";
71 require_once DOL_DOCUMENT_ROOT.
"/theme/".$conf->theme.
"/theme_vars.inc.php";
74 $badgeStatus8 =
'#993013';
76 $text = $langs->trans(
"BoxTicketType");
77 $this->info_box_head = array(
82 $listofopplabel = array();
83 $listofoppcode = array();
84 $colorseriesstat = array();
85 if ($user->hasRight(
'ticket',
'read')) {
86 $sql =
"SELECT ctt.rowid, ctt.label, ctt.code";
87 $sql .=
" FROM " . MAIN_DB_PREFIX .
"c_ticket_type as ctt";
88 $sql .=
" WHERE ctt.active = 1";
89 $sql .= $this->db->order(
'ctt.rowid',
'ASC');
90 $resql = $this->db->query($sql);
93 $num = $this->db->num_rows($resql);
98 $objp = $this->db->fetch_object($resql);
99 $listofoppcode[$objp->rowid] = $objp->code;
100 $listofopplabel[$objp->rowid] = $objp->label;
101 if (empty($colorused[$objp->code])) {
102 if ($objp->code ==
'ISSUE') {
103 $colorused[$objp->code] = $badgeStatus8;
105 $colorused[$objp->code] =
colorArrayToHex($theme_datacolor[$newcolorkey]);
109 $colorseriesstat[$objp->rowid] = $colorused[$objp->code];
116 $dataseries = array();
118 $sql =
"SELECT t.type_code, COUNT(t.type_code) as nb";
119 $sql .=
" FROM " . MAIN_DB_PREFIX .
"ticket as t";
120 $sql .=
" WHERE t.fk_statut <> 8";
121 $sql .=
" GROUP BY t.type_code";
122 $resql = $this->db->query($sql);
124 $num = $this->db->num_rows($resql);
127 $objp = $this->db->fetch_object($resql);
128 $data[$objp->type_code] = $objp->nb;
131 foreach ($listofoppcode as $rowid => $code) {
132 $dataseries[] = array(
133 'label' => $langs->getLabelFromKey($this->db,
'TicketTypeShort' . $code,
'c_ticket_type',
'code',
'label', $code),
134 'data' => (empty($data[$code]) ? 0 : $data[$code])
141 $stringtoprint .=
'<div class="div-table-responsive-no-min ">';
142 if (!empty($dataseries) && count($dataseries) > 0) {
143 include_once DOL_DOCUMENT_ROOT.
'/core/class/dolgraph.class.php';
146 $mesg = $px1->isGraphKo();
149 $px1->SetDataColor(array_values($colorseriesstat));
152 foreach ($dataseries as $value) {
153 $data[] = array($value[
'label'], $value[
'data']);
154 $totalnb += $value[
'data'];
156 $px1->SetData($data);
157 $px1->setShowLegend(2);
158 if (!empty($conf->dol_optimize_smallscreen)) {
161 $px1->SetType(array(
'pie'));
162 $px1->SetLegend($legend);
163 $px1->SetMaxValue($px1->GetCeilMaxValue());
165 $px1->SetHorizTickIncrement(1);
166 $px1->SetCssPrefix(
"cssboxes");
167 $px1->mode =
'depth';
168 $px1->draw(
'idgraphtickettype');
169 $stringtoprint .= $px1->show($totalnb ? 0 : 1);
171 $stringtoprint .=
'</div>';
172 $this->info_box_contents[][]=array(
173 'td' =>
'class="center"',
174 'text' => $stringtoprint
177 $this->info_box_contents[0][0] = array(
178 'td' =>
'class="center opacitymedium"',
179 'text' =>
'<span class="opacitymedium">'.$langs->trans(
"BoxNoTicketSeverity").
'</span>'
183 $this->info_box_contents[0][0] = array(
184 'td' =>
'class="left"',
185 'text' =>
'<span class="opacitymedium">'.$langs->trans(
"ReadPermissionNotAllowed").
'</span>'