63 global $conf, $user, $langs;
64 global $theme_datacolor, $badgeStatus8;
66 require_once DOL_DOCUMENT_ROOT.
"/core/lib/functions2.lib.php";
67 require_once DOL_DOCUMENT_ROOT.
"/theme/".$conf->theme.
"/theme_vars.inc.php";
70 $badgeStatus8 =
'#993013';
72 $text = $langs->trans(
"BoxTicketType");
73 $this->info_box_head = array(
78 $listofopplabel = array();
79 $listofoppcode = array();
80 $colorseriesstat = array();
81 if ($user->hasRight(
'ticket',
'read')) {
82 $sql =
"SELECT ctt.rowid, ctt.label, ctt.code";
83 $sql .=
" FROM " . MAIN_DB_PREFIX .
"c_ticket_type as ctt";
84 $sql .=
" WHERE ctt.active = 1";
85 $sql .= $this->db->order(
'ctt.rowid',
'ASC');
86 $resql = $this->db->query($sql);
89 $num = $this->db->num_rows($resql);
94 $objp = $this->db->fetch_object($resql);
95 $listofoppcode[$objp->rowid] = $objp->code;
96 $listofopplabel[$objp->rowid] = $objp->label;
97 if (empty($colorused[$objp->code])) {
98 if ($objp->code ==
'ISSUE') {
99 $colorused[$objp->code] = $badgeStatus8;
101 $colorused[$objp->code] =
colorArrayToHex($theme_datacolor[$newcolorkey]);
105 $colorseriesstat[$objp->rowid] = $colorused[$objp->code];
112 $dataseries = array();
114 $sql =
"SELECT t.type_code, COUNT(t.type_code) as nb";
115 $sql .=
" FROM " . MAIN_DB_PREFIX .
"ticket as t";
116 $sql .=
" WHERE t.fk_statut <> 8";
117 $sql .=
" GROUP BY t.type_code";
118 $resql = $this->db->query($sql);
120 $num = $this->db->num_rows($resql);
123 $objp = $this->db->fetch_object($resql);
124 $data[$objp->type_code] = $objp->nb;
127 foreach ($listofoppcode as $rowid => $code) {
128 $dataseries[] = array(
129 'label' => $langs->getLabelFromKey($this->db,
'TicketTypeShort' . $code,
'c_ticket_type',
'code',
'label', $code),
130 'data' => (empty($data[$code]) ? 0 : $data[$code])
137 $stringtoprint .=
'<div class="div-table-responsive-no-min ">';
138 if (!empty($dataseries) && count($dataseries) > 0) {
139 include_once DOL_DOCUMENT_ROOT.
'/core/class/dolgraph.class.php';
142 $mesg = $px1->isGraphKo();
145 $px1->SetDataColor(array_values($colorseriesstat));
148 foreach ($dataseries as $value) {
149 $data[] = array($value[
'label'], $value[
'data']);
150 $totalnb += $value[
'data'];
152 $px1->SetData($data);
153 $px1->setShowLegend(2);
154 if (!empty($conf->dol_optimize_smallscreen)) {
157 $px1->SetType(array(
'pie'));
158 $px1->SetLegend($legend);
159 $px1->SetMaxValue($px1->GetCeilMaxValue());
161 $px1->SetHorizTickIncrement(1);
162 $px1->SetCssPrefix(
"cssboxes");
163 $px1->mode =
'depth';
164 $px1->draw(
'idgraphtickettype');
165 $stringtoprint .= $px1->show($totalnb ? 0 : 1);
167 $stringtoprint .=
'</div>';
168 $this->info_box_contents[][] = array(
169 'td' =>
'class="center"',
170 'text' => $stringtoprint
173 $this->info_box_contents[0][0] = array(
174 'td' =>
'class="center opacitymedium"',
175 'text' =>
'<span class="opacitymedium">'.$langs->trans(
"BoxNoTicketSeverity").
'</span>'
179 $this->info_box_contents[0][0] = array(
180 'td' =>
'class="left"',
181 'text' =>
'<span class="opacitymedium">'.$langs->trans(
"ReadPermissionNotAllowed").
'</span>'