66 global
$conf, $user, $langs;
67 global $theme_datacolor, $badgeStatus8;
69 require_once DOL_DOCUMENT_ROOT.
"/core/lib/functions2.lib.php";
70 require_once DOL_DOCUMENT_ROOT.
"/theme/".
$conf->theme.
"/theme_vars.inc.php";
73 $badgeStatus8 =
'#993013';
75 $text = $langs->trans(
"BoxTicketType");
76 $this->info_box_head = array(
81 $listofopplabel = array();
82 $listofoppcode = array();
83 $colorseriesstat = array();
84 if ($user->hasRight(
'ticket',
'read')) {
85 $sql =
"SELECT ctt.rowid, ctt.label, ctt.code";
86 $sql .=
" FROM " . MAIN_DB_PREFIX .
"c_ticket_type as ctt";
87 $sql .=
" WHERE ctt.active = 1";
88 $sql .= $this->db->order(
'ctt.rowid',
'ASC');
89 $resql = $this->db->query($sql);
92 $num = $this->db->num_rows($resql);
97 $objp = $this->db->fetch_object($resql);
98 $listofoppcode[$objp->rowid] = $objp->code;
99 $listofopplabel[$objp->rowid] = $objp->label;
100 if (empty($colorused[$objp->code])) {
101 if ($objp->code ==
'ISSUE') {
102 $colorused[$objp->code] = $badgeStatus8;
104 $colorused[$objp->code] =
colorArrayToHex($theme_datacolor[$newcolorkey]);
108 $colorseriesstat[$objp->rowid] = $colorused[$objp->code];
115 $dataseries = array();
117 $sql =
"SELECT t.type_code, COUNT(t.type_code) as nb";
118 $sql .=
" FROM " . MAIN_DB_PREFIX .
"ticket as t";
119 $sql .=
" WHERE t.fk_statut <> 8";
120 $sql .=
" GROUP BY t.type_code";
121 $resql = $this->db->query($sql);
123 $num = $this->db->num_rows($resql);
126 $objp = $this->db->fetch_object($resql);
127 $data[$objp->type_code] = $objp->nb;
130 foreach ($listofoppcode as $rowid => $code) {
131 $dataseries[] = array(
132 'label' => $langs->getLabelFromKey($this->db,
'TicketTypeShort' . $code,
'c_ticket_type',
'code',
'label', $code),
133 'data' => (empty($data[$code]) ? 0 : $data[$code])
140 $stringtoprint .=
'<div class="div-table-responsive-no-min ">';
141 if (!empty($dataseries) && count($dataseries) > 0) {
142 include_once DOL_DOCUMENT_ROOT.
'/core/class/dolgraph.class.php';
145 $mesg = $px1->isGraphKo();
148 $px1->SetDataColor(array_values($colorseriesstat));
151 foreach ($dataseries as $value) {
152 $data[] = array($value[
'label'], $value[
'data']);
153 $totalnb += $value[
'data'];
155 $px1->SetData($data);
156 $px1->setShowLegend(2);
157 if (!empty(
$conf->dol_optimize_smallscreen)) {
160 $px1->SetType(array(
'pie'));
161 $px1->SetLegend($legend);
162 $px1->SetMaxValue($px1->GetCeilMaxValue());
164 $px1->SetHorizTickIncrement(1);
165 $px1->SetCssPrefix(
"cssboxes");
166 $px1->mode =
'depth';
167 $px1->draw(
'idgraphtickettype');
168 $stringtoprint .= $px1->show($totalnb ? 0 : 1);
170 $stringtoprint .=
'</div>';
171 $this->info_box_contents[][] = array(
172 'td' =>
'class="center"',
173 'text' => $stringtoprint
176 $this->info_box_contents[0][0] = array(
177 'td' =>
'class="center opacitymedium"',
178 'text' =>
'<span class="opacitymedium">'.$langs->trans(
"BoxNoTicketSeverity").
'</span>'
182 $this->info_box_contents[0][0] = array(
183 'td' =>
'class="left"',
184 'text' =>
'<span class="opacitymedium">'.$langs->trans(
"ReadPermissionNotAllowed").
'</span>'