X-Git-Url: https://git.harvie.cz/?a=blobdiff_plain;f=assistants%2Fbank.inc.php;h=067e98943b2859fc9adb18b90057859585d5a2f2;hb=7da3f2f4cedfd49dc4cc946f6f0e63846089e23e;hp=449249b986a79ced98ddf827cae5c2f43c31723c;hpb=ee2e74152b83654cd26c2e913555f147e6fa19e2;p=mirrors%2FSokoMan.git
diff --git a/assistants/bank.inc.php b/assistants/bank.inc.php
index 449249b..067e989 100644
--- a/assistants/bank.inc.php
+++ b/assistants/bank.inc.php
@@ -26,6 +26,13 @@ function bank_get_accounts($ctx, $all=false) {
return $accounts;
}
+function bank_get_last_to($ctx, $account) {
+ global $bank_table;
+ $account=$ctx->db->quote(bank_name($account));
+ $fetch = $ctx->db->safe_query_fetch("SELECT ${bank_table}_to FROM ${bank_table} WHERE ${bank_table}_from=$account ORDER BY ${bank_table}_time DESC LIMIT 1;");
+ return $fetch[0][$bank_table.'_to'];
+}
+
function bank_add_account($ctx, $name) {
bank_transaction($ctx, $name, $name, "Created account \"$name\"");
}
@@ -54,22 +61,33 @@ function bank_rename_account($ctx, $old, $new) {
);
}
-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");
+ $this->post_redirect_get("$URL_INTERNAL/admin","ÃÄet byl vytvoÅen");
}
if(isset($_POST['rename_account'])) {
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 byl upraven");
} else {
- $this->post_redirect_get("$URL_INTERNAL","Takový úÄet již existuje!", false);
+ $this->post_redirect_get("$URL_INTERNAL/admin","Takový úÄet již existuje!", false);
}
}
if(isset($_POST['transaction'])) {
@@ -82,10 +100,15 @@ if(isset($_POST['transaction'])) {
//bank_add_account($this, 'material');
echo("Banka - ");
-echo("Správa úÄtů - ");
-echo("ÃÄty: ");
+echo("Správa úÄtů - ");
+echo("ÃÄty:
");
$accounts = bank_get_accounts($this, $SUBPATH[0]=='admin');
-foreach($accounts as $account) echo("$account, ");
+$lastaccount=false;
+foreach($accounts as $account) {
+ if($lastaccount && $lastaccount[0]!=$account[0] && !preg_match('/[a-zA-Z0-9]/', $lastaccount[0])) echo('
');
+ echo("$account, ");
+ $lastaccount=$account;
+}
switch($SUBPATH[0]) {
default:
@@ -98,7 +121,8 @@ switch($SUBPATH[0]) {
$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 ("