ryxeo-glpi-git / inc / stat.function.php @ b67d8923
Historique | Voir | Annoter | Télécharger (35,8 ko)
1 |
<?php
|
---|---|
2 |
/*
|
3 |
* @version $Id: stat.function.php 7881 2009-01-23 17:56:15Z moyo $
|
4 |
-------------------------------------------------------------------------
|
5 |
GLPI - Gestionnaire Libre de Parc Informatique
|
6 |
Copyright (C) 2003-2009 by the INDEPNET Development Team.
|
7 |
|
8 |
http://indepnet.net/ http://glpi-project.org
|
9 |
-------------------------------------------------------------------------
|
10 |
|
11 |
LICENSE
|
12 |
|
13 |
This file is part of GLPI.
|
14 |
|
15 |
GLPI is free software; you can redistribute it and/or modify
|
16 |
it under the terms of the GNU General Public License as published by
|
17 |
the Free Software Foundation; either version 2 of the License, or
|
18 |
(at your option) any later version.
|
19 |
|
20 |
GLPI is distributed in the hope that it will be useful,
|
21 |
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
22 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
23 |
GNU General Public License for more details.
|
24 |
|
25 |
You should have received a copy of the GNU General Public License
|
26 |
along with GLPI; if not, write to the Free Software
|
27 |
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
28 |
--------------------------------------------------------------------------
|
29 |
*/
|
30 |
|
31 |
// ----------------------------------------------------------------------
|
32 |
// Original Author of file:
|
33 |
// Purpose of file:
|
34 |
// ----------------------------------------------------------------------
|
35 |
|
36 |
if (!defined('GLPI_ROOT')){ |
37 |
die("Sorry. You can't access directly to this file"); |
38 |
} |
39 |
|
40 |
/** Determine if a table is a dropdown one for stat
|
41 |
* @param $table string : table name
|
42 |
* @return boolean
|
43 |
*/
|
44 |
function is_dropdown_stat($table) { |
45 |
$dropdowns = array ("locations","os","model"); |
46 |
if(in_array(str_replace("glpi_dropdown_","",$table),$dropdowns)) return true; |
47 |
elseif(strcmp("glpi_type_computers",$table) == 0) return true; |
48 |
else return false; |
49 |
} |
50 |
|
51 |
|
52 |
function getStatsItems($date1,$date2,$type){ |
53 |
global $CFG_GLPI,$DB; |
54 |
$val=array(); |
55 |
|
56 |
switch ($type){ |
57 |
case "technicien": |
58 |
$val = getNbIntervTech($date1,$date2); |
59 |
break;
|
60 |
case "technicien_followup": |
61 |
$val = getNbIntervTechFollowup($date1,$date2); |
62 |
break;
|
63 |
case "enterprise": |
64 |
$val = getNbIntervEnterprise($date1,$date2); |
65 |
|
66 |
break;
|
67 |
case "user": |
68 |
$val = getNbIntervAuthor($date1,$date2); |
69 |
break;
|
70 |
case "recipient": |
71 |
$val = getNbIntervRecipient($date1,$date2); |
72 |
break;
|
73 |
case "category": |
74 |
$val = getNbIntervCategory($date1,$date2); |
75 |
break;
|
76 |
case "group": |
77 |
$val = getNbIntervGroup($date1,$date2); |
78 |
break;
|
79 |
case "assign_group": |
80 |
$val = getNbIntervAssignGroup($date1,$date2); |
81 |
break;
|
82 |
|
83 |
case "priority": |
84 |
$val = getNbIntervPriority($date1,$date2); |
85 |
|
86 |
break;
|
87 |
case "request_type": |
88 |
$val = getNbIntervRequestType($date1,$date2); |
89 |
|
90 |
break;
|
91 |
case "glpi_type_computers": |
92 |
case "glpi_dropdown_model": |
93 |
case "glpi_dropdown_os": |
94 |
case "glpi_dropdown_locations": |
95 |
$val = getNbIntervDropdown($type); |
96 |
|
97 |
break;
|
98 |
// DEVICE CASE
|
99 |
default :
|
100 |
$device_table = getDeviceTable($type); |
101 |
|
102 |
//select devices IDs (table row)
|
103 |
$query = "select ID, designation from `".$device_table."` order by designation"; |
104 |
$result = $DB->query($query); |
105 |
|
106 |
if($DB->numrows($result) >=1) { |
107 |
$i = 0; |
108 |
while($line = $DB->fetch_assoc($result)) { |
109 |
$val[$i]['ID'] = $line['ID']; |
110 |
$val[$i]['link'] = $line['designation']; |
111 |
$i++;
|
112 |
} |
113 |
} |
114 |
|
115 |
break;
|
116 |
} |
117 |
return $val; |
118 |
} |
119 |
|
120 |
function displayStats($type,$field,$date1,$date2,$start,$value,$value2=""){ |
121 |
global $LANG,$CFG_GLPI; |
122 |
|
123 |
// Set display type for export if define
|
124 |
$output_type=HTML_OUTPUT; |
125 |
if (isset($_GET["display_type"])) |
126 |
$output_type=$_GET["display_type"]; |
127 |
|
128 |
if ($output_type==HTML_OUTPUT) // HTML display |
129 |
echo "<div align ='center'>"; |
130 |
|
131 |
if (is_array($value)){ |
132 |
|
133 |
|
134 |
$end_display=$start+$_SESSION["glpilist_limit"]; |
135 |
$numrows=count($value); |
136 |
if (isset($_GET['export_all'])) { |
137 |
$start=0; |
138 |
$end_display=$numrows; |
139 |
} |
140 |
$nbcols=8; |
141 |
if ($output_type!=HTML_OUTPUT) // not HTML display |
142 |
$nbcols--;
|
143 |
echo displaySearchHeader($output_type,$end_display-$start+1,$nbcols); |
144 |
echo displaySearchNewLine($output_type); |
145 |
$header_num=1; |
146 |
echo displaySearchHeaderItem($output_type," ",$header_num); |
147 |
if ($output_type==HTML_OUTPUT){ // HTML display |
148 |
echo displaySearchHeaderItem($output_type,"",$header_num); |
149 |
} |
150 |
echo displaySearchHeaderItem($output_type,$LANG["stats"][13],$header_num); |
151 |
echo displaySearchHeaderItem($output_type,$LANG["stats"][11],$header_num); |
152 |
echo displaySearchHeaderItem($output_type,$LANG["stats"][15],$header_num); |
153 |
echo displaySearchHeaderItem($output_type,$LANG["stats"][25],$header_num); |
154 |
echo displaySearchHeaderItem($output_type,$LANG["stats"][27],$header_num); |
155 |
echo displaySearchHeaderItem($output_type,$LANG["stats"][30],$header_num); |
156 |
// End Line for column headers
|
157 |
echo displaySearchEndLine($output_type); |
158 |
$row_num=1; |
159 |
for ($i=$start;$i< $numrows && $i<($end_display);$i++){ |
160 |
$row_num++;
|
161 |
$item_num=1; |
162 |
echo displaySearchNewLine($output_type,$i%2); |
163 |
echo displaySearchItem($output_type,$value[$i]['link'],$item_num,$row_num); |
164 |
if ($output_type==HTML_OUTPUT){ // HTML display |
165 |
|
166 |
$link=""; |
167 |
if ($value[$i]['ID']>0){ |
168 |
$link="<a href='stat.graph.php?ID=".$value[$i]['ID']."&date1=$date1&date2=$date2&type=$type".(!empty($value2)?"&champ=$value2":"")."'><img src=\"".$CFG_GLPI["root_doc"]."/pics/stats_item.png\" alt='' title=''></a>"; |
169 |
} |
170 |
echo displaySearchItem($output_type,$link,$item_num,$row_num); |
171 |
} |
172 |
|
173 |
//le nombre d'intervention
|
174 |
//the number of intervention
|
175 |
$opened=constructEntryValues("inter_total",$date1,$date2,$type,$value[$i]["ID"],$value2); |
176 |
$nb_opened=array_sum($opened); |
177 |
echo displaySearchItem($output_type,$nb_opened,$item_num,$row_num); |
178 |
//le nombre d'intervention resolues
|
179 |
//the number of resolved intervention
|
180 |
$solved=constructEntryValues("inter_solved",$date1,$date2,$type,$value[$i]["ID"],$value2); |
181 |
$nb_solved=array_sum($solved); |
182 |
echo displaySearchItem($output_type,$nb_solved,$item_num,$row_num); |
183 |
//Le temps moyen de resolution
|
184 |
//The average time to resolv
|
185 |
$data=constructEntryValues("inter_avgsolvedtime",$date1,$date2,$type,$value[$i]["ID"],$value2); |
186 |
foreach ($data as $key2 => $val2){ |
187 |
$data[$key2]*=$solved[$key2]; |
188 |
} |
189 |
if ($nb_solved>0) |
190 |
$nb=array_sum($data)/$nb_solved; |
191 |
else $nb=0; |
192 |
|
193 |
$timedisplay=$nb*HOUR_TIMESTAMP; |
194 |
if ($output_type==HTML_OUTPUT || $output_type==PDF_OUTPUT_LANDSCAPE || $output_type==PDF_OUTPUT_PORTRAIT){ |
195 |
$timedisplay=timestampToString($timedisplay,0); |
196 |
} |
197 |
echo displaySearchItem($output_type,$timedisplay,$item_num,$row_num); |
198 |
//Le temps moyen de l'intervention r�lle
|
199 |
//The average realtime to resolv
|
200 |
$data=constructEntryValues("inter_avgrealtime",$date1,$date2,$type,$value[$i]["ID"],$value2); |
201 |
foreach ($data as $key2 => $val2){ |
202 |
$data[$key2]*=$solved[$key2]; |
203 |
} |
204 |
$total_realtime=array_sum($data); |
205 |
if ($nb_solved>0) |
206 |
$nb=$total_realtime/$nb_solved; |
207 |
else $nb=0; |
208 |
|
209 |
$timedisplay=$nb*MINUTE_TIMESTAMP; |
210 |
if ($output_type==HTML_OUTPUT || $output_type==PDF_OUTPUT_LANDSCAPE || $output_type==PDF_OUTPUT_PORTRAIT){ |
211 |
$timedisplay=timestampToString($timedisplay,0); |
212 |
} |
213 |
echo displaySearchItem($output_type,$timedisplay,$item_num,$row_num); |
214 |
//Le temps total de l'intervention r�lle
|
215 |
//The total realtime to resolv
|
216 |
$timedisplay=$total_realtime*MINUTE_TIMESTAMP; |
217 |
if ($output_type==HTML_OUTPUT || $output_type==PDF_OUTPUT_LANDSCAPE || $output_type==PDF_OUTPUT_PORTRAIT){ |
218 |
$timedisplay=timestampToString($timedisplay,0); |
219 |
} |
220 |
echo displaySearchItem($output_type,$timedisplay,$item_num,$row_num); |
221 |
//Le temps moyen de prise en compte du ticket
|
222 |
//The average time to take a ticket into account
|
223 |
$data=constructEntryValues("inter_avgtakeaccount",$date1,$date2,$type,$value[$i]["ID"],$value2); |
224 |
|
225 |
foreach ($data as $key2 => $val2){ |
226 |
$data[$key2]*=$solved[$key2]; |
227 |
} |
228 |
if ($nb_solved>0) |
229 |
$nb=array_sum($data)/$nb_solved; |
230 |
else $nb=0; |
231 |
|
232 |
$timedisplay=$nb*HOUR_TIMESTAMP; |
233 |
if ($output_type==HTML_OUTPUT || $output_type==PDF_OUTPUT_LANDSCAPE || $output_type==PDF_OUTPUT_PORTRAIT){ |
234 |
$timedisplay=timestampToString($timedisplay,0); |
235 |
} |
236 |
echo displaySearchItem($output_type,$timedisplay,$item_num,$row_num); |
237 |
|
238 |
echo displaySearchEndLine($output_type); |
239 |
} |
240 |
// Display footer
|
241 |
echo displaySearchFooter($output_type); |
242 |
} else {
|
243 |
echo $LANG["stats"][23]; |
244 |
} |
245 |
if ($output_type==HTML_OUTPUT) // HTML display |
246 |
echo "</div>"; |
247 |
} |
248 |
|
249 |
|
250 |
/** Get users which have intervention assigned to between 2 dates
|
251 |
* @param $date1 date : begin date
|
252 |
* @param $date2 date : end date
|
253 |
* @return array contains the distinct users which have any intervention assigned to.
|
254 |
*/
|
255 |
function getNbIntervTech($date1,$date2){ |
256 |
global $DB; |
257 |
$query = "SELECT distinct glpi_tracking.assign as assign, glpi_users.name as name, glpi_users.realname as realname, glpi_users.firstname as firstname"; |
258 |
$query.= " FROM glpi_tracking "; |
259 |
$query.= " LEFT JOIN glpi_users ON (glpi_users.ID=glpi_tracking.assign) "; |
260 |
|
261 |
$query.=getEntitiesRestrictRequest("WHERE","glpi_tracking"); |
262 |
if ($date1!="") $query.= " AND glpi_tracking.date >= '". $date1 ."' "; |
263 |
if ($date2!="") $query.= " AND glpi_tracking.date <= adddate( '". $date2 ."' , INTERVAL 1 DAY ) "; |
264 |
$query.= " ORDER BY realname, firstname, name"; |
265 |
$result = $DB->query($query); |
266 |
$tab=array(); |
267 |
|
268 |
if($DB->numrows($result) >=1) { |
269 |
while($line = $DB->fetch_assoc($result)) { |
270 |
$tmp['ID']= $line["assign"]; |
271 |
$tmp['link']=formatUserName($line["assign"],$line["name"],$line["realname"],$line["firstname"],1); |
272 |
$tab[]=$tmp; |
273 |
} |
274 |
} |
275 |
return $tab; |
276 |
} |
277 |
|
278 |
/** Get users which have followup assigned to between 2 dates
|
279 |
* @param $date1 date : begin date
|
280 |
* @param $date2 date : end date
|
281 |
* @return array contains the distinct users which have any followup assigned to.
|
282 |
*/
|
283 |
function getNbIntervTechFollowup($date1,$date2){ |
284 |
global $DB; |
285 |
$query = "SELECT DISTINCT glpi_followups.author as author, glpi_users.name as name, glpi_users.realname as realname, glpi_users.firstname as firstname"; |
286 |
$query.= " FROM glpi_tracking "; |
287 |
$query.= " LEFT JOIN glpi_followups ON (glpi_tracking.ID = glpi_followups.tracking) "; |
288 |
$query.= " LEFT JOIN glpi_users ON (glpi_users.ID=glpi_followups.author) "; |
289 |
|
290 |
$query.=getEntitiesRestrictRequest("WHERE","glpi_tracking"); |
291 |
if ($date1!="") $query.= " AND glpi_tracking.date >= '". $date1 ."' "; |
292 |
if ($date2!="") $query.= " AND glpi_tracking.date <= adddate( '". $date2 ."' , INTERVAL 1 DAY ) "; |
293 |
|
294 |
$query.=" AND glpi_followups.author <> 0 AND glpi_followups.author IS NOT NULL"; |
295 |
$query.= " ORDER BY realname,firstname, name"; |
296 |
$result = $DB->query($query); |
297 |
$tab=array(); |
298 |
|
299 |
if($DB->numrows($result) >=1) { |
300 |
while($line = $DB->fetch_assoc($result)) { |
301 |
$tmp['ID']= $line["author"]; |
302 |
$tmp['link']=formatUserName($line["author"],$line["name"],$line["realname"],$line["firstname"],1); |
303 |
$tab[]=$tmp; |
304 |
} |
305 |
} |
306 |
return $tab; |
307 |
} |
308 |
|
309 |
|
310 |
/** Get enterprises which have followup assigned to between 2 dates
|
311 |
* @param $date1 date : begin date
|
312 |
* @param $date2 date : end date
|
313 |
* @return array contains the distinct enterprises which have any tickets assigned to.
|
314 |
*/
|
315 |
function getNbIntervEnterprise($date1,$date2){ |
316 |
global $DB,$CFG_GLPI; |
317 |
$query = "SELECT distinct glpi_tracking.assign_ent as assign_ent, glpi_enterprises.name as name"; |
318 |
$query.= " FROM glpi_tracking "; |
319 |
$query.= " LEFT JOIN glpi_enterprises ON (glpi_enterprises.ID=glpi_tracking.assign_ent) "; |
320 |
|
321 |
$query.=getEntitiesRestrictRequest("WHERE","glpi_tracking"); |
322 |
if ($date1!="") $query.= " AND glpi_tracking.date >= '". $date1 ."' "; |
323 |
if ($date2!="") $query.= " AND glpi_tracking.date <= adddate( '". $date2 ."' , INTERVAL 1 DAY ) "; |
324 |
|
325 |
$query.= " ORDER BY name"; |
326 |
$tab=array(); |
327 |
$result = $DB->query($query); |
328 |
if($DB->numrows($result) >0) { |
329 |
|
330 |
while($line = $DB->fetch_assoc($result)) { |
331 |
$tmp["ID"]=$line["assign_ent"]; |
332 |
$tmp["link"]="<a href='".$CFG_GLPI["root_doc"]."/front/enterprise.form.php?ID=".$line["assign_ent"]."'>"; |
333 |
$tmp["link"].=$line["name"]; |
334 |
$tmp["link"].="</a>"; |
335 |
$tab[]=$tmp; |
336 |
} |
337 |
|
338 |
} |
339 |
return $tab; |
340 |
} |
341 |
|
342 |
/** Get dropdown values
|
343 |
* @param $dropdown string : table name
|
344 |
* @return array contains the distinct dropdown values
|
345 |
*/
|
346 |
function getNbIntervDropdown($dropdown){ |
347 |
global $DB,$CFG_GLPI; |
348 |
$field="name"; |
349 |
|
350 |
if (in_array($dropdown,$CFG_GLPI["dropdowntree_tables"])) { |
351 |
$field="completename"; |
352 |
} |
353 |
$where=" "; |
354 |
$order=" ORDER BY $field"; |
355 |
if (in_array($dropdown,$CFG_GLPI["specif_entities_tables"])){ |
356 |
$where=getEntitiesRestrictRequest(" WHERE",$dropdown); |
357 |
$order=" ORDER BY FK_entities, $field"; |
358 |
} |
359 |
|
360 |
$query = "SELECT * FROM `". $dropdown."` ".$where.$order; |
361 |
$tab=array(); |
362 |
$result = $DB->query($query); |
363 |
if($DB->numrows($result) >0) { |
364 |
while($line = $DB->fetch_assoc($result)) { |
365 |
$tmp['ID']= $line["ID"]; |
366 |
$tmp['link']=$line[$field]; |
367 |
$tab[]=$tmp; |
368 |
} |
369 |
|
370 |
} |
371 |
return $tab; |
372 |
|
373 |
} |
374 |
|
375 |
/** Get authors of tickets between 2 dates
|
376 |
* @param $date1 date : begin date
|
377 |
* @param $date2 date : end date
|
378 |
* @return array contains the distinct authors which have tickets
|
379 |
*/
|
380 |
function getNbIntervAuthor($date1,$date2){ |
381 |
global $DB; |
382 |
$query = "SELECT DISTINCT glpi_tracking.author as ID, glpi_users.name as name, glpi_users.realname as realname, glpi_users.firstname as firstname FROM glpi_tracking INNER JOIN glpi_users ON (glpi_users.ID=glpi_tracking.author)"; |
383 |
$query.=getEntitiesRestrictRequest("WHERE","glpi_tracking"); |
384 |
if ($date1!="") $query.= " AND glpi_tracking.date >= '". $date1 ."' "; |
385 |
if ($date2!="") $query.= " AND glpi_tracking.date <= adddate( '". $date2 ."' , INTERVAL 1 DAY ) "; |
386 |
|
387 |
$query.= " ORDER BY realname, firstname, name"; |
388 |
$result = $DB->query($query); |
389 |
$tab=array(); |
390 |
if($DB->numrows($result) >=1) { |
391 |
while($line = $DB->fetch_assoc($result)) { |
392 |
$tmp['ID']= $line["ID"]; |
393 |
$tmp['link']=formatUserName($line["ID"],$line["name"],$line["realname"],$line["firstname"],1); |
394 |
$tab[]=$tmp; |
395 |
} |
396 |
} |
397 |
return $tab; |
398 |
|
399 |
} |
400 |
|
401 |
/** Get recipient of tickets between 2 dates
|
402 |
* @param $date1 date : begin date
|
403 |
* @param $date2 date : end date
|
404 |
* @return array contains the distinct recipents which have tickets
|
405 |
*/
|
406 |
function getNbIntervRecipient($date1,$date2){ |
407 |
global $DB; |
408 |
$query = "SELECT DISTINCT glpi_tracking.recipient as ID, glpi_users.name as name, glpi_users.realname as realname, glpi_users.firstname as firstname FROM glpi_tracking LEFT JOIN glpi_users ON (glpi_users.ID=glpi_tracking.recipient)"; |
409 |
$query.=getEntitiesRestrictRequest("WHERE","glpi_tracking"); |
410 |
if ($date1!="") $query.= " AND glpi_tracking.date >= '". $date1 ."' "; |
411 |
if ($date2!="") $query.= " AND glpi_tracking.date <= adddate( '". $date2 ."' , INTERVAL 1 DAY ) "; |
412 |
|
413 |
$query.= " ORDER BY realname, firstname, name"; |
414 |
$result = $DB->query($query); |
415 |
$tab=array(); |
416 |
if($DB->numrows($result) >=1) { |
417 |
while($line = $DB->fetch_assoc($result)) { |
418 |
$tmp['ID']= $line["ID"]; |
419 |
$tmp['link']=formatUserName($line["ID"],$line["name"],$line["realname"],$line["firstname"],1); |
420 |
$tab[]=$tmp; |
421 |
} |
422 |
} |
423 |
return $tab; |
424 |
|
425 |
} |
426 |
|
427 |
/** Get priorities of tickets between 2 dates
|
428 |
* @param $date1 date : begin date
|
429 |
* @param $date2 date : end date
|
430 |
* @return array contains the distinct priorities of tickets
|
431 |
*/
|
432 |
function getNbIntervPriority($date1,$date2){ |
433 |
global $DB; |
434 |
|
435 |
$query = "SELECT DISTINCT priority |
436 |
FROM glpi_tracking ".getEntitiesRestrictRequest("WHERE","glpi_tracking"); |
437 |
if ($date1!="") $query.= " AND glpi_tracking.date >= '". $date1 ."' "; |
438 |
if ($date2!="") $query.= " AND glpi_tracking.date <= adddate( '". $date2 ."' , INTERVAL 1 DAY ) "; |
439 |
$query.=" ORDER BY priority"; |
440 |
|
441 |
$result = $DB->query($query); |
442 |
$tab=array(); |
443 |
if($DB->numrows($result) >=1) { |
444 |
$i = 0; |
445 |
while($line = $DB->fetch_assoc($result)) { |
446 |
$tmp['ID']= $line["priority"]; |
447 |
$tmp['link']=getPriorityName($line["priority"]); |
448 |
$tab[]=$tmp; |
449 |
} |
450 |
} |
451 |
return $tab; |
452 |
|
453 |
} |
454 |
|
455 |
/** Get request types of tickets between 2 dates
|
456 |
* @param $date1 date : begin date
|
457 |
* @param $date2 date : end date
|
458 |
* @return array contains the distinct request types of tickets
|
459 |
*/
|
460 |
function getNbIntervRequestType($date1,$date2){ |
461 |
global $DB; |
462 |
$query = "SELECT DISTINCT request_type |
463 |
FROM glpi_tracking ".getEntitiesRestrictRequest("WHERE","glpi_tracking"); |
464 |
if ($date1!="") $query.= " AND glpi_tracking.date >= '". $date1 ."' "; |
465 |
if ($date2!="") $query.= " AND glpi_tracking.date <= adddate( '". $date2 ."' , INTERVAL 1 DAY ) "; |
466 |
$query.=" ORDER BY request_type"; |
467 |
$result = $DB->query($query); |
468 |
$tab=array(); |
469 |
if($DB->numrows($result) >=1) { |
470 |
while($line = $DB->fetch_assoc($result)) { |
471 |
$tmp['ID']= $line["request_type"]; |
472 |
$tmp['link']=getRequestTypeName($line["request_type"]); |
473 |
$tab[]=$tmp; |
474 |
} |
475 |
} |
476 |
|
477 |
return $tab; |
478 |
} |
479 |
|
480 |
/** Get categories of tickets between 2 dates
|
481 |
* @param $date1 date : begin date
|
482 |
* @param $date2 date : end date
|
483 |
* @return array contains the distinct categories of tickets
|
484 |
*/
|
485 |
function getNbIntervCategory($date1,$date2){ |
486 |
global $DB; |
487 |
|
488 |
$query = "SELECT DISTINCT glpi_dropdown_tracking_category.ID, glpi_dropdown_tracking_category.completename AS category |
489 |
FROM glpi_tracking
|
490 |
LEFT JOIN glpi_dropdown_tracking_category ON (glpi_tracking.category = glpi_dropdown_tracking_category.ID) ";
|
491 |
$query.=getEntitiesRestrictRequest(" WHERE","glpi_tracking"); |
492 |
if ($date1!="") $query.= " AND glpi_tracking.date >= '". $date1 ."' "; |
493 |
if ($date2!="") $query.= " AND glpi_tracking.date <= adddate( '". $date2 ."' , INTERVAL 1 DAY ) "; |
494 |
|
495 |
$query.=" ORDER BY glpi_dropdown_tracking_category.completename"; |
496 |
|
497 |
$result = $DB->query($query); |
498 |
$tab=array(); |
499 |
if($DB->numrows($result) >=1) { |
500 |
while($line = $DB->fetch_assoc($result)) { |
501 |
$tmp['ID']= $line["ID"]; |
502 |
$tmp['link']=$line["category"]; |
503 |
$tab[]=$tmp; |
504 |
} |
505 |
} |
506 |
return $tab; |
507 |
} |
508 |
|
509 |
|
510 |
/** Get groups which have tickets between 2 dates
|
511 |
* @param $date1 date : begin date
|
512 |
* @param $date2 date : end date
|
513 |
* @return array contains the distinct groups of tickets
|
514 |
*/
|
515 |
function getNbIntervGroup($date1,$date2){ |
516 |
global $DB; |
517 |
$query = "SELECT DISTINCT glpi_groups.id AS ID,glpi_groups.name FROM glpi_tracking |
518 |
LEFT JOIN glpi_groups ON (glpi_tracking.FK_group = glpi_groups.ID)";
|
519 |
$query.=getEntitiesRestrictRequest(" WHERE","glpi_tracking"); |
520 |
if ($date1!="") $query.= " AND glpi_tracking.date >= '". $date1 ."' "; |
521 |
if ($date2!="") $query.= " AND glpi_tracking.date <= adddate( '". $date2 ."' , INTERVAL 1 DAY ) "; |
522 |
$query.=" ORDER BY glpi_groups.name"; |
523 |
|
524 |
$result = $DB->query($query); |
525 |
$tab=array(); |
526 |
|
527 |
if($DB->numrows($result) >=1) { |
528 |
while($line = $DB->fetch_assoc($result)) { |
529 |
$tmp['ID']= $line["ID"]; |
530 |
$tmp['link']=$line["name"]; |
531 |
|
532 |
$tab[]=$tmp; |
533 |
} |
534 |
} |
535 |
return $tab; |
536 |
} |
537 |
|
538 |
|
539 |
/** Get groups assigned to tickets between 2 dates
|
540 |
* @param $date1 date : begin date
|
541 |
* @param $date2 date : end date
|
542 |
* @return array contains the distinct groups assigned to a tickets
|
543 |
*/
|
544 |
function getNbIntervAssignGroup($date1,$date2){ |
545 |
global $DB; |
546 |
$query = "SELECT DISTINCT glpi_groups.id AS ID,glpi_groups.name FROM glpi_tracking |
547 |
LEFT JOIN glpi_groups ON (glpi_tracking.assign_group = glpi_groups.ID)";
|
548 |
$query.=getEntitiesRestrictRequest(" WHERE","glpi_tracking"); |
549 |
if ($date1!="") $query.= " AND glpi_tracking.date >= '". $date1 ."' "; |
550 |
if ($date2!="") $query.= " AND glpi_tracking.date <= adddate( '". $date2 ."' , INTERVAL 1 DAY ) "; |
551 |
$query.=" ORDER BY glpi_groups.name"; |
552 |
|
553 |
$result = $DB->query($query); |
554 |
$tab=array(); |
555 |
|
556 |
if($DB->numrows($result) >=1) { |
557 |
while($line = $DB->fetch_assoc($result)) { |
558 |
$tmp['ID']= $line["ID"]; |
559 |
$tmp['link']=$line["name"]; |
560 |
|
561 |
$tab[]=$tmp; |
562 |
} |
563 |
} |
564 |
return $tab; |
565 |
} |
566 |
|
567 |
function constructEntryValues($type,$begin="",$end="",$param="",$value="",$value2=""){ |
568 |
global $DB; |
569 |
|
570 |
if (empty($end)) $end=date("Y-m-d"); |
571 |
$end.=" 23:59:59"; |
572 |
// 1 an par defaut
|
573 |
if (empty($begin)) $begin=date("Y-m-d",mktime(0,0,0,date("m"),date("d"),date("Y")-1)); |
574 |
$begin.=" 00:00:00"; |
575 |
|
576 |
$query=""; |
577 |
|
578 |
$WHERE=getEntitiesRestrictRequest("WHERE","glpi_tracking"); |
579 |
if (empty($WHERE)){ |
580 |
$WHERE=" WHERE 1 "; |
581 |
} |
582 |
$LEFTJOIN=""; |
583 |
switch ($param){ |
584 |
|
585 |
case "technicien": |
586 |
$WHERE.=" AND glpi_tracking.assign='$value'"; |
587 |
break;
|
588 |
case "technicien_followup": |
589 |
$WHERE.=" AND glpi_followups.author='$value'"; |
590 |
$LEFTJOIN= "LEFT JOIN glpi_followups ON (glpi_followups.tracking = glpi_tracking.ID)"; |
591 |
break;
|
592 |
case "enterprise": |
593 |
$WHERE.=" AND glpi_tracking.assign_ent='$value'"; |
594 |
break;
|
595 |
case "user": |
596 |
$WHERE.=" AND glpi_tracking.author='$value'"; |
597 |
break;
|
598 |
case "recipient": |
599 |
$WHERE.=" AND glpi_tracking.recipient='$value'"; |
600 |
break;
|
601 |
case "category": |
602 |
if (!empty($value)){ |
603 |
$categories=getSonsOfTreeItem("glpi_dropdown_tracking_category",$value); |
604 |
$condition=""; |
605 |
$first=true; |
606 |
foreach ($categories as $ID){ |
607 |
if ($first){ |
608 |
$first=false; |
609 |
} else {
|
610 |
$condition.=","; |
611 |
} |
612 |
$condition.=$ID; |
613 |
} |
614 |
|
615 |
$WHERE.=" AND glpi_tracking.category IN ($condition)"; |
616 |
} else {
|
617 |
$WHERE.=" AND glpi_tracking.category = '$value' "; |
618 |
} |
619 |
break;
|
620 |
case "group": |
621 |
$WHERE.=" AND glpi_tracking.FK_group='$value'"; |
622 |
break;
|
623 |
case "assign_group": |
624 |
$WHERE.=" AND glpi_tracking.assign_group='$value'"; |
625 |
break;
|
626 |
case "priority": |
627 |
$WHERE.=" AND glpi_tracking.priority='$value'"; |
628 |
break;
|
629 |
case "request_type": |
630 |
$WHERE.=" AND glpi_tracking.request_type='$value'"; |
631 |
break;
|
632 |
|
633 |
case "device": |
634 |
//select computers IDs that are using this device;
|
635 |
|
636 |
$LEFTJOIN= "INNER JOIN glpi_computers ON (glpi_computers.ID = glpi_tracking.computer AND glpi_tracking.device_type='".COMPUTER_TYPE."') INNER JOIN glpi_computer_device ON ( glpi_computers.ID = glpi_computer_device.FK_computers AND glpi_computer_device.device_type = '".$value2."' AND glpi_computer_device.FK_device = '".$value."' )"; |
637 |
|
638 |
$WHERE.=" AND glpi_computers.is_template <> '1' "; |
639 |
|
640 |
break;
|
641 |
case "comp_champ": |
642 |
$LEFTJOIN= "INNER JOIN glpi_computers ON (glpi_computers.ID = glpi_tracking.computer AND glpi_tracking.device_type='".COMPUTER_TYPE."')"; |
643 |
|
644 |
$WHERE.=" AND `glpi_computers`.`$value2`='$value' AND glpi_computers.is_template <> '1'"; |
645 |
break;
|
646 |
} |
647 |
switch($type) { |
648 |
|
649 |
case "inter_total": |
650 |
if (!empty($begin)) $WHERE.= " AND glpi_tracking.date >= '$begin' "; |
651 |
if (!empty($end)) $WHERE.= " AND glpi_tracking.date <= '$end' "; |
652 |
|
653 |
$query="SELECT FROM_UNIXTIME(UNIX_TIMESTAMP(glpi_tracking.date),'%Y-%m') AS date_unix, COUNT(glpi_tracking.ID) AS total_visites FROM glpi_tracking ".$LEFTJOIN.$WHERE. |
654 |
" GROUP BY date_unix ORDER BY glpi_tracking.date";
|
655 |
break;
|
656 |
case "inter_solved": |
657 |
$WHERE.=" AND ( glpi_tracking.status = 'old_done' OR glpi_tracking.status = 'old_notdone') AND glpi_tracking.closedate <> '0000-00-00 00:00:00' "; |
658 |
if (!empty($begin)) $WHERE.= " AND glpi_tracking.closedate >= '$begin' "; |
659 |
if (!empty($end)) $WHERE.= " AND glpi_tracking.closedate <= '$end' "; |
660 |
|
661 |
$query="SELECT FROM_UNIXTIME(UNIX_TIMESTAMP(glpi_tracking.closedate),'%Y-%m') AS date_unix, COUNT(glpi_tracking.ID) AS total_visites FROM glpi_tracking ".$LEFTJOIN.$WHERE. |
662 |
" GROUP BY date_unix ORDER BY glpi_tracking.closedate";
|
663 |
break;
|
664 |
case "inter_avgsolvedtime" : |
665 |
$WHERE.=" AND ( glpi_tracking.status = 'old_done' OR glpi_tracking.status = 'old_notdone') AND glpi_tracking.closedate <> '0000-00-00 00:00:00' "; |
666 |
if (!empty($begin)) $WHERE.= " AND glpi_tracking.closedate >= '$begin' "; |
667 |
if (!empty($end)) $WHERE.= " AND glpi_tracking.closedate <= '$end' "; |
668 |
|
669 |
$query="SELECT FROM_UNIXTIME(UNIX_TIMESTAMP(glpi_tracking.closedate),'%Y-%m') AS date_unix, |
670 |
AVG(TIME_TO_SEC( TIMEDIFF(glpi_tracking.closedate,glpi_tracking.date))/".HOUR_TIMESTAMP.") AS total_visites FROM glpi_tracking ". |
671 |
$LEFTJOIN.$WHERE. |
672 |
" GROUP BY date_unix ORDER BY glpi_tracking.closedate";
|
673 |
break;
|
674 |
case "inter_avgrealtime" : |
675 |
if ($param=="technicien_followup") |
676 |
$realtime_table="glpi_followups"; |
677 |
else $realtime_table="glpi_tracking"; |
678 |
$WHERE.=" AND $realtime_table.realtime > '0' "; |
679 |
if (!empty($begin)) $WHERE.= " AND glpi_tracking.closedate >= '$begin' "; |
680 |
if (!empty($end)) $WHERE.= " AND glpi_tracking.closedate <= '$end' "; |
681 |
|
682 |
$query="SELECT FROM_UNIXTIME(UNIX_TIMESTAMP(glpi_tracking.closedate),'%Y-%m') AS date_unix, ".MINUTE_TIMESTAMP."*AVG($realtime_table.realtime) AS total_visites FROM glpi_tracking ". |
683 |
$LEFTJOIN.$WHERE. |
684 |
" GROUP BY date_unix ORDER BY glpi_tracking.closedate";
|
685 |
break;
|
686 |
case "inter_avgtakeaccount" : |
687 |
$WHERE.=" AND ( glpi_tracking.status = 'old_done' OR glpi_tracking.status = 'old_notdone') AND glpi_tracking.closedate <> '0000-00-00 00:00:00' "; |
688 |
if (!empty($begin)) $WHERE.= " AND glpi_tracking.closedate >= '$begin' "; |
689 |
if (!empty($end)) $WHERE.= " AND glpi_tracking.closedate <= '$end' "; |
690 |
|
691 |
$query="SELECT glpi_tracking.ID AS ID, FROM_UNIXTIME(UNIX_TIMESTAMP(glpi_tracking.closedate),'%Y-%m') AS date_unix, MIN(UNIX_TIMESTAMP(glpi_tracking.closedate)-UNIX_TIMESTAMP(glpi_tracking.date)) AS OPEN, MIN(UNIX_TIMESTAMP(glpi_followups.date)-UNIX_TIMESTAMP(glpi_tracking.date)) AS FIRST FROM glpi_tracking LEFT JOIN glpi_followups ON (glpi_followups.tracking = glpi_tracking.ID) "; |
692 |
if (!ereg("glpi_followups",$LEFTJOIN)){ |
693 |
$query.=$LEFTJOIN; |
694 |
} |
695 |
$query.=$WHERE." GROUP BY glpi_tracking.ID"; |
696 |
break;
|
697 |
|
698 |
// $query = " from glpi_tracking LEFT JOIN glpi_followups ON (glpi_followups.tracking = glpi_tracking.ID) where glpi_tracking.status ='old' and closedate != '0000-00-00' and YEAR(glpi_tracking.date) = YEAR(NOW())";
|
699 |
|
700 |
} |
701 |
//echo $query."<br><br>";
|
702 |
$entrees=array(); |
703 |
$count=array(); |
704 |
if (empty($query)) return array(); |
705 |
|
706 |
$result=$DB->query($query); |
707 |
if ($result&&$DB->numrows($result)>0) |
708 |
while ($row = $DB->fetch_array($result)) { |
709 |
$date = $row['date_unix']; |
710 |
if ($type=="inter_avgtakeaccount"){ |
711 |
$min=$row["OPEN"]; |
712 |
if (!empty($row["FIRST"])&&!is_null($row["FIRST"])&&$row["FIRST"]<$min) $min=$row["FIRST"]; |
713 |
if (!isset($entrees["$date"])) {$entrees["$date"]=$min; $count["$date"]=1;} |
714 |
else {$entrees["$date"]+=$min;$count["$date"]++;} |
715 |
} else {
|
716 |
$visites = round($row['total_visites']); |
717 |
$entrees["$date"] = $visites; |
718 |
} |
719 |
} |
720 |
|
721 |
|
722 |
|
723 |
if ($type=="inter_avgtakeaccount"){ |
724 |
|
725 |
foreach ($entrees as $key => $val){ |
726 |
$entrees[$key]=round($entrees[$key]/$count[$key]/HOUR_TIMESTAMP); |
727 |
|
728 |
} |
729 |
} |
730 |
|
731 |
// Remplissage de $entrees pour les mois ou il n'y a rien
|
732 |
|
733 |
$min=-1; |
734 |
$max=0; |
735 |
if (count($entrees)==0) return $entrees; |
736 |
|
737 |
foreach ($entrees as $key => $val){ |
738 |
$time=strtotime($key."-01"); |
739 |
if ($min>$time||$min<0) $min=$time; |
740 |
if ($max<$time) $max=$time; |
741 |
} |
742 |
|
743 |
$end_time=strtotime(date("Y-m",strtotime($end))."-01"); |
744 |
$begin_time=strtotime(date("Y-m",strtotime($begin))."-01"); |
745 |
|
746 |
if ($max<$end_time) $max=$end_time; |
747 |
if ($min>$begin_time) $min=$begin_time; |
748 |
$current=$min; |
749 |
|
750 |
while ($current<=$max){ |
751 |
$curentry=date("Y-m",$current); |
752 |
if (!isset($entrees["$curentry"])) $entrees["$curentry"]=0; |
753 |
$month=date("m",$current); |
754 |
$year=date("Y",$current); |
755 |
|
756 |
$current=mktime(0,0,0,intval($month)+1,1,intval($year)); |
757 |
} |
758 |
|
759 |
return $entrees; |
760 |
} |
761 |
|
762 |
|
763 |
|
764 |
/** Get groups assigned to tickets between 2 dates
|
765 |
* BASED ON SPIP DISPLAY GRAPH : www.spip.net
|
766 |
* @param $type string : "month" or "year"
|
767 |
* @param $entrees array : array containing data to displayed
|
768 |
* @param $titre string : title
|
769 |
* @param $unit string : unit
|
770 |
* @param $showtotal boolean : also show total values ?
|
771 |
* @return array contains the distinct groups assigned to a tickets
|
772 |
*/
|
773 |
function graphBy($entrees,$titre="",$unit="",$showtotal=1,$type="month"){ |
774 |
|
775 |
global $DB,$CFG_GLPI,$LANG; |
776 |
ksort($entrees); |
777 |
$total=""; |
778 |
if ($showtotal==1) $total=array_sum($entrees); |
779 |
|
780 |
echo "<p align='center'>"; |
781 |
echo "<font face='verdana,arial,helvetica,sans-serif' size='2'><strong>$titre - $total $unit</strong></font>"; |
782 |
|
783 |
echo "<div class='center'>"; |
784 |
|
785 |
if (count($entrees)>0){ |
786 |
|
787 |
$max = max($entrees); |
788 |
$maxgraph = substr(ceil(substr($max,0,2) / 10)."000000000000", 0, strlen($max)); |
789 |
|
790 |
if ($maxgraph < 10) $maxgraph = 10; |
791 |
if (1.1 * $maxgraph < $max) $maxgraph.="0"; |
792 |
if (0.8*$maxgraph > $max) $maxgraph = 0.8 * $maxgraph; |
793 |
$rapport = 200 / $maxgraph; |
794 |
|
795 |
$largeur = floor(420 / (count($entrees))); |
796 |
if ($largeur < 1) $largeur = 1; |
797 |
if ($largeur > 50) $largeur = 50; |
798 |
} |
799 |
|
800 |
echo "<table cellpadding='0' cellspacing='0' border='0' ><tr><td style='background-image:url(".$CFG_GLPI["root_doc"]."/pics/fond-stats.gif)' >"; |
801 |
echo "<table cellpadding='0' cellspacing='0' border='0'><tr>"; |
802 |
echo "<td bgcolor='black'><img src='".$CFG_GLPI["root_doc"]."/pics/noir.png' width='1' height='200' alt=''></td>"; |
803 |
|
804 |
// Presentation graphique
|
805 |
$n = 0; |
806 |
$decal = 0; |
807 |
$tab_moyenne = ""; |
808 |
$total_loc=0; |
809 |
while (list($key, $value) = each($entrees)) { |
810 |
$n++;
|
811 |
|
812 |
if ($decal == 30) $decal = 0; |
813 |
$decal ++;
|
814 |
$tab_moyenne[$decal] = $value; |
815 |
|
816 |
$total_loc = $total_loc + $value; |
817 |
reset($tab_moyenne); |
818 |
|
819 |
$moyenne = 0; |
820 |
while (list(,$val_tab) = each($tab_moyenne)) |
821 |
$moyenne += $val_tab; |
822 |
$moyenne = $moyenne / count($tab_moyenne); |
823 |
|
824 |
$hauteur_moyenne = round($moyenne * $rapport) ; |
825 |
$hauteur = round($value * $rapport) ; |
826 |
echo "<td valign='bottom' width=".$largeur.">"; |
827 |
|
828 |
if ($hauteur >= 0){ |
829 |
if ($hauteur_moyenne > $hauteur) { |
830 |
$difference = ($hauteur_moyenne - $hauteur) -1; |
831 |
echo "<img alt=\"$key: $value\" title=\"$key: $value\" src='".$CFG_GLPI["root_doc"]."/pics/moyenne.png' width=".$largeur." height='1' >"; |
832 |
echo "<img alt=\"$key: $value\" title=\"$key: $value\" src='".$CFG_GLPI["root_doc"]."/pics/rien.gif' width=".$largeur." height=".$difference." >"; |
833 |
echo "<img alt=\"$key: $value\" title=\"$key: $value\" src='".$CFG_GLPI["root_doc"]."/pics/noir.png' width=".$largeur." height='1' >"; |
834 |
if (ereg("-01",$key)){ // janvier en couleur foncee |
835 |
echo "<img alt=\"$key: $value\" title=\"$key: $value\" src='".$CFG_GLPI["root_doc"]."/pics/fondgraph1.png' width=".$largeur." height=".$hauteur." >"; |
836 |
} |
837 |
else {
|
838 |
echo "<img alt=\"$key: $value\" title=\"$key: $value\" src='".$CFG_GLPI["root_doc"]."/pics/fondgraph2.png' width=".$largeur." height=".$hauteur." >"; |
839 |
} |
840 |
} |
841 |
else if ($hauteur_moyenne < $hauteur) { |
842 |
$difference = ($hauteur - $hauteur_moyenne) -1; |
843 |
echo "<img alt=\"$key: $value\" title=\"$key: $value\" src='".$CFG_GLPI["root_doc"]."/pics/noir.png' width=".$largeur." height='1'>"; |
844 |
if (ereg("-01",$key)){ // janvier en couleur foncee |
845 |
$couleur = "1"; |
846 |
$couleur2 = "2"; |
847 |
} |
848 |
else {
|
849 |
$couleur = "2"; |
850 |
$couleur2 = "1"; |
851 |
} |
852 |
echo "<img alt=\"$key: $value\" title=\"$key: $value\" src='".$CFG_GLPI["root_doc"]."/pics/fondgraph$couleur.png' width=".$largeur." height=".$difference.">"; |
853 |
echo "<img alt=\"$key: $value\" title=\"$key: $value\" src='".$CFG_GLPI["root_doc"]."/pics/moyenne.png' width=".$largeur." height='1'>"; |
854 |
echo "<img alt=\"$key: $value\" title=\"$key: $value\" src='".$CFG_GLPI["root_doc"]."/pics/fondgraph$couleur.png' width=".$largeur." height=".$hauteur_moyenne.">"; |
855 |
} |
856 |
else {
|
857 |
echo "<img alt=\"$key: $value\" title=\"$key: $value\" src='".$CFG_GLPI["root_doc"]."/pics/noir.png' width=".$largeur." height='1'>"; |
858 |
if (ereg("-01",$key)){ // janvier en couleur foncee |
859 |
echo "<img alt=\"$key: $val_tab\" title=\"$key: $value\" src='".$CFG_GLPI["root_doc"]."/pics/fondgraph1.png' width=".$largeur." height=".$hauteur.">"; |
860 |
} |
861 |
else {
|
862 |
echo "<img alt=\"$key: $value\" title=\"$key: $value\" src='".$CFG_GLPI["root_doc"]."/pics/fondgraph2.png' width=".$largeur." height=".$hauteur.">"; |
863 |
} |
864 |
} |
865 |
} |
866 |
|
867 |
echo "<img alt=\"$value\" title=\"$value\" src='".$CFG_GLPI["root_doc"]."/pics/rien.gif' width=".$largeur." height='1'>"; |
868 |
echo "</td>\n"; |
869 |
|
870 |
} |
871 |
echo "<td bgcolor='black'><img src='".$CFG_GLPI["root_doc"]."/pics/noir.png' width='1' height='1' alt=''></td>"; |
872 |
echo "</tr>"; |
873 |
if ($largeur>10){ |
874 |
echo "<tr><td></td>"; |
875 |
foreach ($entrees as $key => $val){ |
876 |
if ($type=="month"){ |
877 |
$splitter=split("-",$key); |
878 |
echo "<td class='center'>".utf8_substr($LANG["calendarM"][$splitter[1]-1],0,3)."</td>"; |
879 |
} else if ($type=="year"){ |
880 |
echo "<td class='center'>".substr($key,2,2)."</td>"; |
881 |
} |
882 |
} |
883 |
echo "</tr>"; |
884 |
} |
885 |
|
886 |
if ($maxgraph<=10) $r=2; |
887 |
else if ($maxgraph<=100) $r=1; |
888 |
else $r=0; |
889 |
echo "</table>"; |
890 |
echo "</td>"; |
891 |
echo "<td style='background-image:url(".$CFG_GLPI["root_doc"]."/pics/fond-stats.gif)' valign='bottom'><img src='".$CFG_GLPI["root_doc"]."/pics/rien.gif' style='background-color:black;' width='3' height='1' alt=''></td>"; |
892 |
echo "<td><img src='".$CFG_GLPI["root_doc"]."/pics/rien.gif' width='5' height='1' alt=''></td>"; |
893 |
echo "<td valign='top'>"; |
894 |
echo "<table cellpadding='0' cellspacing='0' border='0'>"; |
895 |
echo "<tr><td height='15' valign='top'>"; |
896 |
echo "<font face='arial,helvetica,sans-serif' size='1'><strong>".formatNumber($maxgraph,false,$r)."</strong></font>"; |
897 |
echo "</td></tr>"; |
898 |
echo "<tr><td height='25' valign='middle'>"; |
899 |
echo "<font face='arial,helvetica,sans-serif' size='1' color='#999999'>".formatNumber(7*($maxgraph/8),false,$r)."</font>"; |
900 |
echo "</td></tr>"; |
901 |
echo "<tr><td height='25' valign='middle'>"; |
902 |
echo "<font face='arial,helvetica,sans-serif' size='1'>".formatNumber(3*($maxgraph/4),false,$r)."</font>"; |
903 |
echo "</td></tr>"; |
904 |
echo "<tr><td height='25' valign='middle'>"; |
905 |
echo "<font face='arial,helvetica,sans-serif' size='1' color='#999999'>".formatNumber(5*($maxgraph/8),false,$r)."</font>"; |
906 |
echo "</td></tr>"; |
907 |
echo "<tr><td height='25' valign='middle'>"; |
908 |
echo "<font face='arial,helvetica,sans-serif' size='1'><strong>".formatNumber($maxgraph/2,false,$r)."</strong></font>"; |
909 |
echo "</td></tr>"; |
910 |
echo "<tr><td height='25' valign='middle'>"; |
911 |
echo "<font face='arial,helvetica,sans-serif' size='1' color='#999999'>".formatNumber(3*($maxgraph/8),false,$r)."</font>"; |
912 |
echo "</td></tr>"; |
913 |
echo "<tr><td height='25' valign='middle'>"; |
914 |
echo "<font face='arial,helvetica,sans-serif' size='1'>".formatNumber($maxgraph/4,false,$r)."</font>"; |
915 |
echo "</td></tr>"; |
916 |
echo "<tr><td height='25' valign='middle'>"; |
917 |
echo "<font face='arial,helvetica,sans-serif' size='1' color='#999999'>".formatNumber(1*($maxgraph/8),false,$r)."</font>"; |
918 |
echo "</td></tr>"; |
919 |
echo "<tr><td height='10' valign='bottom'>"; |
920 |
echo "<font face='arial,helvetica,sans-serif' size='1'><strong>0</strong></font>"; |
921 |
echo "</td>"; |
922 |
|
923 |
echo "</tr></table>"; |
924 |
echo "</td></tr></table>"; |
925 |
echo "</div>"; |
926 |
|
927 |
|
928 |
|
929 |
} |
930 |
|
931 |
|
932 |
function showItemStats($target,$date1,$date2,$start){ |
933 |
global $DB,$CFG_GLPI,$LANG; |
934 |
|
935 |
|
936 |
$view_entities=isMultiEntitiesMode();
|
937 |
|
938 |
if ($view_entities){ |
939 |
$entities=getAllDatasFromTable('glpi_entities'); |
940 |
} |
941 |
|
942 |
$output_type=HTML_OUTPUT; |
943 |
if (isset($_GET["display_type"])) |
944 |
$output_type=$_GET["display_type"]; |
945 |
|
946 |
if (empty($date2)) $date2=date("Y-m-d"); |
947 |
$date2.=" 23:59:59"; |
948 |
// 1 an par defaut
|
949 |
if (empty($date1)) $date1=date("Y-m-d",mktime(0,0,0,date("m"),date("d"),date("Y")-1)); |
950 |
$date1.=" 00:00:00"; |
951 |
|
952 |
|
953 |
$query="SELECT device_type,computer,COUNT(*) AS NB |
954 |
FROM glpi_tracking
|
955 |
WHERE date<= '".$date2."' AND date>= '".$date1."' ".getEntitiesRestrictRequest("AND","glpi_tracking")." |
956 |
GROUP BY device_type,computer ORDER BY NB DESC";
|
957 |
|
958 |
$result=$DB->query($query); |
959 |
$numrows=$DB->numrows($result); |
960 |
|
961 |
if ($numrows>0){ |
962 |
if ($output_type==HTML_OUTPUT){ |
963 |
printPager($start,$numrows,$target,"date1=".$date1."&date2=".$date2."&type=hardwares&start=$start",STAT_TYPE); |
964 |
echo "<div class='center'>"; |
965 |
} |
966 |
|
967 |
$i=$start; |
968 |
if (isset($_GET['export_all'])) |
969 |
$i=0; |
970 |
|
971 |
$end_display=$start+$_SESSION["glpilist_limit"]; |
972 |
if (isset($_GET['export_all'])) |
973 |
$end_display=$numrows; |
974 |
echo displaySearchHeader($output_type,$end_display-$start+1,2,1); |
975 |
$header_num=1; |
976 |
echo displaySearchNewLine($output_type); |
977 |
echo displaySearchHeaderItem($output_type,$LANG["common"][1],$header_num); |
978 |
if ($view_entities){ |
979 |
echo displaySearchHeaderItem($output_type,$LANG["entity"][0],$header_num); |
980 |
} |
981 |
echo displaySearchHeaderItem($output_type,$LANG["stats"][13],$header_num); |
982 |
echo displaySearchEndLine($output_type); |
983 |
|
984 |
$DB->data_seek($result,$start); |
985 |
|
986 |
$ci=new CommonItem(); |
987 |
while ($i < $numrows && $i<($end_display)){ |
988 |
$item_num=1; |
989 |
// Get data and increment loop variables
|
990 |
$data=$DB->fetch_assoc($result); |
991 |
if ($ci->getFromDB($data["device_type"],$data["computer"])){ |
992 |
//echo "<tr class='tab_bg_2$del'><td>".$ci->getLink()."</td><td>".$data["NB"]."</td></tr>";
|
993 |
echo displaySearchNewLine($output_type,$i%2); |
994 |
echo displaySearchItem($output_type,$ci->getLink(),$item_num,$i-$start+1,"align='center'"." ".($ci->getField("deleted")?" class='deleted' ":"")); |
995 |
if ($view_entities){ |
996 |
$ent=$ci->getField('FK_entities'); |
997 |
if ($ent==0){ |
998 |
$ent=$LANG["entity"][2]; |
999 |
} else {
|
1000 |
$ent=$entities[$ent]['completename']; |
1001 |
} |
1002 |
echo displaySearchItem($output_type,$ent,$item_num,$i-$start+1,"align='center'"." ".($ci->getField("deleted")?" class='deleted' ":"")); |
1003 |
} |
1004 |
echo displaySearchItem($output_type,$data["NB"],$item_num,$i-$start+1,"align='center'"." ".($ci->getField("deleted")?" class='deleted' ":"")); |
1005 |
} |
1006 |
$i++;
|
1007 |
} |
1008 |
|
1009 |
echo displaySearchFooter($output_type); |
1010 |
if ($output_type==HTML_OUTPUT) |
1011 |
echo "</div>"; |
1012 |
} |
1013 |
|
1014 |
} |
1015 |
|
1016 |
|
1017 |
?>
|