2
# IRM - The Information Resource Manager
4
# Software Report Module
5
# Copyright (C) 2002 Big Walnut Local Schools
6
# written by David Maxwell, Technician Big Walnut Local Schools
7
# Contains altered code from irm.inc and default.php files included with
8
# the 1.3.4 version of IRM.
10
# This program is free software; you can redistribute it and/or modify
11
# it under the terms of the GNU General Public License as published by
12
# the Free Software Foundation; either version 2 of the License, or
13
# (at your option) any later version.
15
# This program is distributed in the hope that it will be useful,
16
# but WITHOUT ANY WARRANTY; without even the implied warranty of
17
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
# GNU General Public License (in file COPYING) for more details.
20
# You should have received a copy of the GNU General Public License
21
# along with this program; if not, write to the Free Software
22
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24
################################################################################
27
# v0.01 First functional version of Software Report Module
28
# v0.02 Better formatting of number of installs, name of software in question
29
# printed on the reports.
31
# v0.03 Ability to sort results added.
32
# v0.1 Configurable number of results per search page.
33
# v0.11 Results pages have link to return to the modules's main menu. Functions
36
# v0.2 Code cleanups. Rewrote and renamed the function that was used to
37
# obtain the number of installs. Some of the code was in the main
38
# menu portion of the module. It worked but was ugly. This rewrite
39
# simplified both the main menu and the function in question.
41
# v0.3 Module will now report a software package if it has been installed
42
# through a bundle. It will also report how many from a bundle and
43
# indicate which machines having the package are installed in that
44
# bundle. Included code from irm.inc cleaned up and even more
45
# heavily altered to make the bundle reporting work. Also eliminated
46
# the numInstalledShow function. softwareComputerListView now returns
47
# the number of installs.
49
# The software bundle changes break the code that limits the number
50
# of rows in the html table. The code is still present but commented
51
# out until I can figure out how to fix it.
53
# v0.4 Ability to select number of results per HTML page re-enabled. Added
54
# newlines to end of strings that generate HTML for HTML source
57
# v0.41 Computer ID correctly displayed in reports. Fix contributed by
58
# Stephen J. Lawrence Jr. <slawrence@ucdavis.edu>
60
# v0.5 Made compatible with IRM 1.5.x. Will no longer work with 1.4.x and
63
# v0.51 Missed a bug in autogenerated computers-info.php URLs. Fixed.
64
################################################################################
67
# The format of the report is the same as Computers list view and is
68
# controlled by the same preferences.
69
################################################################################
71
require_once '../../include/irm.inc';
72
require_once 'include/reports.inc.php';
73
require_once 'lib/Config.php';
77
# softwareComputerListView function actually generates the results
78
# table when called with the appropriate argument. This is a modified
79
# version of the ComputerListView function from irm.inc. It requires
80
# a software ID, sort criteria (one of computers table column name),
81
# and the number of results per page of HTML. It generates on screen
82
# tables and returns the number of installs of the software in question.
84
function softwareComputerListView($sID, $sort, $numresults)
87
global $IRMName, $field, $goto, $contains, $style, $USERPREFIX;
89
$USERPREFIX=Config::AbsLoc('users');
91
$DB = Config::Database();
92
$uname = $DB->getTextValue($IRMName);
94
$query = "SELECT * FROM prefs WHERE (user = $uname)";
96
$result = $DB->getRow($query);
98
$stype = Checked($result['type']);
99
$sos = Checked($result['os']);
100
$sosver = Checked($result['osver']);
101
$sprocessor = Checked($result['processor']);
102
$sprocessor_speed = Checked($result['processor_speed']);
103
$slocation = Checked($result['location']);
104
$sserial = Checked($result['serial']);
105
$sotherserial = Checked($result['otherserial']);
106
$sramtype = Checked($result['ramtype']);
107
$sram = Checked($result['ram']);
108
$snetwork = Checked($result['network']);
109
$sip = Checked($result['ip']);
110
$smac = Checked($result['mac']);
111
$shdspace = Checked($result['hdspace']);
112
$scontact = Checked($result['contact']);
113
$scontact_num = Checked($result['contact_num']);
114
$scomments = Checked($result['comments']);
115
$sdate_mod = Checked($result['date_mod']);
120
PRINT "<th>"._("Name")."</th>";
124
if ($stype == "checked")
126
PRINT "<th>"._("Type")."</th>";
129
if ($sos == "checked")
131
PRINT "<th>"._("OS")."</th>";
134
if ($sosver == "checked")
136
PRINT "<th>"._("OS Version")."</th>";
139
if ($sprocessor == "checked")
141
PRINT "<th>"._("Processor")."</th>";
144
if ($sprocessor_speed == "checked")
146
PRINT "<th>"._("Proc. Speed")."</th>";
149
if ($slocation == "checked")
151
PRINT "<th>"._("Location")."</th>";
154
if ($sserial == "checked")
156
PRINT "<th>"._("Serial Number")."</th>";
159
if ($sotherserial == "checked")
161
PRINT "<th>"._("Other Serial Number")."</th>";
164
if ($sramtype == "checked")
166
PRINT "<th>"._("RAM Type")."</th>";
169
if ($sram == "checked")
171
PRINT "<th>"._("RAM Amount (in MB)")."</th>";
174
if ($snetwork == "checked")
176
PRINT "<th>"._("Network")."</th>";
179
if ($sip == "checked")
181
PRINT "<th>"._("IP")."</th>";
184
if ($smac == "checked")
186
PRINT "<th>"._("Net/MAC Addr")."</th>";
189
if ($shdspace == "checked")
191
PRINT "<th>"._("HD Space")."</th>";
194
if ($scontact == "checked")
196
PRINT "<th>"._("Contact Person")."</th>";
199
if ($scontact_num == "checked")
201
PRINT "<th>"._("Contact Number")."</th>";
204
if ($scomments == "checked")
206
PRINT "<th>"._("Comments")."</th>";
209
if ($sdate_mod == "checked")
211
PRINT "<th>"._("Date Modified")."</th>";
218
$bundle_query = "SELECT bID from software_bundles where sID=$sID";
219
$bundles = $DB->getAll($bundle_query);
220
$numbundles = count($bundles);
224
foreach ($bundles as $result)
226
$package[$i] = $result["bID"];
230
$where_clause = "inst_software.sID=";
234
foreach($package as $v)
237
$where_clause = "$where_clause"."$v";
239
$where_clause = "$where_clause"." OR inst_software.sID=$v";
243
$packagename = softwareName($v);
244
$softquery = "SELECT * FROM computers LEFT JOIN inst_software ON computers.ID=inst_software.cID WHERE
245
$where_clause ORDER by sID,$sort";
247
$data = $DB->getAll($softquery);
248
$numRows = count($data);
250
# Chop off any records we want to skip
252
$data = array_slice($data, $goto);
253
if (count($data) > $numresults)
256
$data = array_slice($data, 0, $numresults);
264
foreach ($data as $result)
267
$ID = $result["cID"];
268
$soft_id = $result["sID"];
269
$name = $result["name"];
270
$type = $result["type"];
272
$osver = $result["osver"];
273
$processor = $result["processor"];
274
$processor_speed = $result["processor_speed"];
275
$location = $result["location"];
276
$serial = $result["serial"];
277
$otherserial = $result["otherserial"];
278
$ramtype = $result["ramtype"];
279
$ram = $result["ram"];
280
$network = $result["network"];
282
$mac = $result["mac"];
283
$hdspace = $result["hdspace"];
284
$comments = $result["comments"];
285
$date_mod = $result["date_mod"];
286
$contact = $result["contact"];
287
$contact_num = $result["contact_num"];
288
$comments = $comments;
290
if($previous_soft != $soft_id)
292
$query = "SELECT name FROM computers LEFT JOIN inst_software ON computers.ID=inst_software.cID WHERE inst_software.sID=$soft_id";
293
$sth4 = $DB->getAll($query);
294
$soft_num = count($sth4);
295
$soft_name = softwareName($soft_id);
296
print '<tr class="softwareupdate">';
297
PRINT "<TD align=\"center\" COLSPAN=\"$numChecked\"><b>$soft_name - $soft_num</b></TD>";
301
PRINT '<tr class="softwaredetail">';
302
PRINT "<TD><A HREF=\"$USERPREFIX/computers-info.php?ID=$ID\">$name($ID)</A></TD>\n";
304
if ($stype == "checked")
306
PRINT "<TD>$type</TD>";
308
if ($sos == "checked")
310
PRINT "<TD>$os</TD>";
312
if ($sosver == "checked")
314
PRINT "<TD>$osver</TD>";
316
if ($sprocessor == "checked")
318
PRINT "<TD>$processor</TD>";
320
if ($sprocessor_speed == "checked")
322
PRINT "<TD>$processor_speed</TD>";
324
if ($slocation == "checked")
326
PRINT "<TD>$location</TD>";
328
if ($sserial == "checked")
330
PRINT "<TD>$serial</TD>";
332
if ($sotherserial == "checked")
334
PRINT "<TD>$otherserial</TD>";
336
if ($sramtype == "checked")
338
PRINT "<TD>$ramtype</TD>";
340
if ($sram == "checked")
342
PRINT "<TD>$ram</TD>";
344
if ($snetwork == "checked")
346
PRINT "<TD>$network</TD>";
348
if ($sip == "checked")
350
PRINT "<TD>$ip</TD>";
352
if ($smac == "checked")
354
PRINT "<TD>$mac</TD>";
356
if ($shdspace == "checked")
358
PRINT "<TD>$hdspace</TD>";
360
if ($scontact == "checked")
362
PRINT "<TD>$contact</TD>";
364
if ($scontact_num == "checked")
366
PRINT "<TD>$contact_num</TD>";
368
if ($scomments == "checked")
370
PRINT "<TD>$comments</TD>";
372
if ($sdate_mod == "checked")
374
PRINT "<TD>$date_mod</TD>";
380
$previous_soft = $soft_id;
384
$backgoto = $goto - $numresults;
385
$forgoto = $goto + $numresults;
393
PRINT "<form><input type=hidden name=goto value=$backgoto>
394
<input type=hidden name=Show value=\"yes\">
395
<input type=hidden name=sID value=$sID>
396
<input type=hidden name=sort value=$sort>
397
<input type=hidden name=numresults value=$numresults>
398
<input type=submit value=\"".sprintf(_("Previous %s"), $numresults)."\"></form>\n";
404
if ($forgoto < $numRows)
406
PRINT "<form><input type=hidden name=goto value=$forgoto>
407
<input type=hidden name=Show value=\"yes\">
408
<input type=hidden name=sID value=$sID>
409
<input type=hidden name=sort value=$sort>
410
<input type=hidden name=numresults value=$numresults>
411
<input type=submit value=\"".sprintf(_("Next %s"), $numresults)."\"></form>\n";
422
# softwareName returns the name of an installed software package when
423
# passed a numeric software ID.
425
function softwareName($softID)
427
$DB = Config::Database();
428
$query = "SELECT name FROM software WHERE ID = $softID";
429
$sth = $DB->getRow($query);
430
$software = $sth["name"];
434
# The following code generate the main menu and results tables.
436
$USERPREFIX=Config::AbsLoc('users/reports');
442
commonHeader(_("Software Installation Report"));
443
$software_name = softwareName($sID);
446
PRINT '<tr class="softwareheader">';
447
PRINT "<th colspan=2>\n";
448
printf(_("Machines that have %s installed, sorted by %s"), "<i>$software_name</i>", "<i>$sort</i>");
452
$numinstalled=softwareComputerListView($sID,$sort, $numresults);
455
PRINT "<td><b>"._("Number of Installs:")."</td>";
456
PRINT "<td>$numinstalled</b></td>";
460
printf('<a href="%s">%s</a>', Config::AbsLoc("users/reports/software.php"), _("Create a new Software Report"));
466
commonHeader(_("Software Install Report"));
468
__("Welcome to the Software Install Report! This will tell which machines have a particular software package installed.");
471
PRINT "<th>\n" . _("Select A Software Package") . "\n</th>";
474
PRINT '<tr class="softwaredetail">';
477
PRINT "<form action=\"".Config::AbsLoc('users/reports/software.php')."\">";
479
SoftwareDropdown( "dropdown_software");
482
#TODO This should be picked up from the database ?
483
$selbox = "<select name=sort size=1>
484
<option value=\"name\">"._("Name")."</option>
485
<option value=\"ID\">"._("IRM ID")."</option>
486
<option value=\"location\">"._("Location")."</option>
487
<option value=\"type\">"._("Type")."</option>
488
<option value=\"os\">"._("Operating System")."</option>
489
<option value=\"osver\">"._("Operating System Version")."</option>
490
<option value=\"processor\">"._("Processor")."</option>
491
<option value=\"processor_speed\">"._("Processor Speed")."</option>
492
<option value=\"serial\">"._("Serial Number")."</option>
493
<option value=\"otherserial\">"._("Other Number")."</option>
494
<option value=\"ramtype\">"._("RAM Type")."</option>
495
<option value=\"ram\">"._("RAM Amount")."</option>
496
<option value=\"network\">"._("Network Card Type/Brand")."</option>
497
<option value=\"ip\">"._("IP Address")."</option>
498
<option value=\"mac\">"._("MAC/Network Address")."</option>
499
<option value=\"hdspace\">"._("Hard Drive Capacity")."</option>
500
<option value=\"comments\">"._("Comments")."</option>
501
<option value=\"contact\">"._("Contact Person")."</option>
502
<option value=\"contact_num\">"._("Contact Number")."</option>
503
<option value=\"date_mod\">"._("Date Last Modified")."</option>
506
printf(_("sorted by %s"), $selbox);
508
printf(_("with %s results per page"), "<select name=numresults size=1>
509
<option value=\"15\">15</option>
510
<option value=\"25\">25</option>
511
<option value=\"35\">35</option>
512
<option value=\"50\">50</option>
513
<option value=\"100\">100</option>
516
PRINT "<input type=submit value=\""._("Show")."\"><input type=hidden name=Show value=yes>\n";