|
|
|
@ -49,7 +49,6 @@ new_account() {
|
|
|
|
|
echo "Account ID: $acc_id"
|
|
|
|
|
;;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# If the user selects anything other than [Yy]
|
|
|
|
|
* ) echo "Aborted"
|
|
|
|
|
;;
|
|
|
|
@ -100,6 +99,8 @@ do
|
|
|
|
|
echo "1) Withdraw"
|
|
|
|
|
echo "2) Deposit"
|
|
|
|
|
echo "3) Transfer"
|
|
|
|
|
echo "4) Quick balance check"
|
|
|
|
|
echo ""
|
|
|
|
|
echo "0) Go Back"
|
|
|
|
|
echo ""
|
|
|
|
|
read -n1 -p "*Banking Menu: Select from the above: " ii_bank
|
|
|
|
@ -107,13 +108,35 @@ do
|
|
|
|
|
|
|
|
|
|
case $ii_bank in
|
|
|
|
|
[0q] ) break ;;
|
|
|
|
|
1 ) read -p "Withdraw from user: " bank_user
|
|
|
|
|
read -p "Amount to withdraw: " bank_wth_amt
|
|
|
|
|
echo "$bank_user" | awk 'FNR == 1 {print}'
|
|
|
|
|
bank_1_amt=$($db_conn "select id,username,balance from account join balance using (id) where username='$bank_user';"| awk 'FNR == 3' | awk -F\| '{print $3}')
|
|
|
|
|
bank_user_id=$($db_conn "select id,username,balance from account join balance using (id) where username='$bank_user';" | awk 'FNR == 3' | awk -F\| '{print $1}')
|
|
|
|
|
new_amt=$($db_conn "select balance - '$bank_wth_amt' from balance where id = '$bank_user_id';" | awk 'FNR ==3')
|
|
|
|
|
$db_conn "update balance set balance = '$new_amt' where id = '$bank_user_id';" ;;
|
|
|
|
|
1 ) read -p "Withdraw from user: " with_user
|
|
|
|
|
read -p "Amount to withdraw: " with_amt
|
|
|
|
|
LAST_USER=$with_user
|
|
|
|
|
## Not sure why this was here...
|
|
|
|
|
#echo "$with_user" | awk 'FNR == 1 {print}'
|
|
|
|
|
# Grabs the current amount the user has stored in the database.
|
|
|
|
|
with_1_amt=$($db_conn "select id,username,balance from account join balance using (id) where username='$with_user';"| awk 'FNR == 3' | awk -F\| '{print $3}')
|
|
|
|
|
# This grabs the user's ID to use on the balance table.
|
|
|
|
|
with_user_id=$($db_conn "select id,username,balance from account join balance using (id) where username='$with_user';" | awk 'FNR == 3' | awk -F\| '{print $1}')
|
|
|
|
|
# Does the math to minus the withdraw.
|
|
|
|
|
with_new_amt=$($db_conn "select balance - '$with_amt' from balance where id = '$with_user_id';" | awk 'FNR ==3')
|
|
|
|
|
# Updates the database with the new amount.
|
|
|
|
|
$db_conn "update balance set balance = '$with_new_amt' where id = '$with_user_id';"
|
|
|
|
|
;;
|
|
|
|
|
2 ) read -p "Deposit to user: " depo_user
|
|
|
|
|
read -p "Amount to deposit: " depo_amt
|
|
|
|
|
LAST_USER=$depo_user
|
|
|
|
|
depo_1_amt=$($db_conn "select id,username,balance from account join balance using (id) where username='$depo_user';"| awk 'FNR == 3' | awk -F\| '{print $3}')
|
|
|
|
|
# This grabs the user's ID to use on the balance table.
|
|
|
|
|
depo_user_id=$($db_conn "select id,username,balance from account join balance using (id) where username='$depo_user';" | awk 'FNR == 3' | awk -F\| '{print $1}')
|
|
|
|
|
# Does the math to add the withdraw.
|
|
|
|
|
depo_new_amt=$($db_conn "select balance + '$depo_amt' from balance where id = '$depo_user_id';" | awk 'FNR ==3')
|
|
|
|
|
# Updates the database with the new amount.
|
|
|
|
|
$db_conn "update balance set balance = '$depo_new_amt' where id = '$depo_user_id';" ;;
|
|
|
|
|
4 ) $db_conn "select id,username,balance from account join balance using (id) where username='$LAST_USER';" ;;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
* ) clear ;;
|
|
|
|
|
esac
|
|
|
|
|
done
|
|
|
|
|