Added categories and Filter widget

This commit is contained in:
Florian "flowdy" Heß
2017-01-29 15:57:34 +01:00
parent 6f19437901
commit d7db9a2eb1
23 changed files with 167 additions and 40 deletions

View File

@@ -59,9 +59,17 @@ sub upsert {
sub history {
my $self = shift;
my $history = $self->app->db->resultset("History")->search({
account => $self->stash("account")
}, { order_by => { -desc => [qw/date/] } });
my %query = ( account => $self->stash("account") );
if ( my $p = $self->param("purpose") ) {
# ...
}
my $history = $self->app->db->resultset("History")->search(
TrsrDB::HTTP::process_table_filter_widget(
$self, \%query,
{ order_by => { -desc => [qw/date/] } }
)
);
$self->stash( history => $history );
}

View File

@@ -20,7 +20,9 @@ sub list {
}
my $rs = $account->search_related(
credits => {}, { order_by => { -desc => [qw/date/] } }
credits => TrsrDB::HTTP::process_table_filter_widget(
$self, {}, { order_by => { -desc => [qw/date/] }}
)
);
$self->stash( credits => $rs );
@@ -39,14 +41,20 @@ sub upsert {
account => $self->stash("account"),
date => strftime("%Y-%m-%d", localtime)
});
$self->stash( credit => $credit );
$self->stash(
credit => $credit,
categories => $db->resultset("Category")->search_rs({}, {
order_by => { -asc => [qw/ID/] }
})
);
if ( $self->req->method eq 'GET' ) {
return;
}
for my $field ( qw/account date purpose value/ ) {
for my $field ( qw/account date purpose category value/ ) {
my $value = $self->param($field);
$value = undef if !length $value;
$credit->$field($value);
}
$credit->update_or_insert();

View File

@@ -20,7 +20,9 @@ sub list {
}
my $rs = $account->search_related(
debits => {}, { order_by => { -desc => [qw/date/] }}
debits => TrsrDB::HTTP::process_table_filter_widget(
$self, {}, { order_by => { -desc => [qw/date/] }}
)
);
$self->stash( debits => $rs );
@@ -33,7 +35,7 @@ sub upsert {
my $db = $self->app->db;
my $id = $self->stash("id");
my @FIELDS = qw/billId date purpose value targetCredit/;
my @FIELDS = qw/billId date purpose category value targetCredit/;
my $debtor = $self->stash("account") // $self->param("debtor");
if ( $self->req->method eq 'POST' && $debtor =~ s{^@}{} ) {
@@ -74,7 +76,14 @@ sub upsert {
}
);
my @targets = map { [ $_->credId, $_->account->ID, $_->purpose ] } $targets->all;
$self->stash( targets => \@targets, targets_count => $targets->count );
my $categories = $db->resultset("Category")->search_rs({}, {
order_by => { -asc => [qw/ID/] }
});
$self->stash(
categories => $categories,
targets => \@targets,
targets_count => $targets->count
);
return;
}