diff --git a/.gitignore b/.gitignore index 3268211..9eccd17 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ .*.sw? +*~ diff --git a/brmbar3/USEFUL.txt b/brmbar3/USEFUL.txt new file mode 100644 index 0000000..11c0071 --- /dev/null +++ b/brmbar3/USEFUL.txt @@ -0,0 +1,8 @@ +Accounts with multiple barcodes: + +SELECT accounts.name,barcodes.account,barcodes.barcode +FROM "barcodes" +join accounts on accounts.id = barcodes.account +where barcodes.account in (select a from (select count(*) as c, account as a from barcodes group by account) as dt where c > 1) +ORDER BY "account" DESC + diff --git a/brmbar3/brmbar-gui-qt4/ChargeCredit.qml b/brmbar3/brmbar-gui-qt4/ChargeCredit.qml index 8eda557..cdcc006 100644 --- a/brmbar3/brmbar-gui-qt4/ChargeCredit.qml +++ b/brmbar3/brmbar-gui-qt4/ChargeCredit.qml @@ -100,8 +100,17 @@ Item { } function chargeCredit() { - var balance = shop.chargeCredit(amount, userdbid) - status_text.setStatus("Charged! "+username+"'s credit is "+balance+".", "#ffff7c") + var balance=0 + if (!isNaN(amount)) { + if(amount>=0) { + balance = shop.chargeCredit(amount, userdbid) + status_text.setStatus("Charged "+amount+"! "+username+"'s credit is "+balance+".", "#ffff7c") + } else { + balance = shop.withdrawCredit((amount*(-1)), userdbid) + status_text.setStatus("Withdrawn "+amount+"! "+username+"'s credit is "+balance+".", "#ffff7c") + } + } loadPage("MainPage") + } } diff --git a/brmbar3/brmbar-gui-qt4/Withdraw.qml b/brmbar3/brmbar-gui-qt4/Withdraw.qml index a9e7700..2d8c49b 100644 --- a/brmbar3/brmbar-gui-qt4/Withdraw.qml +++ b/brmbar3/brmbar-gui-qt4/Withdraw.qml @@ -100,8 +100,17 @@ Item { } function withdrawCredit() { - var balance = shop.withdrawCredit(amount, userdbid) - status_text.setStatus("Withdrawn! "+username+"'s credit is "+balance+".", "#ffff7c") + var balance=0 + if (!isNaN(amount)) { + amount=(amount*1) + if(amount>=0) { + balance = shop.withdrawCredit(amount, userdbid) + status_text.setStatus("Withdrawn "+amount+"! "+username+"'s credit is "+balance+".", "#ffff7c") + } else { + balance = shop.chargeCredit((amount*(-1)),userdbid) + status_text.setStatus("Charged "+amount+"! "+username+"'s credit is "+balance+".", "#ffff7c") + } + } loadPage("MainPage") } } diff --git a/brmbar3/dluhy.sh b/brmbar3/dluhy.sh index 5ec9adc..61c2a46 100755 --- a/brmbar3/dluhy.sh +++ b/brmbar3/dluhy.sh @@ -1,3 +1,3 @@ p1=`echo -n "brmbar - dluhy: "; echo "SELECT name, crbalance FROM account_balances WHERE acctype = 'debt' AND crbalance < -100 AND name NOT LIKE '%overflow%' AND name NOT LIKE 'sachyo' ORDER BY crbalance ASC" | psql brmbar | tail -n +3 | grep '|' | tr -s " " | sed -e "s/ |/:/g" -e "s/$/;/" | tr -d "\n"` p2=`echo "SELECT sum(crbalance) FROM account_balances WHERE acctype = 'debt' AND crbalance < 0 AND name NOT LIKE '%overflow%' AND name NOT LIKE 'sachyo'" | psql brmbar | tail -n +3 | head -n 1 | tr -s " "` -echo "$p1 total$p2 Kc" | ssh -p 110 -i /home/brmlab/.ssh/id_rsa jenda@coralmyn.hrach.eu +echo "$p1 total$p2 Kc. https://www.elektro-obojky.cz/" | ssh -p 110 -i /home/brmlab/.ssh/id_rsa jenda@coralmyn.hrach.eu