From 6ac79ef1e0b1e745179d956f52eabe58cc2b0134 Mon Sep 17 00:00:00 2001
From: Chris Cormack
Date: Mon, 29 Oct 2007 13:21:47 -0500
Subject: [PATCH] Can now delete reports
Signed-off-by: Chris Cormack
Signed-off-by: Joshua Ferraro
---
C4/Reports.pm | 11 ++++++++++-
.../en/modules/reports/guided_reports_start.tmpl | 15 +++++++++------
reports/guided_reports.pl | 10 ++++++++++
3 files changed, 29 insertions(+), 7 deletions(-)
diff --git a/C4/Reports.pm b/C4/Reports.pm
index a63c4117eb..a67651ee55 100644
--- a/C4/Reports.pm
+++ b/C4/Reports.pm
@@ -34,7 +34,7 @@ $VERSION = 0.01;
qw(get_report_types get_report_areas get_columns build_query get_criteria
save_report get_saved_reports execute_query get_saved_report create_compound run_compound
get_column_type get_distinct_values save_dictionary get_from_dictionary
- delete_definition);
+ delete_definition delete_report);
our %table_areas;
$table_areas{'1'} =
@@ -389,6 +389,15 @@ sub save_report {
}
+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);
+ $sth->finish();
+}
+
sub get_saved_reports {
my $dbh = C4::Context->dbh();
my $query = "SELECT * FROM saved_sql ORDER by date_created";
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/guided_reports_start.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/reports/guided_reports_start.tmpl
index c89831152c..2faaffeeab 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/guided_reports_start.tmpl
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/reports/guided_reports_start.tmpl
@@ -42,14 +42,17 @@ reports
Load Saved Reports
Choose the report to run from the list
+
diff --git a/reports/guided_reports.pl b/reports/guided_reports.pl
index 4881212074..62f3198e30 100755
--- a/reports/guided_reports.pl
+++ b/reports/guided_reports.pl
@@ -76,6 +76,16 @@ elsif ( $phase eq 'Used saved' ) {
$template->param( 'savedreports' => $reports );
}
+elsif ( $phase eq 'Delete Saved') {
+
+ # delete a report from the saved reports list
+ $no_html = 1;
+ my $id = $input->param('reports');
+ delete_report($id);
+ print $input->redirect("/cgi-bin/koha/reports/guided_reports.pl?phase=Used%20saved");
+
+}
+
elsif ( $phase eq 'Report on this Area' ) {
# they have choosen a new report and the area to report on
--
2.39.2