forked from sitracker/sitracker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinventory_site.php
More file actions
131 lines (122 loc) · 4.49 KB
/
inventory_site.php
File metadata and controls
131 lines (122 loc) · 4.49 KB
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
<?php
// inventory_site.php - View site's inventory items
//
// SiT (Support Incident Tracker) - Support call tracking system
// Copyright (C) 2010-2014 The Support Incident Tracker Project
// Copyright (C) 2000-2009 Salford Software Ltd. and Contributors
//
// This software may be used and distributed according to the terms
// of the GNU General Public License, incorporated herein by reference.
require ('core.php');
$permission = PERM_NOT_REQUIRED;
require (APPLICATION_LIBPATH . 'functions.inc.php');
require (APPLICATION_LIBPATH . 'auth.inc.php');
$title = "$strInventory - $strSite";
if(!$CONFIG['inventory_enabled'])
{
html_redirect('index.php', FALSE);
exit;
}
if (is_numeric($_GET['id']))
{
//View site inventory
$siteid = clean_int($_GET['id']);
if (!empty($_REQUEST['filter']))
{
$filter = cleanvar($_REQUEST['filter']);
}
include (APPLICATION_INCPATH . 'htmlheader.inc.php');
echo "<h2>".icon('site', 32)." ".site_name($siteid)."</h2>";
echo "<p class='inventory'>";
echo "<a href='inventory_new.php?site={$siteid}'>";
echo icon('new', 16)." {$strNew}</a> | ";
echo "<a href='inventory.php'>".icon('site', 16)." {$strBackToSites}</a></p>";
$sql = "SELECT *, i.name AS name , i.id AS id, ";
$sql .= "i.notes AS notes, ";
$sql .= "i.active AS active ";
$sql .= "FROM `{$dbInventory}` AS i, `{$dbSites}` AS s ";
$sql .= "WHERE siteid='{$siteid}' ";
$sql .= "AND siteid=s.id ";
if (!empty($filter))
{
// $sql .= "AND type='{$filter}' ";
}
if ($_SESSION['userconfig']['show_inactive_data'] != 'TRUE')
{
$sql .= "AND i.active = 1 ";
}
$sql .= "ORDER BY i.active DESC, ";
$sql .= "i.modified DESC";
//$sql .= "GROUP BY type DESC ";
$result = mysqli_query($db, $sql);
if (mysqli_error($db)) trigger_error("MySQL Query Error ".mysqli_error($db), E_USER_WARNING);
// echo "<form action='{$_SERVER['PHP_SELF']}?site={$siteid}' method='post'>";
// echo "<p align='center'>".icon('filter', 16)." {$strFilter}: ";
// echo "<select name='filter' onchange='form.submit();'>";
// echo "<option value=''></option>";
// foreach ($CONFIG['inventory_types'] as $code => $name)
// {
// echo "<option value='{$code}'";
// if ($filter == $code)
// {
// echo " selected='selected' ";
// }
// echo ">{$name}</option>";
// }
// echo "</select> <a href='{$_SERVER['PHP_SELF']}?site={$siteid}'>";
// echo "{$strClearFilter}</a></p>";
// echo "</form>";
if (mysqli_num_rows($result) > 0)
{
echo "<table class='maintable'>";
echo "<tr><th>{$strInventoryItems}</th><th>{$strPrivacy}</th>";
echo "<th>{$strCreatedBy}</th><th>{$strOwner}</th><th>{$strActions}</th></tr>";
$shade = 'shade1';
while ($row = mysqli_fetch_object($result))
{
echo "<tr class='{$shade}'><td>".icon('inventory', 16);
echo " {$row->name}, {$CONFIG['inventory_types'][$row->type]}";
if ($row->active != 1)
{
echo " (inactive)";
}
echo "</td><td align='center'>";
if ($row->privacy == 'private')
{
echo icon('private', 16);
}
elseif ($row->privacy == 'adminonly')
{
echo icon('review', 16, $strAdmin);
}
echo "</td><td>".user_realname($row->createdby)."</td><td>";
echo contact_realname($row->contactid)."</td><td>";
$operations = array();
if (($row->privacy == 'private' AND $sit[2] != $row->createdby) OR
$row->privacy == 'adminonly' AND !user_permission($sit[2], PERM_ADMIN))
{
echo "{$strView}</a> ";
echo "{$strEdit}";
}
else
{
$operations[$strView] = "inventory_view.php?id={$row->id}";
$operations[$strEdit] = "inventory_edit.php?id={$row->id}";
echo html_action_links($operations);
}
echo "</td></tr>";
if ($shade == 'shade1') $shade = 'shade2';
else $shade = 'shade1';
}
echo "</table>";
echo "<p class='inventory'>".icon('new', 16);
echo " <a href='inventory_new.php?site={$siteid}'>";
echo "{$strNew}</a></p>";
}
else
{
echo user_alert($strNoRecords, E_USER_NOTICE);
}
include (APPLICATION_INCPATH . 'htmlfooter.inc.php');
}
?>