Starting interactive banking

master
Matt Theissen 4 years ago
parent 6ccf3f533c
commit 64e3ba4ad1

@ -11,6 +11,7 @@ ssh_host="knd-db01.kniod.corp"
# Functions # Functions
new_account() { new_account() {
clear
read -p "Enter the name of your account: " user1 read -p "Enter the name of your account: " user1
echo "" echo ""
echo "Your account name will be $user1." echo "Your account name will be $user1."
@ -52,19 +53,30 @@ list_user() {
list_balance() { list_balance() {
# Bal Menu # Bal Menu
clear clear
while true
do
echo "1) List all users balances." echo "1) List all users balances."
echo "2) List a specific user's balance." echo "2) User Search"
echo "3) Go back."
echo "" echo ""
read -n1 -p "Select from the menu above: " ii read -n1 -p "*Balance Menu: Select from the above: " ii
echo "" echo ""
case $ii in case $ii in
1 ) ssh $ssh_user@$ssh_host "psql -U ddbank -d ddbank -c \"select id,username from account join balance using (id);\"" ;; 1 ) ssh $ssh_user@$ssh_host "psql -U ddbank -d ddbank -c \"select id,username,balance from account join balance using (id);\"" ;;
2 ) read -p "Enter the user account name: " bal_user 2 ) read -p "Enter the user account name: " bal_user
bal_user1=$(ssh $ssh_user@$ssh_host "psql -U ddbank -d ddbank -c \"select id,username,balance from account join balance using (id);\"") bal_user1=$(ssh $ssh_user@$ssh_host "psql -U ddbank -d ddbank -c \"select id,username,balance from account join balance using (id);\"")
echo "$bal_user1" | awk 'FNR == 1 {print}' echo "$bal_user1" | awk 'FNR == 1 {print}'
echo "$bal_user1" | grep "$bal_user" ;; echo "$bal_user1" | grep -iE "$bal_user"
echo "" ;;
3 ) break ;;
esac esac
done
}
dwt_menu() {
echo "sub-menu goes here"
} }
while true while true
@ -75,6 +87,7 @@ do
echo "1) Create new user account." echo "1) Create new user account."
echo "2) List user accounts." echo "2) List user accounts."
echo "3) List user(s) balance." echo "3) List user(s) balance."
echo "4) Deposit, withdraw, transfer"
echo "9) Clear contents of screen" echo "9) Clear contents of screen"
echo "0) Exit" echo "0) Exit"
echo "" echo ""
@ -84,7 +97,7 @@ do
2 ) list_user ;; 2 ) list_user ;;
3 ) list_balance ;; 3 ) list_balance ;;
9 ) clear ;; 9 ) clear ;;
0 ) exit 0 ) break
esac esac
done done