diff --git a/bank b/bank index 9d54d5f..0479703 100755 --- a/bank +++ b/bank @@ -12,17 +12,17 @@ source ${HOME}/.dndbank.conf fail_badsel() { printf "\n$(tput setaf 3)ERROR 10:$(tput sgr0) $(tput bold)Bad selection!$(tput sgr0)\n\n" # Restart at main menu - show_menu + show_menu init } ### Menu -pre_menu() { +hold_menu() { echo "Press [Enter] to continue..." read } show_menu() { - [ "$1" == "init" ] || pre_menu + #[ "$1" == "init" ] || pre_menu printf 'Select a function by number: 1. Create Account @@ -97,7 +97,7 @@ create_account() { printf "\n$(tput bold)$(tput setaf 1)ABORT\n\n$(tput sgr0)" ;; esac - show_menu + hold_menu } delete_account() { @@ -112,9 +112,9 @@ delete_account() { make_deposit() { eval "$dbconnect -c \"SELECT * FROM account;\"" read -p "Enter Account ID: " ID - read -p "Enter amount of GP to deposit: " amount + read -p "Enter amount of gp to deposit: " amount tstamp=$(date +%Y-%m-%d\ %H:%M:%S) - read -p "Depositing ${amount} into account ${ID}. Are you sure? (y/N)" -n1 CONFIRM + read -p "Depositing ${amount}gp into account ${ID}. Are you sure? (y/N)" -n1 CONFIRM case $CONFIRM in [Yy]) printf "\n$(tput bold)Depositing...\n\n$(tput sgr0)" @@ -129,7 +129,7 @@ make_deposit() { printf "\n$(tput bold)$(tput setaf 1)ABORT\n\n$(tput sgr0)" ;; esac - show_menu + hold_menu # # Transaction (Deposit) # INSERT INTO transaction (account,deposit,timestamp) VALUES ((SELECT id FROM account WHERE name = ${name}),${amount},${tstamp}); # UPDATE balance SET gold = gold + 123.45 WHERE id = (SELECT id FROM account WHERE name = ${name}); @@ -138,9 +138,9 @@ make_deposit() { make_withdrawal() { eval "$dbconnect -c \"SELECT * FROM account;\"" read -p "Enter Account ID: " ID - read -p "Enter amount of GP to withdraw: " amount + read -p "Enter amount of gp to withdraw: " amount tstamp=$(date +%Y-%m-%d\ %H:%M:%S) - read -p "Withdrawing ${amount} from account ${ID}. Are you sure? (y/N)" -n1 CONFIRM + read -p "Withdrawing ${amount}gp from account ${ID}. Are you sure? (y/N)" -n1 CONFIRM case $CONFIRM in [Yy]) printf "\n$(tput bold)Withdrawing...\n\n$(tput sgr0)" @@ -155,7 +155,7 @@ make_withdrawal() { printf "\n$(tput bold)$(tput setaf 1)ABORT\n\n$(tput sgr0)" ;; esac - show_menu + hold_menu # # Transaction (Withdraw) # INSERT INTO transaction (account,withdrawal,timestamp) VALUES ((SELECT id FROM account WHERE name = ${name}),${amount},${tstamp}); # UPDATE balance SET gold = gold - 12.34 WHERE id = (SELECT id FROM account WHERE name = ${name}); @@ -163,12 +163,12 @@ make_withdrawal() { show_balance() { eval "$dbconnect -c \"SELECT account.id,account.name,gold FROM balance INNER JOIN account ON account.id = balance.id ORDER BY name;\"" - show_menu + hold_menu } show_transactions_all() { eval "$dbconnect -c \"SELECT transaction.id,account.name,withdrawal,deposit,timestamp FROM transaction INNER JOIN account ON account.id = transaction.account ORDER BY timestamp;\"" - show_menu + hold_menu } show_transactions() { @@ -176,9 +176,11 @@ show_transactions() { echo eval "$dbconnect -c \"SELECT transaction.id,account.name,withdrawal,deposit,timestamp FROM transaction INNER JOIN account ON account.id = transaction.account ORDER BY timestamp;\"" | grep -iE "$name|timestamp|------" echo - show_menu + hold_menu } -show_menu init +while true; do + show_menu init +done exit 1