-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclear_inventory.php
executable file
·94 lines (76 loc) · 2.32 KB
/
clear_inventory.php
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
<?php
// *************************************************************
// file: clear_inventory.php
// created by: Alex Gordon, Elliott Staude
// date: 04-22-2014
// purpose: A page used for clearing the inventory status of all computers on record.
//
// *************************************************************
// include nav bar and other default page items
include('header.php');
// check the session to see if the person is authenticated
if(!isset($_SESSION['user']))
{
header('Location: login.php');
}
//The following segments consult with the permissions of the user and
//accordingly render the page and/or allow the user to perform certain
//actions based on the permissions level
// Faculty
if($_SESSION['access']==FACULTY_PERMISSION || $_SESSION['access']==USER_PERMISSION )
{
header('Location: home.php');
}
// User or Manager
if($_SESSION['access']==ADMIN_PERMISSION)
{
?>
<div class="row">
<div class="large-10 large-centered columns">
<h1>Clear Inventory</h1>
<ul class="breadcrumbs">
<li><a href="home.php">Home</a></li>
<li class="current"><a href="#">Clear Inventory</a></li>
</ul>
</div>
</div>
<?php
// This is the BIG RED BUTTON - resets the inventory status of all computers on record
if (isset($_POST['ResetInventory']))
{
include('open_db.php');
$clearingQuery = "UPDATE computers
SET inventoried = 0";
// Run query
$clearingResult = sqlsrv_query($conn, $clearingQuery);
// Make sure that the query went through successfully
if(!$clearingResult)
{
echo print_r( sqlsrv_errors(), true);
exit;
}
sqlsrv_close( $conn);
echo "<div class=\"large-8 large-centered columns\">";
echo "<h3 class=\"large-centered\">Data successfully cleared</h3>";
echo "</div>";
}
?>
<form method="post" action="">
<div class="row">
<div class="large-4 large-centered columns">
<dl class="accordion large-12 columns" data-accordion>
<dd>
<a href="#deletePanel">Reset inventory</a>
<div id="deletePanel" class="content alert">
<p>Are you sure you want to clear inventory and reset all computers to noninventoried status? This action cannot be undone.</p>
<input type="submit" name="ResetInventory" value="Reset inventory" class="button alert">
</div>
</dd>
</dl>
</div>
</div>
</form>
<?php
}
include('footer.php')
?>