Systèmes d'exploitation par implantation

"; echo ""; echo ""; $green_grand_total = 0; $yellow_grand_total = 0; $red_grand_total = 0; $blue_grand_total = 0; $grand_total = 0; # parcours des régions $query = "SELECT id,name,completename FROM glpi_entities WHERE (id=0 OR entities_id=0)"; $query .= " ".getEntitiesRestrictRequest("AND", "glpi_entities"); $region_result = $DB->query($query); while ($region_data = $DB->fetch_assoc($region_result)) { $region_id = $region_data['id']; if ($region_id != 0) { $region_name = getTreeLeafValueName("glpi_entities", $region_id); } else { $region_name = "AUF (non classé)"; } echo ""; $green_total = 0; $yellow_total = 0; $red_total = 0; $blue_total = 0; $region_total = 0; # operating systems per computer $query = "SELECT COUNT(c.id) AS count, e.name AS ename, (CASE WHEN o.name REGEXP '^Debian ' THEN SUBSTRING_INDEX(REPLACE(o.name,' GNU/Linux',''),'.',1) WHEN o.name REGEXP '^Ubuntu ' THEN SUBSTRING_INDEX(REPLACE(o.name,' LTS',''),'.',2) WHEN o.name REGEXP '^Microsoft ' THEN REPLACE(o.name,'Microsoft ','') WHEN o.name REGEXP '^Mac ' THEN REPLACE(o.name,'Mac ','') ELSE o.name END) AS oname FROM `$table_item` c LEFT JOIN glpi_entities e ON (c.entities_id = e.id) LEFT JOIN glpi_operatingsystems o ON (c.operatingsystems_id = o.id) WHERE c.is_deleted = '0' AND c.is_template = '0' ".getEntitiesRestrictRequest("AND", "c"); if ($region_id != 0) { $query .= " AND ".getRealQueryForTreeItem("glpi_entities", $region_id, "e.id"); } else { $query .= " AND e.id = '0'"; } $query .= " GROUP BY 2,3 ORDER BY 2,3"; $result = $DB->query($query); while ($data=$DB->fetch_assoc($result)) { if (empty($data['ename'])) { $data['ename'] = "(indéterminé)"; } if (empty($data['oname'])) { $data['oname'] = "(indéterminé)"; } if (($data['oname'] == 'Debian 7') || ($data['oname'] == 'Ubuntu 12.04')) { $oname_plus = ''; $green_total += $data['count']; } elseif (($data['oname'] == 'Debian 6') || ($data['oname'] == 'Ubuntu 10.04')) { $oname_plus = ''; $yellow_total += $data['count']; } elseif ((substr($data['oname'],0,7) == 'Windows') || (substr($data['oname'],strlen($data['oname'])-4,4) == 'OS X')) { $oname_plus = ''; $blue_total += $data['count']; } else { $oname_plus = ''; $red_total += $data['count']; } echo ""; echo ""; echo ""; echo ""; $region_total += $data['count']; } $green_svg = ''; $yellow_svg = ''; $red_svg = ''; $blue_svg = ''; echo ""; echo ""; echo ""; $green_grand_total += $green_total; $yellow_grand_total += $yellow_total; $red_grand_total += $red_total; $blue_grand_total += $blue_total; $grand_total += $region_total; } // fin des régions echo ""; # total operating systems $query = "SELECT COUNT(*) FROM `".$table_item."` LEFT JOIN `glpi_computers_items` ON (`glpi_computers_items`.`itemtype` = '".$itemtype."' AND `glpi_computers_items`.`items_id` = `".$table_item."`.`id`) WHERE `".$table_item."`.`is_deleted` = '0' AND `".$table_item."`.`is_template` = '0' ". getEntitiesRestrictRequest("AND", $table_item); $result = $DB->query($query); $total = $DB->result($result, 0, 0); $green_svg = ''; $yellow_svg = ''; $red_svg = ''; $blue_svg = ''; echo ""; echo ""; echo ""; echo "
ImplantationSystème d'exploitationQuantité
$region_name
  ".$data['ename']."".$oname_plus." ".$data['oname']."".$data['count']."
  Sous-total".$green_svg.$yellow_svg.$red_svg.$blue_svg."$region_total
 
Total général".$green_svg.$yellow_svg.$red_svg.$blue_svg."$total
"; Html::footer(); ?>