Posting Date: October 29 Team Name: Team F8LException Project Title: Online Banking System Link to Github: https://github.com/dhurng/cs157AOnlineBanking/edit/master/proj.txt Database Schema 1. User {userId, username, password, loanId, accountId1, accountId2} int userId: autogenerated user id number. String username: Customer's username. String password: Customer's password. int loanId: loan number, if user has a loan. int accountId1: account number for first account int accountId2: account number for second account 2. Transfer {id1, id2, amount} int id1: sender account. int id2: recipient account. double amount: amount to transfer. 3. Loan {loanId, userId, amount, paymentDueDate, paymentDate balance} int loanId: loan number. int userId: user who owns this loan. double amount: amount to pay. Date paymentDueDate: date payment is due Date paymentDate: date most recent payment was made double balance: remaining balance. 4. Account {accountId, userId, balance, interestRate, accountType} int accountId: account number. int userId: user who owns this account. double balance: account balance. double interestRate: interest rate to add to balance. String accountType: account type - savings, checking 5. Transaction {userId, accountId, accountType, date, amount, transactionType, toId} int userId: customer id int accountId: account number or loan number String accountType: checking, savings, loan Date date: date of transaction double amount: transaction amount String transactionType: transaction type - deposit, withdraw, interest, payment int toId: to customer id, for transfers Functional Requirements 1. Customer can register to create a new user. 2. Customer can open a new account. 3. Customer can close their account. 4. Customer can log into their account. 5. Customer can change password. 6. Customer can reset their password. 7. Customer can check their checking or savings account balance. 8. Customer can check their loan balance. 9. Customer can withdraw from their checking or savings accounts. 10. Customer can deposit to their checking or savings accounts. 11. Customer can view their statements from each account (Checking and Savings). 12. Customer can pay their loan payment. 13. Administrator can reset non-Admin password. 14. Administrator can view customers who have a zero balance in their checking and/or savings account. 15. Administrator can view who is a late paying their loan payment. Requirements Functionalities //Send Query to Database function queryMysql($query){ global $conection; $result = $conection->query($query); if (!$result) die ($conection->error); return $result; } // 1. Customer Registers to Create new User function registerUser ($username, $password){ $result = queryMysql("INSERT INTO User(username, password) VALUES ('$username', '$password'", $link) or die ("Database Error"); } //2. Customer opens a New Account function registerAccount ($userid, $initialAmount, $accountType){ $result = queryMysql("INSERT INTO Account(userId, balance, accountType) VALUES ('$userId', '$initialAmount', '$accountType'", $link) or die ("Database Error"); $result = queryMysql("INSERT INTO Transaction(userId, accountId, accountType, amount, date) VALUES ('$userId', 'accountId', '$accountType', '$initialAmount', '$today'", $link) or die ("Database Error"); // 3. Customer Closes Account function cancelAccount ($userId, $accountId){ $result = queryMysql("DELETE FROM Account WHERE userId='$userId' and accountId='$accountId'", $link) or die ("Database Error"); } // 4. Customer Logs In function userLogIn ($username, $password){ $result = queryMysql("SELECT * FROM User WHERE username='$username' and password='$password'", $link) or die ("Database Error"); } // 5. Customer Changes Password function checkPassword($username, $oldPass, $newPass){ $result = queryMysql("UPDATE User SET password = '$newPass' WHERE username='$username' and password='$oldPass'", $link) or die ("Database Error"); } // 6. Reset Customer Password function resetPassword ($username, $userId) { $salt1 = "qm&h"; $token = hash('f8luser', "$salt1'somePassword'"); $result = queryMysql("UPDATE User SET password='$token' WHERE username='$username' and userId='$userId'", $link) or die ("Database Error"); return $token; } // 7. Check Checking Account Balance function get_CheckingBalance ($username, $accountId) { include 'db_connect.php'; $result=mysql_query("SELECT balance FROM account WHERE accountType='checking' and username='$username' and accountId='$accountId'", $link) or die ("Database Error"); } // 8. Check Savings Account Balance function check_SavingBalance ($username, $accountId) { include 'db_connect.php'; $result=mysql_query("SELECT balance FROM account WHERE accountType='savings' and username='$username' and accountId='$accountId'", $link) or die ("Database Error"); } // 9. Customer can withdraw from their accounts. function accountWithdraw($userId, $accountId, $accountType, $amount) { include 'db_connect.php'; $result=mysql_query("UPDATE Account SET balance=balance-'$amount' WHERE userId='$userId' and accountId='$accountId'", $link) or die ("Database Error"); $result = queryMysql("INSERT INTO Transaction(userId, accountId, accountType, amount, date) VALUES ('$userId', 'accountId', '$accountType', '$amount', '$today'", $link) or die ("Database Error"); } // 10. Customer can deposit to their accounts. function accountDeposit($userId, $accountId, $accountType, $amount) { include 'db_connect.php'; $result=mysql_query("UPDATE Account SET balance=balance+'$amount' WHERE userId='$userId' and accountId='$accountId'", $link) or die ("Database Error"); $result = queryMysql("INSERT INTO Transaction(userId, accountId, accountType, amount, date) VALUES ('$userId', 'accountId', '$accountType', '$amount', '$today'", $link) or die ("Database Error"); } // 11. Customer can view their statements from each account (Checking and Savings). function viewStatement($userId) { include 'db_connect.php'; $result=mysql_query("SELECT accountType, date, transactionType, amount FROM Transaction GROUP BY accountType HAVING userId='$userId' ORDER BY date", $link) or die ("Database Error"); } // 12. Customer can pay their loan payment. function loanPayment($userId, $loanId, $amount) { include 'db_connect.php'; $result=mysql_query("UPDATE Loan SET balance=balance-'$amount', paymentDate='$today' WHERE userId='$userId' and loanId='$loanId'", $link) or die ("Database Error"); $result = queryMysql("INSERT INTO Transaction(userId, loanId, accountType, amount) VALUES ('$userId', 'loanId', 'loan', '$amount'", $link) or die ("Database Error"); } // 13. Administrator can reset non-Admin password. function adminResetUserPassword ($userId, $newPassword) { include 'db_connect.php'; $result = queryMysql("UPDATE User SET password='$newPassword' WHERE userId='$userId'", $link) or die ("Database Error"); } // 14. Administrator can view customers who have a zero balance in their checking and/or savings account. function adminGetPoorUsers() { include 'db_connect.php'; $result = queryMysql("SELECT userId FROM User WHERE balance<=0", $link) or die ("Database Error"); } // 15. Administrator can view who is late paying their loan payment. function adminGetUsersOfOverdueLoans() { include 'db_connect.php'; $result=mysql_query("SELECT userId FROM User WHERE userId IN (SELECT userId FROM Loan WHERE paymentDueDate