Projet

Général

Profil

Paste
Statistiques
| Branche: | Révision:

ryxeo-glpi-git / plugins / anet_epacks / front / plugin_anet_epacks.view_array_recap.php @ f4699b2f

Historique | Voir | Annoter | Télécharger (19,2 ko)

1
<?php
2

    
3
  /*
4
    Creation de la vue ...
5
    CREATE  ALGORITHM = TEMPTABLE VIEW glpi_plugin_anet_epacks_ssh_max AS SELECT *
6
    FROM `glpi_plugin_anet_epacks_ssh` as s1
7
    WHERE sshdate=(SELECT MAX(sshdate) FROM `glpi_plugin_anet_epacks_ssh` as s2 WHERE s1.FK_serveur=s2.FK_serveur)
8

9
    Comme c'est super long et cause un lag monstrueux a l ouverture on remplace par une table "normale" qui est
10
    periodiquement remise a jour ...
11

12
    CREATE TABLE IF NOT EXISTS `glpi_plugin_anet_epacks_ssh_max` (
13
    `ID` int(11) NOT NULL auto_increment,
14
    `sshstatus` binary(1) NOT NULL,
15
    `FK_serveur` int(11) NOT NULL,
16
    `log` text collate utf8_unicode_ci NOT NULL,
17
    `sshdate` datetime NOT NULL,
18
    PRIMARY KEY  (`ID`),
19
    KEY `FK_serveur` (`FK_serveur`)
20
    ) ENGINE=MyISAM  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci ; 
21
    
22
    A lancer periodiquement (?)
23
    TRUNCATE TABLE `glpi_plugin_anet_epacks_ssh_max` ;
24
    INSERT INTO glpi_plugin_anet_epacks_ssh_max SELECT * FROM `glpi_plugin_anet_epacks_ssh` as s1  WHERE sshdate=(SELECT MAX(sshdate) FROM `glpi_plugin_anet_epacks_ssh` as s2 WHERE s1.FK_serveur=s2.FK_serveur) ;
25
    
26

27
    on utilise la meme astuce pour l autre view: glpi_plugin_anet_epacks_recencement_max
28

29
    CREATE TABLE IF NOT EXISTS `glpi_plugin_anet_epacks_recencement_max` (
30
    `id` int(11) NOT NULL auto_increment,
31
    `ladate` timestamp NOT NULL default CURRENT_TIMESTAMP,
32
    `site` text collate utf8_unicode_ci NOT NULL,
33
    `phone` varchar(20) collate utf8_unicode_ci NOT NULL,
34
    `rvd` varchar(100) collate utf8_unicode_ci NOT NULL,
35
    `adresse1` text collate utf8_unicode_ci NOT NULL,
36
    `adresse2` text collate utf8_unicode_ci NOT NULL,
37
    `ville` varchar(100) collate utf8_unicode_ci NOT NULL,
38
    `cpostal` varchar(10) collate utf8_unicode_ci NOT NULL,
39
    `pays` varchar(100) collate utf8_unicode_ci NOT NULL,
40
    `nom` varchar(100) collate utf8_unicode_ci NOT NULL,
41
    `prenom` varchar(100) collate utf8_unicode_ci NOT NULL,
42
    `email` varchar(100) collate utf8_unicode_ci NOT NULL,
43
    `mac0` varchar(15) collate utf8_unicode_ci NOT NULL,
44
    `mac1` varchar(15) collate utf8_unicode_ci NOT NULL,
45
    `proc` varchar(100) collate utf8_unicode_ci NOT NULL,
46
    `ram` varchar(100) collate utf8_unicode_ci NOT NULL,
47
    `hdd0` varchar(100) collate utf8_unicode_ci NOT NULL,
48
    `hdd1` varchar(100) collate utf8_unicode_ci NOT NULL,
49
    `anet` varchar(100) collate utf8_unicode_ci NOT NULL,
50
    `tel` varchar(20) collate utf8_unicode_ci NOT NULL,
51
    `contrat` varchar(100) collate utf8_unicode_ci NOT NULL,
52
    `nbprofs` int(11) NOT NULL,
53
    `nbeleves` int(11) NOT NULL,
54
    `nbpc` int(11) NOT NULL,
55
    `ip` varchar(16) collate utf8_unicode_ci NOT NULL,
56
    `FK_serveur` int(11) default NULL,
57
    PRIMARY KEY  (`id`),
58
    UNIQUE KEY `FK_serveur` (`FK_serveur`)
59
    ) ENGINE=MyISAM  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
60
    
61
    Et lance periodiquement
62
    TRUNCATE TABLE `glpi_plugin_anet_epacks_recencement_max` ;
63
    INSERT INTO glpi_plugin_anet_epacks_recencement_max SELECT * FROM glpi_plugin_anet_epacks_recencement as s1
64
    WHERE ladate=(SELECT MAX(ladate) FROM `glpi_plugin_anet_epacks_recencement` as s2 WHERE s1.FK_serveur=s2.FK_serveur) ;
65

66
    En fait, ca se passe dans anet.ryxeo.com/statistiques.php
67

68
  */
