);
}
-function bank_get_overview($ctx) {
+function bank_get_overview($ctx,$prefix='') {
global $bank_table;
$accounts = bank_get_accounts($ctx);
- foreach($accounts as $acc) $overview[]=array("${bank_table}_account"=>$acc,"${bank_table}_total"=>bank_get_total($ctx, $acc));
+ foreach($accounts as $acc) {
+ $total=bank_get_total($ctx, $acc);
+ $overview['table'][]=array("${prefix}account"=>$acc,"${prefix}total"=>$total);
+ $overview['array'][$acc]=$total;
+ }
return $overview;
}
+if(isset($bank_json_only) && $bank_json_only) {
+ $overview=bank_get_overview($this);
+ die(json_encode(array(
+ 'overview'=>$overview['array']
+ )));
+}
+
if(isset($_POST['create_account'])) {
- bank_add_account($this, $_POST['account_name']);
- $this->post_redirect_get("$URL_INTERNAL","Účet byl vytvořen");
+ $new_account=$_POST['account_name'];
+ bank_add_account($this, $new_account);
+ $this->post_redirect_get("$URL_INTERNAL/admin","Účet <b>$new_account</b> byl vytvořen!");
}
if(isset($_POST['rename_account'])) {
+ $new_account=$_POST['account_new'];
+ $old_account=$_POST['account_old'];
if(bank_rename_account($this, $_POST['account_old'], $_POST['account_new'])) {
- $this->post_redirect_get("$URL_INTERNAL","Účet byl upraven");
+ $this->post_redirect_get("$URL_INTERNAL/admin","Účet <b>$old_account</b> byl přejmenován na <b>$new_account</b>!");
} else {
- $this->post_redirect_get("$URL_INTERNAL","Takový účet již existuje!", false);
+ $this->post_redirect_get("$URL_INTERNAL/admin","Účet <b>$new_account</b> již existuje!", false);
}
}
if(isset($_POST['transaction'])) {
- 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);
+ $account_from=$_POST['account_from'];
+ $account_to=$_POST['account_to'];
+ $amount=$_POST['amount'];
$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?account=".$_POST['account_from'],"Transakce byla provedena");
+ if(!is_numeric($amount) || $amount < 0) $this->post_redirect_get("$URL_INTERNAL?account=".$account_from,"Lze převádět jen kladné částky", true);
+ if(strlen($comment)<4) $this->post_redirect_get("$URL_INTERNAL?account=".$account_from,"Komentář musí mít alespoň 4 znaky!",true);
+ bank_transaction($this, $account_from, $account_to, $comment, $amount);
+ $this->post_redirect_get("$URL_INTERNAL?account=".$account_from,"Transakce byla provedena:<br />Převod <b>$amount $bank_currency</b> z účtu <b>$account_from</b> na účet <b>$account_to</b>.<br />($comment)");
}
//bank_add_account($this, 'material');
echo("<a href='$URL/'>Banka</a> - ");
-echo("<a href='$URL/admin'>Správa účtů</a> - ");
-echo("Účty: ");
+echo("<a href='$URL/admin'>Správa účtů - </a>");
+echo("Účty: <br />");
$accounts = bank_get_accounts($this, $SUBPATH[0]=='admin');
-foreach($accounts as $account) echo("<a href='$URL?account=$account'>$account</a>, ");
+$lastaccount=false;
+foreach($accounts as $account) {
+ if($lastaccount && $lastaccount[0]!=$account[0] && !preg_match('/[a-zA-Z0-9]/', $lastaccount[0])) echo('<br />');
+ echo("<a href='$URL?account=$account'>$account</a>, ");
+ $lastaccount=$account;
+}
switch($SUBPATH[0]) {
default:
$result = $this->db->safe_query_fetch("SELECT SUM(${bank_table}_amount) as troughput FROM ${bank_table};");
echo("Obrat: ".$result[0]['troughput'].' '.$bank_currency);
$result = $this->db->safe_query_fetch("SELECT * FROM `${bank_table}` ORDER BY ${bank_table}_time DESC;");
- echo $this->html->render_item_table(bank_get_overview($this),'bank');
+ $overview=bank_get_overview($this,$bank_table.'_');
+ echo $this->html->render_item_table($overview['table'],'bank');
echo ("<h2>Přehled transakcí</h2>");
} else {
$account=bank_name($_GET['account']);