MFG stary php na produkcnim serveru
[mirrors/SokoMan.git] / assistants / bank.inc.php
index 3040f0e0115a222b5ecb6b180ff9f98b6275cbde..73ea875d22a30af1b776fd8ead47d4defcd285e4 100644 (file)
@@ -61,13 +61,24 @@ 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) {
+               $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) {
+       $overview=bank_get_overview($this);
+       die(json_encode(array(
+               'overview'=>$overview['array']
+       )));
+}
+
 if(isset($_POST['create_account'])) {
        bank_add_account($this, $_POST['account_name']);
        $this->post_redirect_get("$URL_INTERNAL","Účet byl vytvořen");
@@ -105,7 +116,8 @@ 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');
+                       $overview=bank_get_overview($this,$bank_table.'_');
+                       echo $this->html->render_item_table($overview['table'],'bank');
                        echo ("<h2>Přehled transakcí</h2>");
                } else {
                        $account=bank_name($_GET['account']);
@@ -115,7 +127,7 @@ switch($SUBPATH[0]) {
                        ?>
                        <form action="?" method="POST">
                                Převést <input type="number" name="amount" value="" /> <?php echo $bank_currency; ?>
-                               z účtu <?php echo $account; ?> <input type="hidden" name="account_from" value="<?php echo $account; ?>" />
+                               z účtu <b><?php echo $account; ?></b> <input type="hidden" name="account_from" value="<?php echo $account; ?>" />
                                na účet <select name='account_to'>
                                        <?php
                                                //Ziskat posledni cilovy ucet a presunout na zacatek $accounts
This page took 0.105034 seconds and 4 git commands to generate.