69

    
70
  // Affiche le tableau recap de tous les serveurs
71

    
72
if(!defined('GLPI_ROOT')){
73
  define('GLPI_ROOT', '../../..');
74
 }
75
include_once (GLPI_ROOT . "/inc/includes.php");
76
//include_once (GLPI_CONFIG_DIR . "/config_db_slave.php");
77

    
78
//On essaye d'utiliser le proxy/cache mysql
79
//$DBSlave = new DBSlave;
80

    
81
//Fabrique la requete en fonction des besoins de liste des serveurs sous maintenance ou non
82
//$maintenance = 1 -> ceux qui sons sous maintenance (sur)
83
//$maintenance = 0 -> ceux qu'on ne sais pas (ça sera a faire quand on aura saisi tous les contrats)
84
//$maintenance = -1 -> ceux qui ne veulent pas de maintenance
85
//le champ peut etre a deux -> on ne veut meme plus les afficher
86
//
87
//
88
function local_make_query($data, $entityid, $maintenance) {
89
  $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.*,
90
(g5.nbeleves+g5.nbprofs) as nbusers, g5.nbpc as nbpc
91
FROM glpi_plugin_anet_epacks AS e
92
LEFT JOIN glpi_plugin_anet_epacks_ssh_max AS ssh ON e.FK_serveur=ssh.FK_serveur
93
LEFT JOIN glpi_entities AS g3 ON e.FK_client=g3.ID
94
LEFT JOIN glpi_computers AS g4 ON e.FK_serveur=g4.ID
95
LEFT JOIN glpi_plugin_anet_epacks_recencement_max AS g5 ON e.FK_serveur=g5.FK_serveur\n";
96

    
97
  //WHERE e.Fk_Serveur > '0'\n";
98
  if($data['name'] == "revendeur" || $data['name'] == "dsi") {
99
    if($maintenance == 0 || $maintenance ==  1) {
100
      $query .= "WHERE e.FK_contract >= '0' AND e.FK_activation='" . $entityid . "'\n";
101
    }
102
    else if($maintenance == -1) {
103
      $query .= "WHERE e.FK_contract='-1' AND e.FK_activation='" . $entityid . "'\n";
104
    }
105
      //GROUP BY e.FK_serveur
106
    $query .= "GROUP BY e.FK_serveur
107
ORDER BY client ASC
108
LIMIT 500;";
109
  }
110
  else {
111
    //On n'affiche pas les serveurs qui ne sont pas "Zen"
112
    if($maintenance == 0 || $maintenance ==  1) {
113
      $query .= "WHERE e.FK_contract >= '0' AND e.FK_Serveur>'0'\n";
114
    }
115
    else if($maintenance == -1) {
116
      $query .= "WHERE e.FK_contract='-1' AND e.FK_Serveur>'0'\n";
117
    }
118
    //GROUP BY e.FK_serveur
119
    //On ne peut pas group by client a cause de l'historique ou on avait pas la meme structure
120
    //de base
121
    $query .= "GROUP BY e.FK_serveur
122
ORDER BY client ASC
123
LIMIT 500;";
124
  }
125

    
126
  //  if($maintenance == -1) {
127
  //print $query;
128
  //  }
129
  return $query;
130
}
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
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

    
150
//Special pour les "dsi" quand on convertis a la vollee les comptes post-only en dsi pour les animtice
151
function local_make_query_dsi($data, $entityid, $maintenance) {
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.*,
153
(g5.nbeleves+g5.nbprofs) as nbusers, g5.nbpc as nbpc
154
FROM glpi_plugin_anet_epacks AS e
155
LEFT JOIN glpi_plugin_anet_epacks_ssh_max AS ssh ON e.FK_serveur=ssh.FK_serveur
156
LEFT JOIN glpi_entities AS g3 ON e.FK_client=g3.ID
157
LEFT JOIN glpi_computers AS g4 ON e.FK_serveur=g4.ID
158
LEFT JOIN glpi_plugin_anet_epacks_recencement_max AS g5 ON e.FK_serveur=g5.FK_serveur\n";
159

    
160
  //WHERE e.Fk_Serveur > '0'\n";
161
  if($data['name'] == "dsi") {
162
    if($maintenance == 0 || $maintenance ==  1) {
163
      $query .= "WHERE e.FK_enduser='$entityid' AND e.FK_contract >= '0' AND e.FK_activation > '0'\n";
164
    }
165
    else if($maintenance == -1) {
166
      $query .= "WHERE e.FK_enduser='$entityid' AND e.FK_contract='-1' AND e.FK_activation > '0'\n";
167
    }
168
    //GROUP BY e.FK_serveur
169
    $query .= "GROUP BY e.FK_serveur
170
ORDER BY client ASC
171
LIMIT 500;";
172
  }
173
  else {
174
    $query = "";
175
  }
176

    
177
  //  if($maintenance == -1) {
178
  //print $query;
179
  //  }
180
  return $query;
181
}
182

    
183

    
184
function local_make_raw($q,$maintenance) {
185

    
186
}
187

    
188

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

    
194
  global $total_nbpc_maint;
