Limit dlouhejch vypisu v kase
authorThomas Mudrunka <tomas@mudrunka.cz>
Mon, 23 Jun 2014 18:18:26 +0000 (20:18 +0200)
committerThomas Mudrunka <tomas@mudrunka.cz>
Mon, 23 Jun 2014 18:18:26 +0000 (20:18 +0200)
assistants/bank.inc.php

index d6137cf30d54fac64139d22738471fd8e7e6da12..548e56db082d72b2df5478e89e43000457e2b92f 100644 (file)
@@ -3,6 +3,7 @@ $bank_currency='Kč';
 global $bank_table;
 $bank_table='transaction';
 $recursive=true; //USE RECURSIVE QUERIES???
+$limit=23;
 
 function bank_name($name) {
        return strtolower(trim($name));
@@ -145,6 +146,9 @@ foreach($accounts as $account) {
 switch($SUBPATH[0]) {
        default:
 
+               if(isset($_GET['limit'])) $limit = intval($_GET['limit']);
+               $limit_sql = $limit==0 ? '' : ' LIMIT '.intval($limit);
+
                if(!isset($_GET['account'])) {
                        echo("<h1>Banka $month</h1>");
                        echo ("<h2>Stav $month</h2>");
@@ -152,7 +156,7 @@ switch($SUBPATH[0]) {
                        echo("Transakcí $month: ".$result[0]['troughput']."<br />");
                        $result = $this->db->safe_query_fetch("SELECT SUM(${bank_table}_amount) as troughput FROM ${bank_table} WHERE ".bank_month_sql($this,$month).';');
                        echo("Obrat $month: ".$result[0]['troughput'].' '.$bank_currency);
-                       $result = $this->db->safe_query_fetch("SELECT * FROM `${bank_table}` WHERE ".bank_month_sql($this,$month)." ORDER BY ${bank_table}_time DESC;");
+                       $result = $this->db->safe_query_fetch("SELECT * FROM `${bank_table}` WHERE ".bank_month_sql($this,$month)." ORDER BY ${bank_table}_time DESC".$limit_sql.";");
                        $overview=bank_get_overview($this,$bank_table.'_',$month);
                        echo $this->html->render_item_table($overview['table'],'bank');
                } else {
@@ -185,11 +189,16 @@ switch($SUBPATH[0]) {
                                -(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":'';
                        //(@flux := IF(transaction_to='harvie',IF(transaction_from='harvie',0,1),IF(transaction_from='harvie',-1,0))) as flux
-                       $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;");
+                       $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".$limit_sql.";");
                }
                echo ("<h2>Přehled transakcí $month</h2>");
                echo $this->html->render_item_table($result,$bank_table);
 
+               if(!isset($_GET['limit']))
+                       echo("<a href='?".$_SERVER['QUERY_STRING']."&limit=0'>zobrazit vše...</a>");
+               if($limit == 0)
+                       echo('to je vše.');
+
                break;
        case 'admin':
 ?>
This page took 0.242845 seconds and 4 git commands to generate.