JSON API ke kase
authorThomas Mudrunka <tomas@mudrunka.cz>
Fri, 31 May 2013 04:43:44 +0000 (06:43 +0200)
committerThomas Mudrunka <tomas@mudrunka.cz>
Fri, 31 May 2013 04:43:44 +0000 (06:43 +0200)
apis/bank.inc.php [new file with mode: 0644]
assistants/bank.inc.php

diff --git a/apis/bank.inc.php b/apis/bank.inc.php
new file mode 100644 (file)
index 0000000..419dd35
--- /dev/null
@@ -0,0 +1,3 @@
+<?php
+$bank_json_only=true;
+require('assistants/bank.inc.php');
index d01d8c45816b45597956a997915a3ec5152a07e2..eb04f230f993052eac4398ad2fa810e7a18fc05f 100644 (file)
@@ -61,13 +61,17 @@ function bank_rename_account($ctx, $old, $new) {
        );
 }
 
-function bank_get_overview($ctx) {
+function bank_get_overview($ctx,$prefix='') {
        global $bank_table;
        $accounts = bank_get_accounts($ctx);
-       foreach($accounts as $acc) $overview[]=array("${bank_table}_account"=>$acc,"${bank_table}_total"=>bank_get_total($ctx, $acc));
+       foreach($accounts as $acc) $overview[]=array("${prefix}account"=>$acc,"${prefix}total"=>bank_get_total($ctx, $acc));
        return $overview;
 }
 
+if(isset($bank_json_only) && $bank_json_only) die(json_encode(array(
+       'overview'=>bank_get_overview($this)
+)));
+
 if(isset($_POST['create_account'])) {
        bank_add_account($this, $_POST['account_name']);
        $this->post_redirect_get("$URL_INTERNAL","Účet byl vytvořen");
@@ -105,7 +109,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');
+                       echo $this->html->render_item_table(bank_get_overview($this, $bank_table.'_'),'bank');
                        echo ("<h2>Přehled transakcí</h2>");
                } else {
                        $account=bank_name($_GET['account']);
This page took 0.339134 seconds and 4 git commands to generate.