195
  global $total_nbusers_maint;
196
  global $total_nbpc_hors_maint;
197
  global $total_nbusers_hors_maint;
198
  global $num_debut_ligne;
199
  global $tab_deja_affiche;
200

    
201

    
202
  $result = $DB->query($q) or die($DB->error());
203
       
204
  $total_nbpc = 0;
205
  $total_nbusers = 0;
206
  //La liste des entites qu'on affiche
207

    
208
  for($i = 0; $i < $DB->numrows($result); $i++) {
209
    $num_debut_ligne++;
210
    $data=$DB->fetch_array($result);
211

    
212
    if(! in_array($data['entityid'],$tab_deja_affiche)) {
213
      $tab_deja_affiche[] = $data['entityid'];
214
      $ssh_dateLastOK = "";
215
      if($data['sshstatus'] == 1)
216
        $ssh_status = "<font color=\"green\">OK</font>";
217
      else if($data['sshdate']) {
218
        $ssh_status = "<font color=\"red\">ERR</font>";
219
        //Es-ce qu'on a deja reussi a se connecter sur ce serveur ?
220
        $queryLastOK = "SELECT sshdate FROM glpi_plugin_anet_epacks_ssh WHERE FK_serveur='" . $data['FK_serveur'] . "' AND sshstatus=1 ORDER BY sshdate DESC LIMIT 1";
221
        if($resultLastOK = $DB->query($queryLastOK)) {
222
          $dataLastOK = $DB->fetch_array($resultLastOK);
223
          if($dataLastOK[0]) {
224
            //          print_r($dataLastOK);
225
            $ssh_status .= "<br /><font color=\"green\">LAST OK</font>";
226
            $ssh_dateLastOK = "<br />" . $dataLastOK[0];
227
          }
228
        }
229
        else {
230
          $ssh_dateLastOK = "";
231
        }
232
        //print $queryLastOK;
233
      }
234
      else
235
        $ssh_status = "<font color=\"orange\">???</font>";
236
      $s .= "<tr class='tab_bg_2'>
237
  <td align=\"left\">\n";
238
      if($data['entityid'] > 0) {
239
        $s .= "    " . $num_debut_ligne . ". <a href=\"../../manageentity/index.php?active_entity=" . $data['entityid'] . "\">" . $data['client'] . ": " . $data['serveur'] . "</a>\n";
240
      }
241
      else {
242
                $s .= "    " . $num_debut_ligne . ". " . $data['client'] . ": " . $data['serveur'] . "(abonnement zen jamais activé, serveur fantôme ?)\n";
243
      }
244
      
245
      $s .= "  </td>
246
  <td>" . $ssh_status . "</td>
247
  <td>" . $data['sshdate'] . $ssh_dateLastOK . "</td>
248
  <td align=\"left\">" . $data['os_license_id'] . " " . $data['otherserial'] . "<br />" . $data['os_license_number'] . " " . $data['otherserial'] ."</td>
249
  <td>" . $data['nbpc'] . "</td>
250
  <td>" . $data['nbusers'] . "</td>
251
  <td>
252
  </td>
253
</tr>\n";
254
      /*
255
       <a href=\"../../../front/contract.php?contains[0]=" . $data['client'] . "\"><img src=\"img/stock_hand-signed.png\" title=\"Contrat\"></a>
256
       <a href=\"../../../front/tracking.php?contains[0]=" . $data['client'] . "\"><img src=\"img/stock_web-support.png\" title=\"Tickets\"></a>
257
       <a href=\"../../../front/user.php?contains[0]=" . $data['client'] . "\"><img src=\"img/stock_people.png\" title=\"Droits d'accès\"></a>
258
      */
259
      $total_nbpc += $data['nbpc'];
260
      $total_nbusers += $data['nbusers'];
261
    }
262
  }
