+function bank_get_total($ctx, $account, $string=false) {
+ $account_sql=$ctx->db->quote($account);
+ $result = $ctx->db->safe_query_fetch("SELECT SUM(bank_amount) FROM `bank` WHERE `bank_to`=$account_sql;");
+ $deposits = $result[0]['SUM(bank_amount)'];
+ $result = $ctx->db->safe_query_fetch("SELECT SUM(bank_amount) FROM `bank` WHERE `bank_from`=$account_sql;");
+ $withdrawals = $result[0]['SUM(bank_amount)'];
+ if($string) return "$deposits-$withdrawals";
+ return $deposits-$withdrawals;
+}
+
+function bank_get_overview($ctx) {
+ $accounts = bank_get_accounts($ctx);
+ foreach($accounts as $acc) $overview[]=array("bank_account"=>$acc,"bank_total"=>bank_get_total($ctx, $acc));
+ return $overview;
+}
+