From 300918e4886433f9f5b52779d8cf2027fcbdcb1a Mon Sep 17 00:00:00 2001 From: Owen Leonard Date: Wed, 3 Jul 2013 10:05:55 -0400 Subject: [PATCH] Bug 3134: add ability to selelct multiple reports to delete at once This patch adds the option to select multiple saved reports for deletion. To test you must have two or more saved reports to delete. Deletion should work properly when: - Selecting one report for deletion by checking the box. - Selecting more than one report for deletion by checking boxes. - Clicking the old "Delete" link Clicking the delete button should prompt you to confirm. Clicking cancel should cancel. Clicking the delete button when no boxes are checked should trigger an alert asking you to select reports for deletion. Signed-off-by: Liz Rea Functional tests pass, template tests pass. Signed-off-by: Katrin Fischer Signed-off-by: Jonathan Druart Signed-off-by: Galen Charlton --- C4/Reports/Guided.pm | 14 +++++++------- .../modules/reports/guided_reports_start.tt | 19 +++++++++++++++++-- reports/guided_reports.pl | 11 +++++++++-- 3 files changed, 33 insertions(+), 11 deletions(-) diff --git a/C4/Reports/Guided.pm b/C4/Reports/Guided.pm index f0db7a3719..9447c7185a 100644 --- a/C4/Reports/Guided.pm +++ b/C4/Reports/Guided.pm @@ -609,13 +609,13 @@ sub format_results { } sub delete_report { - my ($id) = @_; - my $dbh = C4::Context->dbh(); - my $query = "DELETE FROM saved_sql WHERE id = ?"; - my $sth = $dbh->prepare($query); - $sth->execute($id); -} - + my (@ids) = @_; + my $dbh = C4::Context->dbh; + my $query = 'DELETE FROM saved_sql WHERE id IN (' . join( ',', ('?') x @ids ) . ')'; + my $sth = $dbh->prepare($query); + $sth->execute(@ids); + $sth->finish; +} my $SAVED_REPORTS_BASE_QRY = < +
+ @@ -293,7 +304,7 @@ canned reports and writing custom SQL reports.

[% FOREACH savedreport IN savedreports %] [% UNLESS ( loop.odd ) %][% ELSE %][% END %] - +
[% savedreport.id %] [% IF ( savedreport.report_name ) %] [% savedreport.report_name %] @@ -338,6 +349,10 @@ canned reports and writing custom SQL reports.

[% END %]
+
+ +
+
[% ELSE %]
diff --git a/reports/guided_reports.pl b/reports/guided_reports.pl index 929feea20a..b9c49ad023 100755 --- a/reports/guided_reports.pl +++ b/reports/guided_reports.pl @@ -108,11 +108,18 @@ elsif ( $phase eq 'Build new' ) { ); } +elsif ( $phase eq 'Delete Multiple') { + my @ids = $input->param('ids'); + delete_report( @ids ); + print $input->redirect("/cgi-bin/koha/reports/guided_reports.pl?phase=Use%20saved"); + exit; +} + elsif ( $phase eq 'Delete Saved') { # delete a report from the saved reports list - my $id = $input->param('reports'); - delete_report($id); + my $ids = $input->param('reports'); + delete_report($ids); print $input->redirect("/cgi-bin/koha/reports/guided_reports.pl?phase=Use%20saved"); exit; } -- 2.39.5