Hezci JSON z kasy
authorThomas Mudrunka <tomas@mudrunka.cz>
Fri, 31 May 2013 04:54:42 +0000 (06:54 +0200)
committerThomas Mudrunka <tomas@mudrunka.cz>
Fri, 31 May 2013 04:54:42 +0000 (06:54 +0200)
assistants/bank.inc.php

index eb04f230f993052eac4398ad2fa810e7a18fc05f..0c0e27d3ba7caaf91199dbdcc88421d9d28d4753 100644 (file)
@@ -64,12 +64,16 @@ function bank_rename_account($ctx, $old, $new) {
 function bank_get_overview($ctx,$prefix='') {
        global $bank_table;
        $accounts = bank_get_accounts($ctx);
-       foreach($accounts as $acc) $overview[]=array("${prefix}account"=>$acc,"${prefix}total"=>bank_get_total($ctx, $acc));
+       foreach($accounts as $acc) {
+               $total=bank_get_total($ctx, $acc);
+               $overview['table'][]=array("${prefix}account"=>$acc,"${prefix}total"=>$total);
+               $overview['array'][$acc]=$total;
+       }
        return $overview;
 }
 
 if(isset($bank_json_only) && $bank_json_only) die(json_encode(array(
-       'overview'=>bank_get_overview($this)
+       'overview'=>bank_get_overview($this)['array']
 )));
 
 if(isset($_POST['create_account'])) {
@@ -109,7 +113,7 @@ switch($SUBPATH[0]) {
            $result = $this->db->safe_query_fetch("SELECT SUM(${bank_table}_amount) as troughput FROM ${bank_table};");
                        echo("Obrat: ".$result[0]['troughput'].' '.$bank_currency);
            $result = $this->db->safe_query_fetch("SELECT * FROM `${bank_table}` ORDER BY ${bank_table}_time DESC;");
-                       echo $this->html->render_item_table(bank_get_overview($this, $bank_table.'_'),'bank');
+                       echo $this->html->render_item_table(bank_get_overview($this, $bank_table.'_')['table'],'bank');
                        echo ("<h2>Přehled transakcí</h2>");
                } else {
                        $account=bank_name($_GET['account']);
This page took 0.144891 seconds and 4 git commands to generate.