use parent qw(SL::Controller::Base);
+use SL::Controller::Helper::Filtered;
use SL::Controller::Helper::GetModels;
use SL::Controller::Helper::Paginated;
use SL::Controller::Helper::Sorted;
use Rose::Object::MakeMethods::Generic
(
- scalar => [ qw(history) ],
+ scalar => [ qw(history db_args flat_filter filter_summary) ],
'scalar --get_set_init' => [ qw(task_server) ],
);
__PACKAGE__->run_before('add_stylesheet');
__PACKAGE__->run_before('check_task_server');
+__PACKAGE__->make_filtered(
+ MODEL => 'BackgroundJobHistory',
+ LAUNDER_TO => 'filter'
+);
__PACKAGE__->make_paginated(ONLY => [ qw(list) ]);
__PACKAGE__->make_sorted(
sub action_list {
my ($self) = @_;
+ $self->make_filter_summary;
+
$self->render('background_job_history/list',
title => $::locale->text('Background job history'),
ENTRIES => $self->get_models);
$::request->{layout}->use_stylesheet('lx-office-erp/background_jobs.css');
}
+sub make_filter_summary {
+ my ($self) = @_;
+
+ my $filter = $::form->{filter} || {};
+ my @filters = (
+ [ "package_name:substr::ilike", $::locale->text('Package name') ],
+ [ "result:substr::ilike", $::locale->text('Result') ],
+ [ "error:substr::ilike", $::locale->text('Error') ],
+ [ "run_at:date::ge", $::locale->text('Run at') . " " . $::locale->text('From Date') ],
+ [ "run_at:date::le", $::locale->text('Run at') . " " . $::locale->text('To Date') ],
+ );
+
+ my @filter_strings = grep { $_ }
+ map { $filter->{ $_->[0] } ? $_->[1] . ' ' . $filter->{ $_->[0] } : undef }
+ @filters;
+
+ my %status = (
+ failed => $::locale->text('failed'),
+ success => $::locale->text('succeeded'),
+ );
+ push @filter_strings, $status{ $filter->{'status:eq_ignore_empty'} } if $filter->{'status:eq_ignore_empty'};
+
+ $self->filter_summary(join(', ', @filter_strings));
+}
+
1;
'Current / Next Level' => 'Aktuelles / Nächstes Mahnlevel',
'Current Earnings' => 'Gewinn',
'Current assets account' => 'Konto für Umlaufvermögen',
+ 'Current filter' => 'Aktueller Filter',
'Current profile' => 'Aktuelles Profil',
'Current status' => 'Aktueller Status',
'Current value:' => 'Aktueller Wert:',
--- /dev/null
+[%- USE L %][%- USE LxERP %][%- USE HTML %]
+<form action="controller.pl" method="post">
+ <div class="filter_toggle">
+ <a href="#" onClick="javascript:$('.filter_toggle').toggle()">[% LxERP.t8('Show Filter') %]</a>
+ [% IF SELF.filter_summary %]([% LxERP.t8("Current filter") %]: [% SELF.filter_summary %])[% END %]
+ </div>
+
+ <div class="filter_toggle" style="display:none">
+ <a href="#" onClick="javascript:$('.filter_toggle').toggle()">[% LxERP.t8('Hide Filter') %]</a>
+ <table id="filter_table">
+ <tr>
+ <th align="right">[% LxERP.t8('Package name') %]</th>
+ <td>[% L.input_tag('filter.package_name:substr::ilike', filter.package_name_substr__ilike, size = 20) %]</td>
+ </tr>
+ <tr>
+ <th align="right">[% LxERP.t8('Result') %]</th>
+ <td>[% L.input_tag('filter.result:substr::ilike', filter.result_substr__ilike, size = 20) %]</td>
+ </tr>
+ <tr>
+ <th align="right">[% LxERP.t8('Error') %]</th>
+ <td>[% L.input_tag('filter.error:substr::ilike', filter.error_substr__ilike, size = 20) %]</td>
+ </tr>
+ <tr>
+ <th align="right">[% LxERP.t8('Status') %]</th>
+ <td>[% L.select_tag('filter.status:eq_ignore_empty', [ [ '', '' ], [ 'failed', LxERP.t8('failed') ], [ 'success', LxERP.t8('succeeded') ] ], default=filter.status_eq_ignore_empty) %]</td>
+ </tr>
+ <tr>
+ <th align="right">[% LxERP.t8('Run at') %] [% LxERP.t8('From Date') %]</th>
+ <td>[% L.date_tag('filter.run_at:date::ge', filter.run_at_date__ge) %]</td>
+ </tr>
+ <tr>
+ <th align="right">[% LxERP.t8('Run at') %] [% LxERP.t8('To Date') %]</th>
+ <td>[% L.date_tag('filter.run_at:date::le', filter.run_at_date__le) %]</td>
+ </tr>
+ </table>
+
+ [% L.hidden_tag('action', 'BackgroundJobHistory/dispatch') %]
+ [% L.hidden_tag('sort_by', FORM.sort_by) %]
+ [% L.hidden_tag('sort_dir', FORM.sort_dir) %]
+ [% L.hidden_tag('page', FORM.page) %]
+ [% L.submit_tag('action_list', LxERP.t8('Continue'))%]
+
+ <a href="#" onClick="javascript:$('#filter_table input,#filter_table select').val('');">[% LxERP.t8('Reset') %]</a>
+
+ </div>
+
+</form>
[% USE HTML %][% USE L %][% USE LxERP %]
- <h1>[% FORM.title %]</h1>
+<h1>[% FORM.title %]</h1>
[%- INCLUDE 'common/flash.html' %]
- <form method="post" action="controller.pl">
- [% IF !ENTRIES.size %]
- <p>
- [%- LxERP.t8('There are no entries in the background job history.') %]
- </p>
-
- [%- ELSE %]
- <table id="background_job_history_list" class="background_job_list" width="100%">
- <thead>
- <tr class="listheading">
- <th>[% L.sortable_table_header('package_name') %]</th>
- <th>[% L.sortable_table_header('run_at') %]</th>
- <th>[% L.sortable_table_header('status') %]</th>
- <th>[% L.sortable_table_header('result') %]</th>
- <th>[% L.sortable_table_header('error') %]</th>
- </tr>
- </thead>
-
- <tbody>
- [%- FOREACH entry = ENTRIES %]
- <tr class="listrow[% loop.count % 2 %]" id="background_job_history_id_[% entry.id %]">
- <td>
- <a href="[% SELF.url_for(action => 'show', id => entry.id, back_to => SELF.get_callback) %]">
- [%- HTML.escape(entry.package_name) %]
- </a>
- </td>
- <td>[%- HTML.escape(entry.run_at.to_lxoffice('precision' => 'second')) %]</td>
- <td>
- [%- IF entry.status == 'success' %]
- [%- LxERP.t8('succeeded') %]
- [%- ELSIF entry.status == 'failure' %]
- [%- LxERP.t8('failed') %]
- [%- ELSE %]
- [%- HTML.escape(entry.status) %]
- [%- END %]
- </td>
- <td>[%- HTML.escape(entry.result) %]</td>
- <td>[% IF entry.error_col %]<pre>[%- HTML.escape(L.truncate(entry.error_col)) %]</pre>[%- END %]</td>
- </tr>
+[%- PROCESS 'background_job_history/_filter.html' filter=SELF.filter %]
+
+[% IF !ENTRIES.size %]
+ <p>
+ [%- LxERP.t8('There are no entries in the background job history.') %]
+ </p>
+
+[%- ELSE %]
+ <table id="background_job_history_list" class="background_job_list" width="100%">
+ <thead>
+ <tr class="listheading">
+ <th>[% L.sortable_table_header('package_name') %]</th>
+ <th>[% L.sortable_table_header('run_at') %]</th>
+ <th>[% L.sortable_table_header('status') %]</th>
+ <th>[% L.sortable_table_header('result') %]</th>
+ <th>[% L.sortable_table_header('error') %]</th>
+ </tr>
+ </thead>
+
+ <tbody>
+ [%- FOREACH entry = ENTRIES %]
+ <tr class="listrow[% loop.count % 2 %]" id="background_job_history_id_[% entry.id %]">
+ <td>
+ <a href="[% SELF.url_for(action => 'show', id => entry.id, back_to => SELF.get_callback) %]">
+ [%- HTML.escape(entry.package_name) %]
+ </a>
+ </td>
+ <td>[%- HTML.escape(entry.run_at.to_lxoffice('precision' => 'second')) %]</td>
+ <td>
+ [%- IF entry.status == 'success' %]
+ [%- LxERP.t8('succeeded') %]
+ [%- ELSIF entry.status == 'failure' %]
+ [%- LxERP.t8('failed') %]
+ [%- ELSE %]
+ [%- HTML.escape(entry.status) %]
[%- END %]
- </tbody>
- </table>
+ </td>
+ <td>[%- HTML.escape(entry.result) %]</td>
+ <td>[% IF entry.error_col %]<pre>[%- HTML.escape(L.truncate(entry.error_col)) %]</pre>[%- END %]</td>
+ </tr>
[%- END %]
+ </tbody>
+ </table>
+[%- END %]
- [% L.paginate_controls %]
+[% L.paginate_controls %]
- <hr size="3" noshade>
+<hr size="3" noshade>
- <p>
- <a href="[% SELF.url_for(controller => 'BackgroundJob', action => 'list') %]">[%- LxERP.t8('View background jobs') %]</a>
- |
- <a href="[% SELF.url_for(controller => 'TaskServer', action => 'show') %]">[%- LxERP.t8('Task server control') %]</a>
- </p>
- </form>
+<p>
+ <a href="[% SELF.url_for(controller => 'BackgroundJob', action => 'list') %]">[%- LxERP.t8('View background jobs') %]</a>
+ |
+ <a href="[% SELF.url_for(controller => 'TaskServer', action => 'show') %]">[%- LxERP.t8('Task server control') %]</a>
+</p>