Mezisoučty v kase (sem zvědavej při kolika radcich se to vysere :-)
authorThomas Mudrunka <tomas@mudrunka.cz>
Sat, 1 Jun 2013 23:53:17 +0000 (01:53 +0200)
committerThomas Mudrunka <tomas@mudrunka.cz>
Sat, 1 Jun 2013 23:54:53 +0000 (01:54 +0200)
assistants/bank.inc.php
locale/cs/messages.inc.php

index f6bc5c5172ee190fd4e45432f2859759bae61b20..4c816cb975abda280ce8e85a5211986b7e7d93f9 100644 (file)
@@ -2,6 +2,7 @@
 $bank_currency='Kč';
 global $bank_table;
 $bank_table='transaction';
+$recursive=true; //USE RECURSIVE QUERIES???
 
 function bank_name($name) {
        return strtolower(trim($name));
@@ -174,7 +175,11 @@ switch($SUBPATH[0]) {
                        <?php
 
                        echo(bank_get_total($this,$account,$month,true)." $bank_currency");
-                       $result = $this->db->safe_query_fetch("SELECT * FROM `${bank_table}` WHERE (`${bank_table}_to`=$account_sql OR `${bank_table}_from`=$account_sql) AND (".bank_month_sql($this,$month).") ORDER BY ${bank_table}_time DESC;");
+                       $subtotal=$recursive?",(
+                               (SELECT SUM(${bank_table}_amount) FROM ${bank_table} x WHERE ${bank_table}_to=$account_sql AND x.${bank_table}_id<=${bank_table}.${bank_table}_id)
+                               -(SELECT SUM(${bank_table}_amount) FROM ${bank_table} x WHERE ${bank_table}_from=$account_sql AND x.${bank_table}_id<=${bank_table}.${bank_table}_id)
+                               ) as ${bank_table}_subtotal":'';
+                       $result = $this->db->safe_query_fetch("SELECT *${subtotal} FROM `${bank_table}` WHERE (`${bank_table}_to`=$account_sql OR `${bank_table}_from`=$account_sql) AND (".bank_month_sql($this,$month).") ORDER BY ${bank_table}_time DESC;"); //TADY
                }
                echo ("<h2>Přehled transakcí $month</h2>");
                echo $this->html->render_item_table($result,$bank_table);
index f8316e8ac194f62ebdc19355d0421fdcfb45f688..94e86f40f925718d5f2d6e354293a406dd400c02 100644 (file)
@@ -71,6 +71,7 @@ $LOCALE_MESSAGES = array(
                'transaction_author_backend' => 'Odpověný',
                'transaction_comment' => 'Popis',
                'transaction_total' => 'Součet',
+               'transaction_subtotal' => 'Mezisoučet',
                'transaction_account' => 'Účet',
 
                'model_relations' => 'Souvisejici s timto modelem',
This page took 0.132672 seconds and 4 git commands to generate.