File: report.default.php

package info (click to toggle)
glpi 0.68.2-1etch0.1
  • links: PTS
  • area: main
  • in suites: etch-m68k
  • size: 7,464 kB
  • ctags: 9,655
  • sloc: php: 69,502; sql: 3,514; sh: 175; makefile: 61
file content (367 lines) | stat: -rw-r--r-- 12,574 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
<?php
/*
 * @version $Id: report.default.php 3895 2006-09-17 15:41:25Z moyo $
 -------------------------------------------------------------------------
 GLPI - Gestionnaire Libre de Parc Informatique
 Copyright (C) 2003-2006 by the INDEPNET Development Team.

 http://indepnet.net/   http://glpi-project.org
 -------------------------------------------------------------------------

 LICENSE

 This file is part of GLPI.

 GLPI is free software; you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
 the Free Software Foundation; either version 2 of the License, or
 (at your option) any later version.

 GLPI is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.

 You should have received a copy of the GNU General Public License
 along with GLPI; if not, write to the Free Software
 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 --------------------------------------------------------------------------
 */

// ----------------------------------------------------------------------
// Original Author of file:
// Purpose of file:
// ----------------------------------------------------------------------


include ("_relpos.php");

$NEEDED_ITEMS=array("software");
include ($phproot . "/inc/includes.php");

checkRight("reports","r");

commonHeader($lang["Menu"][6],$_SERVER["PHP_SELF"]);

# Title

echo "<div align='center'><big><b>GLPI ".$lang["Menu"][6]."</b></big><br><br>";

# 1. Get some number data

$query = "SELECT count(ID) FROM glpi_computers where deleted ='N' AND is_template = '0' ";
$result = $db->query($query);
$number_of_computers = $db->result($result,0,0);

$query = "SELECT count(ID) FROM glpi_software where deleted ='N'  AND is_template = '0' ";
$result = $db->query($query);
$number_of_software = $db->result($result,0,0);

$query = "SELECT count(ID) FROM glpi_printers where deleted ='N'  AND is_template = '0' AND is_global='0' ";
$result = $db->query($query);
$number_of_printers = $db->result($result,0,0);

$query2="SELECT ID FROM glpi_printers where deleted ='N'  AND is_template = '0' AND is_global='1' ";
$result = $db->query($query2);
if ($db->numrows($result)){
	while ($data=$db->fetch_assoc($result)){
		$query="SELECT count(*) FROM glpi_connect_wire WHERE type='".PRINTER_TYPE."' AND end1='".$data["ID"]."';";
		$result2 = $db->query($query);
		$number_of_printers += $db->result($result2,0,0);
	}
}


$query = "SELECT count(ID) FROM glpi_networking where deleted ='N'  AND is_template = '0' ";
$result = $db->query($query);
$number_of_networking = $db->result($result,0,0);

$query = "SELECT count(ID) FROM glpi_monitors where deleted ='N'  AND is_template = '0' AND is_global='0'  ";
$result = $db->query($query);
$number_of_monitors = $db->result($result,0,0);

$query2="SELECT ID FROM glpi_monitors where deleted ='N'  AND is_template = '0' AND is_global='1' ";
$result = $db->query($query2);
if ($db->numrows($result)){
	while ($data=$db->fetch_assoc($result)){
		$query="SELECT count(*) FROM glpi_connect_wire WHERE type='".MONITOR_TYPE."' AND end1='".$data["ID"]."';";
		$result2 = $db->query($query);
		$number_of_monitors += $db->result($result2,0,0);
	}
}


$query = "SELECT count(ID) FROM glpi_peripherals where deleted ='N'  AND is_template = '0' AND is_global='0'  ";
$result = $db->query($query);
$number_of_peripherals = $db->result($result,0,0);

$query2="SELECT ID FROM glpi_peripherals where deleted ='N'  AND is_template = '0' AND is_global='1' ";
$result = $db->query($query2);
if ($db->numrows($result)){
	while ($data=$db->fetch_assoc($result)){
		$query="SELECT count(*) FROM glpi_connect_wire WHERE type='".PERIPHERAL_TYPE."' AND end1='".$data["ID"]."';";
		$result2 = $db->query($query);
		$number_of_peripherals += $db->result($result2,0,0);
	}
}

$query = "SELECT count(ID) FROM glpi_phones where deleted ='N'  AND is_template = '0' ";
$result = $db->query($query);
$number_of_phones = $db->result($result,0,0);

$query2="SELECT ID FROM glpi_phones where deleted ='N'  AND is_template = '0' AND is_global='1' ";
$result = $db->query($query2);
if ($db->numrows($result)){
	while ($data=$db->fetch_assoc($result)){
		$query="SELECT count(*) FROM glpi_connect_wire WHERE type='".PHONE_TYPE."' AND end1='".$data["ID"]."';";
		$result2 = $db->query($query);
		$number_of_phones += $db->result($result2,0,0);
	}
}

# 2. Spew out the data in a table

