Added cancellation option to the start of most functions

master
Aaron Johnson 4 years ago
parent 95f3f61cb0
commit 8057215475

15
bank

@ -112,7 +112,8 @@ get_name() {
} }
create_account() { create_account() {
read -p "Enter Account Name: " name read -p "Enter Account Name ('c' to cancel): " name
([ "$name" == "c" ] || [ "$name" == "c" ]) && return
tstamp=$(date +%Y-%m-%d\ %H:%M:%S) tstamp=$(date +%Y-%m-%d\ %H:%M:%S)
read -p "Creating account: '${name}'. Are you sure? (y/N)" -n1 CONFIRM read -p "Creating account: '${name}'. Are you sure? (y/N)" -n1 CONFIRM
case $CONFIRM in case $CONFIRM in
@ -132,7 +133,8 @@ create_account() {
disable_account() { disable_account() {
eval "$dbconnect -c \"SELECT id,name,created FROM account WHERE enabled = true ORDER BY name;\"" eval "$dbconnect -c \"SELECT id,name,created FROM account WHERE enabled = true ORDER BY name;\""
read -p "Enter Account ID: " ID read -p "Enter Account ID ('c' to cancel): " ID
([ "$ID" == "c" ] || [ "$ID" == "c" ]) && return
read -p "$(tput bold)$(tput setaf 3)DISABLING$(tput sgr0) account #${ID}: $(get_name $ID bold). Are you sure? (y/N)" -n1 CONFIRM read -p "$(tput bold)$(tput setaf 3)DISABLING$(tput sgr0) account #${ID}: $(get_name $ID bold). Are you sure? (y/N)" -n1 CONFIRM
case $CONFIRM in case $CONFIRM in
[Yy]) [Yy])
@ -151,7 +153,8 @@ disable_account() {
enable_account() { enable_account() {
echo "DISABLED Accounts:" echo "DISABLED Accounts:"
eval "$dbconnect -c \"SELECT id,name,created FROM account WHERE enabled = false ORDER BY name;\"" eval "$dbconnect -c \"SELECT id,name,created FROM account WHERE enabled = false ORDER BY name;\""
read -p "Enter Account ID: " ID read -p "Enter Account ID ('c' to cancel): " ID
([ "$ID" == "c" ] || [ "$ID" == "c" ]) && return
read -p "$(tput bold)Enabling$(tput sgr0) account #${ID}: $(get_name $ID bold). Are you sure? (y/N)" -n1 CONFIRM read -p "$(tput bold)Enabling$(tput sgr0) account #${ID}: $(get_name $ID bold). Are you sure? (y/N)" -n1 CONFIRM
case $CONFIRM in case $CONFIRM in
[Yy]) [Yy])
@ -169,7 +172,8 @@ enable_account() {
make_deposit() { make_deposit() {
eval "$dbconnect -c \"SELECT id,name FROM account WHERE enabled = true ORDER BY name;\"" eval "$dbconnect -c \"SELECT id,name FROM account WHERE enabled = true ORDER BY name;\""
read -p "Enter Account ID: " ID read -p "Enter Account ID ('c' to cancel): " ID
([ "$ID" == "c" ] || [ "$ID" == "c" ]) && return
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) tstamp=$(date +%Y-%m-%d\ %H:%M:%S)
read -p "Depositing ${amount}gp into account #${ID}: $(get_name $ID bold). Are you sure? (y/N)" -n1 CONFIRM read -p "Depositing ${amount}gp into account #${ID}: $(get_name $ID bold). Are you sure? (y/N)" -n1 CONFIRM
@ -192,7 +196,8 @@ make_deposit() {
make_withdrawal() { make_withdrawal() {
eval "$dbconnect -c \"SELECT account.id,account.name,gold FROM balance INNER JOIN account ON account.id = balance.id WHERE account.enabled = true ORDER BY name;\"" #Show balances first eval "$dbconnect -c \"SELECT account.id,account.name,gold FROM balance INNER JOIN account ON account.id = balance.id WHERE account.enabled = true ORDER BY name;\"" #Show balances first
read -p "Enter Account ID: " ID read -p "Enter Account ID ('c' to cancel): " ID
([ "$ID" == "c" ] || [ "$ID" == "c" ]) && return
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) tstamp=$(date +%Y-%m-%d\ %H:%M:%S)
read -p "Withdrawing ${amount}gp from account #${ID}: $(get_name $ID bold). Are you sure? (y/N)" -n1 CONFIRM read -p "Withdrawing ${amount}gp from account #${ID}: $(get_name $ID bold). Are you sure? (y/N)" -n1 CONFIRM

Loading…
Cancel
Save