Projet

Général

Profil

Révision 8fc45dd9

Voir les différences:

plugins/anet_epacks/front/plugin_anet_epacks.view_array_recap.php
129 129
  return $query;
130 130
}
131 131

  
132
//special pour trouver les serveurs existants mais les enduser=0 (abonnement zen pas fait ou autre ?)
133
function local_make_query_zarb() {
134
  $query = "SELECT e.*, e.FK_enduser as entityid, g3.name as client, g4.name as serveur, g4.os_license_number, g4.os_license_id, g4.otherserial, ssh.*,
135
(g5.nbeleves+g5.nbprofs) as nbusers, g5.nbpc as nbpc
136
FROM glpi_plugin_anet_epacks AS e
137
LEFT JOIN glpi_plugin_anet_epacks_ssh_max AS ssh ON e.FK_serveur=ssh.FK_serveur
138
LEFT JOIN glpi_entities AS g3 ON e.FK_client=g3.ID OR e.FK_enduser=g3.ID
139
LEFT JOIN glpi_computers AS g4 ON e.FK_serveur=g4.ID
140
LEFT JOIN glpi_plugin_anet_epacks_recencement_max AS g5 ON e.FK_serveur=g5.FK_serveur\n";
141
  $query .= "WHERE e.FK_enduser='0' AND e.FK_client!='0'\n";
142
  $query .= "GROUP BY e.FK_serveur
143
ORDER BY client ASC
144
LIMIT 500;";
145
  //print "<pre>$query</pre>\n";
146
  return $query;
147
}
148

  
149

  
132 150
//Special pour les "dsi" quand on convertis a la vollee les comptes post-only en dsi pour les animtice
133 151
function local_make_query_dsi($data, $entityid, $maintenance) {
134 152
  $query = "SELECT e.*, e.FK_enduser as entityid, g3.name as client, g4.name as serveur, g4.os_license_number, g4.os_license_id, g4.otherserial, ssh.*,
......
168 186
}
169 187

  
170 188

  
171
function local_make_array($q,$maintenance) {
189
//Si enduser=0 -> on affiche les "zarb"
190
function local_make_array($q,$maintenance,$enduser=1) {
172 191
  global $DB;
173 192
  global $glpiid;
174 193

  
......
256 275
      $listentity = "'" . $entityparent . "'";
257 276
  }
258 277
  //$query = "SELECT ID FROM glpi_entities WHERE parentID='" . $entityparent . "'";
259
  
260
  $query = "SELECT e.*, e.FK_enduser as entityid, g3.name as client, g4.name as serveur, g4.os_license_number, g4.os_license_id, g4.otherserial, ssh.*,
278

  
279
  if($enduser == 1) {
280
    $query = "SELECT e.*, e.FK_enduser as entityid, g3.name as client, g4.name as serveur, g4.os_license_number, g4.os_license_id, g4.otherserial, ssh.*,
261 281
(sum(g5.nbeleves)+sum(g5.nbprofs)) as nbusers, g5.nbpc as nbpc
262 282
FROM glpi_plugin_anet_epacks AS e
263 283
LEFT JOIN glpi_plugin_anet_epacks_ssh_max AS ssh ON e.FK_serveur=ssh.FK_serveur
264 284
LEFT JOIN glpi_entities AS g3 ON e.FK_client=g3.ID OR e.FK_enduser=g3.ID
265 285
LEFT JOIN glpi_computers AS g4 ON e.FK_serveur=g4.ID
266 286
LEFT JOIN glpi_plugin_anet_epacks_recencement_max AS g5 ON e.FK_serveur=g5.FK_serveur\n";
267
  //WHERE e.Fk_Serveur > '0'\n";
268

  
287
    //WHERE e.Fk_Serveur > '0'\n";
269 288

  
270
  if($maintenance == 0 || $maintenance ==  1) {
271
    $query .= "WHERE e.FK_contract >= '0'";
272
  }
273
  else if($maintenance == -1) {
274
    $query .= "WHERE e.FK_contract='-1'";
289
    if($maintenance == 0 || $maintenance ==  1) {
290
      $query .= "WHERE e.FK_contract >= '0'";
291
    }
292
    else if($maintenance == -1) {
293
      $query .= "WHERE e.FK_contract='-1'";
294
    }
295
    
296
    if(trim($listentity) != "")
297
      $query .= " AND g3.parentID IN (" . $listentity . ")\n";
298
    //GROUP BY e.FK_serveur
299
    else {
300
      $query = "";
301
    }
302
    if($query != "") 
303
      $query .= "GROUP BY e.FK_client
304
ORDER BY client
305
LIMIT 500;";
275 306
  }
276

  
277
  if(trim($listentity) != "")
278
    $query .= " AND g3.parentID IN (" . $listentity . ")\n";
279
  //GROUP BY e.FK_serveur
280 307
  else {
281
    $query = "";
308
    $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.*
309
FROM glpi_plugin_anet_epacks AS e
310
LEFT JOIN glpi_plugin_anet_epacks_ssh_max AS ssh ON e.FK_serveur=ssh.FK_serveur
311
LEFT JOIN glpi_entities AS g3 ON e.FK_client=g3.ID OR e.FK_enduser=g3.ID
312
LEFT JOIN glpi_computers AS g4 ON e.FK_serveur=g4.ID
313
LEFT JOIN glpi_plugin_anet_epacks_recencement_max AS g5 ON e.FK_serveur=g5.FK_serveur
314
WHERE e.FK_enduser='0' AND e.FK_client!='0'
315
ORDER BY client\n";
316
    //print $query;
282 317
  }
283
  if($query != "") 
284
    $query .= "GROUP BY e.FK_client
285
ORDER BY client
286
LIMIT 500;";
287
  
318
    
288 319
  //print $query;
289
  
320

  
321

  
290 322
  if($query != "") 
291 323
    $result = $DB->query($query) or die($DB->error());
292 324
  
......
294 326
    $num_debut_ligne++;
295 327
    $data=$DB->fetch_array($result);
296 328
    $ssh_dateLastOK = "";
297
    if(! in_array($data['entityid'],$tab_deja_affiche)) {
329
    if(! in_array($data['entityid'],$tab_deja_affiche) || $enduser==0) {
298 330
      $tab_deja_affiche[] = $data['entityid'];
299 331
      if($data['sshstatus'] == 1)
300 332
	$ssh_status = "<font color=\"green\">OK</font>";
......
432 464
      $maintenance = -1;
433 465
      $queryHM = local_make_query($data, $entityid, $maintenance);
434 466
      $str_hors_maint .= local_make_array($queryHM,$maintenance);
467
      
468
      //et maintenant les epacks dont le FK_enduser=0 mais FK_serveur!=0
469
      //Uniquement pour ryxeo
470
      if($data['name'] == "super-admin") { 
471
	$num_debut_ligne = 0;
472
	$queryZarb = local_make_query_zarb();
473
	//print "<pre>$queryZarb</pre>";
474
	//On passe 0 comme 3 argument
475
	$str_zarb .= local_make_array($queryZarb,0,0);
476
      }
435 477
    }
436 478
  }
437 479

  
......
445 487
  print $str_hors_maint;
446 488
  print local_make_array_footer($total_nbpc_hors_maint,$total_nbusers_hors_maint);
447 489

  
490
  //Uniquement pour ryxeo
491
  if($str_zarb != "") { 
492
    print "<h1>Tableau récapitulatif des serveurs étranges [dont la maintenance n'a pas été activée (abonnement zen sur webadmin) ??]</h1>";
493
    print local_make_array_header();
494
    print $str_zarb;
495
    print local_make_array_footer(0,0);
496
  }
497

  
448 498
  commonFooter();
449 499
  exit;
450 500
 }

Formats disponibles : Unified diff

Redmine Appliance - Powered by TurnKey Linux