263
  
264
  //Maintenant toutes les entités sur lesquelles on a des droits recursifs
265
  $queryR = "SELECT glpi_users_profiles.FK_entities as entity FROM glpi_users_profiles WHERE glpi_users_profiles.FK_users='" . $glpiid . "' AND glpi_users_profiles.recursive=1 GROUP BY FK_entities";
266
  //print $queryR;
267
  $resultR = $DB->query($queryR);
268
  $listentity = "";
269
  for($r = 0; $r < $DB->numrows($resultR); $r++) {
270
    $dataR=$DB->fetch_array($resultR);
271
    $entityparent = $dataR['entity'];
272
    if($listentity != "")
273
      $listentity .= ", '" . $entityparent . "'";
274
    else
275
      $listentity = "'" . $entityparent . "'";
276
  }
277
  //$query = "SELECT ID FROM glpi_entities WHERE parentID='" . $entityparent . "'";
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.*,
281
(sum(g5.nbeleves)+sum(g5.nbprofs)) as nbusers, g5.nbpc as nbpc
282
FROM glpi_plugin_anet_epacks AS e
283
LEFT JOIN glpi_plugin_anet_epacks_ssh_max AS ssh ON e.FK_serveur=ssh.FK_serveur
284
LEFT JOIN glpi_entities AS g3 ON e.FK_client=g3.ID
285
LEFT JOIN glpi_computers AS g4 ON e.FK_serveur=g4.ID
286
LEFT JOIN glpi_plugin_anet_epacks_recencement_max AS g5 ON e.FK_serveur=g5.FK_serveur\n";
287
    //WHERE e.Fk_Serveur > '0'\n";
288

    
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;";
306
  }
307
  else {
308
    //LEFT JOIN glpi_entities AS g3 ON e.FK_client=g3.ID OR e.FK_enduser=g3.ID
309
    $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.*
310
FROM glpi_plugin_anet_epacks AS e
311
LEFT JOIN glpi_plugin_anet_epacks_ssh_max AS ssh ON e.FK_serveur=ssh.FK_serveur
312
LEFT JOIN glpi_entities AS g3 ON e.FK_client=g3.ID
313
LEFT JOIN glpi_computers AS g4 ON e.FK_serveur=g4.ID
314
LEFT JOIN glpi_plugin_anet_epacks_recencement_max AS g5 ON e.FK_serveur=g5.FK_serveur
315
WHERE e.FK_enduser='0' AND e.FK_client!='0'
316
ORDER BY client\n";
317
    //print $query;
318
  }
319
    
320
  //print $query;
321

    
322

    
323
  if($query != "") 
324
    $result = $DB->query($query) or die($DB->error());
325
  
