-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadd.php
More file actions
369 lines (329 loc) · 13.1 KB
/
add.php
File metadata and controls
369 lines (329 loc) · 13.1 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
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
368
369
<?php
include_once 'header.php';
if ($_POST['hw_type']){ $hardware = $_POST['hw_type'];}
if($_SESSION['id'] == 'ok'){
?>
<script language="JavaScript" type="text/javascript">
<!--
// IsNumeric Function
function IsNumeric(sText)
{
var ValidChars = "0123456789";
var IsNumber=true;
var Char;
for (i = 0; i < sText.length && IsNumber == true; i++)
{
Char = sText.charAt(i);
if (ValidChars.indexOf(Char) == -1)
{
IsNumber = false;
}
}
return IsNumber;
}
// Email Validation Function
function validateEmail(sText) {
var regex = /^[a-zA-Z0-9._-]+@([a-zA-Z0-9.-]+\.)+[a-zA-Z0-9.-]{2,4}$/;
return regex.test(sText);
}
// Check the form
function checkForm () {
TheForm = (document.add)
// Check for Common Name
if (TheForm.common_name.value==""){
alert("Please enter the Common Name.\ne.g.: HS-Tech-99")
TheForm.common_name.focus();
return false;
}
// Check for Serial Number
if (TheForm.sn.value==""){
alert("Please enter the Serial Number.\ne.g.: a2431")
TheForm.sn.focus();
return false;
}
// Check to see that a building has been selected
if (TheForm.building.selectedIndex==0){
alert("Please select a building.\ne.g.: High School")
TheForm.building.focus();
return false;
}
// Check for a room
if (TheForm.room.value==""){
alert("Please enter a room.\ne.g.: Office")
TheForm.room.focus();
return false;
}
// Check for a computer model id
if (TheForm.computer_model_id.value==""){
alert("Please enter a computer model.\ne.g. Gateway 4500")
TheForm.computer_model_id.focus();
return false;
}
return true
}
// -->
</script>
<div data-role="dialog">
<?php
switch ($hardware) {
case 'computer':
?>
<div data-role="header" data-theme="a">
<h1>Add Computer</h1>
</div><!-- /header -->
<div data-role="content" class="mybg">
<label for="basic"><b>Fill out the form, then click submit:</b></label>
<br />
<br />
<form action="update.php" method="post" name="add" onSubmit="return checkForm();">
<input type="hidden" name="action" value="save">
<input type="hidden" name="hw_type" value="computer">
<label for="basic"><b>Hardware Type:</b></label>
<label for="basic"><?php print "computer"?></label>
<br />
<br />
<label for="basic"><b>Common Name:</b></label>
<input type="text" name="common_name" value="" data-mini="true" maxlength="255" />
<label for="basic"><b>Serial Number:</b></label>
<input type="text" name="sn" value="" data-mini="true" maxlength="255" />
<label for="basic"><b>Building:</b></label>
<?php include_once 'common/buildings.inc.php';?>
<label for="basic"><b>Room:</b></label>
<input type="text" name="room" value="" data-mini="true" maxlength="255" />
<label for="basic"><b>Assigned PC:</b></label>
<select name="assigned_pc">
<option selected value="0">False</option>
<option value="1">True</option>
</select>
<label for="basic"><b>Purchase Date:</b></label>
<input type="date" name="purchase_date" value="" data-mini="true" maxlength="255" />
<label for="basic"><b>Warranty Expires:</b></label>
<input type="date" name="warranty_expire" value="" data-mini="true" maxlength="255" />
<label for="basic"><b>Computer Model:</b></label>
<?php
//Create MySQL statement to populate hardware list
$sql_statement_md = 'SELECT * FROM computer_model ORDER BY computer_model_id';
//Execute built query...
$results_md = mysql_query($sql_statement_md) or die ('Error in <b>' . $sql_statement_md . '</b>. ' . mysql_error());
//create drop down list
echo '<select name="computer_model_id">';
echo "<option selected value='99'>-Select Computer Model-</option>";
while($hw=mysql_fetch_array($results_md))
{
echo '<option value="'.$hw['computer_model_id'].'" selected>'.$hw['model']. ' | ' .$hw['manuf'].'</option>';
}
echo "</select>";
?>
<label for="basic"><b>Notes:</b></label>
<input type="text" name="notes" value="" data-mini="true" maxlength="255" />
<?php
break;
case 'monitor':
?>
<div data-role="header" data-theme="a">
<h1>Add Monitor</h1>
</div><!-- /header -->
<div data-role="content">
<label for="basic"><b>Fill out the form, then click submit:</b></label>
<br />
<br />
<form action="update.php" method="post" name="add" onSubmit="return checkForm();">
<input type="hidden" name="action" value="save">
<input type="hidden" name="hw_type" value="monitor">
<label for="basic"><b>Hardware Type:</b></label>
<label for="basic"><?php print "monitor"?></label>
<br />
<br />
<label for="basic"><b>Common Name:</b></label>
<input type="text" name="common_name" value="" data-mini="true" maxlength="255" />
<label for="basic"><b>Serial Number:</b></label>
<input type="text" name="sn" value="" data-mini="true" maxlength="255" />
<label for="basic"><b>Building:</b></label>
<?php include_once 'common/buildings.inc.php';?>
<label for="basic"><b>Room:</b></label>
<input type="text" name="room" value="" data-mini="true" maxlength="255" />
<label for="basic"><b>Purchase Date:</b></label>
<input type="date" name="purchase_date" value="" data-mini="true" maxlength="255" />
<label for="basic"><b>Warranty Expires:</b></label>
<input type="date" name="warranty_expire" value="" data-mini="true" maxlength="255" />
<label for="basic"><b>Monitor Model:</b></label>
<?php
//Create MySQL statement to populate hardware list
$sql_statement_md = 'SELECT * FROM monitor_model ORDER BY monitor_model_id';
//Execute built query...
$results_md = mysql_query($sql_statement_md) or die ('Error in <b>' . $sql_statement_md . '</b>. ' . mysql_error());
//create drop down list
echo '<select name="monitor_model_id">';
echo "<option value=''>-Select Monitor Model-</option>";
while($hw=mysql_fetch_array($results_md))
{
echo '<option value="'.$hw['monitor_model_id'].'" selected>'.$hw['model']. ' | ' .$hw['manuf'].'</option>';
}
echo "</select>";
?>
<label for="basic"><b>Notes:</b></label>
<input type="text" name="notes" value="" data-mini="true" maxlength="255" />
<?php
break;
case 'projector':
?>
<div data-role="header" data-theme="a">
<h1>Add Projector</h1>
</div><!-- /header -->
<div data-role="content">
<label for="basic"><b>Fill out the form, then click submit:</b></label>
<br />
<br />
<form action="update.php" method="post" name="add" onSubmit="return checkForm();">
<input type="hidden" name="action" value="save">
<input type="hidden" name="hw_type" value="projector">
<label for="basic"><b>Hardware Type:</b></label>
<label for="basic"><?php print "projector"?></label>
<br />
<br />
<label for="basic"><b>Common Name:</b></label>
<input type="text" name="common_name" value="" data-mini="true" maxlength="255" />
<label for="basic"><b>Serial Number:</b></label>
<input type="text" name="sn" value="" data-mini="true" maxlength="255" />
<label for="basic"><b>Building:</b></label>
<?php include_once 'common/buildings.inc.php';?>
<label for="basic"><b>Room:</b></label>
<input type="text" name="room" value="" data-mini="true" maxlength="255" />
<label for="basic"><b>Purchase Date:</b></label>
<input type="date" name="purchase_date" value="" data-mini="true" maxlength="255" />
<label for="basic"><b>Warranty Expires:</b></label>
<input type="date" name="warranty_expire" value="" data-mini="true" maxlength="255" />
<label for="basic"><b>Projector Model:</b></label>
<?php
//Create MySQL statement to populate hardware list
$sql_statement_md = 'SELECT * FROM projector_model ORDER BY projector_model_id';
//Execute built query...
$results_md = mysql_query($sql_statement_md) or die ('Error in <b>' . $sql_statement_md . '</b>. ' . mysql_error());
//create drop down list
echo '<select name="projector_model_id">';
echo "<option value=''>-Select Projector Model-</option>";
while($hw=mysql_fetch_array($results_md))
{
echo '<option value="'.$hw['projector_model_id'].'" selected>'.$hw['model']. ' | ' .$hw['manuf'].'</option>';
}
echo "</select>";
?>
<label for="basic"><b>Notes:</b></label>
<input type="text" name="notes" value="" data-mini="true" maxlength="255" />
<?php
break;
case 'scanner':
?>
<div data-role="header" data-theme="a">
<h1>Add Scanner</h1>
</div><!-- /header -->
<div data-role="content">
<label for="basic"><b>Fill out the form, then click submit:</b></label>
<br />
<br />
<form action="update.php" method="post" name="add" onSubmit="return checkForm();">
<input type="hidden" name="action" value="save">
<input type="hidden" name="hw_type" value="scanner">
<label for="basic"><b>Hardware Type:</b></label>
<label for="basic"><?php print "scanner"?></label>
<br />
<br />
<label for="basic"><b>Common Name:</b></label>
<input type="text" name="common_name" value="" data-mini="true" maxlength="255" />
<label for="basic"><b>Serial Number:</b></label>
<input type="text" name="sn" value="" data-mini="true" maxlength="255" />
<label for="basic"><b>Building:</b></label>
<?php include_once 'common/buildings.inc.php';?>
<label for="basic"><b>Room:</b></label>
<input type="text" name="room" value="" data-mini="true" maxlength="255" />
<label for="basic"><b>Purchase Date:</b></label>
<input type="date" name="purchase_date" value="" data-mini="true" maxlength="255" />
<label for="basic"><b>Warranty Expires:</b></label>
<input type="date" name="warranty_expire" value="" data-mini="true" maxlength="255" />
<label for="basic"><b>Scanner Model:</b></label>
<?php
//Create MySQL statement to populate hardware list
$sql_statement_md = 'SELECT * FROM scanner_model ORDER BY scanner_model_id';
//Execute built query...
$results_md = mysql_query($sql_statement_md) or die ('Error in <b>' . $sql_statement_md . '</b>. ' . mysql_error());
//create drop down list
echo '<select name="scanner_model_id">';
echo "<option value=''>-Select Scanner Model-</option>";
while($hw=mysql_fetch_array($results_md))
{
echo '<option value="'.$hw['scanner_model_id'].'" selected>'.$hw['model']. ' | ' .$hw['manuf'].'</option>';
}
echo "</select>";
?>
<label for="basic"><b>Notes:</b></label>
<input type="text" name="notes" value="" data-mini="true" maxlength="255" />
<?php
break;
default:
?>
<div data-role="header" data-theme="a">
<h1>Add Printer</h1>
</div><!-- /header -->
<div data-role="content">
<label for="basic"><b>Fill out the form, then click submit:</b></label>
<br />
<br />
<form action="update.php" method="post" name="add" onSubmit="return checkForm();">
<input type="hidden" name="action" value="save">
<input type="hidden" name="hw_type" value="printer">
<label for="basic"><b>Hardware Type:</b></label>
<label for="basic"><?php print "printer"?></label>
<br />
<br />
<label for="basic"><b>Common Name:</b></label>
<input type="text" name="common_name" value="" data-mini="true" maxlength="255" />
<label for="basic"><b>Serial Number:</b></label>
<input type="text" name="sn" value="" data-mini="true" maxlength="255" />
<label for="basic"><b>Building:</b></label>
<?php include_once 'common/buildings.inc.php';?>
<label for="basic"><b>Room:</b></label>
<input type="text" name="room" value="" data-mini="true" maxlength="255" />
<label for="basic"><b>Purchase Date:</b></label>
<input type="date" name="purchase_date" value="" data-mini="true" maxlength="255" />
<label for="basic"><b>Warranty Expires:</b></label>
<input type="date" name="warranty_expire" value="" data-mini="true" maxlength="255" />
<label for="basic"><b>Printer Model:</b></label>
<?php
//Create MySQL statement to populate hardware list
$sql_statement_md = 'SELECT * FROM printer_model ORDER BY printer_model_id';
//Execute built query...
$results_md = mysql_query($sql_statement_md) or die ('Error in <b>' . $sql_statement_md . '</b>. ' . mysql_error());
//create drop down list
echo '<select name="printer_model_id">';
echo "<option value=''>-Select Printer Model-</option>";
while($hw=mysql_fetch_array($results_md))
{
echo '<option value="'.$hw['printer_model_id'].'" selected>'.$hw['model']. ' | ' .$hw['manuf'].'</option>';
}
echo "</select>";
?>
<label for="basic"><b>Notes:</b></label>
<input type="text" name="notes" value="" data-mini="true" maxlength="255" />
<?php
break;
}
?>
<span data-mini="true">
<input type="button" value="Back" class="button" title="Go back" onClick="history.go(-1)" data-inline="true">
<input type="submit" name="Submit" value="Submit" class="button" title="Submit work order" data-inline="true" data-theme="d">
</span>
</form>
</div>
<?php
} else {
?>
<label for="basic">You're Not Logged in!</label>
<form action="/mobilelogin.php" method="get">
<input type="hidden" name="adding" value="yes" />
<a href="/mobilelogin.php" data-inline="true" data-role="button">Login</a>
</form>
<?php
}
include_once 'footer.php';
include_once 'common/end.inc.php';
?>