68 global $conf, $user, $langs;
69 global $theme_datacolor, $badgeStatus8;
71 require_once DOL_DOCUMENT_ROOT.
"/core/lib/functions2.lib.php";
72 require_once DOL_DOCUMENT_ROOT.
"/theme/".$conf->theme.
"/theme_vars.inc.php";
75 $badgeStatus8 =
'#993013';
77 $text = $langs->trans(
"BoxTicketType");
78 $this->info_box_head = array(
83 $listofopplabel = array();
84 $listofoppcode = array();
85 $colorseriesstat = array();
86 if ($user->rights->ticket->read) {
87 $sql =
"SELECT ctt.rowid, ctt.label, ctt.code";
88 $sql .=
" FROM " . MAIN_DB_PREFIX .
"c_ticket_type as ctt";
89 $sql .=
" WHERE ctt.active = 1";
90 $sql .= $this->db->order(
'ctt.rowid',
'ASC');
91 $resql = $this->db->query($sql);
94 $num = $this->db->num_rows($resql);
99 $objp = $this->db->fetch_object($resql);
100 $listofoppcode[$objp->rowid] = $objp->code;
101 $listofopplabel[$objp->rowid] = $objp->label;
102 if (empty($colorused[$objp->code])) {
103 if ($objp->code ==
'ISSUE') {
104 $colorused[$objp->code] = $badgeStatus8;
106 $colorused[$objp->code] =
colorArrayToHex($theme_datacolor[$newcolorkey]);
110 $colorseriesstat[$objp->rowid] = $colorused[$objp->code];
117 $dataseries = array();
119 $sql =
"SELECT t.type_code, COUNT(t.type_code) as nb";
120 $sql .=
" FROM " . MAIN_DB_PREFIX .
"ticket as t";
121 $sql .=
" WHERE t.fk_statut <> 8";
122 $sql .=
" GROUP BY t.type_code";
123 $resql = $this->db->query($sql);
125 $num = $this->db->num_rows($resql);
128 $objp = $this->db->fetch_object($resql);
129 $data[$objp->type_code] = $objp->nb;
132 foreach ($listofoppcode as $rowid => $code) {
133 $dataseries[] = array(
134 'label' => $langs->getLabelFromKey($this->db,
'TicketTypeShort' . $code,
'c_ticket_type',
'code',
'label', $code),
135 'data' => (empty($data[$code]) ? 0 : $data[$code])
142 $stringtoprint .=
'<div class="div-table-responsive-no-min ">';
143 if (!empty($dataseries) && count($dataseries) > 0) {
144 include_once DOL_DOCUMENT_ROOT.
'/core/class/dolgraph.class.php';
147 $mesg = $px1->isGraphKo();
150 $px1->SetDataColor(array_values($colorseriesstat));
153 foreach ($dataseries as $value) {
154 $data[] = array($value[
'label'], $value[
'data']);
155 $totalnb += $value[
'data'];
157 $px1->SetData($data);
158 $px1->setShowLegend(2);
159 if (!empty($conf->dol_optimize_smallscreen)) {
162 $px1->SetType(array(
'pie'));
163 $px1->SetLegend($legend);
164 $px1->SetMaxValue($px1->GetCeilMaxValue());
166 $px1->SetHorizTickIncrement(1);
167 $px1->SetCssPrefix(
"cssboxes");
168 $px1->mode =
'depth';
169 $px1->draw(
'idgraphtickettype');
170 $stringtoprint .= $px1->show($totalnb ? 0 : 1);
172 $stringtoprint .=
'</div>';
173 $this->info_box_contents[][]=array(
174 'td' =>
'class="center"',
175 'text' => $stringtoprint
178 $this->info_box_contents[0][0] = array(
179 'td' =>
'class="center opacitymedium"',
180 'text' => $langs->trans(
"BoxNoTicketSeverity"),
184 $this->info_box_contents[0][0] = array(
185 'td' =>
'class="left"',
186 'text' => $langs->trans(
"ReadPermissionNotAllowed"),