326
  for($i = 0; $i < $DB->numrows($result); $i++) {
327
    $num_debut_ligne++;
328
    $data=$DB->fetch_array($result);
329
    $ssh_dateLastOK = "";
330
    if(! in_array($data['entityid'],$tab_deja_affiche) || $enduser==0) {
331
      $tab_deja_affiche[] = $data['entityid'];
332
      if($data['sshstatus'] == 1)
333
        $ssh_status = "<font color=\"green\">OK</font>";
334
      else if($data['sshdate']) {
335
        $ssh_status = "<font color=\"red\">ERR</font>";
336
        //Es-ce qu'on a deja reussi a se connecter sur ce serveur ?
337
        $queryLastOK = "SELECT sshdate FROM glpi_plugin_anet_epacks_ssh WHERE FK_serveur='" . $data['FK_serveur'] . "' AND sshstatus=1 ORDER BY sshdate DESC LIMIT 1";
338
        if($resultLastOK = $DB->query($queryLastOK)) {
339
          $dataLastOK = $DB->fetch_array($resultLastOK);
340
          if($dataLastOK[0]) {
341
            //          print_r($dataLastOK);
342
            $ssh_status .= "<br /><font color=\"green\">LAST OK</font>";
343
            $ssh_dateLastOK = "<br />" . $dataLastOK[0];
344
          }
345
        }
346
        else {
347
          $ssh_dateLastOK = "";
348
        }
349
        //print $queryLastOK;
350
      }
351
      else
352
        $ssh_status = "<font color=\"orange\">???</font>";
353
      $s .= "<tr class='tab_bg_2'>
354
  <td align=\"left\">\n";
355
      if($data['entityid'] > 0) {
356
        $s .= "    " . $num_debut_ligne . ". <a href=\"../../manageentity/index.php?active_entity=" . $data['entityid'] . "\">" . $data['client'] . ": " . $data['serveur'] . "</a>\n";
357
      }
358
      else {
359
        $s .= "    " . $num_debut_ligne . ". " . $data['client'] . ": " . $data['serveur'] . "(abonnement zen jamais activé, serveur fantôme ?)\n";
360
      }
361

    
362
      $s .= "  </td>
363
  <td>" . $ssh_status . "</td>
364
  <td>" . $data['sshdate'] . $ssh_dateLastOK . "</td>
365
  <td align=\"left\">" . $data['os_license_id'] . " " . $data['otherserial'] . "<br />" . $data['os_license_number'] . " " . $data['otherserial'] . "</td>
366
  <td>" . $data['nbpc'] . "</td>
367
  <td>" . $data['nbusers'] . "</td>
368
  <td>
369
  </td>
370
</tr>\n";
371
      /*
372
          <a href=\"../../../front/contract.php?contains[0]=" . $data['client'] . "\"><img src=\"img/stock_hand-signed.png\" title=\"Contrat\"></a>
373
          <a href=\"../../../front/tracking.php?contains[0]=" . $data['client'] . "\"><img src=\"img/stock_web-support.png\" title=\"Tickets\"></a>
374
          <a href=\"../../../front/user.php?contains[0]=" . $data['client'] . "\"><img src=\"img/stock_people.png\" title=\"Droits d'accès\"></a>
375
      */
376
      $total_nbpc += $data['nbpc'];
377
      $total_nbusers += $data['nbusers'];
378
    }
379
    else {
380
      //print "deja affiché :: " . $data['entityid'];
381
    }
382
  }
383
  
384
  
385
  
386
  /*
387
   <a href=\"../../../front/central.php?active_entity=" . $data['entityid'] . "\"><img src=\"img/stock_about.png\" title=\"Incarner le client " . $data['client'] . "\"></a>
388
   <a href=\"../../../front/computer.php?contains[0]=" . $data['client'] . "\"><img src=\"img/stock_form-add-field.png\" title=\"Inventaire\"></a>
389
  */
390
  if($maintenance == 0) {
391
    $total_nbpc_maint += $total_nbpc;
392
    $total_nbusers_maint += $total_nbusers;
393
  }
394
  else {
395
    $total_nbpc_hors_maint += $total_nbpc;
396
    $total_nbusers_hors_maint += $total_nbusers;
397
  }
398
  return $s;
