Projet

Général

Profil

Révision 3eab2531

Voir les différences:

plugins/anet_epacks/front/plugin_anet_epacks.verif_comptes_dsi.php
37 37
verif_et_update(5);
38 38
verif_et_update(6);
39 39

  
40
$query = "UPDATE `glpi_users` SET FK_entities='1' WHERE `FK_entities` = 0 AND email NOT LIKE '%ryxeo.com'";
41
$result = $DB->query($query);
42

  
40 43
commonFooter();
41 44
?>
plugins/anet_epacks/front/plugin_anet_epacks.view_array_recap.php
129 129
  return $query;
130 130
}
131 131

  
132
//Special pour les "dsi" quand on convertis a la vollee les comptes post-only en dsi pour les animtice
133
function local_make_query_dsi($data, $entityid, $maintenance) {
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

  
142
  //WHERE e.Fk_Serveur > '0'\n";
143
  if($data['name'] == "dsi") {
144
    if($maintenance == 0 || $maintenance ==  1) {
145
      $query .= "WHERE e.FK_enduser='$entityid' AND e.FK_contract >= '0' AND e.FK_activation > '0'\n";
146
    }
147
    else if($maintenance == -1) {
148
      $query .= "WHERE e.FK_enduser='$entityid' AND e.FK_contract='-1' AND e.FK_activation > '0'\n";
149
    }
150
    //GROUP BY e.FK_serveur
151
    $query .= "GROUP BY e.FK_serveur
152
ORDER BY client ASC
153
LIMIT 500;";
154
  }
155
  else {
156
    $query = "";
157
  }
158

  
159
  //  if($maintenance == -1) {
160
  //print $query;
161
  //  }
162
  return $query;
163
}
164

  
165

  
166
function local_make_raw($q,$maintenance) {
167

  
168
}
169

  
132 170

  
133 171
function local_make_array($q,$maintenance) {
134 172
  global $DB;
135
  global $DB;
136 173
  global $glpiid;
137 174

  
175
  global $total_nbpc_maint;
176
  global $total_nbusers_maint;
177
  global $total_nbpc_hors_maint;
178
  global $total_nbusers_hors_maint;
179
  global $num_debut_ligne;
180
  global $tab_deja_affiche;
181

  
182

  
138 183
  $result = $DB->query($q) or die($DB->error());
139
    
140
  print "<table style=\"width:100%; padding: 0 10px 0 10px;\">
141
<tr class='tab_bg_2'>
142
  <th>Nom</th>
143
  <th><img src=\"img/stock_channel.png\" alt=\"Télémaintenance (SSH)\" title=\"Télémaintenance (SSH)\"></th>
144
  <th>Date du test</th>
145
  <th>Adresse DynDNS</th>
146
  <th><img src=\"img/computer.png\" alt=\"Nombre de postes\" title=\"Nombre de postes clients\"></th>
147
  <th><img src=\"img/stock_people.png\" alt=\"Nombre d'utilisateurs\" title=\"Nombre d'utilisateurs\"></th>
148
  <th><img src=\"img/stock_hand-signed.png\" title=\"Contrat\"></th>
149
</tr>\n";
150
    
184
       
151 185
  $total_nbpc = 0;
152 186
  $total_nbusers = 0;
153 187
  //La liste des entites qu'on affiche
154
  $tab_deja_affiche = array();
155
  $num_debut_ligne = 0;
156 188

  
157 189
  for($i = 0; $i < $DB->numrows($result); $i++) {
158 190
    $num_debut_ligne++;
159 191
    $data=$DB->fetch_array($result);
160
    $tab_deja_affiche[] = $data['entityid'];
161
    $ssh_dateLastOK = "";
162
    if($data['sshstatus'] == 1)
163
      $ssh_status = "<font color=\"green\">OK</font>";
164
    else if($data['sshdate']) {
165
      $ssh_status = "<font color=\"red\">ERR</font>";
166
      //Es-ce qu'on a deja reussi a se connecter sur ce serveur ?
167
      $queryLastOK = "SELECT sshdate FROM glpi_plugin_anet_epacks_ssh WHERE FK_serveur='" . $data['FK_serveur'] . "' AND sshstatus=1 ORDER BY sshdate DESC LIMIT 1";
168
      if($resultLastOK = $DB->query($queryLastOK)) {
169
	$dataLastOK = $DB->fetch_array($resultLastOK);
170
	if($dataLastOK[0]) {
171
	  //	  print_r($dataLastOK);
172
	  $ssh_status .= "<br /><font color=\"green\">LAST OK</font>";
173
	  $ssh_dateLastOK = "<br />" . $dataLastOK[0];
192

  
193
    if(! in_array($data['entityid'],$tab_deja_affiche)) {
194
      $tab_deja_affiche[] = $data['entityid'];
195
      $ssh_dateLastOK = "";
196
      if($data['sshstatus'] == 1)
197
	$ssh_status = "<font color=\"green\">OK</font>";
198
      else if($data['sshdate']) {
199
	$ssh_status = "<font color=\"red\">ERR</font>";
200
	//Es-ce qu'on a deja reussi a se connecter sur ce serveur ?
201
	$queryLastOK = "SELECT sshdate FROM glpi_plugin_anet_epacks_ssh WHERE FK_serveur='" . $data['FK_serveur'] . "' AND sshstatus=1 ORDER BY sshdate DESC LIMIT 1";
202
	if($resultLastOK = $DB->query($queryLastOK)) {
203
	  $dataLastOK = $DB->fetch_array($resultLastOK);
204
	  if($dataLastOK[0]) {
205
	    //	  print_r($dataLastOK);
206
	    $ssh_status .= "<br /><font color=\"green\">LAST OK</font>";
207
	    $ssh_dateLastOK = "<br />" . $dataLastOK[0];
208
	  }
209
	}
210
	else {
211
	  $ssh_dateLastOK = "";
174 212
	}
213
	//print $queryLastOK;
214
      }
215
      else
216
	$ssh_status = "<font color=\"orange\">???</font>";
217
      $s .= "<tr class='tab_bg_2'>
218
  <td align=\"left\">\n";
219
      if($data['entityid'] > 0) {
220
	$s .= "    " . $num_debut_ligne . ". <a href=\"../../manageentity/index.php?active_entity=" . $data['entityid'] . "\">" . $data['client'] . ": " . $data['serveur'] . "</a>\n";
175 221
      }
176 222
      else {
177
	$ssh_dateLastOK = "";
223
	$s .= "    " . $num_debut_ligne . ". " . $data['client'] . ": " . $data['serveur'] . "(abonnement zen jamais activé)\n";
178 224
      }
179
      //print $queryLastOK;
180
    }
181
    else
182
      $ssh_status = "<font color=\"orange\">???</font>";
183
    print "<tr class='tab_bg_2'>
184
  <td align=\"left\">\n";
185
    if($data['entityid'] > 0) {
186
      print "    " . $num_debut_ligne . ". <a href=\"../../manageentity/index.php?active_entity=" . $data['entityid'] . "\">" . $data['client'] . ": " . $data['serveur'] . "</a>\n";
187
    }
188
    else {
189
      print "    " . $num_debut_ligne . ". " . $data['client'] . ": " . $data['serveur'] . "(abonnement zen jamais activé)\n";
190
    }
191
    print "  </td>
225
      
226
      $s .= "  </td>
192 227
  <td>" . $ssh_status . "</td>
193 228
  <td>" . $data['sshdate'] . $ssh_dateLastOK . "</td>
194 229
  <td align=\"left\">" . $data['os_license_id'] . " " . $data['otherserial'] . "<br />" . $data['os_license_number'] . " " . $data['otherserial'] ."</td>
......
197 232
  <td>
198 233
  </td>
199 234
</tr>\n";
200
    /*
201
     <a href=\"../../../front/contract.php?contains[0]=" . $data['client'] . "\"><img src=\"img/stock_hand-signed.png\" title=\"Contrat\"></a>
202
     <a href=\"../../../front/tracking.php?contains[0]=" . $data['client'] . "\"><img src=\"img/stock_web-support.png\" title=\"Tickets\"></a>
203
     <a href=\"../../../front/user.php?contains[0]=" . $data['client'] . "\"><img src=\"img/stock_people.png\" title=\"Droits d'accès\"></a>
204
    */
205
    $total_nbpc += $data['nbpc'];
206
    $total_nbusers += $data['nbusers'];
235
      /*
236
       <a href=\"../../../front/contract.php?contains[0]=" . $data['client'] . "\"><img src=\"img/stock_hand-signed.png\" title=\"Contrat\"></a>
237
       <a href=\"../../../front/tracking.php?contains[0]=" . $data['client'] . "\"><img src=\"img/stock_web-support.png\" title=\"Tickets\"></a>
238
       <a href=\"../../../front/user.php?contains[0]=" . $data['client'] . "\"><img src=\"img/stock_people.png\" title=\"Droits d'accès\"></a>
239
      */
240
      $total_nbpc += $data['nbpc'];
241
      $total_nbusers += $data['nbusers'];
242
    }
207 243
  }
208 244
  
209 245
  //Maintenant toutes les entités sur lesquelles on a des droits recursifs
......
241 277
  if(trim($listentity) != "")
242 278
    $query .= " AND g3.parentID IN (" . $listentity . ")\n";
243 279
  //GROUP BY e.FK_serveur
244
  $query .= "GROUP BY e.FK_client
280
  else {
281
    $query = "";
282
  }
283
  if($query != "") 
284
    $query .= "GROUP BY e.FK_client
245 285
ORDER BY client
246 286
LIMIT 500;";
247 287
  
248 288
  //print $query;
249 289
  
250
  $result = $DB->query($query) or die($DB->error());
290
  if($query != "") 
291
    $result = $DB->query($query) or die($DB->error());
251 292
  
252 293
  for($i = 0; $i < $DB->numrows($result); $i++) {
253 294
    $num_debut_ligne++;
......
276 317
      }
277 318
      else
278 319
	$ssh_status = "<font color=\"orange\">???</font>";
279
      print "<tr class='tab_bg_2'>
320
      $s .= "<tr class='tab_bg_2'>
280 321
  <td align=\"left\">\n";
281 322
      if($data['entityid'] > 0) {
282
	print "    " . $num_debut_ligne . ". <a href=\"../../manageentity/index.php?active_entity=" . $data['entityid'] . "\">" . $data['client'] . ": " . $data['serveur'] . "</a>\n";
323
	$s .= "    " . $num_debut_ligne . ". <a href=\"../../manageentity/index.php?active_entity=" . $data['entityid'] . "\">" . $data['client'] . ": " . $data['serveur'] . "</a>\n";
283 324
      }
284 325
      else {
285
	print "    " . $num_debut_ligne . ". " . $data['client'] . ": " . $data['serveur'] . "(abonnement zen jamais activé)\n";
326
	$s .= "    " . $num_debut_ligne . ". " . $data['client'] . ": " . $data['serveur'] . "(abonnement zen jamais activé)\n";
286 327
      }
287
      print "  </td>
328
      $s .= "  </td>
288 329
  <td>" . $ssh_status . "</td>
289 330
  <td>" . $data['sshdate'] . $ssh_dateLastOK . "</td>
290 331
  <td align=\"left\">" . $data['os_license_id'] . " " . $data['otherserial'] . "<br />" . $data['os_license_number'] . " " . $data['otherserial'] . "</td>
......
312 353
   <a href=\"../../../front/central.php?active_entity=" . $data['entityid'] . "\"><img src=\"img/stock_about.png\" title=\"Incarner le client " . $data['client'] . "\"></a>
313 354
   <a href=\"../../../front/computer.php?contains[0]=" . $data['client'] . "\"><img src=\"img/stock_form-add-field.png\" title=\"Inventaire\"></a>
314 355
  */
315
  
316
  print "<tr class='tab_bg_2'>
356
  if($maintenance == 0) {
357
    $total_nbpc_maint += $total_nbpc;
358
    $total_nbusers_maint += $total_nbusers;
359
  }
360
  else {
361
    $total_nbpc_hors_maint += $total_nbpc;
362
    $total_nbusers_hors_maint += $total_nbusers;
363
  }
364
  return $s;
365
}
366

  
367
function local_make_array_header() {
368
  return   "<table style=\"width:100%; padding: 0 10px 0 10px;\">
369
<tr class='tab_bg_2'>
370
  <th>Nom</th>
371
  <th><img src=\"img/stock_channel.png\" alt=\"Télémaintenance (SSH)\" title=\"Télémaintenance (SSH)\"></th>
372
  <th>Date du test</th>
373
  <th>Adresse DynDNS</th>
374
  <th><img src=\"img/computer.png\" alt=\"Nombre de postes\" title=\"Nombre de postes clients\"></th>
375
  <th><img src=\"img/stock_people.png\" alt=\"Nombre d'utilisateurs\" title=\"Nombre d'utilisateurs\"></th>
376
  <th><img src=\"img/stock_hand-signed.png\" title=\"Contrat\"></th>
377
</tr>\n";
378

  
379
}
380

  
381
function local_make_array_footer($total_nbpc, $total_nbusers) {
382
  $s .= "<tr class='tab_bg_2'>
317 383
  <td colspan=\"4\">Totaux: </td>
318 384
  <td>" . $total_nbpc . "</td>
319 385
  <td>" . $total_nbusers . "</td>
320 386
  <td></td>
321 387
</tr>\n";
322
  
323
  print "</table>";
324
  
388

  
389
  $s .= "</table>";
390
  return $s;
325 391
}
326 392

  
393

  
327 394
commonHeader("AbulEdu.NET -- Tableau récapitulatif -- Accueil RyXéo",$_SERVER['PHP_SELF'],"config","plugins");
328 395

  
329 396
$glpiid = $_SESSION['glpiID'];
......
335 402
//print $query;
336 403
//exit;
337 404

  
405
$total_nbpc_maint    = 0;
406
$total_nbusers_maint = 0;
407
$total_nbpc_hors_maint    = 0;
408
$total_nbusers_hors_maint = 0;
409
$tab_deja_affiche = array();
410

  
338 411
$result = $DB->query($query);
339 412
if($result) {
340
  $data=$DB->fetch_array($result);
341
  $entityid = $data['FK_entities'];
342
  if($data['name'] == "revendeur" || $data['name'] == "dsi" || $data['name'] == "super-admin") {
413
  while($data=$DB->fetch_array($result)) {
343 414
    $entityid = $data['FK_entities'];
344
    
345
    //print $query;
346
    //exit;
415
    if($data['name'] == "revendeur" || $data['name'] == "dsi" || $data['name'] == "super-admin") {
416
      //print $query;
417
      $entityid = $data['FK_entities'];
347 418
      
348
    print "<h1>Tableau récapitulatif de vos serveurs sous maintenance</h1>";
349
    $maintenance = 0;
350
    $querySM = local_make_query($data, $entityid, $maintenance);
351
    local_make_array($querySM,$maintenance);
352

  
353
    print "<h1>Tableau récapitulatif de vos serveurs hors maintenance</h1>";
354
    $maintenance = -1;
355
    $queryHM = local_make_query($data, $entityid, $maintenance);
356
    local_make_array($queryHM,$maintenance);
357
    
358
    commonFooter();
359
    exit;
419
      //print $query;
420
      //exit;
421
      
422
      $maintenance = 0;
423
      $querySM = local_make_query($data, $entityid, $maintenance);
424
      $str_sous_maint .= local_make_array($querySM,$maintenance);
425
      
426
      $querySM = local_make_query_dsi($data, $entityid, $maintenance);
427
      //print $querySM;
428
      if($querySM != "")
429
	$str_sous_maint .= local_make_array($querySM,$maintenance);
430
      
431
      $num_debut_ligne = 0;
432
      $maintenance = -1;
433
      $queryHM = local_make_query($data, $entityid, $maintenance);
434
      $str_hors_maint .= local_make_array($queryHM,$maintenance);
435
    }
360 436
  }
437

  
438
  print "<h1>Tableau récapitulatif de vos serveurs sous maintenance</h1>";
439
  print local_make_array_header();
440
  print $str_sous_maint;
441
  print local_make_array_footer($total_nbpc_maint,$total_nbusers_maint);
442

  
443
  print "<h1>Tableau récapitulatif de vos serveurs hors maintenance</h1>";
444
  print local_make_array_header();
445
  print $str_hors_maint;
446
  print local_make_array_footer($total_nbpc_hors_maint,$total_nbusers_hors_maint);
447

  
448
  commonFooter();
449
  exit;
361 450
 }
362 451

  
363 452
?>

Formats disponibles : Unified diff

Redmine Appliance - Powered by TurnKey Linux