From: Thomas Mudrunka Date: Fri, 24 May 2013 23:58:48 +0000 (+0200) Subject: Podpora kasy X-Git-Url: https://git.harvie.cz/?a=commitdiff_plain;h=f94aa899b883c5d3218699245c0d75965d1d98fb;p=mirrors%2FSokoMan.git Podpora kasy --- diff --git a/assistants/bank.inc.php b/assistants/bank.inc.php new file mode 100644 index 0000000..4c64d0d --- /dev/null +++ b/assistants/bank.inc.php @@ -0,0 +1,92 @@ +db->quote($ctx->db->auth->get_user_id()); + $from=$ctx->db->quote(bank_name($from)); + $to=$ctx->db->quote(bank_name($to)); + + $comment=trim($comment); + if(strlen($comment)<4) die("Komentář musí mít alespoň 4 znaky!"); + $comment=$ctx->db->quote($comment); + + $sql="INSERT INTO `bank` (`bank_time`, `bank_from`, `bank_to`, `bank_amount`, `bank_author`, `bank_comment`) VALUES (now(), $from, $to, $amount, $author, $comment);"; + $ctx->db->safe_query($sql); +} + +function bank_get_accounts($ctx) { + $fetch = $ctx->db->safe_query_fetch('SELECT DISTINCT bank_to FROM bank ORDER BY bank_to;'); + foreach($fetch as $account) $accounts[]=$account['bank_to']; + return $accounts; +} + +function bank_add_account($ctx, $name) { + bank_transaction($ctx, $name, $name, "Created account \"$name\""); +} + +if(isset($_POST['create_account'])) { + bank_add_account($this, $_POST['account_name']); + $this->post_redirect_get("$URL_INTERNAL","Účet byl vytvořen"); +} +if(isset($_POST['transaction'])) { + bank_transaction($this, $_POST['account_from'], $_POST['account_to'], $_POST['comment'], $_POST['amount']); + $this->post_redirect_get("$URL_INTERNAL","Transakce byla provedena"); //TODO redirect na account_from +} + +//bank_add_account($this, 'material'); + 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

"); + $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;"); + } 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.")

"); + + ?> +
+ Převést + z účtu + na účet (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;"); + } + echo $this->html->render_item_table($result); + + + break; + case 'admin': +?> +
+ Account name: + + +
+ 'return($this->auth->get_username_by_id($result[$key][$col]));', - 'lock_author' => 'return($this->auth->get_username_by_id($result[$key][$col]));' + 'lock_author' => 'return($this->auth->get_username_by_id($result[$key][$col]));', + 'bank_author' => 'return($this->auth->get_username_by_id($result[$key][$col]));' ); //TODO: Hardcoded foreach($result as $key => $row) { foreach($translate_cols as $col => $backend) if(isset($result[$key][$col])){ diff --git a/locale/cs/messages.inc.php b/locale/cs/messages.inc.php index d7a4b8a..2bef640 100644 --- a/locale/cs/messages.inc.php +++ b/locale/cs/messages.inc.php @@ -57,6 +57,15 @@ $LOCALE_MESSAGES = array( 'status_name' => 'Stav', 'category_name' => 'Kategorie', + 'bank_id' => 'Transakce', + 'bank_time' => 'Čas', + 'bank_from' => 'Zdrojový účet', + 'bank_to' => 'Cílový účet', + 'bank_amount' => 'Částka', + 'bank_author' => 'Odpověný', + 'bank_author_backend' => 'Odpověný', + 'bank_comment' => 'Popis', + 'model_relations' => 'Souvisejici s timto modelem', 'category_relations' => 'V teto kategorii', 'producer_relations' => 'Od tohoto vyrobce',