62 global $conf, $user, $langs;
63 $dataseries = array();
66 $badgeStatus0 =
'#cbd3d3';
67 $badgeStatus1 =
'#bc9526';
68 $badgeStatus1b =
'#bc9526';
69 $badgeStatus2 =
'#9c9c26';
70 $badgeStatus3 =
'#bca52b';
71 $badgeStatus4 =
'#25a580';
72 $badgeStatus4b =
'#25a580';
73 $badgeStatus5 =
'#cad2d2';
74 $badgeStatus6 =
'#cad2d2';
75 $badgeStatus7 =
'#baa32b';
76 $badgeStatus8 =
'#993013';
77 $badgeStatus9 =
'#e7f0f0';
78 if (file_exists(DOL_DOCUMENT_ROOT.
'/theme/'.$conf->theme.
'/theme_vars.inc.php')) {
79 include DOL_DOCUMENT_ROOT.
'/theme/'.$conf->theme.
'/theme_vars.inc.php';
84 $param_day =
'DOLUSERCOOKIE_ticket_last_days';
86 if (
GETPOST($param_day) >= 15) {
94 require_once DOL_DOCUMENT_ROOT.
"/ticket/class/ticket.class.php";
95 $text = $langs->trans(
"BoxTicketLastXDays", $days).
' '.
img_picto(
'',
'filter.png',
'id="idsubimgDOLUSERCOOKIE_ticket_last_days" class="linkobject"');
96 $this->info_box_head = array(
105 if ($user->hasRight(
'ticket',
'read')) {
106 $sql =
"SELECT CAST(t.datec AS DATE) as datec, COUNT(t.datec) as nb";
107 $sql .=
" FROM ".MAIN_DB_PREFIX.
"ticket as t";
108 $sql .=
" WHERE CAST(t.datec AS DATE) > '".$this->db->idate($minimumdatec).
"'";
109 $sql .=
" GROUP BY CAST(t.datec AS DATE)";
111 $resql = $this->db->query($sql);
113 $num = $this->db->num_rows($resql);
116 $objp = $this->db->fetch_object($resql);
117 while ($minimumdatecformated < $objp->datec) {
118 $dataseries[] = array(
'label' =>
dol_print_date($minimumdatec,
'day'),
'data' => 0);
122 $dataseries[] = array(
'label' =>
dol_print_date($this->db->jdate($objp->datec),
'day'),
'data' => $objp->nb);
127 while (count($dataseries) < $days) {
128 $dataseries[] = array(
'label' =>
dol_print_date($minimumdatec,
'day'),
'data' => 0);
136 $stringtoshow =
'<div class="div-table-responsive-no-min">';
137 $stringtoshow .=
'<script nonce="'.getNonce().
'" type="text/javascript">
138 jQuery(document).ready(function() {
139 jQuery("#idsubimgDOLUSERCOOKIE_ticket_last_days").click(function() {
140 jQuery("#idfilterDOLUSERCOOKIE_ticket_last_days").toggle();
144 $stringtoshow .=
'<div class="center hideobject" id="idfilterDOLUSERCOOKIE_ticket_last_days">';
145 $stringtoshow .=
'<form class="flat formboxfilter" method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
146 $stringtoshow .=
'<input type="hidden" name="token" value="'.newToken().
'">';
147 $stringtoshow .=
'<input type="hidden" name="action" value="refresh">';
148 $stringtoshow .=
'<input type="hidden" name="DOL_AUTOSET_COOKIE" value="DOLUSERCOOKIE_ticket_last_days:days">';
149 $stringtoshow .=
' <input class="flat" size="4" type="text" name="'.$param_day.
'" value="'.$days.
'">'.$langs->trans(
"Days");
150 $stringtoshow .=
'<input type="image" alt="'.$langs->trans(
"Refresh").
'" src="'.
img_picto($langs->trans(
"Refresh"),
'refresh.png',
'',
'', 1).
'">';
151 $stringtoshow .=
'</form>';
152 $stringtoshow .=
'</div>';
154 include_once DOL_DOCUMENT_ROOT.
'/core/class/dolgraph.class.php';
157 $mesg = $px1->isGraphKo();
161 foreach ($dataseries as $value) {
162 $data[] = array($value[
'label'], $value[
'data']);
163 $totalnb += $value[
'data'];
165 $px1->SetData($data);
167 $px1->setShowLegend(0);
168 $px1->SetType(array(
'bars'));
169 $px1->SetLegend(array($langs->trans(
'BoxNumberOfTicketByDay')));
170 $px1->SetMaxValue($px1->GetCeilMaxValue());
171 $px1->SetHeight(192);
173 $px1->SetHorizTickIncrement(1);
174 $px1->SetCssPrefix(
"cssboxes");
175 $px1->mode =
'depth';
177 $px1->draw(
'idgraphticketlastxdays');
178 $graphtoshow = $px1->show($totalnb ? 0 : 1);
181 $stringtoshow .= $graphtoshow;
183 $stringtoshow .=
'</div>';
185 $this->info_box_contents[][] = array(
187 'text' => $stringtoshow
190 $this->info_box_contents[0][0] = array(
191 'td' =>
'class="center"',
192 'text' =>
'<span class="opacitymedium">'.$stringtoshow.$langs->trans(
"BoxNoTicketLastXDays", $days).
'</span>'
196 $this->info_box_contents[0][0] = array(
197 'td' =>
'class="left"',
198 'text' =>
'<span class="opacitymedium">'.$langs->trans(
"ReadPermissionNotAllowed").
'</span>'