399
}
400

    
401
function local_make_array_header() {
402
  return   "<table style=\"width:100%; padding: 0 10px 0 10px;\">
403
<tr class='tab_bg_2'>
404
  <th>Nom</th>
405
  <th><img src=\"img/stock_channel.png\" alt=\"Télémaintenance (SSH)\" title=\"Télémaintenance (SSH)\"></th>
406
  <th>Date du test</th>
407
  <th>Adresse DynDNS</th>
408
  <th><img src=\"img/computer.png\" alt=\"Nombre de postes\" title=\"Nombre de postes clients\"></th>
409
  <th><img src=\"img/stock_people.png\" alt=\"Nombre d'utilisateurs\" title=\"Nombre d'utilisateurs\"></th>
410
  <th><img src=\"img/stock_hand-signed.png\" title=\"Contrat\"></th>
411
</tr>\n";
412

    
413
}
414

    
415
function local_make_array_footer($total_nbpc, $total_nbusers) {
416
  $s .= "<tr class='tab_bg_2'>
417
  <td colspan=\"4\">Totaux: </td>
418
  <td>" . $total_nbpc . "</td>
419
  <td>" . $total_nbusers . "</td>
420
  <td></td>
421
</tr>\n";
422

    
423
  $s .= "</table>";
424
  return $s;
425
}
426

    
427

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

    
430
$glpiid = $_SESSION['glpiID'];
431

    
432
global $DB;
433

    
434
$query = "SELECT glpi_profiles.name AS name,glpi_users_profiles.FK_entities as FK_entities FROM glpi_profiles,glpi_users_profiles,glpi_users WHERE glpi_users_profiles.FK_users='" . $glpiid . "' AND glpi_users_profiles.FK_profiles=glpi_profiles.ID GROUP BY FK_entities";
435

    
436
//print $query;
437
//exit;
438

    
439
$total_nbpc_maint         = 0;
440
$total_nbusers_maint      = 0;
441
$total_nbpc_hors_maint    = 0;
442
$total_nbusers_hors_maint = 0;
443
$tab_deja_affiche         = array();
444
$num_debut_ligne_maint    = 0;
445
$num_debut_ligne_horsmaint = 0;
446

    
447
$result = $DB->query($query);
448
if($result) {
449
  while($data=$DB->fetch_array($result)) {
450
    $entityid = $data['FK_entities'];
451
    if($data['name'] == "revendeur" || $data['name'] == "dsi" || $data['name'] == "super-admin") {
452
      $num_debut_ligne = $num_debut_ligne_maint;
453
      //print $query;
454
      $entityid = $data['FK_entities'];
455
      
456
      $maintenance = 0;
457
      $querySM = local_make_query($data, $entityid, $maintenance);
458
      $str_sous_maint .= local_make_array($querySM,$maintenance);
459
      
460
      $querySM = local_make_query_dsi($data, $entityid, $maintenance);
461
      //print $querySM;
462
      if($querySM != "")
463
        $str_sous_maint .= local_make_array($querySM,$maintenance);
464
      
465
      $num_debut_ligne_maint = $num_debut_ligne;
466
      $num_debut_ligne = 0;
467
      $maintenance = -1;
468
      $queryHM = local_make_query($data, $entityid, $maintenance);
469
      $str_hors_maint .= local_make_array($queryHM,$maintenance);
470
      
471
      //et maintenant les epacks dont le FK_enduser=0 mais FK_serveur!=0
472
      //Uniquement pour ryxeo
473
      if($data['name'] == "super-admin") { 
474
        $num_debut_ligne_horsmaint = $num_debut_ligne;
475
        $num_debut_ligne = 0;
476
        $queryZarb = local_make_query_zarb();
477
        //print "<pre>$queryZarb</pre>";
478
        //On passe 0 comme 3 argument
479
        $str_zarb .= local_make_array($queryZarb,0,0);
480
      }
481
    }
482
  }
483
  
484
  print "<h1>Tableau récapitulatif de vos serveurs sous maintenance</h1>";
485
  print local_make_array_header();
486
  print $str_sous_maint;
487
  print local_make_array_footer($total_nbpc_maint,$total_nbusers_maint);
488
  
489
  print "<h1>Tableau récapitulatif de vos serveurs hors maintenance</h1>";
490
  print local_make_array_header();
491
  print $str_hors_maint;
492
  print local_make_array_footer($total_nbpc_hors_maint,$total_nbusers_hors_maint);
493
  
494
  //Uniquement pour ryxeo
495
  if($str_zarb != "") { 
496
    print "<h1>Tableau récapitulatif des serveurs étranges [dont la maintenance n'a pas été activée (abonnement zen sur webadmin) ??]</h1>";
497
    print local_make_array_header();
498
    print $str_zarb;
499
    print local_make_array_footer(0,0);
500
  }
501
  
502
  commonFooter();
503
  exit;
504
 }
505

    
506
?>
Redmine Appliance - Powered by TurnKey Linux