Vylepseni chybovejch hlasek
authorThomas Mudrunka <tomas@mudrunka.cz>
Sat, 25 May 2013 01:29:03 +0000 (03:29 +0200)
committerThomas Mudrunka <tomas@mudrunka.cz>
Sat, 25 May 2013 01:29:03 +0000 (03:29 +0200)
assistants/bank.inc.php
index.php

index 670cfba8c2167e87536edafaf5cdce60601761a5..173ff04dde2953d8c69df608f95c7a62e09cc134 100644 (file)
@@ -10,10 +10,7 @@ function bank_transaction($ctx, $from, $to, $comment, $amount=0) {
        $from=$ctx->db->quote(bank_name($from));
        $to=$ctx->db->quote(bank_name($to));
        $amount=$ctx->db->quote($amount);
-
-       $comment=trim($comment);
-       if(strlen($comment)<4) die("Komentář musí mít alespoň 4 znaky!");
-       $comment=$ctx->db->quote($comment);
+       $comment=$ctx->db->quote(trim($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);
@@ -50,9 +47,11 @@ if(isset($_POST['create_account'])) {
        $this->post_redirect_get("$URL_INTERNAL","Účet byl vytvořen");
 }
 if(isset($_POST['transaction'])) {
-       if(!is_numeric($_POST['amount']) || $_POST['amount'] < 0) $this->post_redirect_get("$URL_INTERNAL","Lze převádět jen kladné částky", true);
+       if(!is_numeric($_POST['amount']) || $_POST['amount'] < 0) $this->post_redirect_get("$URL_INTERNAL?account=".$_POST['account_from'],"Lze převádět jen kladné částky", true);
+       $comment=trim($_POST['comment']);
+       if(strlen($comment)<4) $this->post_redirect_get("$URL_INTERNAL?account=".$_POST['account_from'],"Komentář musí mít alespoň 4 znaky!",true);
        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
+       $this->post_redirect_get("$URL_INTERNAL?account=".$_POST['account_from'],"Transakce byla provedena");
 }
 
 //bank_add_account($this, 'material');
index a7059586ba1c7bbe37b6f3b8fa3b87324a264006..903b68328e248dfbcb92c619e95fc1039bbc54ff 100755 (executable)
--- a/index.php
+++ b/index.php
@@ -1015,7 +1015,8 @@ class Sklad_UI {
 
        function post_redirect_get($location, $message='', $error=false, $translate=true) {
                $messaget = $translate ? T($message) : $message;
-               $url_args = $messaget != '' ? '?message='.urlencode($messaget) : '';
+               $separator = preg_match('/\?/', $location) ? '&' : '?';
+               $url_args = $messaget != '' ? $separator.'message='.urlencode($messaget) : '';
                $location = $this->html->internal_url($location).$url_args;
                header('Location: '.$location);
                if($error) trigger_error($message);
This page took 0.245417 seconds and 4 git commands to generate.