echo "<table class='tab_cadre' width='80%'>";
echo "<tr class='tab_bg_2'><td>".$lang["Menu"][0].":</td><td>$number_of_computers</td></tr>";	
echo "<tr class='tab_bg_2'><td>".$lang["Menu"][2].":</td><td>$number_of_printers</td></tr>";
echo "<tr class='tab_bg_2'><td>".$lang["Menu"][1].":</td><td>$number_of_networking</td></tr>";
echo "<tr class='tab_bg_2'><td>".$lang["Menu"][4].":</td><td>$number_of_software</td></tr>";
echo "<tr class='tab_bg_2'><td>".$lang["Menu"][3].":</td><td>$number_of_monitors</td></tr>";
echo "<tr class='tab_bg_2'><td>".$lang["Menu"][16].":</td><td>$number_of_peripherals</td></tr>";
echo "<tr class='tab_bg_2'><td>".$lang["Menu"][34].":</td><td>$number_of_phones</td></tr>";

echo "<tr><td colspan='2' height=10></td></tr>";
echo  "<tr class='tab_bg_1'><td colspan='2'><b>".$lang["setup"][5].":</b></td></tr>";


# 3. Get some more number data (operating systems per computer)

$query = "SELECT * FROM glpi_dropdown_os ORDER BY name";
$result = $db->query($query);
$i = -1;
$number = $db->numrows($result);
while ($i < $number) {
	if ($i<0){
		$id=0;
		$os_search=" (os='0'  OR os IS NULL) ";
		$os="------";
	} else {
		$os = $db->result($result, $i, "name");
		$id= $db->result($result, $i, "ID");
		$os_search=" os='$id' ";
	}
	$query = "SELECT count(*) FROM glpi_computers WHERE deleted ='N'  AND is_template = '0' AND $os_search";
	$result2 = $db->query($query);
	$counter = $db->result($result2,0,0);
	echo "<tr class='tab_bg_2'><td>$os</td><td>$counter</td></tr>";
	$i++;
}

echo "<tr><td colspan='2' height=10></td></tr>";
echo  "<tr class='tab_bg_1'><td colspan='2'><b>".$lang["Menu"][4].":</b></td></tr>";


# 4. Get some more number data (installed softwares)

$query = "SELECT ID, name,version FROM glpi_software WHERE deleted ='N'  AND is_template = '0' ORDER BY name";
$result = $db->query($query);
$i = 0;
$number = $db->numrows($result);
while ($i < $number) {
	$version=$db->result($result,$i,"version");
	if (!empty($version))
		$version =" - ".$version;
	echo "<tr class='tab_bg_2'><td>".$db->result($result,$i,"name").$version."</td><td>";
	echo countInstallations($db->result($result,$i,"ID"));
	echo "</td></tr>";
	$i++;
}

echo "<tr><td colspan='2' height=10></td></tr>";
echo  "<tr class='tab_bg_1'><td colspan='2'><b>".$lang["Menu"][1].":</b></td></tr>";

# 4. Get some more number data (Networking)

$query = "SELECT * FROM glpi_type_networking ORDER BY name";
$result = $db->query($query);
$i = -1;
$number = $db->numrows($result);
while ($i < $number) {
	if ($i<0){
		$type=0;
		$type_search=" (type='0' OR type IS NULL) ";
		$net="------";
	} else {
		$type = $db->result($result, $i, "ID");
		$type_search=" type='$type' ";
		$net = $db->result($result, $i, "name");
	}
	$query = "SELECT count(*) FROM glpi_networking WHERE ($type_search AND deleted ='N'  AND is_template = '0')";
	$result3 = $db->query($query);
	$counter = $db->result($result3,0,0);
	echo "<tr class='tab_bg_2'><td>$net</td><td>$counter</td></tr>";
	$i++;
}

echo "<tr><td colspan='2' height=10></td></tr>";
echo  "<tr class='tab_bg_1'><td colspan='2'><b>".$lang["Menu"][3].":</b></td></tr>";

# 4. Get some more number data (Monitor)

$query = "SELECT * FROM glpi_type_monitors ORDER BY name";
$result = $db->query($query);
$i = -1;
$number = $db->numrows($result);
while ($i < $number) {
	if ($i<0){
		$type=0;
		$type_search=" (type='0' OR type IS NULL) ";
		$net="------";
	} else {
		$type = $db->result($result, $i, "ID");
		$type_search=" type='$type' ";
		$net = $db->result($result, $i, "name");
	}
	$query = "SELECT count(*) FROM glpi_monitors WHERE $type_search AND deleted ='N'  AND is_template = '0' AND is_global='0'";
	$result3 = $db->query($query);
	$counter = $db->result($result3,0,0);

	$query2="SELECT ID FROM glpi_monitors where $type_search AND deleted ='N'  AND is_template = '0' AND is_global='1' ";
	$result2 = $db->query($query2);
	if ($db->numrows($result2)){
		while ($data=$db->fetch_assoc($result2)){
			$query="SELECT count(*) FROM glpi_connect_wire WHERE type='".MONITOR_TYPE."' AND end1='".$data["ID"]."';";
			$result3 = $db->query($query);
			$counter += $db->result($result3,0,0);
		}
	}


	echo "<tr class='tab_bg_2'><td>$net</td><td>$counter</td></tr>";
	$i++;
}

