diff --git a/WebContent/html/javascript/admin.js b/WebContent/html/javascript/admin.js
new file mode 100644
index 0000000..468600d
--- /dev/null
+++ b/WebContent/html/javascript/admin.js
@@ -0,0 +1,126 @@
+var dev1 = {
+ id: 1,
+ name:"George",
+ description:"George is probably the coolest iPhone to exist. Ever. Point blank, period.",
+ hardware:"iphone",
+ software:"apple",
+};
+
+var dev2 = {
+ id: 2,
+ name:"Greyson",
+ description:"Greyson is pretty cool.. I guess.",
+ hardware:"iphone",
+ software:"apple",
+};
+
+var dev3 = {
+ id: 3,
+ name:"Linkin Park",
+ description:'"The hardest part of ending is starting again."',
+ hardware:"ipad",
+ software:"apple",
+};
+
+var dev4 = {
+ id: 4,
+ name:"Abercrombie",
+ description:"To all the people that hated me in high school, I have the prettiest clothes you all wear now!!",
+ hardware:"ipad",
+ software:"apple",
+};
+
+var dev5 = {
+ id: 5,
+ name:"Hulk",
+ description:"Go ahead and HULK SMASH! this awesome computer stick into your USB.",
+ hardware:"computerStick",
+ software:"intel",
+};
+
+var dev6 = {
+ id: 6,
+ name:"Captain America",
+ description:'"Make America Great Again. Wait, thats someone else.."',
+ hardware:"computerStick",
+ software:"intel",
+};
+
+var devices = [dev1, dev2, dev3, dev4, dev5, dev6];
+
+show();
+
+/**
+This displays all the requested items on the screen.
+**/
+function show(){
+ //get the option that you selected
+ var requested = getRequestedItems();
+ var html = '
Please review the device requests below.
';
+
+ //iterate through the hardcoded device DB and select all the ones that match the selected option
+ for(var i = 0; i < requested.length; i++){
+ for(var j = 0; j < devices.length; j++){
+ if(requested[i] === devices[j].id){
+ html += '
";
+
+ //add to HTML page
+ document.getElementById('devContainer').innerHTML = html;
+
+ //now we need to add event listeners to all the request buttons
+ var approvebuttons = document.getElementsByClassName('approvebutton');
+ for(var i = 0; i < approvebuttons.length; i++){
+ approvebuttons[i].addEventListener('click',approveRequest);
+ }
+}
+
+/**
+This function gets requested items from local storage.
+**/
+function getRequestedItems(){
+ var requested = new Array; //make new array
+ var requested_str = localStorage.getItem('requested'); //get the string from local storage
+ if(requested_str !== '' && requested_str !== null){ //as long as its not null
+ requested = JSON.parse(requested_str); //make into array
+ }
+ return requested; //return value is an array
+}
+
+/**
+This function approves a request!
+**/
+function approveRequest(){
+ var id = this.getAttribute('id');
+ id = parseInt(id.replace(/[^0-9\.]/g,''),10); //this gets just the numerical value from the id!
+ var unavailable = getUnavailableItems(); //this is an array
+ var requested = getRequestedItems();
+ unavailable.push(id); //push to bottom of cart
+ localStorage.setItem('unavailable', JSON.stringify(unavailable));
+ for(var j = 0; j < requested.length; j++){ //iterate cart
+ if(requested[j] == id){ //match ids
+ requested.splice(j,1); //remove from the cart
+ break;
+ }
+ }
+ localStorage.setItem('requested', JSON.stringify(requested)); //update local storage
+ show();
+ $('#approved').fadeIn(1000);
+ $('#approved').fadeIn(1000);
+ $('#approved').fadeOut(1000);
+}
+
+function getUnavailableItems(){
+ var unavailable = new Array;
+ var unavailable_str = localStorage.getItem('unavailable');
+ if(unavailable_str !== "" && unavailable_str !== null){
+ unavailable = JSON.parse(unavailable_str);
+ }
+ return unavailable;
+}
\ No newline at end of file
diff --git a/WebContent/html/javascript/navbar.js b/WebContent/html/javascript/navbar.js
index 6e62706..0cd657f 100644
--- a/WebContent/html/javascript/navbar.js
+++ b/WebContent/html/javascript/navbar.js
@@ -1 +1 @@
-document.getElementById('navbaruniversal').innerHTML = '
'
\ No newline at end of file
diff --git a/WebContent/html/javascript/shoppingCart.js b/WebContent/html/javascript/shoppingCart.js
index 498d818..04cd257 100644
--- a/WebContent/html/javascript/shoppingCart.js
+++ b/WebContent/html/javascript/shoppingCart.js
@@ -149,14 +149,14 @@ function orderSelected(){
if(response == true){ //if they confirm
for(var i = 0; i < checked.length; i++){ //iterate all the checked off devices
var id = checked[i]; //get the id of each device
- var unavailable = getUnavailableItems(); //get the unavailable items
+ var requested = getRequestedItems(); //get the unavailable items
var cart = getCartItems(); //get the cart
- unavailable.push(id); //add to unavailable list
+ requested.push(id); //add to unavailable list
for(var j = 0; j < cart.length; j++){ //iterate cart
if(cart[j] == id) //match id's
cart.splice(j,1); //remove from the cart
}
- localStorage.setItem('unavailable', JSON.stringify(unavailable)); //update local storage
+ localStorage.setItem('requested', JSON.stringify(requested)); //update local storage
localStorage.setItem('cart', JSON.stringify(cart)); //update local storage
}
checked = new Array; //reset the checked off array
@@ -194,9 +194,9 @@ function orderAll(){
var cart = getCartItems(); //get the cart
for(var i = 0; i < cart.length; i++){ //iterate the cart
var id = cart[i]; //get the id of each device
- var unavailable = getUnavailableItems(); //get the unavailable items
- unavailable.push(id); //add to unavailable list
- localStorage.setItem('unavailable', JSON.stringify(unavailable)); //update local storage
+ var requested = getRequestedItems(); //get the unavailable items
+ requested.push(id); //add to unavailable list
+ localStorage.setItem('requested', JSON.stringify(requested)); //update local storage
}
checked = new Array; //reset the checked off array
cart = new Array; //cart should now be empty, so reset also
@@ -219,13 +219,13 @@ function deleteAll(){
}
/**
-This function gets unavailable items from local storage.
+This function gets requested items from local storage.
**/
-function getUnavailableItems(){
- var unavailable = new Array; //make new array
- var unavailable_str = localStorage.getItem('unavailable'); //get the string from local storage
- if(unavailable_str !== '' && unavailable_str !== null){ //as long as its not null
- unavailable = JSON.parse(unavailable_str); //make into array
+function getRequestedItems(){
+ var requested = new Array; //make new array
+ var requested_str = localStorage.getItem('requested'); //get the string from local storage
+ if(requested_str !== '' && requested_str !== null){ //as long as its not null
+ requested = JSON.parse(requested_str); //make into array
}
- return unavailable; //return value is an array
+ return requested; //return value is an array
}
\ No newline at end of file
diff --git a/WebContent/html/webpages/admin.html b/WebContent/html/webpages/admin.html
new file mode 100644
index 0000000..094bfa8
--- /dev/null
+++ b/WebContent/html/webpages/admin.html
@@ -0,0 +1,83 @@
+
+
+
+
+
+
+
+
+
+ Synchrony Financial
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Admin View Approvals
+
+
+
+
+
Approved!
+
+
+
+
+
+
\ No newline at end of file
diff --git a/bin/database/MySQLAccess.class b/bin/database/MySQLAccess.class
new file mode 100644
index 0000000..f494f5e
Binary files /dev/null and b/bin/database/MySQLAccess.class differ
diff --git a/bin/features/RequestHandler.class b/bin/features/RequestHandler.class
new file mode 100644
index 0000000..aa20869
Binary files /dev/null and b/bin/features/RequestHandler.class differ
diff --git a/bin/functionality_managers/ClientManager.class b/bin/functionality_managers/ClientManager.class
new file mode 100644
index 0000000..781f456
Binary files /dev/null and b/bin/functionality_managers/ClientManager.class differ
diff --git a/bin/functionality_managers/SystemManager.class b/bin/functionality_managers/SystemManager.class
new file mode 100644
index 0000000..9514632
Binary files /dev/null and b/bin/functionality_managers/SystemManager.class differ