67 global $conf, $user, $langs;
68 $dataseries = array();
71 $badgeStatus0 =
'#cbd3d3';
72 $badgeStatus1 =
'#bc9526';
73 $badgeStatus1b =
'#bc9526';
74 $badgeStatus2 =
'#9c9c26';
75 $badgeStatus3 =
'#bca52b';
76 $badgeStatus4 =
'#25a580';
77 $badgeStatus4b =
'#25a580';
78 $badgeStatus5 =
'#cad2d2';
79 $badgeStatus6 =
'#cad2d2';
80 $badgeStatus7 =
'#baa32b';
81 $badgeStatus8 =
'#993013';
82 $badgeStatus9 =
'#e7f0f0';
83 if (file_exists(DOL_DOCUMENT_ROOT.
'/theme/'.$conf->theme.
'/theme_vars.inc.php')) {
84 include DOL_DOCUMENT_ROOT.
'/theme/'.$conf->theme.
'/theme_vars.inc.php';
89 $param_day =
'DOLUSERCOOKIE_ticket_last_days';
91 if (
GETPOST($param_day) >= 15) {
99 require_once DOL_DOCUMENT_ROOT.
"/ticket/class/ticket.class.php";
100 $text = $langs->trans(
"BoxTicketLastXDays", $days).
' '.
img_picto(
'',
'filter.png',
'id="idsubimgDOLUSERCOOKIE_ticket_last_days" class="linkobject"');
101 $this->info_box_head = array(
110 if ($user->rights->ticket->read) {
111 $sql =
"SELECT CAST(t.datec AS DATE) as datec, COUNT(t.datec) as nb";
112 $sql .=
" FROM ".MAIN_DB_PREFIX.
"ticket as t";
113 $sql .=
" WHERE CAST(t.datec AS DATE) > '".$this->db->idate($minimumdatec).
"'";
114 $sql .=
" GROUP BY CAST(t.datec AS DATE)";
116 $resql = $this->db->query($sql);
118 $num = $this->db->num_rows($resql);
121 $objp = $this->db->fetch_object($resql);
122 while ($minimumdatecformated < $objp->datec) {
123 $dataseries[] = array(
'label' =>
dol_print_date($minimumdatec,
'day'),
'data' => 0);
127 $dataseries[] = array(
'label' =>
dol_print_date($objp->datec,
'day'),
'data' => $objp->nb);
132 while (count($dataseries) < $days) {
133 $dataseries[] = array(
'label' =>
dol_print_date($minimumdatec,
'day'),
'data' => 0);
141 $stringtoshow =
'<div class="div-table-responsive-no-min">';
142 $stringtoshow .=
'<script nonce="'.getNonce().
'" type="text/javascript">
143 jQuery(document).ready(function() {
144 jQuery("#idsubimgDOLUSERCOOKIE_ticket_last_days").click(function() {
145 jQuery("#idfilterDOLUSERCOOKIE_ticket_last_days").toggle();
149 $stringtoshow .=
'<div class="center hideobject" id="idfilterDOLUSERCOOKIE_ticket_last_days">';
150 $stringtoshow .=
'<form class="flat formboxfilter" method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
151 $stringtoshow .=
'<input type="hidden" name="token" value="'.newToken().
'">';
152 $stringtoshow .=
'<input type="hidden" name="action" value="refresh">';
153 $stringtoshow .=
'<input type="hidden" name="DOL_AUTOSET_COOKIE" value="DOLUSERCOOKIE_ticket_last_days:days">';
154 $stringtoshow .=
' <input class="flat" size="4" type="text" name="'.$param_day.
'" value="'.$days.
'">'.$langs->trans(
"Days");
155 $stringtoshow .=
'<input type="image" alt="'.$langs->trans(
"Refresh").
'" src="'.
img_picto($langs->trans(
"Refresh"),
'refresh.png',
'',
'', 1).
'">';
156 $stringtoshow .=
'</form>';
157 $stringtoshow .=
'</div>';
159 include_once DOL_DOCUMENT_ROOT.
'/core/class/dolgraph.class.php';
162 $mesg = $px1->isGraphKo();
166 foreach ($dataseries as $value) {
167 $data[] = array($value[
'label'], $value[
'data']);
168 $totalnb += $value[
'data'];
170 $px1->SetData($data);
172 $px1->setShowLegend(0);
173 $px1->SetType(array(
'bars'));
174 $px1->SetLegend(array($langs->trans(
'BoxNumberOfTicketByDay')));
175 $px1->SetMaxValue($px1->GetCeilMaxValue());
176 $px1->SetHeight(192);
178 $px1->SetHorizTickIncrement(1);
179 $px1->SetCssPrefix(
"cssboxes");
180 $px1->mode =
'depth';
182 $px1->draw(
'idgraphticketlastxdays');
183 $graphtoshow = $px1->show($totalnb ? 0 : 1);
186 $stringtoshow .= $graphtoshow;
188 $stringtoshow .=
'</div>';
190 $this->info_box_contents[][] = array(
192 'text' => $stringtoshow
195 $this->info_box_contents[0][0] = array(
196 'td' =>
'class="center opacitymedium"',
197 'text' => $stringtoshow.$langs->trans(
"BoxNoTicketLastXDays", $days)
201 $this->info_box_contents[0][0] = array(
202 'td' =>
'class="left"',
203 'text' => $langs->trans(
"ReadPermissionNotAllowed"),