-
Notifications
You must be signed in to change notification settings - Fork 0
/
locations.php
176 lines (148 loc) · 4.86 KB
/
locations.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
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
<!DOCTYPE html>
<html lang="en">
<head>
<?php
include('general.php');
include('dbconnect.php');
putLinks();
session_start();
if( strcasecmp($_SERVER['REQUEST_METHOD'],"POST") === 0) {
$_SESSION['postdata'] = $_POST;
header("Location: ".$_SERVER['PHP_SELF']."?".$_SERVER['QUERY_STRING']);
exit;
}
if( isset($_SESSION['postdata'])) {
$_POST = $_SESSION['postdata'];
unset($_SESSION['postdata']);
}
?>
<title>Chromis PHP - Locations</title>
</head>
<body>
<header class="site__header island">
<div class="wrap">
<span id="animationSandbox" style="display: block;" class="tada animated">
<h1 class="site__title mega text-center">Location Master</h1>
</span>
</div>
</header>
<form action="locations.php" method="post" enctype="multipart/form-data">
<div class="row">
<div class="form-group">
<div class="col-lg-4"></div>
<div class="col-lg-4 text-right">
<a class="glyphicon glyphicon-home" style="font-size:30px;color:orange" href="/chromisphp/"></a>
<div class="input-group">
<div class="input-group-addon">Locations</div>
<input type="text" class="form-control" name="Location" id="inlineFormInputGroup" placeholder="Location" required>
</div>
<br />
<button type="submit" class="btn btn-success" id="btnSave" name="Save">Save</button>
<button type="submit" class="btn btn-warning" id="btnRemove" name="Remove">Remove</button>
<button type="submit" class="btn btn-info" id="btnRefresh" name="Refresh" formnovalidate>Refresh</button>
</div>
<div class="col-lg-4"></div>
</div>
</div>
</form>
<br />
<div class="row">
<div class="col-lg-4"></div>
<div class="col-lg-4">
<div class="panel panel-default">
<!-- Table -->
<table class="table table-striped">
<thead>
<?php
//include('dbconnect.php');
/* session_start();
if( strcasecmp($_SERVER['REQUEST_METHOD'],"POST") === 0) {
$_SESSION['postdata'] = $_POST;
header("Location: ".$_SERVER['PHP_SELF']."?".$_SERVER['QUERY_STRING']);
exit;
}
if( isset($_SESSION['postdata'])) {
$_POST = $_SESSION['postdata'];
unset($_SESSION['postdata']);
} */
refreshRecords();
function refreshRecords() {
echo '<tr>';
echo '<th class="label visible-lg-inline-block label-info text-center" width="100%">Location Description</th>';
echo '</tr>';
echo '</thead>';
$conn = dbConn();
$sql = "SELECT NAME FROM locations";
$result = mysqli_query($conn, $sql);
if (mysqli_num_rows($result) > 0) {
// output data of each row
while($row = mysqli_fetch_assoc($result)) {
//echo "<tr><td>". $row["ID"] ."</td>" . "<td>". $row["NAME"] ."</td></tr>";
echo "<tr><td>". $row["NAME"] ."</td></tr>";
}
} else {
//echo "0 results";
echo "<tr><td>". "No records found!" ."</td></tr>";
}
mysqli_close($conn);
$conn=null;
$sql="";
}
?>
</table>
</div>
</div>
<div class="col-lg-4"></div>
</div>
</div>
<?php
if (isset($_POST['Save']))
{
echo '<div class="label label-warning">' . 'Save pressed!' . '</div>';
//--REPLACE INTO categories (ID,NAME) VALUES (CONVERT(UUID(),CHAR),'TEST03');
$conn = dbConn();
$location = $_POST['Location'];
$sql = "REPLACE INTO locations (SITEGUID,NAME) VALUES (CONVERT(UUID(),CHAR),'". $location ."')";
$result = mysqli_query($conn, $sql);
if ($result) {
echo '<div class="label label-success">' . 'Record updated!' . '</div>';
echo "<meta http-equiv='refresh' content='0'>";
}
else
{
echo '<div class="label label-danger">' . 'failed to save!' . '</div>';
}
mysqli_close($conn);
$conn=null;
$sql="";
}
if (isset($_POST['Remove']))
{
echo '<div class="label label-warning">' . 'Remove pressed!' . '</div>';
$conn =dbConn();
$remLocation = $_POST['Location'];
$sql = "DELETE FROM locations WHERE NAME = '". $remLocation ."'";
echo '<div class="label label-info">' . 'Query:=' . $sql . '</div>';
$result = mysqli_query($conn, $sql);
if ($result) {
echo '<div class="label label-danger">' . 'Record Removed!' . $result . '</div>';
echo "<meta http-equiv='refresh' content='0'>";
}
else
{
echo '<div class="label label-danger">' . 'failed to Remove!' . '</div>';
echo $result;
}
mysqli_close($conn);
$conn=null;
$sql="";
}
?>
<?php
//include('general.php');
putScripts();
stickfooter();
?>
<!--
--> </body>
</html>