From c1a0f5b1edbdcf349ea5cab1c75821094c6ebf69 Mon Sep 17 00:00:00 2001 From: Mark Tompsett Date: Wed, 25 Apr 2018 23:34:11 +0000 Subject: [PATCH] Bug 20495: Follow up to refactor tools/scheduler TEST PLAN --------- This doesn't require the other patch applied. -- Make sure you have at least 2 saved reports. If you create them from an empty DB, they are 1 and 2 otherwise, you'll need to know their ID numbers. Home -> Tools -> Task Scheduler -- The Report Dropdown has content! localhost:8081/cgi-bin/koha/tools/scheduler.pl?id=1 -- The Report Dropdown is non-empty and correctly selected -- Attempt with id=2, different report selected. apply this patch restart_all Home -> Tools -> Task Scheduler -- Report dropdown has same content! localhost:8081/cgi-bin/koha/tools/scheduler.pl?id=1 -- The Report Dropdown is non-empty and correctly selected -- Attempt with id=2, different report selected. -- effectively no change. run koha qa test tools --- tools/scheduler.pl | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/tools/scheduler.pl b/tools/scheduler.pl index 3cf6b7e..6b8fb50 100755 --- a/tools/scheduler.pl +++ b/tools/scheduler.pl @@ -25,6 +25,7 @@ use C4::Auth; use CGI qw ( -utf8 ); use C4::Output; use Koha::DateUtils;; +use Koha::Reports; use vars qw($debug); @@ -106,14 +107,18 @@ foreach my $job ( values %$jobs ) { @jobloop = sort { $a->{TIME} cmp $b->{TIME} } @jobloop; -my $reports = get_saved_reports(); -if ( defined $id ) { - foreach my $report (@$reports) { - $report->{'selected'} = 1 if $report->{'id'} eq $id; - } +my @reports = Koha::Reports->search({}); +my @savedreports; +foreach my $report (@reports) { + my $is_selected = defined $id ? $report->id eq $id : 0; + push @savedreports, { + 'id' => $report->id, + 'report_name' => $report->report_name, + 'selected' => $is_selected, + }; } -$template->param( 'savedreports' => $reports ); +$template->param( 'savedreports' => \@savedreports ); $template->param( JOBS => \@jobloop ); my $time = localtime(time); $template->param( 'time' => $time ); -- 2.1.4