From 98437b3bc357f5fed5b5c3a8fd2e04f5539b8901 Mon Sep 17 00:00:00 2001 From: Thomas Mudrunka Date: Sat, 25 May 2013 03:17:36 +0200 Subject: [PATCH] =?utf8?q?Hez=C4=8D=C3=AD=20p=C5=99ehled=20v=20bance?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- assistants/bank.inc.php | 46 ++++++++++++++++++++++++++------------ locale/cs/messages.inc.php | 2 ++ 2 files changed, 34 insertions(+), 14 deletions(-) diff --git a/assistants/bank.inc.php b/assistants/bank.inc.php index 06a0155..670cfba 100644 --- a/assistants/bank.inc.php +++ b/assistants/bank.inc.php @@ -29,6 +29,22 @@ function bank_add_account($ctx, $name) { bank_transaction($ctx, $name, $name, "Created account \"$name\""); } +function bank_get_total($ctx, $account, $string=false) { + $account_sql=$ctx->db->quote($account); + $result = $ctx->db->safe_query_fetch("SELECT SUM(bank_amount) FROM `bank` WHERE `bank_to`=$account_sql;"); + $deposits = $result[0]['SUM(bank_amount)']; + $result = $ctx->db->safe_query_fetch("SELECT SUM(bank_amount) FROM `bank` WHERE `bank_from`=$account_sql;"); + $withdrawals = $result[0]['SUM(bank_amount)']; + if($string) return "$deposits-$withdrawals"; + return $deposits-$withdrawals; +} + +function bank_get_overview($ctx) { + $accounts = bank_get_accounts($ctx); + foreach($accounts as $acc) $overview[]=array("bank_account"=>$acc,"bank_total"=>bank_get_total($ctx, $acc)); + return $overview; +} + if(isset($_POST['create_account'])) { bank_add_account($this, $_POST['account_name']); $this->post_redirect_get("$URL_INTERNAL","Účet byl vytvořen"); @@ -40,28 +56,29 @@ if(isset($_POST['transaction'])) { } //bank_add_account($this, 'material'); - echo("Banka - "); - echo("Správa účtů - "); - echo("Účty: "); - $accounts = bank_get_accounts($this); - foreach($accounts as $account) echo("$account, "); +echo("Banka - "); +echo("Správa účtů - "); +echo("Účty: "); +$accounts = bank_get_accounts($this); +foreach($accounts as $account) echo("$account, "); switch($SUBPATH[0]) { default: if(!isset($_GET['account'])) { echo("

Banka

"); + echo ("

Stav

"); + $result = $this->db->safe_query_fetch("SELECT COUNT(bank_amount) as troughput FROM bank;"); + echo("Transakcí: ".$result[0]['troughput']."
"); $result = $this->db->safe_query_fetch("SELECT SUM(bank_amount) as troughput FROM bank;"); echo("Obrat: ".$result[0]['troughput'].' '.$bank_currency); $result = $this->db->safe_query_fetch("SELECT * FROM `bank` ORDER BY bank_time DESC;"); + echo $this->html->render_item_table(bank_get_overview($this)); + echo ("

Přehled transakcí

"); } else { $account=bank_name($_GET['account']); $account_sql=$this->db->quote($account); - $result = $this->db->safe_query_fetch("SELECT SUM(bank_amount) FROM `bank` WHERE `bank_to`=$account_sql;"); - $deposits = $result[0]['SUM(bank_amount)']; - $result = $this->db->safe_query_fetch("SELECT SUM(bank_amount) FROM `bank` WHERE `bank_from`=$account_sql;"); - $withdrawals = $result[0]['SUM(bank_amount)']; - echo("

Účet: ".$_GET['account']." (".($deposits-$withdrawals).$bank_currency.")

"); + echo("

Účet: ".$account." (".bank_get_total($this,$account).$bank_currency.")

"); ?>
@@ -69,27 +86,28 @@ switch($SUBPATH[0]) { z účtu na účet (pozor, dluhy se převádí opačným směrem než peníze!)
- Důvod: + (pozor, dluhy se převádí opačným směrem než peníze!)

+ Důvod:
db->safe_query_fetch("SELECT * FROM `bank` WHERE `bank_to`=$account_sql OR `bank_from`=$account_sql ORDER BY bank_time DESC;"); } $this->html->table_hide_columns($result, 'bank'); echo $this->html->render_item_table($result); - break; case 'admin': ?> +

Account name:
+

'Odpověný', 'bank_author_backend' => 'Odpověný', 'bank_comment' => 'Popis', + 'bank_total' => 'Součet', + 'bank_account' => 'Účet', 'model_relations' => 'Souvisejici s timto modelem', 'category_relations' => 'V teto kategorii', -- 2.30.2