From 4f9ce7f52a8ddda8858e5a6e1b72ef7c89408508 Mon Sep 17 00:00:00 2001
From: Owen Leonard
Date: Tue, 15 Jan 2013 10:39:09 -0500
Subject: [PATCH] Bug 3134 - Ability to selelct multiple reports to delete at
once
Content-Type: text/plain; charset="utf-8"
This patch adds the option to select multiple saved reports for
deletion. Text output of the report id (of little information value to
the user) is replaced with a checkbox, and sorting has been removed from
that table column.
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.
---
C4/Reports/Guided.pm | 18 +++++++++++-------
.../en/modules/reports/guided_reports_start.tt | 19 +++++++++++++++++--
reports/guided_reports.pl | 12 ++++++++++--
3 files changed, 38 insertions(+), 11 deletions(-)
diff --git a/C4/Reports/Guided.pm b/C4/Reports/Guided.pm
index 279ac57..6d4665b 100644
--- a/C4/Reports/Guided.pm
+++ b/C4/Reports/Guided.pm
@@ -607,13 +607,17 @@ 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) = @_;
+ if ($ids) {
+ my $dbh = C4::Context->dbh;
+ my $sth = $dbh->prepare("DELETE FROM saved_sql WHERE id IN ($ids)");
+ $sth->execute();
+ $sth->finish;
+ return 1;
+ } else {
+ return 0;
+ }
+}
my $SAVED_REPORTS_BASE_QRY = <
@@ -151,10 +160,12 @@ canned reports and writing custom SQL reports.
[% INCLUDE 'table-pager.inc' perpage='20' %]
+
[% ELSE %]
[% IF (filter_set) %]
No saved reports match your criteria.
diff --git a/reports/guided_reports.pl b/reports/guided_reports.pl
index de18072..5f57c5b 100755
--- a/reports/guided_reports.pl
+++ b/reports/guided_reports.pl
@@ -109,11 +109,19 @@ elsif ( $phase eq 'Build new' ) {
);
}
+elsif ( $phase eq 'Delete Multiple') {
+
+ my @ids = $input->param('ids');
+ delete_report( join ",", @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;
}
--
1.7.9.5