Projet

Général

Profil

Révision 1b365d67

Voir les différences:

plugins/anet_epacks/front/plugin_anet_epacks.view_array_recap.php
14 14
 }
15 15
include_once (GLPI_ROOT . "/inc/includes.php");
16 16

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

  
19
$glpiid = $_SESSION['glpiID'];
20

  
21
global $DB;
22
$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 AND glpi_users.FK_entities=glpi_users_profiles.FK_entities GROUP BY FK_entities";
23

  
24
//print $query;
25
$result = $DB->query($query);
26
if($result) {
27
  $data=$DB->fetch_array($result);
28
  $entityid = $data['FK_entities'];
29
  if($data['name'] == "revendeur" || $data['name'] == "dsi" || $data['name'] == "super-admin") {
30
    print "<h1>Tableau récapitulatif de vos serveurs</h1>";
31
    $entityid = $data['FK_entities'];
32
    
33
    $query = "SELECT e.*, e.FK_enduser as entityid, g3.name as client, g4.name as serveur, g4.os_license_number, g4.os_license_id, ssh.*,
17
//Fabrique la requete en fonction des besoins de liste des serveurs sous maintenance ou non
18
//$maintenance = 1 -> ceux qui sons sous maintenance (sur)
19
//$maintenance = 0 -> ceux qu'on ne sais pas (ça sera a faire quand on aura saisi tous les contrats)
20
//$maintenance = -1 -> ceux qui ne veulent pas de maintenance
21
//le champ peut etre a deux -> on ne veut meme plus les afficher
22
function local_make_query($data, $entityid, $maintenance) {
23
  $query = "SELECT e.*, e.FK_enduser as entityid, g3.name as client, g4.name as serveur, g4.os_license_number, g4.os_license_id, ssh.*,
34 24
(sum(g5.nbeleves)+sum(g5.nbprofs)) as nbusers, g5.nbpc as nbpc
35 25
FROM glpi_plugin_anet_epacks AS e
36 26
LEFT JOIN glpi_plugin_anet_epacks_ssh_max AS ssh ON e.FK_serveur=ssh.FK_serveur
......
38 28
LEFT JOIN glpi_computers AS g4 ON e.FK_serveur=g4.ID
39 29
LEFT JOIN glpi_plugin_anet_epacks_recencement_max AS g5 ON e.FK_serveur=g5.FK_serveur\n";
40 30

  
41
    //WHERE e.Fk_Serveur > '0'\n";
42
    if($data['name'] == "revendeur" || $data['name'] == "dsi") {
31
  //WHERE e.Fk_Serveur > '0'\n";
32
  if($data['name'] == "revendeur" || $data['name'] == "dsi") {
33
    if($maintenance == 0 || $maintenance ==  1) {
43 34
      $query .= "WHERE e.FK_contract >= '0' AND e.FK_activation='" . $entityid . "'\n";
35
    }
36
    else if($maintenance == -1) {
37
      $query .= "WHERE e.FK_contract='-1' AND e.FK_activation='" . $entityid . "'\n";
38
    }
44 39
      //GROUP BY e.FK_serveur
45
      $query .= "GROUP BY e.FK_client
40
    $query .= "GROUP BY e.FK_client
46 41
ORDER BY client
47 42
LIMIT 500;";
48
    }
49
    else {
50
      //On n'affiche pas les serveurs qui ne sont pas "Zen"
43
  }
44
  else {
45
    //On n'affiche pas les serveurs qui ne sont pas "Zen"
46
    if($maintenance == 0 || $maintenance ==  1) {
51 47
      $query .= "WHERE e.FK_contract >= '0' AND e.FK_Serveur>'0'\n";
52
      //GROUP BY e.FK_serveur
53
      //On ne peut pas group by client a cause de l'historique ou on avait pas la meme structure
54
      //de base
55
      $query .= "GROUP BY e.FK_serveur
48
    }
49
    else if($maintenance == -1) {
50
      $query .= "WHERE e.FK_contract='-1' AND e.FK_Serveur>'0'\n";
51
    }
52
    //GROUP BY e.FK_serveur
53
    //On ne peut pas group by client a cause de l'historique ou on avait pas la meme structure
54
    //de base
55
    $query .= "GROUP BY e.FK_serveur
56 56
ORDER BY client
57 57
LIMIT 500;";
58
    }
59
    
60
    //print $query;
61
    //exit;
62
    
63
    $result = $DB->query($query) or die($DB->error());
58
  }
59

  
60
  //  if($maintenance == -1) {
61
  //    print $query;
62
  //  }
63
  return $query;
64
}
65

  
66

  
67
function local_make_array($q,$maintenance) {
68
  global $DB;
69
  global $glpiid;
70

  
71
  $result = $DB->query($q) or die($DB->error());
64 72
    
65
    print "<table>
73
  print "<table>
66 74
<tr class='tab_bg_2'>
67 75
  <th>Nom</th>
68 76
  <th><img src=\"img/stock_channel.png\" alt=\"Télémaintenance (SSH)\" title=\"Télémaintenance (SSH)\"></th>
......
73 81
  <th><img src=\"img/stock_hand-signed.png\" title=\"Contrat\"></th>
74 82
</tr>\n";
75 83
    
76
    $total_nbpc = 0;
77
    $total_nbusers = 0;
78
    //La liste des entites qu'on affiche
79
    $tab_deja_affiche = array();
84
  $total_nbpc = 0;
85
  $total_nbusers = 0;
86
  //La liste des entites qu'on affiche
87
  $tab_deja_affiche = array();
80 88
    
81
    for($i = 0; $i < $DB->numrows($result); $i++) {
82
      $data=$DB->fetch_array($result);
89
  for($i = 0; $i < $DB->numrows($result); $i++) {
90
    $data=$DB->fetch_array($result);
91
    $tab_deja_affiche[] = $data['entityid'];
92
    $ssh_dateLastOK = "";
93
    if($data['sshstatus'] == 1)
94
      $ssh_status = "<font color=\"green\">OK</font>";
95
    else if($data['sshdate']) {
96
      $ssh_status = "<font color=\"red\">ERR</font>";
97
      //Es-ce qu'on a deja reussi a se connecter sur ce serveur ?
98
      $queryLastOK = "SELECT sshdate FROM glpi_plugin_anet_epacks_ssh WHERE FK_serveur='" . $data['FK_serveur'] . "' AND sshstatus=1 ORDER BY sshdate DESC LIMIT 1";
99
      if($resultLastOK = $DB->query($queryLastOK)) {
100
	$dataLastOK = $DB->fetch_array($resultLastOK);
101
	if($dataLastOK[0]) {
102
	  //	  print_r($dataLastOK);
103
	  $ssh_status .= "<br /><font color=\"green\">LAST OK</font>";
104
	  $ssh_dateLastOK = "<br />" . $dataLastOK[0];
105
	}
106
      }
107
      else {
108
	$ssh_dateLastOK = "";
109
      }
110
      //print $queryLastOK;
111
    }
112
    else
113
      $ssh_status = "<font color=\"orange\">???</font>";
114
    print "<tr class='tab_bg_2'>
115
  <td align=\"left\">\n";
116
    if($data['entityid'] > 0) {
117
      print "    " . ($i+1) . ". <a href=\"../../manageentity/index.php?active_entity=" . $data['entityid'] . "\">" . $data['client'] . ": " . $data['serveur'] . "</a>\n";
118
    }
119
    else {
120
      print "    " . ($i+1) . ". " . $data['client'] . ": " . $data['serveur'] . "(abonnement zen jamais activé)\n";
121
    }
122
    print "  </td>
123
  <td>" . $ssh_status . "</td>
124
  <td>" . $data['sshdate'] . $ssh_dateLastOK . "</td>
125
  <td align=\"left\">" . $data['os_license_id'] . "<br />" . $data['os_license_number'] . "</td>
126
  <td>" . $data['nbpc'] . "</td>
127
  <td>" . $data['nbusers'] . "</td>
128
  <td>
129
  </td>
130
</tr>\n";
131
    /*
132
     <a href=\"../../../front/contract.php?contains[0]=" . $data['client'] . "\"><img src=\"img/stock_hand-signed.png\" title=\"Contrat\"></a>
133
     <a href=\"../../../front/tracking.php?contains[0]=" . $data['client'] . "\"><img src=\"img/stock_web-support.png\" title=\"Tickets\"></a>
134
     <a href=\"../../../front/user.php?contains[0]=" . $data['client'] . "\"><img src=\"img/stock_people.png\" title=\"Droits d'accès\"></a>
135
    */
136
    $total_nbpc += $data['nbpc'];
137
    $total_nbusers += $data['nbusers'];
138
  }
139
  
140
  //Maintenant toutes les entités sur lesquelles on a des droits recursifs
141
  $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";
142
  //print $queryR;
143
  $resultR = $DB->query($queryR);
144
  $listentity = "";
145
  for($r = 0; $r < $DB->numrows($resultR); $r++) {
146
    $dataR=$DB->fetch_array($resultR);
147
    $entityparent = $dataR['entity'];
148
    if($listentity != "")
149
      $listentity .= ", '" . $entityparent . "'";
150
    else
151
      $listentity = "'" . $entityparent . "'";
152
  }
153
  //$query = "SELECT ID FROM glpi_entities WHERE parentID='" . $entityparent . "'";
154
  
155
  $query = "SELECT e.*, e.FK_enduser as entityid, g3.name as client, g4.name as serveur, g4.os_license_number, g4.os_license_id, ssh.*,
156
(sum(g5.nbeleves)+sum(g5.nbprofs)) as nbusers, g5.nbpc as nbpc
157
FROM glpi_plugin_anet_epacks AS e
158
LEFT JOIN glpi_plugin_anet_epacks_ssh_max AS ssh ON e.FK_serveur=ssh.FK_serveur
159
LEFT JOIN glpi_entities AS g3 ON e.FK_client=g3.ID
160
LEFT JOIN glpi_computers AS g4 ON e.FK_serveur=g4.ID
161
LEFT JOIN glpi_plugin_anet_epacks_recencement_max AS g5 ON e.FK_serveur=g5.FK_serveur\n";
162
  //WHERE e.Fk_Serveur > '0'\n";
163

  
164

  
165
  if($maintenance == 0 || $maintenance ==  1) {
166
    $query .= "WHERE e.FK_contract >= '0'";
167
  }
168
  else if($maintenance == -1) {
169
    $query .= "WHERE e.FK_contract='-1'";
170
  }
171

  
172
  if(trim($listentity) != "")
173
    $query .= " AND g3.parentID IN (" . $listentity . ")\n";
174
  //GROUP BY e.FK_serveur
175
  $query .= "GROUP BY e.FK_client
176
ORDER BY serveur,client
177
LIMIT 500;";
178
  
179
  //print $query;
180
  
181
  $result = $DB->query($query) or die($DB->error());
182
  
183
  for($i = 0; $i < $DB->numrows($result); $i++) {
184
    $data=$DB->fetch_array($result);
185
    $ssh_dateLastOK = "";
186
    if(! in_array($data['entityid'],$tab_deja_affiche)) {
83 187
      $tab_deja_affiche[] = $data['entityid'];
84
      $ssh_dateLastOK = "";
85 188
      if($data['sshstatus'] == 1)
86 189
	$ssh_status = "<font color=\"green\">OK</font>";
87 190
      else if($data['sshdate']) {
......
120 223
  <td>
121 224
  </td>
122 225
</tr>\n";
123
/*
124
    <a href=\"../../../front/contract.php?contains[0]=" . $data['client'] . "\"><img src=\"img/stock_hand-signed.png\" title=\"Contrat\"></a>
125
    <a href=\"../../../front/tracking.php?contains[0]=" . $data['client'] . "\"><img src=\"img/stock_web-support.png\" title=\"Tickets\"></a>
126
    <a href=\"../../../front/user.php?contains[0]=" . $data['client'] . "\"><img src=\"img/stock_people.png\" title=\"Droits d'accès\"></a>
127
*/
128
      $total_nbpc += $data['nbpc'];
129
      $total_nbusers += $data['nbusers'];
130
    }
131

  
132
    //Maintenant toutes les entités sur lesquelles on a des droits recursifs
133
    $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";
134
    //print $queryR;
135
    $resultR = $DB->query($queryR);
136
    $listentity = "";
137
    for($r = 0; $r < $DB->numrows($resultR); $r++) {
138
      $dataR=$DB->fetch_array($resultR);
139
      $entityparent = $dataR['entity'];
140
      if($listentity != "")
141
	$listentity .= ", '" . $entityparent . "'";
142
      else
143
	$listentity = "'" . $entityparent . "'";
144
    }
145
    //$query = "SELECT ID FROM glpi_entities WHERE parentID='" . $entityparent . "'";
146
      
147
    $query = "SELECT e.*, e.FK_enduser as entityid, g3.name as client, g4.name as serveur, g4.os_license_number, g4.os_license_id, ssh.*,
148
(sum(g5.nbeleves)+sum(g5.nbprofs)) as nbusers, g5.nbpc as nbpc
149
FROM glpi_plugin_anet_epacks AS e
150
LEFT JOIN glpi_plugin_anet_epacks_ssh_max AS ssh ON e.FK_serveur=ssh.FK_serveur
151
LEFT JOIN glpi_entities AS g3 ON e.FK_client=g3.ID
152
LEFT JOIN glpi_computers AS g4 ON e.FK_serveur=g4.ID
153
LEFT JOIN glpi_plugin_anet_epacks_recencement_max AS g5 ON e.FK_serveur=g5.FK_serveur\n";
154
    //WHERE e.Fk_Serveur > '0'\n";
155
    $query .= "WHERE g3.parentID IN (" . $listentity . ")\n";
156
    //GROUP BY e.FK_serveur
157
    $query .= "GROUP BY e.FK_client
158
ORDER BY serveur,client
159
LIMIT 500;";
160
    
161
    //print $query;
162
    
163
    $result = $DB->query($query) or die($DB->error());
164
    
165
    for($i = 0; $i < $DB->numrows($result); $i++) {
166
      $data=$DB->fetch_array($result);
167
      $ssh_dateLastOK = "";
168
      if(! in_array($data['entityid'],$tab_deja_affiche)) {
169
	$tab_deja_affiche[] = $data['entityid'];
170
	if($data['sshstatus'] == 1)
171
	  $ssh_status = "<font color=\"green\">OK</font>";
172
	else if($data['sshdate']) {
173
	  $ssh_status = "<font color=\"red\">ERR</font>";
174
	  //Es-ce qu'on a deja reussi a se connecter sur ce serveur ?
175
	  $queryLastOK = "SELECT sshdate FROM glpi_plugin_anet_epacks_ssh WHERE FK_serveur='" . $data['FK_serveur'] . "' AND sshstatus=1 ORDER BY sshdate DESC LIMIT 1";
176
	  if($resultLastOK = $DB->query($queryLastOK)) {
177
	    $dataLastOK = $DB->fetch_array($resultLastOK);
178
	    if($dataLastOK[0]) {
179
	      //	  print_r($dataLastOK);
180
	      $ssh_status .= "<br /><font color=\"green\">LAST OK</font>";
181
	      $ssh_dateLastOK = "<br />" . $dataLastOK[0];
182
	    }
183
	  }
184
	  else {
185
	    $ssh_dateLastOK = "";
186
	  }
187
	  //print $queryLastOK;
188
	}
189
	else
190
	  $ssh_status = "<font color=\"orange\">???</font>";
191
	print "<tr class='tab_bg_2'>
192
  <td align=\"left\">\n";
193
	if($data['entityid'] > 0) {
194
	  print "    " . ($i+1) . ". <a href=\"../../manageentity/index.php?active_entity=" . $data['entityid'] . "\">" . $data['client'] . ": " . $data['serveur'] . "</a>\n";
195
	}
196
	else {
197
	  print "    " . ($i+1) . ". " . $data['client'] . ": " . $data['serveur'] . "(abonnement zen jamais activé)\n";
198
	}
199
	print "  </td>
200
  <td>" . $ssh_status . "</td>
201
  <td>" . $data['sshdate'] . $ssh_dateLastOK . "</td>
202
  <td align=\"left\">" . $data['os_license_id'] . "<br />" . $data['os_license_number'] . "</td>
203
  <td>" . $data['nbpc'] . "</td>
204
  <td>" . $data['nbusers'] . "</td>
205
  <td>
206
  </td>
207
</tr>\n";
208
	/*
226
      /*
209 227
	  <a href=\"../../../front/contract.php?contains[0]=" . $data['client'] . "\"><img src=\"img/stock_hand-signed.png\" title=\"Contrat\"></a>
210 228
	  <a href=\"../../../front/tracking.php?contains[0]=" . $data['client'] . "\"><img src=\"img/stock_web-support.png\" title=\"Tickets\"></a>
211 229
	  <a href=\"../../../front/user.php?contains[0]=" . $data['client'] . "\"><img src=\"img/stock_people.png\" title=\"Droits d'accès\"></a>
212
	*/
213
	$total_nbpc += $data['nbpc'];
214
	$total_nbusers += $data['nbusers'];
215
      }
216
      else {
217
	//print "deja affiché :: " . $data['entityid'];
218
      }
230
      */
231
      $total_nbpc += $data['nbpc'];
232
      $total_nbusers += $data['nbusers'];
219 233
    }
234
    else {
235
      //print "deja affiché :: " . $data['entityid'];
236
    }
237
  }
220 238
  
221

  
222
    
223
    /*
224
      <a href=\"../../../front/central.php?active_entity=" . $data['entityid'] . "\"><img src=\"img/stock_about.png\" title=\"Incarner le client " . $data['client'] . "\"></a>
225
      <a href=\"../../../front/computer.php?contains[0]=" . $data['client'] . "\"><img src=\"img/stock_form-add-field.png\" title=\"Inventaire\"></a>
226
*/
227
    
228
    print "<tr class='tab_bg_2'>
239
  
240
  
241
  /*
242
   <a href=\"../../../front/central.php?active_entity=" . $data['entityid'] . "\"><img src=\"img/stock_about.png\" title=\"Incarner le client " . $data['client'] . "\"></a>
243
   <a href=\"../../../front/computer.php?contains[0]=" . $data['client'] . "\"><img src=\"img/stock_form-add-field.png\" title=\"Inventaire\"></a>
244
  */
245
  
246
  print "<tr class='tab_bg_2'>
229 247
  <td colspan=\"4\">Totaux: </td>
230 248
  <td>" . $total_nbpc . "</td>
231 249
  <td>" . $total_nbusers . "</td>
232 250
  <td></td>
233 251
</tr>\n";
252
  
253
  print "</table>";
254
  
255
}
256

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

  
259
$glpiid = $_SESSION['glpiID'];
260

  
261
global $DB;
262
$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 AND glpi_users.FK_entities=glpi_users_profiles.FK_entities GROUP BY FK_entities";
263

  
264
//print $query;
265
$result = $DB->query($query);
266
if($result) {
267
  $data=$DB->fetch_array($result);
268
  $entityid = $data['FK_entities'];
269
  if($data['name'] == "revendeur" || $data['name'] == "dsi" || $data['name'] == "super-admin") {
270
    $entityid = $data['FK_entities'];
234 271
    
235
    
236
    print "</table>";
272
    //print $query;
273
    //exit;
274
      
275
    print "<h1>Tableau récapitulatif de vos serveurs sous maintenance</h1>";
276
    $maintenance = 0;
277
    $querySM = local_make_query($data, $entityid, $maintenance);
278
    local_make_array($querySM,$maintenance);
279

  
280
    print "<h1>Tableau récapitulatif de vos serveurs hors maintenance</h1>";
281
    $maintenance = -1;
282
    $queryHM = local_make_query($data, $entityid, $maintenance);
283
    local_make_array($queryHM,$maintenance);
237 284
    
238 285
    commonFooter();
239 286
    exit;
plugins/manageentity/inc/plugin_manageentity.functions_display.php
74 74
	else{
75 75
		echo "<form method='post' action=\"./index.php\">";
76 76
		echo "<div align='center'><table class='tab_cadre' align='center' width='95%'>";
77
		echo "<tr><th colspan='3'>".$LANGMANAGEENTITY["manageentity"][3].":</th></tr>";
77
		echo "<tr><th colspan='3'>".$LANGMANAGEENTITY["manageentity"][3]." - <a href=\"" . $CFG_GLPI["root_doc"] . "/front/contract.form.php\">[créer un contrat]</a> :</th></tr>";
78 78
		echo "<tr><th>".$LANG["common"][16]."</th>";
79 79
		echo "<th>".$LANG["financial"][4]."</th>";
80 80
		echo "<th>".$LANG["common"][25]."</th>";
......
467 467
	if ($number > 0) {
468 468
		echo "<br><div align='center'><table class='tab_cadre' align='center' width='95%'>";
469 469
		echo "<tr>";
470
		echo "<th colspan='3'>Epack et Installation</th>";
470
		echo "<th colspan='3'>Epack et Installation - <a href=\"desactiver_maintenance.php?" . $DB->result($result, $i, "code") . "\">[marquer hors maintenance]</a> - </th>";
471 471
		echo "</tr>";
472 472
		echo "<tr class='tab_bg_2'>";
473 473
		echo "<td width=\"33%\">".$DB->result($result, $i, "code")."</td>";

Formats disponibles : Unified diff

Redmine Appliance - Powered by TurnKey Linux