/
employee.php
344 lines (255 loc) · 10.4 KB
/
employee.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
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
<html>
<body>
<style>
body {background-color:black}
body {color:Red}
h1 {color:Red}
p {color:white}
legend {color: red}
</style>
<div class="row">
<div class="large-3 columns">
<h1><img src="http://placehold.it/400x100&text=DATABLAZERGAMES"/></h1>
</div>
</div>
</body>
</html>
<?php
//Login to Database
$dbhandle = oci_connect("ora_i8b9", "a46664124", "ug");
if (!$dbhandle) {
$m = oci_error();
echo $m['message'], "\n";
exit;
}
else {
echo "EmployeeID:"; echo $_COOKIE["ForEmployeeCookie"];
echo " ";
}
?>
<html>
<body>
<p>
</p>
<fieldset>
<legend>Add New Game to Database:</legend>
<!-- ADD New Game Button -->
<form action = "employee.php" method="POST">
<p>Enter the Name:</p> <input type="text" name="Nameone" />
<p>Enter the Barcode:</p> <input type="number" name="Barcodeone" />
<p>Enter the ESRB:</p> <input type="text" name="rateone" />
<p>Enter The Number Players:</p> <input type="number" name="playersone" />
<p>Enter the Price: </p> <input type = "number" name = "priceone" />
<p>Enter the BranchID: </p> <input type = "number" name = "Bone" />
<p>Enter the City: </p> <input type = "text" name = "cityone" />
<p>Enter the Address: </p> <input type = "text" name = "addone" />
<p>Enter the Quantity: </p> <input type = "number" name = "quantityone" />
<p></p>
<input type="submit" value="AddGames" name = "submit">
</form>
</fieldset>
<p>
</p>
</body>
</html>
<?php
if (isset($_POST['submit']) and $_POST['submit']=="AddGames"){
$Name = $_POST['Nameone'];
$Barcode = $_POST['Barcodeone'];
$ESRB = $_POST['rateone'];
$Players = $_POST['playersone'];
$Price = $_POST['priceone'];
$Bid = $_POST['Bone'];
$City = $_POST['cityone'];
$Address = $_POST['addone'];
$Quantity = $_POST['quantityone'];
$queryone = "Insert INTO PRODUCTBARCODE VALUES (" . $Barcode . ",'" . $Name . "', ". $Price.")";
$querytwo = "Insert INTO GAME VALUES( " . $Barcode . ", '" . $ESRB . "'," . $Players . ")";
$queryoneone = "Insert INTO BRANCH VALUES (" . $Bid . ",'" . $City . "', '". $Address."')";
$querytwotwo = "Insert INTO HAS VALUES (" . $Bid . "," . $Barcode . ", ". $Quantity.")";
$selectedone = OCI_parse($dbhandle, $queryone);
$selectedtwo = OCI_parse($dbhandle, $querytwo);
$selectedoneone = OCI_parse($dbhandle, $queryoneone);
$selectedtwotwo = OCI_parse($dbhandle, $querytwotwo);
$succuessone = OCI_execute($selectedone);
$succuesstwo = OCI_execute($selectedtwo);
$succuessoneone = OCI_execute($selectedoneone);
$succuesstwotwo = OCI_execute($selectedtwotwo);
if(!$succuessone){
echo "no";
}
OCICommit($dbhandle);
}
?>
<html>
<body>
<fieldset>
<legend>Add New Console to the Database:</legend>
<form action = "employee.php" method="POST">
<p>Enter the Name:</p> <input type="text" name="Nametwo" />
<p>Enter the Barcode:</p> <input type="number" name="Barcodetwo" />
<p>Enter the Price: </p> <input type = "number" name = "pricetwo" />
<p>Enter the BranchID: </p> <input type = "number" name = "Btwo" />
<p>Enter the City: </p> <input type = "text" name = "citytwo" />
<p>Enter the Address: </p> <input type = "text" name = "addtwo" />
<p>Enter the Quantity: </p> <input type = "number" name = "quantitytwo" />
<p> </p>
<input type="submit" value="AddConsole" name = "submit">
</form>
</fieldset>
</body>
</html>
<?php
if (isset($_POST['submit']) and $_POST['submit']=="AddConsole"){
$Nameone = $_POST['Nametwo'];
$Barcodeone = $_POST['Barcodetwo'];
$Priceone = $_POST['pricetwo'];
$Bidone = $_POST['Btwo'];
$Cityone = $_POST['citytwo'];
$Addressone = $_POST['addtwo'];
$Quantityone = $_POST['quantitytwo'];
$querythree = "Insert INTO PRODUCTBARCODE VALUES (" . $Barcodeone . ",'" . $Nameone . "', ". $Priceone.")";
$queryfour = "Insert INTO CONSOLE VALUES( " . $Barcodeone . ")";
$querythreethree = "Insert INTO BRANCH VALUES (" . $Bidone . ",'" . $Cityone . "', '". $Addressone."')";
$queryfourfour = "Insert INTO HAS VALUES (" . $Bidone . "," . $Barcodeone . ", ". $Quantityone.")";
$selectedthree = OCI_parse($dbhandle, $querythree);
$selectedfour = OCI_parse($dbhandle, $queryfour);
$selectedthreethree= OCI_parse($dbhandle, $querythreethree);
$selectedfourfour = OCI_parse($dbhandle, $queryfourfour);
$succuessthree = OCI_execute($selectedthree);
$succuessfour = OCI_execute($selectedfour);
$succuessthreethree = OCI_execute($selectedthreethree);
$succuessfourfour = OCI_execute($selectedfourfour);
if(!$succuessthree){
echo "you really no";
}
OCICommit($dbhandle);
}
?>
<html>
<body>
<fieldset>
<legend>Add New Console to the ACCESSORY:</legend>
<form action = "employee.php" method="POST">
<p>Enter the Name:</p> <input type="text" name="Namethree" />
<p>Enter the Barcode:</p> <input type="number" name="Barcodethree" />
<p>Enter the Price: </p> <input type = "number" name = "pricethree" />
<p>Enter the BranchID: </p> <input type = "number" name = "Bthree" />
<p>Enter the City: </p> <input type = "text" name = "citythree" />
<p>Enter the Address: </p> <input type = "text" name = "addthree" />
<p>Enter the Quantity: </p> <input type = "number" name = "quantitythree" />
<p> </p>
<input type="submit" value="AddAccessory" name = "submit">
</form>
</fieldset>
</body>
</html>
<?php
if (isset($_POST['submit']) and $_POST['submit']=="AddAccessory"){
$Nametwo = $_POST['Namethree'];
$Barcodetwo = $_POST['Barcodethree'];
$Pricetwo = $_POST['pricethree'];
$Bidtwo = $_POST['Bthree'];
$Citytwo = $_POST['citythree'];
$Addresstwo = $_POST['addthree'];
$Quantitytwo = $_POST['quantitythree'];
$queryfive = "Insert INTO PRODUCTBARCODE VALUES (" . $Barcodetwo . ",'" . $Nametwo . "', ". $Pricetwo.")";
$querysix = "Insert INTO ACCESSORY VALUES( " . $Barcodetwo . ")";
$queryfivefive = "Insert INTO BRANCH VALUES (" . $Bidtwo . ",'" . $Citytwo . "', '". $Addresstwo."')";
$querysixsix = "Insert INTO HAS VALUES (" . $Bidtwo . "," . $Barcodetwo . ", ". $Quantitytwo.")";
$selectedfive = OCI_parse($dbhandle, $queryfive);
$selectedsix = OCI_parse($dbhandle, $querysix);
$selectedfivefive = OCI_parse($dbhandle, $queryfivefive);
$selectedsixsix = OCI_parse($dbhandle, $querysixsix);
$succuessfive = OCI_execute($selectedfive);
$succuesssix = OCI_execute($selectedsix);
$succuessfivefive = OCI_execute($selectedfivefive);
$succuesssixsix = OCI_execute($selectedsixsix);
if(!$succuesssix){
echo " really really no";
}
OCICommit($dbhandle);
}
?>
<html>
<body>
<fieldset>
<legend>Update Game:</legend>
<form action = "employee.php" method="POST">
<p>Enter the Barcode:</p> <input type="number" name="Barcodeupdate" />
<p>Enter the Quantity:</p> <input type="number" name="Quantityupdate" />
<p>Enter the BranchID: </p> <input type = "number" name = "Branchupdate" />
<p> </p>
<input type="submit" value="UpdateProduct" name = "submit">
</form>
</fieldset>
</body>
</html>
<?php
if (isset($_POST['submit']) and $_POST['submit']=="UpdateProduct"){
$UpdateBarcode = $_POST['Barcodeupdate'];
$UpdateQuantity = $_POST['Quantityupdate'];
$UpdateBranch = $_POST['Branchupdate'];
$normalQuery = "SELECT Quantity FROM Has Where barcode = " .$UpdateBarcode." and bID = ".$UpdateBranch."";
$normalselected = OCI_parse($dbhandle,$normalQuery);
$result = OCI_execute($normalselected);
while ($row = OCI_Fetch_ASSOC($normalselected)){
$finalQuantity = $row['QUANTITY'];
}
$newquantityeye = $finalQuantity + $UpdateQuantity;
echo $newquantityeye;
$updatequery = "update has set Quantity = ".$newquantityeye." Where barcode = ".$UpdateBarcode."";
$updateselected = OCI_parse($dbhandle,$updatequery);
$resultone = OCI_execute($updateselected);
if(!$resultone){
echo "bleh";
}
OCICommit($dbhandle);
}
?>
<html>
<body>
<fieldset>
<legend>Purchase Product:</legend>
<form action = "employee.php" method="POST">
<p>Enter the Barcode:</p> <input type="number" name="BarcodePurchased" />
<p>Enter the Quantity:</p> <input type="number" name="QuantityPurchased" />
<p>Enter the BranchID: </p> <input type = "number" name = "BranchPurchased" />
<p> </p>
<input type="submit" value="PurchaseProduct" name = "submit">
</form>
</fieldset>
</body>
</html>
<?php
if (isset($_POST['submit']) and $_POST['submit']=="PurchaseProduct"){
$PurchasedBarcode = $_POST['BarcodePurchased'];
$PurchasedQuantity = $_POST['QuantityPurchased'];
$PurchasedBranch = $_POST['BranchPurchased'];
$PurchasedQuery = "SELECT Quantity FROM Has Where barcode = " .$PurchasedBarcode." and bID = ".$PurchasedBranch."";
$PurchasedSelected = OCI_parse($dbhandle,$PurchasedQuery);
$resultof = OCI_execute($PurchasedSelected);
while ($row = OCI_Fetch_ASSOC($PurchasedSelected)){
$finaldestinationQuantity = $row['QUANTITY'];
}
$newupdatedquantityeye = $finaldestinationQuantity - $PurchasedQuantity;
echo $newupdatedquantityeye;
$date = strtotime("+15 day");
$endDate = date('M d, Y', $date);
$receiptNumber = 999999999999;
$receiptNumber = $receiptNumber - 1;
$PurchasedQueryone = "update has set Quantity = ".$newupdatedquantityeye." Where barcode = ".$PurchasedBarcode."";
$RecieptUpdateQuery = "Insert INTO PurchaseExpDate VALUES(" . $receiptNumber . ", '" . $endDate . "')";
$PurchasedSelectedone = OCI_parse($dbhandle,$PurchasedQueryone);
$PurchasedReciept = OCI_parse($dbhandle,$RecieptUpdateQuery);
$resultonethousand = OCI_execute($PurchasedSelectedone);
if(!$resultonethousand){
echo "bleh";
}
$resulttwothousand = OCI_execute($PurchasedReciept);
if(!$resulttwothousand){
echo "blah";
}
OCICommit($dbhandle);
}
?>