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