From 67d402c657c9d1cc4554bacb7d87f7de0f6b5d8e Mon Sep 17 00:00:00 2001 From: Progfou Date: Mon, 28 Apr 2014 16:26:36 -0400 Subject: [PATCH] glpi-plugin-auf : ajustement des rapports --- glpi-plugin-auf/plugin/report.computers.php | 145 ++++++++++++-------- glpi-plugin-auf/plugin/report.operatingsystems.php | 4 +- 2 files changed, 88 insertions(+), 61 deletions(-) diff --git a/glpi-plugin-auf/plugin/report.computers.php b/glpi-plugin-auf/plugin/report.computers.php index 39192dc..4f887a2 100644 --- a/glpi-plugin-auf/plugin/report.computers.php +++ b/glpi-plugin-auf/plugin/report.computers.php @@ -49,22 +49,25 @@ function svg_pie_chart($values, $size=16) { return $svg; } +// echo "\nATTENTION : ce rapport est en cours de refonte, merci de ne pas tenir compte des données affichées ci-dessous.

"; + //echo "\nOrdinateurs par implantation

"; echo ""; echo ""; echo ""; -echo ""; -echo ""; -echo ""; -echo ""; +echo ""; +echo ""; +echo ""; +echo ""; +echo ""; echo ""; echo "\n"; $grand_serveurs_total = 0; $grand_serveurs_prod = 0; $grand_internes_total = 0; $grand_internes_prod = 0; $grand_publics_total = 0; $grand_publics_prod = 0; -$grand_total = 0; $grand_virtuels_total = 0; -$grand_autres_total = 0; +$grand_total = 0; +$grand_virtuels_total = 0; $grand_autres_total = 0; # récupération de la liste des régions $query = "SELECT id FROM glpi_entities WHERE (id=0 OR entities_id=0)"; $query .= " ".getEntitiesRestrictRequest("AND", "glpi_entities")." ORDER BY name"; @@ -107,53 +110,71 @@ while ($region_data = $DB->fetch_assoc($region_result)) { $nb_internes_total = 0; $nb_internes_prod = 0; $nb_publics_total = 0; $nb_publics_prod = 0; $nb_virtuels_total = 0; $nb_autres_total = 0; - $query = "SELECT COUNT(c.id) AS count, s.id AS sid, s.completename AS sname + $query = "SELECT s.completename AS sname, ac.est_virtuel AS virtuel, + acc.name AS categorie, acu.name AS utilisation FROM `$table_item` c - LEFT JOIN glpi_entities e ON (c.entities_id = e.id) LEFT JOIN glpi_states s ON (c.states_id = s.id) + LEFT JOIN glpi_plugin_auf_computers ac ON (c.id = ac.id) + LEFT JOIN glpi_plugin_auf_categories acc ON (ac.auf_categories_id = acc.id) + LEFT JOIN glpi_plugin_auf_utilisations acu ON (ac.auf_utilisations_id = acu.id) WHERE c.is_deleted = '0' AND c.is_template = '0' - AND c.entities_id = '".$implant_id."' - GROUP BY 2 ORDER BY 2"; + AND c.entities_id = '".$implant_id."'"; $result = $DB->query($query); while ($data=$DB->fetch_assoc($result)) { - if (preg_match("/^système.*virtu.l/i", $data['sname'])) { - $nb_virtuels_total += $data['count']; - } elseif (preg_match("/^réserv.*serveur.*test/i", $data['sname'])) { - $nb_serveurs_total += $data['count']; - } elseif (preg_match("/^attrib.*serveur.*production/i", $data['sname'])) { - $nb_serveurs_total += $data['count']; - $nb_serveurs_prod += $data['count']; - } elseif (preg_match("/^réserv.*poste.*mission/i", $data['sname'])) { - $nb_internes_total += $data['count']; - } elseif (preg_match("/^attrib.*poste.*interne/i", $data['sname'])) { - $nb_internes_total += $data['count']; - $nb_internes_prod += $data['count']; - } elseif (preg_match("/^réserv.*poste.*stock/i", $data['sname'])) { - $nb_publics_total += $data['count']; - } elseif (preg_match("/^attrib.*poste.*public/i", $data['sname'])) { - $nb_publics_total += $data['count']; - $nb_publics_prod += $data['count']; - } elseif (preg_match("/^sortie/i", $data['sname'])) { - // on ne compte pas les sorties d'inventaire - } else { - $nb_autres_total += $data['count']; + // on ne compte pas les sorties d'inventaire + if (preg_match("/^sortie/i", $data['sname'])) { + continue; + } + // serveurs + if (preg_match("/^infra/i", $data['categorie'])) { + $nb_serveurs_total++; + if (preg_match("/^production/i", $data['utilisation']) && + !preg_match("/panne/i", $data['sname']) ) { + $nb_serveurs_prod++; + } + } + // postes internes + elseif (preg_match("/^poste.*interne/i", $data['categorie'])) { + $nb_internes_total++; + if (preg_match("/^production/i", $data['utilisation']) && + !preg_match("/panne/i", $data['sname']) ) { + $nb_internes_prod++; + } + } + // postes publics + elseif (preg_match("/^poste.*public/i", $data['categorie'])) { + $nb_publics_total++; + if (preg_match("/^production/i", $data['utilisation']) && + !preg_match("/panne/i", $data['sname']) ) { + $nb_publics_prod++; + } + } + // autres + else { + // machines virtuelles + if ($data['virtuel']) { + $nb_virtuels_total++; + // autres + } else { + $nb_autres_total++; + } } } // systèmes dans l'implantation - $total = $nb_serveurs_total + $nb_internes_total + $nb_publics_total + $nb_autres_total; + $total = $nb_serveurs_total + $nb_internes_total + $nb_publics_total; if ($total > 0) { $spaces = ""; for ($i=1;$i<$implant_data['level'];$i++) { $spaces .= "  "; } - $line = ""; - $line .= ""; - $line .= ""; - $line .= ""; - $line .= ""; - $line .= ""; - $line .= ""; - $autres = ($nb_autres_total > 0) ? "(".$nb_autres_total." +) " : ""; - $line .= ""; - $line .= ""; + $line = ""; + $line .= ""; + $line .= ""; + $line .= ""; + $line .= ""; + $line .= ""; + $line .= ""; + $line .= ""; + $line .= ""; + $line .= ""; $table_lines[] = $line; } $region_serveurs_total += $nb_serveurs_total; @@ -169,19 +190,22 @@ while ($region_data = $DB->fetch_assoc($region_result)) { } // fin des implantations de la région $line = ""; - $line .= ""; - $line .= ""; - $line .= ""; - $line .= ""; - $line .= ""; - $line .= ""; - $autres = ($region_autres_total > 0) ? "(".$region_autres_total." +) " : ""; - $line .= ""; - $line .= ""; + $line .= ""; + $line .= ""; + $line .= ""; + $line .= ""; + $line .= ""; + $line .= ""; + $line .= ""; + $line .= ""; + $line .= ""; $table_lines[] = $line; $region_name = svg_pie_chart(Array($region_serveurs_total, $region_internes_total, $region_publics_total, $region_virtuels_total), 16) . $region_name; $table_lines[0] = str_replace("", "", $table_lines[0]); + if ($region_id != 0) { + echo "\n"; + } echo implode("\n", $table_lines); $grand_serveurs_total += $region_serveurs_total; @@ -212,15 +236,16 @@ $result = $DB->query($query); $grand_total = $DB->result($result, 0, 0); */ $line = ""; -$line .= ""; -$line .= ""; -$line .= ""; -$line .= ""; -$line .= ""; -$line .= ""; -$autres = ($grand_autres_total > 0) ? "(".$grand_autres_total." +) " : ""; -$line .= ""; -$line .= ""; +$line .= ""; +$line .= ""; +$line .= ""; +$line .= ""; +$line .= ""; +$line .= ""; +$line .= ""; +$line .= ""; +$line .= ""; +echo "\n"; echo $line; echo "
Implantation".svg_circle('red')." Serveurs".svg_circle('green')." Clients internes".svg_circle('yellow')." Clients publicsTotal
(+ sans statut)
".svg_circle('blue')." Virtuels
".svg_circle('green')." Postes internes".svg_circle('yellow')." Postes publicsTotal".svg_circle('blue')." VirtuelsAutres
(sans statut)
TotalProductionTotalAttribuéTotalAttribué
".$spaces.$implant_name."".$nb_serveurs_total."".$nb_serveurs_prod."".$nb_internes_total."".$nb_internes_prod."".$nb_publics_total."".$nb_publics_prod."".$autres.$total."".$nb_virtuels_total."
$spaces$implant_name$nb_serveurs_total$nb_serveurs_prod$nb_internes_total$nb_internes_prod$nb_publics_total$nb_publics_prod$total$nb_virtuels_total$nb_autres_total
Sous-total".$region_serveurs_total."".$region_serveurs_prod."".$region_internes_total."".$region_internes_prod."".$region_publics_total."".$region_publics_prod."".$autres.$region_total."".$region_virtuels_total."
$region_serveurs_total$region_serveurs_prod$region_internes_total$region_internes_prod$region_publics_total$region_publics_prod$region_total$region_virtuels_total$region_autres_total
$region_name
Total général".$grand_serveurs_total."".$grand_serveurs_prod."".$grand_internes_total."".$grand_internes_prod."".$grand_publics_total."".$grand_publics_prod."".$autres.$grand_total."$grand_virtuels_total
$grand_serveurs_total$grand_serveurs_prod$grand_internes_total$grand_internes_prod$grand_publics_total$grand_publics_prod$grand_total$grand_virtuels_total$grand_autres_total
"; diff --git a/glpi-plugin-auf/plugin/report.operatingsystems.php b/glpi-plugin-auf/plugin/report.operatingsystems.php index 83b765d..9cc48f5 100644 --- a/glpi-plugin-auf/plugin/report.operatingsystems.php +++ b/glpi-plugin-auf/plugin/report.operatingsystems.php @@ -34,6 +34,7 @@ while ($region_data = $DB->fetch_assoc($region_result)) { $region_id = $region_data['id']; if ($region_id != 0) { $region_name = getTreeLeafValueName("glpi_entities", $region_id); + echo "\n"; } else { $region_name = "AUF (non classé)"; } @@ -106,7 +107,8 @@ $blue_grand_total += $blue_total; $grand_total += $region_total; } // fin des régions -echo " "; +#echo " "; +echo "\n"; # total operating systems $query = "SELECT COUNT(*) FROM `".$table_item."` -- 1.7.10.4