public function displayOrder($orderId) { $flightNum = ''; try { $rowCheck = 0; $user = ''; $card = ''; $stat = ''; $price = ''; $date = ''; $address = ''; $stmt = $this->db->prepare(' select account.account_username, customer_payment.card_number, order_status.order_status, `order`.order_total, `order`.order_date, `order`.flight_num, account.account_address from `order`, account, customer_payment, order_status where `order`.order_ID = :order and `order`.account_ID = account.account_ID and `order`.card_ID = customer_payment.card_ID and `order`.order_status_ID = order_status.order_status_ID and (order_status.order_status != "cart" OR order_status.order_status != "canned"); '); $stmt->bindParam(':order', $orderId); if ($stmt->execute()) { while ($data = $stmt->fetch()) { $user = $data[0]; $card = $data[1]; $stat = $data[2]; $price = $data[3]; $date = $data[4]; $flightNum = $data[5]; $address = $data[6]; $rowCheck += 1; } } if ($rowCheck > 0) { echo ' <div class="orderDetail"> order number = ' . $orderId . '</br> username = '******'</br> card number = ' . $card . '</br> order status = ' . $stat . '</br> order price = ' . $price . '</br> order date = ' . $date . '</br> order address = ' . $address . '</br> '; $stmt = $this->db->prepare(' select order_item_detail.order_item_quantity, inventory.item_name, inventory.item_img from order_item_detail, inventory where order_item_detail.order_ID = :ord and inventory.item_ID = order_item_detail.item_ID group by inventory.item_name; '); $stmt->bindParam(':ord', $orderId); if ($stmt->execute()) { while ($data = $stmt->fetch()) { echo '<div class="orderItem"> <img src="data:image/jpeg;base64,' . base64_encode($data[2]) . '" width=100px height=100px/> inventory name = ' . $data[1] . ' </br> quantity = ' . $data[0] . ' </br> '; echo ' </div>'; } } echo '</div> '; if (isset($_SESSION['actType']) && $_SESSION['actType'] == 'employee') { // Add the ability to modify orders in the database if (isset($_REQUEST['ordStat'])) { try { echo $_REQUEST['ordStat']; $this->db->beginTransaction(); $stmt = $this->db->prepare(' update `order` set order_status_ID = :ordStat where order_ID = :ord; '); $stmt->bindParam(':ordStat', $_REQUEST['ordStat']); $stmt->bindParam(':ord', $orderId); $stmt->execute(); $this->db->commit(); } catch (Exception $e) { $this->db->rollBack(); echo 'Order Status Error'; } } if (isset($_REQUEST['flightNum']) && isset($_REQUEST['orderYo']) && $_REQUEST['orderYo'] == $orderId) { try { $this->db->beginTransaction(); $stmt = $this->db->prepare(' update `order` set flight_num = :num where order_ID = :ord'); $stmt->bindParam(':num', $_REQUEST['flightNum']); $stmt->bindParam(':ord', $orderId); $stmt->execute(); $this->db->commit(); bookAPIuse("https://web.njit.edu/~cmn6/IT490/testApi.php", 'addItem', $orderId, $_REQUEST['flightNum']); } catch (Exception $e) { $this->db->rollBack(); } } echo ' <div class="formBody"> <form method="post"> <label>Update Order and Flight statuses</label></br>'; $flights = json_decode(bookAPIuse("https://web.njit.edu/~cmn6/IT490/testApi.php", 'getFlight', 0, 0)); if ($flightNum == '') { echo ' <select name="flightNum">'; foreach ($flights as list($flNumber, $dest)) { echo '<option value=' . $flNumber . '>Flight Number: ' . $flNumber . ' Going to Location: ' . $dest . '</option>'; } echo ' </select></br>'; } echo ' <select name="ordStat">'; $stmt = $this->db->prepare(' select * from order_status;'); if ($stmt->execute()) { while ($data = $stmt->fetch()) { echo '<option value="' . $data[0] . '">' . $data[1] . '</option>'; } } echo ' </select> <input type="hidden" name="orderYo" value="' . $orderId . '"> <button type="submit" name="page" value="pageChOrder">Update Order </form> </div>'; } } } catch (PDOException $e) { } }
public function newUser() { echo ' <div id="registBody"> <h2>New User Sign Up</h2> <h5>Welcome!</h5> <form method="get"> <label>Email</label><br> <input type="email" name="email" required><br> <label>Username</label><br> <input type="text" name="username" required></br> <label>Address</label><br> <select name="address">'; $addArr = json_decode(bookAPIuse("https://web.njit.edu/~cmn6/IT490/testApi.php", 'getAddress', 0, 0)); foreach ($addArr as $key => $value) { echo '<option value=' . $value . '>' . $value . '</option>'; } echo '<option value="none">none</option>'; echo '</select></br> <label>Phone Number</label><br> <input type="text" name="number" required></br> <label>Password</label><br> <input type="password" name="password" required></br> <label>Retype Password</label><br> <input type="password" name="rePass" required></br> <label>Account Type</label><br> <select name="actType" required> <option value="1">Customer</option> <option value="2">Employee</option> </select></br> <button type="submit" name="page" value="pageRegister">Register</button> </form> <form method="get"> <button type="submit" name="page" value="pageLogin">Sign In</button> </form> </div> '; }
public function infoDump() { /** * * Creates form to update user info * **/ echo ' <div class="logBody col-md-6"> <h2>Update User Info</h2> <form method="post"> <label>Email</label> <input type="text" name="email" required><br> <label>Address</label> <select name="address">'; $addArr = json_decode(bookAPIuse("https://web.njit.edu/~cmn6/IT490/testApi.php", 'getAddress', 0, 0)); foreach ($addArr as $key => $value) { echo '<option value=' . $value . '>' . $value . '</option>'; } echo '</select></br> <label>Phone Number</label> <input type="text" name="number" required></br> <label>Password</label> <input type="text" name="password" required></br> <label>Retype Password</label> <input type="text" name="rePass" required></br> <button type="submit" name="page" value="pageActSettings">Register</button> </form> </div> '; }