echo "<tr><td colspan='2' height=10></td></tr>";
echo  "<tr class='tab_bg_1'><td colspan='2'><b>".$lang["Menu"][2].":</b></td></tr>";

# 4. Get some more number data (Printers)

$query = "SELECT * FROM glpi_type_printers ORDER BY name";
$result = $db->query($query);
$i = -1;
$number = $db->numrows($result);
while ($i < $number) {
	if ($i<0){
		$type_search=" (type='0' OR type IS NULL) ";
		$type=0;
		$net="------";
	} else {
		$type = $db->result($result, $i, "ID");
		$type_search=" type='$type' ";
		$net = $db->result($result, $i, "name");
	}
	$query = "SELECT count(*) FROM glpi_printers WHERE $type_search AND deleted ='N'  AND is_template = '0'  AND is_global='0'";

	$result3 = $db->query($query);
	$counter = $db->result($result3,0,0);

	$query2="SELECT ID FROM glpi_printers where $type_search AND deleted ='N'  AND is_template = '0' AND is_global='1' ";
	$result2 = $db->query($query2);
	if ($db->numrows($result2)){
		while ($data=$db->fetch_assoc($result2)){
			$query="SELECT count(*) FROM glpi_connect_wire WHERE type='".PRINTER_TYPE."' AND end1='".$data["ID"]."';";
			$result3 = $db->query($query);
			$counter += $db->result($result3,0,0);
		}
	}


	echo "<tr class='tab_bg_2'><td>$net</td><td>$counter</td></tr>";
	$i++;
}

echo "<tr><td colspan='2' height=10></td></tr>";
echo  "<tr class='tab_bg_1'><td colspan='2'><b>".$lang["Menu"][16].":</b></td></tr>";

# 4. Get some more number data (Peripherals)

$query = "SELECT * FROM glpi_type_peripherals ORDER BY name";
$result = $db->query($query);
$i = -1;
$number = $db->numrows($result);
while ($i < $number) {
	if ($i<0){
		$type=0;
		$type_search=" (type='0' OR type IS NULL) ";
		$net="------";
	} else {
		$type = $db->result($result, $i, "ID");
		$type_search=" type='$type' ";
		$net = $db->result($result, $i, "name");
	}
	$query = "SELECT count(*) FROM glpi_peripherals WHERE $type_search AND deleted ='N'  AND is_template = '0' AND is_global='0'";
	$result3 = $db->query($query);
	$counter = $db->result($result3,0,0);

	$query2="SELECT ID FROM glpi_peripherals where $type_search AND deleted ='N'  AND is_template = '0' AND is_global='1' ";
	$result2 = $db->query($query2);
	if ($db->numrows($result2)){
		while ($data=$db->fetch_assoc($result2)){
			$query="SELECT count(*) FROM glpi_connect_wire WHERE type='".PERIPHERAL_TYPE."' AND end1='".$data["ID"]."';";
			$result3 = $db->query($query);
			$counter += $db->result($result3,0,0);
		}
	}

	echo "<tr class='tab_bg_2'><td>$net</td><td>$counter</td></tr>";
	$i++;
}

echo "<tr><td colspan='2' height=10></td></tr>";
echo  "<tr class='tab_bg_1'><td colspan='2'><b>".$lang["Menu"][34].":</b></td></tr>";

# 4. Get some more number data (Peripherals)

$query = "SELECT * FROM glpi_type_phones ORDER BY name";
$result = $db->query($query);
$i = -1;
$number = $db->numrows($result);
while ($i < $number) {
	if ($i<0){
		$type=0;
		$type_search=" (type='0' OR type IS NULL) ";
		$net="------";
	} else {
		$type = $db->result($result, $i, "ID");
		$type_search=" type='$type' ";
		$net = $db->result($result, $i, "name");
	}
	$query = "SELECT count(*) FROM glpi_phones WHERE $type_search AND deleted ='N'  AND is_template = '0'";
	$result3 = $db->query($query);
	$counter = $db->result($result3,0,0);

	$query2="SELECT ID FROM glpi_phones WHERE $type_search AND deleted ='N'  AND is_template = '0' AND is_global='1' ";
	$result2 = $db->query($query2);
	if ($db->numrows($result2)){
		while ($data=$db->fetch_assoc($result2)){
			$query="SELECT count(*) FROM glpi_connect_wire WHERE type='".PHONE_TYPE."' AND end1='".$data["ID"]."';";
			$result3 = $db->query($query);
			$counter += $db->result($result3,0,0);
		}
	}

	echo "<tr class='tab_bg_2'><td>$net</td><td>$counter</td></tr>";
	$i++;
}


echo "</table></div>";

commonFooter();






?>