commit f4699b2f28ccac16eabffdf7d7801a2d6cb80c71
Author: Eric Seigne <eric.seigne@ryxeo.com>
Date:   Mon Nov 22 22:55:35 2010 +0100

    petite amélioration de la requete de selection

diff --git a/plugins/anet_epacks/front/plugin_anet_epacks.view_array_recap.php b/plugins/anet_epacks/front/plugin_anet_epacks.view_array_recap.php
index 343d63d..9ab5d4a 100644
--- a/plugins/anet_epacks/front/plugin_anet_epacks.view_array_recap.php
+++ b/plugins/anet_epacks/front/plugin_anet_epacks.view_array_recap.php
@@ -90,7 +90,7 @@ function local_make_query($data, $entityid, $maintenance) {
 (g5.nbeleves+g5.nbprofs) as nbusers, g5.nbpc as nbpc
 FROM glpi_plugin_anet_epacks AS e
 LEFT JOIN glpi_plugin_anet_epacks_ssh_max AS ssh ON e.FK_serveur=ssh.FK_serveur
-LEFT JOIN glpi_entities AS g3 ON e.FK_client=g3.ID OR e.FK_enduser=g3.ID
+LEFT JOIN glpi_entities AS g3 ON e.FK_client=g3.ID
 LEFT JOIN glpi_computers AS g4 ON e.FK_serveur=g4.ID
 LEFT JOIN glpi_plugin_anet_epacks_recencement_max AS g5 ON e.FK_serveur=g5.FK_serveur\n";
 
@@ -135,7 +135,7 @@ function local_make_query_zarb() {
 (g5.nbeleves+g5.nbprofs) as nbusers, g5.nbpc as nbpc
 FROM glpi_plugin_anet_epacks AS e
 LEFT JOIN glpi_plugin_anet_epacks_ssh_max AS ssh ON e.FK_serveur=ssh.FK_serveur
-LEFT JOIN glpi_entities AS g3 ON e.FK_client=g3.ID OR e.FK_enduser=g3.ID
+LEFT JOIN glpi_entities AS g3 ON e.FK_client=g3.ID
 LEFT JOIN glpi_computers AS g4 ON e.FK_serveur=g4.ID
 LEFT JOIN glpi_plugin_anet_epacks_recencement_max AS g5 ON e.FK_serveur=g5.FK_serveur\n";
   $query .= "WHERE e.FK_enduser='0' AND e.FK_client!='0'\n";
@@ -153,7 +153,7 @@ function local_make_query_dsi($data, $entityid, $maintenance) {
 (g5.nbeleves+g5.nbprofs) as nbusers, g5.nbpc as nbpc
 FROM glpi_plugin_anet_epacks AS e
 LEFT JOIN glpi_plugin_anet_epacks_ssh_max AS ssh ON e.FK_serveur=ssh.FK_serveur
-LEFT JOIN glpi_entities AS g3 ON e.FK_client=g3.ID OR e.FK_enduser=g3.ID
+LEFT JOIN glpi_entities AS g3 ON e.FK_client=g3.ID
 LEFT JOIN glpi_computers AS g4 ON e.FK_serveur=g4.ID
 LEFT JOIN glpi_plugin_anet_epacks_recencement_max AS g5 ON e.FK_serveur=g5.FK_serveur\n";
 
@@ -239,7 +239,7 @@ function local_make_array($q,$maintenance,$enduser=1) {
 	$s .= "    " . $num_debut_ligne . ". <a href=\"../../manageentity/index.php?active_entity=" . $data['entityid'] . "\">" . $data['client'] . ": " . $data['serveur'] . "</a>\n";
       }
       else {
-	$s .= "    " . $num_debut_ligne . ". " . $data['client'] . ": " . $data['serveur'] . "(abonnement zen jamais activé)\n";
+		$s .= "    " . $num_debut_ligne . ". " . $data['client'] . ": " . $data['serveur'] . "(abonnement zen jamais activé, serveur fantôme ?)\n";
       }
       
       $s .= "  </td>
@@ -281,7 +281,7 @@ function local_make_array($q,$maintenance,$enduser=1) {
 (sum(g5.nbeleves)+sum(g5.nbprofs)) as nbusers, g5.nbpc as nbpc
 FROM glpi_plugin_anet_epacks AS e
 LEFT JOIN glpi_plugin_anet_epacks_ssh_max AS ssh ON e.FK_serveur=ssh.FK_serveur
-LEFT JOIN glpi_entities AS g3 ON e.FK_client=g3.ID OR e.FK_enduser=g3.ID
+LEFT JOIN glpi_entities AS g3 ON e.FK_client=g3.ID
 LEFT JOIN glpi_computers AS g4 ON e.FK_serveur=g4.ID
 LEFT JOIN glpi_plugin_anet_epacks_recencement_max AS g5 ON e.FK_serveur=g5.FK_serveur\n";
     //WHERE e.Fk_Serveur > '0'\n";
@@ -305,10 +305,11 @@ ORDER BY client
 LIMIT 500;";
   }
   else {
+    //LEFT JOIN glpi_entities AS g3 ON e.FK_client=g3.ID OR e.FK_enduser=g3.ID
     $query = "SELECT e.*, e.FK_client as entityid, g3.name as client, g4.name as serveur, g4.os_license_number, g4.os_license_id, g4.otherserial, ssh.*
 FROM glpi_plugin_anet_epacks AS e
 LEFT JOIN glpi_plugin_anet_epacks_ssh_max AS ssh ON e.FK_serveur=ssh.FK_serveur
-LEFT JOIN glpi_entities AS g3 ON e.FK_client=g3.ID OR e.FK_enduser=g3.ID
+LEFT JOIN glpi_entities AS g3 ON e.FK_client=g3.ID
 LEFT JOIN glpi_computers AS g4 ON e.FK_serveur=g4.ID
 LEFT JOIN glpi_plugin_anet_epacks_recencement_max AS g5 ON e.FK_serveur=g5.FK_serveur
 WHERE e.FK_enduser='0' AND e.FK_client!='0'
@@ -355,8 +356,9 @@ ORDER BY client\n";
 	$s .= "    " . $num_debut_ligne . ". <a href=\"../../manageentity/index.php?active_entity=" . $data['entityid'] . "\">" . $data['client'] . ": " . $data['serveur'] . "</a>\n";
       }
       else {
-	$s .= "    " . $num_debut_ligne . ". " . $data['client'] . ": " . $data['serveur'] . "(abonnement zen jamais activé)\n";
+	$s .= "    " . $num_debut_ligne . ". " . $data['client'] . ": " . $data['serveur'] . "(abonnement zen jamais activé, serveur fantôme ?)\n";
       }
+
       $s .= "  </td>
   <td>" . $ssh_status . "</td>
   <td>" . $data['sshdate'] . $ssh_dateLastOK . "</td>
@@ -434,23 +436,23 @@ $query = "SELECT glpi_profiles.name AS name,glpi_users_profiles.FK_entities as F
 //print $query;
 //exit;
 
-$total_nbpc_maint    = 0;
-$total_nbusers_maint = 0;
+$total_nbpc_maint         = 0;
+$total_nbusers_maint      = 0;
 $total_nbpc_hors_maint    = 0;
 $total_nbusers_hors_maint = 0;
-$tab_deja_affiche = array();
+$tab_deja_affiche         = array();
+$num_debut_ligne_maint    = 0;
+$num_debut_ligne_horsmaint = 0;
 
 $result = $DB->query($query);
 if($result) {
   while($data=$DB->fetch_array($result)) {
     $entityid = $data['FK_entities'];
     if($data['name'] == "revendeur" || $data['name'] == "dsi" || $data['name'] == "super-admin") {
+      $num_debut_ligne = $num_debut_ligne_maint;
       //print $query;
       $entityid = $data['FK_entities'];
       
-      //print $query;
-      //exit;
-      
       $maintenance = 0;
       $querySM = local_make_query($data, $entityid, $maintenance);
       $str_sous_maint .= local_make_array($querySM,$maintenance);
@@ -460,6 +462,7 @@ if($result) {
       if($querySM != "")
 	$str_sous_maint .= local_make_array($querySM,$maintenance);
       
+      $num_debut_ligne_maint = $num_debut_ligne;
       $num_debut_ligne = 0;
       $maintenance = -1;
       $queryHM = local_make_query($data, $entityid, $maintenance);
@@ -468,6 +471,7 @@ if($result) {
       //et maintenant les epacks dont le FK_enduser=0 mais FK_serveur!=0
       //Uniquement pour ryxeo
       if($data['name'] == "super-admin") { 
+	$num_debut_ligne_horsmaint = $num_debut_ligne;
 	$num_debut_ligne = 0;
 	$queryZarb = local_make_query_zarb();
 	//print "<pre>$queryZarb</pre>";
@@ -476,17 +480,17 @@ if($result) {
       }
     }
   }
-
+  
   print "<h1>Tableau récapitulatif de vos serveurs sous maintenance</h1>";
   print local_make_array_header();
   print $str_sous_maint;
   print local_make_array_footer($total_nbpc_maint,$total_nbusers_maint);
-
+  
   print "<h1>Tableau récapitulatif de vos serveurs hors maintenance</h1>";
   print local_make_array_header();
   print $str_hors_maint;
   print local_make_array_footer($total_nbpc_hors_maint,$total_nbusers_hors_maint);
-
+  
   //Uniquement pour ryxeo
   if($str_zarb != "") { 
     print "<h1>Tableau récapitulatif des serveurs étranges [dont la maintenance n'a pas été activée (abonnement zen sur webadmin) ??]</h1>";
@@ -494,7 +498,7 @@ if($result) {
     print $str_zarb;
     print local_make_array_footer(0,0);
   }
-
+  
   commonFooter();
   exit;
  }
