62 global $conf, $user, $langs;
63 global $theme_datacolor, $badgeStatus8;
65 require_once DOL_DOCUMENT_ROOT.
"/core/lib/functions2.lib.php";
66 require_once DOL_DOCUMENT_ROOT.
"/theme/".$conf->theme.
"/theme_vars.inc.php";
69 $badgeStatus8 =
'#993013';
71 $text = $langs->trans(
"BoxTicketType");
72 $this->info_box_head = array(
77 $listofopplabel = array();
78 $listofoppcode = array();
79 $colorseriesstat = array();
80 if ($user->hasRight(
'ticket',
'read')) {
81 $sql =
"SELECT ctt.rowid, ctt.label, ctt.code";
82 $sql .=
" FROM " . MAIN_DB_PREFIX .
"c_ticket_type as ctt";
83 $sql .=
" WHERE ctt.active = 1";
84 $sql .= $this->db->order(
'ctt.rowid',
'ASC');
85 $resql = $this->db->query($sql);
88 $num = $this->db->num_rows($resql);
93 $objp = $this->db->fetch_object($resql);
94 $listofoppcode[$objp->rowid] = $objp->code;
95 $listofopplabel[$objp->rowid] = $objp->label;
96 if (empty($colorused[$objp->code])) {
97 if ($objp->code ==
'ISSUE') {
98 $colorused[$objp->code] = $badgeStatus8;
100 $colorused[$objp->code] =
colorArrayToHex($theme_datacolor[$newcolorkey]);
104 $colorseriesstat[$objp->rowid] = $colorused[$objp->code];
111 $dataseries = array();
113 $sql =
"SELECT t.type_code, COUNT(t.type_code) as nb";
114 $sql .=
" FROM " . MAIN_DB_PREFIX .
"ticket as t";
115 $sql .=
" WHERE t.fk_statut <> 8";
116 $sql .=
" GROUP BY t.type_code";
117 $resql = $this->db->query($sql);
119 $num = $this->db->num_rows($resql);
122 $objp = $this->db->fetch_object($resql);
123 $data[$objp->type_code] = $objp->nb;
126 foreach ($listofoppcode as $rowid => $code) {
127 $dataseries[] = array(
128 'label' => $langs->getLabelFromKey($this->db,
'TicketTypeShort' . $code,
'c_ticket_type',
'code',
'label', $code),
129 'data' => (empty($data[$code]) ? 0 : $data[$code])
136 $stringtoprint .=
'<div class="div-table-responsive-no-min ">';
137 if (!empty($dataseries) && count($dataseries) > 0) {
138 include_once DOL_DOCUMENT_ROOT.
'/core/class/dolgraph.class.php';
141 $mesg = $px1->isGraphKo();
144 $px1->SetDataColor(array_values($colorseriesstat));
147 foreach ($dataseries as $value) {
148 $data[] = array($value[
'label'], $value[
'data']);
149 $totalnb += $value[
'data'];
151 $px1->SetData($data);
152 $px1->setShowLegend(2);
153 if (!empty($conf->dol_optimize_smallscreen)) {
156 $px1->SetType(array(
'pie'));
157 $px1->SetLegend($legend);
158 $px1->SetMaxValue($px1->GetCeilMaxValue());
160 $px1->SetHorizTickIncrement(1);
161 $px1->SetCssPrefix(
"cssboxes");
162 $px1->mode =
'depth';
163 $px1->draw(
'idgraphtickettype');
164 $stringtoprint .= $px1->show($totalnb ? 0 : 1);
166 $stringtoprint .=
'</div>';
167 $this->info_box_contents[][]=array(
168 'td' =>
'class="center"',
169 'text' => $stringtoprint
172 $this->info_box_contents[0][0] = array(
173 'td' =>
'class="center opacitymedium"',
174 'text' =>
'<span class="opacitymedium">'.$langs->trans(
"BoxNoTicketSeverity").
'</span>'
178 $this->info_box_contents[0][0] = array(
179 'td' =>
'class="left"',
180 'text' =>
'<span class="opacitymedium">'.$langs->trans(
"ReadPermissionNotAllowed").
'</span>'