ryxeo-glpi-git / plugins / anet_epacks / front / plugin_anet_epacks.view_array_recap.php @ f113d68c
Historique | Voir | Annoter | Télécharger (19,7 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, g6.name as contract
|
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 OR e.FK_enduser=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
|
96 |
LEFT JOIN glpi_contracts AS g6 ON e.FK_contract=g6.ID\n";
|
97 |
|
98 |
//WHERE e.Fk_Serveur > '0'\n";
|
99 |
if($data['name'] == "revendeur" || $data['name'] == "dsi") { |
100 |
if($maintenance == 0 || $maintenance == 1) { |
101 |
$query .= "WHERE e.FK_contract >= '0' AND e.FK_activation='" . $entityid . "'\n"; |
102 |
} |
103 |
else if($maintenance == -1) { |
104 |
$query .= "WHERE e.FK_contract='-1' AND e.FK_activation='" . $entityid . "'\n"; |
105 |
} |
106 |
//GROUP BY e.FK_serveur
|
107 |
$query .= "GROUP BY e.FK_serveur |
108 |
ORDER BY client ASC
|
109 |
LIMIT 500;";
|
110 |
} |
111 |
else {
|
112 |
//On n'affiche pas les serveurs qui ne sont pas "Zen"
|
113 |
if($maintenance == 0 || $maintenance == 1) { |
114 |
$query .= "WHERE e.FK_contract >= '0' AND e.FK_Serveur>'0'\n"; |
115 |
} |
116 |
else if($maintenance == -1) { |
117 |
$query .= "WHERE e.FK_contract='-1' AND e.FK_Serveur>'0'\n"; |
118 |
} |
119 |
//GROUP BY e.FK_serveur
|
120 |
//On ne peut pas group by client a cause de l'historique ou on avait pas la meme structure
|
121 |
//de base
|
122 |
$query .= "GROUP BY e.FK_serveur |
123 |
ORDER BY client ASC
|
124 |
LIMIT 500;";
|
125 |
} |
126 |
|
127 |
// if($maintenance == -1) {
|
128 |
//print $query;
|
129 |
// }
|
130 |
return $query; |
131 |
} |
132 |
|
133 |
//special pour trouver les serveurs existants mais les enduser=0 (abonnement zen pas fait ou autre ?)
|
134 |
function local_make_query_zarb() { |
135 |
$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.*, |
136 |
(g5.nbeleves+g5.nbprofs) as nbusers, g5.nbpc as nbpc, g6.name as contract
|
137 |
FROM glpi_plugin_anet_epacks AS e
|
138 |
LEFT JOIN glpi_plugin_anet_epacks_ssh_max AS ssh ON e.FK_serveur=ssh.FK_serveur
|
139 |
LEFT JOIN glpi_entities AS g3 ON (e.FK_client=g3.ID OR e.FK_enduser=g3.ID)
|
140 |
LEFT JOIN glpi_computers AS g4 ON e.FK_serveur=g4.ID
|
141 |
LEFT JOIN glpi_plugin_anet_epacks_recencement_max AS g5 ON e.FK_serveur=g5.FK_serveur
|
142 |
LEFT JOIN glpi_contracts AS g6 ON e.FK_contract=g6.ID\n";
|
143 |
$query .= "WHERE e.FK_enduser='0' AND e.FK_client!='0'\n"; |
144 |
$query .= "GROUP BY e.FK_serveur |
145 |
ORDER BY client ASC
|
146 |
LIMIT 500;";
|
147 |
//print "<pre>$query</pre>\n";
|
148 |
return $query; |
149 |
} |
150 |
|
151 |
|
152 |
//Special pour les "dsi" quand on convertis a la vollee les comptes post-only en dsi pour les animtice
|
153 |
function local_make_query_dsi($data, $entityid, $maintenance) { |
154 |
$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.*, |
155 |
(g5.nbeleves+g5.nbprofs) as nbusers, g5.nbpc as nbpc, g6.name as contract
|
156 |
FROM glpi_plugin_anet_epacks AS e
|
157 |
LEFT JOIN glpi_plugin_anet_epacks_ssh_max AS ssh ON e.FK_serveur=ssh.FK_serveur
|
158 |
LEFT JOIN glpi_entities AS g3 ON (e.FK_client=g3.ID OR e.FK_enduser=g3.ID)
|
159 |
LEFT JOIN glpi_computers AS g4 ON e.FK_serveur=g4.ID
|
160 |
LEFT JOIN glpi_plugin_anet_epacks_recencement_max AS g5 ON e.FK_serveur=g5.FK_serveur
|
161 |
LEFT JOIN glpi_contracts AS g6 ON e.FK_contract=g6.ID\n";
|
162 |
|
163 |
//WHERE e.Fk_Serveur > '0'\n";
|
164 |
if($data['name'] == "dsi") { |
165 |
if($maintenance == 0 || $maintenance == 1) { |
166 |
$query .= "WHERE e.FK_enduser='$entityid' AND e.FK_contract >= '0' AND e.FK_activation > '0'\n"; |
167 |
} |
168 |
else if($maintenance == -1) { |
169 |
$query .= "WHERE e.FK_enduser='$entityid' AND e.FK_contract='-1' AND e.FK_activation > '0'\n"; |
170 |
} |
171 |
//GROUP BY e.FK_serveur
|
172 |
$query .= "GROUP BY e.FK_serveur |
173 |
ORDER BY client ASC
|
174 |
LIMIT 500;";
|
175 |
} |
176 |
else {
|
177 |
$query = ""; |
178 |
} |
179 |
|
180 |
// if($maintenance == -1) {
|
181 |
//print $query;
|
182 |
// }
|
183 |
return $query; |
184 |
} |
185 |
|
186 |
|
187 |
function local_make_raw($q,$maintenance) { |
188 |
|
189 |
} |
190 |
|
191 |
|
192 |
//Si enduser=0 -> on affiche les "zarb"
|
193 |
function local_make_array($q,$maintenance,$enduser=1) { |
194 |
global $DB; |
195 |
global $glpiid; |
196 |
|
197 |
global $total_nbpc_maint; |
198 |
global $total_nbusers_maint; |
199 |
global $total_nbpc_hors_maint; |
200 |
global $total_nbusers_hors_maint; |
201 |
global $num_debut_ligne; |
202 |
global $tab_deja_affiche; |
203 |
|
204 |
|
205 |
$result = $DB->query($q) or die($DB->error()); |
206 |
|
207 |
$total_nbpc = 0; |
208 |
$total_nbusers = 0; |
209 |
//La liste des entites qu'on affiche
|
210 |
|
211 |
for($i = 0; $i < $DB->numrows($result); $i++) { |
212 |
$num_debut_ligne++;
|
213 |
$data=$DB->fetch_array($result); |
214 |
|
215 |
if(! in_array($data['entityid'],$tab_deja_affiche)) { |
216 |
$tab_deja_affiche[] = $data['entityid']; |
217 |
$ssh_dateLastOK = ""; |
218 |
if($data['sshstatus'] == 1) |
219 |
$ssh_status = "<font color=\"green\">OK</font>"; |
220 |
else if($data['sshdate']) { |
221 |
$ssh_status = "<font color=\"red\">ERR</font>"; |
222 |
//Es-ce qu'on a deja reussi a se connecter sur ce serveur ?
|
223 |
$queryLastOK = "SELECT sshdate FROM glpi_plugin_anet_epacks_ssh WHERE FK_serveur='" . $data['FK_serveur'] . "' AND sshstatus=1 ORDER BY sshdate DESC LIMIT 1"; |
224 |
if($resultLastOK = $DB->query($queryLastOK)) { |
225 |
$dataLastOK = $DB->fetch_array($resultLastOK); |
226 |
if($dataLastOK[0]) { |
227 |
// print_r($dataLastOK);
|
228 |
$ssh_status .= "<br /><font color=\"green\">LAST OK</font>"; |
229 |
$ssh_dateLastOK = "<br />" . $dataLastOK[0]; |
230 |
} |
231 |
} |
232 |
else {
|
233 |
$ssh_dateLastOK = ""; |
234 |
} |
235 |
//print $queryLastOK;
|
236 |
} |
237 |
else
|
238 |
$ssh_status = "<font color=\"orange\">???</font>"; |
239 |
$s .= "<tr class='tab_bg_2'> |
240 |
<td align=\"left\">\n";
|
241 |
if($data['entityid'] > 0) { |
242 |
$s .= " " . $num_debut_ligne . ". <a href=\"../../manageentity/index.php?active_entity=" . $data['entityid'] . "\">" . $data['client'] . ": " . $data['serveur'] . "</a>\n"; |
243 |
} |
244 |
else {
|
245 |
$s .= " " . $num_debut_ligne . ". " . $data['client'] . ": " . $data['serveur'] . "(abonnement zen jamais activé, serveur fantôme ?)\n"; |
246 |
} |
247 |
|
248 |
$s .= " </td> |
249 |
<td>" . $ssh_status . "</td> |
250 |
<td>" . $data['sshdate'] . $ssh_dateLastOK . "</td> |
251 |
<td align=\"left\">" . $data['os_license_id'] . " " . $data['otherserial'] . "<br />" . $data['os_license_number'] . " " . $data['otherserial'] ."</td> |
252 |
<td>" . $data['nbpc'] . "</td> |
253 |
<td>" . $data['nbusers'] . "</td> |
254 |
<td>" . $data['contract'] . "</td> |
255 |
</tr>\n";
|
256 |
/*
|
257 |
<a href=\"../../../front/contract.php?contains[0]=" . $data['client'] . "\"><img src=\"img/stock_hand-signed.png\" title=\"Contrat\"></a>
|
258 |
<a href=\"../../../front/tracking.php?contains[0]=" . $data['client'] . "\"><img src=\"img/stock_web-support.png\" title=\"Tickets\"></a>
|
259 |
<a href=\"../../../front/user.php?contains[0]=" . $data['client'] . "\"><img src=\"img/stock_people.png\" title=\"Droits d'accès\"></a>
|
260 |
*/
|
261 |
$total_nbpc += $data['nbpc']; |
262 |
$total_nbusers += $data['nbusers']; |
263 |
} |
264 |
} |
265 |
|
266 |
//Maintenant toutes les entités sur lesquelles on a des droits recursifs
|
267 |
$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"; |
268 |
//print $queryR;
|
269 |
$resultR = $DB->query($queryR); |
270 |
$listentity = ""; |
271 |
for($r = 0; $r < $DB->numrows($resultR); $r++) { |
272 |
$dataR=$DB->fetch_array($resultR); |
273 |
$entityparent = $dataR['entity']; |
274 |
if($listentity != "") |
275 |
$listentity .= ", '" . $entityparent . "'"; |
276 |
else
|
277 |
$listentity = "'" . $entityparent . "'"; |
278 |
} |
279 |
//$query = "SELECT ID FROM glpi_entities WHERE parentID='" . $entityparent . "'";
|
280 |
|
281 |
if($enduser == 1) { |
282 |
$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.*, |
283 |
(sum(g5.nbeleves)+sum(g5.nbprofs)) as nbusers, g5.nbpc as nbpc, g6.name as contract
|
284 |
FROM glpi_plugin_anet_epacks AS e
|
285 |
LEFT JOIN glpi_plugin_anet_epacks_ssh_max AS ssh ON e.FK_serveur=ssh.FK_serveur
|
286 |
LEFT JOIN glpi_entities AS g3 ON (e.FK_client=g3.ID OR e.FK_enduser=g3.ID)
|
287 |
LEFT JOIN glpi_computers AS g4 ON e.FK_serveur=g4.ID
|
288 |
LEFT JOIN glpi_plugin_anet_epacks_recencement_max AS g5 ON e.FK_serveur=g5.FK_serveur
|
289 |
LEFT JOIN glpi_contracts AS g6 ON e.FK_contract=g6.ID\n";
|
290 |
//WHERE e.Fk_Serveur > '0'\n";
|
291 |
|
292 |
if($maintenance == 0 || $maintenance == 1) { |
293 |
$query .= "WHERE e.FK_contract >= '0'"; |
294 |
} |
295 |
else if($maintenance == -1) { |
296 |
$query .= "WHERE e.FK_contract='-1'"; |
297 |
} |
298 |
|
299 |
if(trim($listentity) != "") |
300 |
$query .= " AND g3.parentID IN (" . $listentity . ")\n"; |
301 |
//GROUP BY e.FK_serveur
|
302 |
else {
|
303 |
$query = ""; |
304 |
} |
305 |
if($query != "") |
306 |
$query .= "GROUP BY e.FK_client |
307 |
ORDER BY client
|
308 |
LIMIT 500;";
|
309 |
} |
310 |
else {
|
311 |
//LEFT JOIN glpi_entities AS g3 ON e.FK_client=g3.ID OR e.FK_enduser=g3.ID
|
312 |
$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.*, g6.name as contract |
313 |
FROM glpi_plugin_anet_epacks AS e
|
314 |
LEFT JOIN glpi_plugin_anet_epacks_ssh_max AS ssh ON e.FK_serveur=ssh.FK_serveur
|
315 |
LEFT JOIN glpi_entities AS g3 ON (e.FK_client=g3.ID OR e.FK_enduser=g3.ID)
|
316 |
LEFT JOIN glpi_computers AS g4 ON e.FK_serveur=g4.ID
|
317 |
LEFT JOIN glpi_plugin_anet_epacks_recencement_max AS g5 ON e.FK_serveur=g5.FK_serveur
|
318 |
LEFT JOIN glpi_contracts AS g6 ON e.FK_contract=g6.ID
|
319 |
WHERE e.FK_enduser='0' AND e.FK_client!='0'
|
320 |
ORDER BY client\n";
|
321 |
//print $query;
|
322 |
} |
323 |
|
324 |
//print $query;
|
325 |
|
326 |
|
327 |
if($query != "") |
328 |
$result = $DB->query($query) or die($DB->error()); |
329 |
|
330 |
for($i = 0; $i < $DB->numrows($result); $i++) { |
331 |
$num_debut_ligne++;
|
332 |
$data=$DB->fetch_array($result); |
333 |
$ssh_dateLastOK = ""; |
334 |
if(! in_array($data['entityid'],$tab_deja_affiche) || $enduser==0) { |
335 |
$tab_deja_affiche[] = $data['entityid']; |
336 |
if($data['sshstatus'] == 1) |
337 |
$ssh_status = "<font color=\"green\">OK</font>"; |
338 |
else if($data['sshdate']) { |
339 |
$ssh_status = "<font color=\"red\">ERR</font>"; |
340 |
//Es-ce qu'on a deja reussi a se connecter sur ce serveur ?
|
341 |
$queryLastOK = "SELECT sshdate FROM glpi_plugin_anet_epacks_ssh WHERE FK_serveur='" . $data['FK_serveur'] . "' AND sshstatus=1 ORDER BY sshdate DESC LIMIT 1"; |
342 |
if($resultLastOK = $DB->query($queryLastOK)) { |
343 |
$dataLastOK = $DB->fetch_array($resultLastOK); |
344 |
if($dataLastOK[0]) { |
345 |
// print_r($dataLastOK);
|
346 |
$ssh_status .= "<br /><font color=\"green\">LAST OK</font>"; |
347 |
$ssh_dateLastOK = "<br />" . $dataLastOK[0]; |
348 |
} |
349 |
} |
350 |
else {
|
351 |
$ssh_dateLastOK = ""; |
352 |
} |
353 |
//print $queryLastOK;
|
354 |
} |
355 |
else
|
356 |
$ssh_status = "<font color=\"orange\">???</font>"; |
357 |
$s .= "<tr class='tab_bg_2'> |
358 |
<td align=\"left\">\n";
|
359 |
if($data['entityid'] > 0) { |
360 |
$s .= " " . $num_debut_ligne . ". <a href=\"../../manageentity/index.php?active_entity=" . $data['entityid'] . "\">" . $data['client'] . ": " . $data['serveur'] . "</a>\n"; |
361 |
} |
362 |
else {
|
363 |
$s .= " " . $num_debut_ligne . ". " . $data['client'] . ": " . $data['serveur'] . "(abonnement zen jamais activé, serveur fantôme ?)\n"; |
364 |
} |
365 |
|
366 |
$s .= " </td> |
367 |
<td>" . $ssh_status . "</td> |
368 |
<td>" . $data['sshdate'] . $ssh_dateLastOK . "</td> |
369 |
<td align=\"left\">" . $data['os_license_id'] . " " . $data['otherserial'] . "<br />" . $data['os_license_number'] . " " . $data['otherserial'] . "</td> |
370 |
<td>" . $data['nbpc'] . "</td> |
371 |
<td>" . $data['nbusers'] . "</td> |
372 |
<td>" . $data['contract'] . "</td> |
373 |
</tr>\n";
|
374 |
/*
|
375 |
<a href=\"../../../front/contract.php?contains[0]=" . $data['client'] . "\"><img src=\"img/stock_hand-signed.png\" title=\"Contrat\"></a>
|
376 |
<a href=\"../../../front/tracking.php?contains[0]=" . $data['client'] . "\"><img src=\"img/stock_web-support.png\" title=\"Tickets\"></a>
|
377 |
<a href=\"../../../front/user.php?contains[0]=" . $data['client'] . "\"><img src=\"img/stock_people.png\" title=\"Droits d'accès\"></a>
|
378 |
*/
|
379 |
$total_nbpc += $data['nbpc']; |
380 |
$total_nbusers += $data['nbusers']; |
381 |
} |
382 |
else {
|
383 |
//print "deja affiché :: " . $data['entityid'];
|
384 |
} |
385 |
} |
386 |
|
387 |
|
388 |
|
389 |
/*
|
390 |
<a href=\"../../../front/central.php?active_entity=" . $data['entityid'] . "\"><img src=\"img/stock_about.png\" title=\"Incarner le client " . $data['client'] . "\"></a>
|
391 |
<a href=\"../../../front/computer.php?contains[0]=" . $data['client'] . "\"><img src=\"img/stock_form-add-field.png\" title=\"Inventaire\"></a>
|
392 |
*/
|
393 |
if($maintenance == 0) { |
394 |
$total_nbpc_maint += $total_nbpc; |
395 |
$total_nbusers_maint += $total_nbusers; |
396 |
} |
397 |
else {
|
398 |
$total_nbpc_hors_maint += $total_nbpc; |
399 |
$total_nbusers_hors_maint += $total_nbusers; |
400 |
} |
401 |
return $s; |
402 |
} |
403 |
|
404 |
function local_make_array_header() { |
405 |
return "<table style=\"width:100%; padding: 0 10px 0 10px;\"> |
406 |
<tr class='tab_bg_2'>
|
407 |
<th>Nom</th>
|
408 |
<th><img src=\"img/stock_channel.png\" alt=\"Télémaintenance (SSH)\" title=\"Télémaintenance (SSH)\"></th>
|
409 |
<th>Date du test</th>
|
410 |
<th>Adresse DynDNS</th>
|
411 |
<th><img src=\"img/computer.png\" alt=\"Nombre de postes\" title=\"Nombre de postes clients\"></th>
|
412 |
<th><img src=\"img/stock_people.png\" alt=\"Nombre d'utilisateurs\" title=\"Nombre d'utilisateurs\"></th>
|
413 |
<th><img src=\"img/stock_hand-signed.png\" title=\"Contrat\"></th>
|
414 |
</tr>\n";
|
415 |
|
416 |
} |
417 |
|
418 |
function local_make_array_footer($total_nbpc, $total_nbusers) { |
419 |
$s .= "<tr class='tab_bg_2'> |
420 |
<td colspan=\"4\">Totaux: </td>
|
421 |
<td>" . $total_nbpc . "</td> |
422 |
<td>" . $total_nbusers . "</td> |
423 |
<td></td>
|
424 |
</tr>\n";
|
425 |
|
426 |
$s .= "</table>"; |
427 |
return $s; |
428 |
} |
429 |
|
430 |
|
431 |
commonHeader("AbulEdu.NET -- Tableau récapitulatif -- Accueil RyXéo",$_SERVER['PHP_SELF'],"config","plugins"); |
432 |
|
433 |
$glpiid = $_SESSION['glpiID']; |
434 |
|
435 |
global $DB; |
436 |
|
437 |
$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"; |
438 |
|
439 |
//print $query;
|
440 |
//exit;
|
441 |
|
442 |
$total_nbpc_maint = 0; |
443 |
$total_nbusers_maint = 0; |
444 |
$total_nbpc_hors_maint = 0; |
445 |
$total_nbusers_hors_maint = 0; |
446 |
$tab_deja_affiche = array(); |
447 |
$num_debut_ligne_maint = 0; |
448 |
$num_debut_ligne_horsmaint = 0; |
449 |
|
450 |
$result = $DB->query($query); |
451 |
if($result) { |
452 |
while($data=$DB->fetch_array($result)) { |
453 |
$entityid = $data['FK_entities']; |
454 |
if($data['name'] == "revendeur" || $data['name'] == "dsi" || $data['name'] == "super-admin") { |
455 |
$num_debut_ligne = $num_debut_ligne_maint; |
456 |
//print $query;
|
457 |
$entityid = $data['FK_entities']; |
458 |
|
459 |
$maintenance = 0; |
460 |
$querySM = local_make_query($data, $entityid, $maintenance); |
461 |
$str_sous_maint .= local_make_array($querySM,$maintenance); |
462 |
|
463 |
$querySM = local_make_query_dsi($data, $entityid, $maintenance); |
464 |
//print $querySM;
|
465 |
if($querySM != "") |
466 |
$str_sous_maint .= local_make_array($querySM,$maintenance); |
467 |
|
468 |
$num_debut_ligne_maint = $num_debut_ligne; |
469 |
$num_debut_ligne = 0; |
470 |
$maintenance = -1; |
471 |
$queryHM = local_make_query($data, $entityid, $maintenance); |
472 |
$str_hors_maint .= local_make_array($queryHM,$maintenance); |
473 |
|
474 |
//et maintenant les epacks dont le FK_enduser=0 mais FK_serveur!=0
|
475 |
//Uniquement pour ryxeo
|
476 |
if($data['name'] == "super-admin") { |
477 |
$num_debut_ligne_horsmaint = $num_debut_ligne; |
478 |
$num_debut_ligne = 0; |
479 |
$queryZarb = local_make_query_zarb();
|
480 |
//print "<pre>$queryZarb</pre>";
|
481 |
//On passe 0 comme 3 argument
|
482 |
$str_zarb .= local_make_array($queryZarb,0,0); |
483 |
} |
484 |
} |
485 |
} |
486 |
|
487 |
print "<h1>Tableau récapitulatif de vos serveurs sous maintenance</h1>"; |
488 |
print local_make_array_header();
|
489 |
print $str_sous_maint; |
490 |
print local_make_array_footer($total_nbpc_maint,$total_nbusers_maint); |
491 |
|
492 |
print "<h1>Tableau récapitulatif de vos serveurs hors maintenance</h1>"; |
493 |
print local_make_array_header();
|
494 |
print $str_hors_maint; |
495 |
print local_make_array_footer($total_nbpc_hors_maint,$total_nbusers_hors_maint); |
496 |
|
497 |
//Uniquement pour ryxeo
|
498 |
if($str_zarb != "") { |
499 |
print "<h1>Tableau récapitulatif des serveurs étranges [dont la maintenance n'a pas été activée (abonnement zen sur webadmin) ??]</h1>"; |
500 |
print local_make_array_header();
|
501 |
print $str_zarb; |
502 |
print local_make_array_footer(0,0); |
503 |
} |
504 |
|
505 |
commonFooter(); |
506 |
exit;
|
507 |
} |
508 |
|
509 |
?>
|