1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
   | <?php
$USEDBREPLICATE= 1;
$DBCONNECION_REQUIRED= 0;
 
define('GLPI_ROOT', '../../../..');
include(GLPI_ROOT."/inc/includes.php");
 
$report= new PluginReportsAutoReport();
 
 
$report->setColumns(array(new PluginReportsColumn('entity', $LANG['entity'][0]),
                          new PluginReportsColumn('location', $LANG['common'][15]),
                          new PluginReportsColumnInteger('computernumber',$LANG['Menu'][0])));
 
$query = "SELECT a.`entity`, a.`location`, b.`computernumber`, a.`id`
                                  FROM (SELECT `glpi_entities`.`completename` AS entity,
                                               `glpi_locations`.`completename` AS location,
                                               `glpi_locations`.`id` AS id
                                        FROM `glpi_locations`
                                        LEFT JOIN `glpi_entities`
                                          ON (`glpi_locations`.`entities_id`=`glpi_entities`.`id`) ".
                                        getEntitiesRestrictRequest(" WHERE ", "glpi_locations").") a
                                  LEFT OUTER JOIN (SELECT count(*) AS computernumber,
                                                          `glpi_computers`.`locations_id` AS id
                                                   FROM `glpi_computers`
                                                   WHERE is_deleted=0 AND is_template=0
                                                   ".getEntitiesRestrictRequest(" AND ", "glpi_computers")."
                                                   GROUP BY `glpi_computers`.`locations_id`) b
                                       ON (a.id = b.id)";
 
$report->setGroupBy("entity");					  
$report->setSqlRequest($query);			  
$report->execute();						  
 
?> | 
Partager