From 4dbe34f231c9e16aeed3d92edb0fbb61ed22c561 Mon Sep 17 00:00:00 2001 From: Nahuel ANGELINETTI Date: Thu, 30 Apr 2009 11:36:52 +0200 Subject: [PATCH] (bug #3174) fill borrower number, and show author and creation date in saved reports This patch add 2 columns in "Use Saved" page whith creation date, and the creator id. It fix the creation of a report, to save the borrowernumber in reports table(to show it after). Signed-off-by: Galen Charlton --- C4/Reports/Guided.pm | 12 +++++++++--- .../en/modules/reports/guided_reports_start.tmpl | 4 +++- reports/guided_reports.pl | 2 +- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/C4/Reports/Guided.pm b/C4/Reports/Guided.pm index ff51ecbb1e..03ee9ff55f 100644 --- a/C4/Reports/Guided.pm +++ b/C4/Reports/Guided.pm @@ -24,6 +24,7 @@ use Carp; use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS); use C4::Context; +use C4::Dates qw/format_date/; use C4::Output; use C4::Dates; use XML::Simple; @@ -437,13 +438,13 @@ Given some sql and a name this will saved it so that it can resued =cut sub save_report { - my ( $sql, $name, $type, $notes ) = @_; + my ( $borrowernumber, $sql, $name, $type, $notes ) = @_; my $dbh = C4::Context->dbh(); $sql =~ s/(\s*\;\s*)$//; # removes trailing whitespace and /;/ my $query = "INSERT INTO saved_sql (borrowernumber,date_created,last_modified,savedsql,report_name,type,notes) VALUES (?,now(),now(),?,?,?,?)"; my $sth = $dbh->prepare($query); - $sth->execute( 0, $sql, $name, $type, $notes ); + $sth->execute( $borrowernumber, $sql, $name, $type, $notes ); } sub update_sql { @@ -516,7 +517,12 @@ sub get_saved_reports { ORDER by date_created"; my $sth = $dbh->prepare($query); $sth->execute(); - return $sth->fetchall_arrayref({}); + + my $result = $sth->fetchall_arrayref({}); + foreach (@$result){ + $_->{date_created} = format_date($_->{date_created}); + } + return $result; } sub get_saved_report { 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 67dc404e67..051a87070e 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 @@ -103,11 +103,13 @@ canned reports and writing custom SQL reports.

Choose the report to run from the list

- + + +
Report NameTypeNotesSaved ResultsSaved SQL 
Report NameTypeNotesAuthorCreation DateSaved ResultsSaved SQL 
"> &phase=Show%20SQL">Show SQL diff --git a/reports/guided_reports.pl b/reports/guided_reports.pl index bf20310884..e9a31bf3ea 100755 --- a/reports/guided_reports.pl +++ b/reports/guided_reports.pl @@ -332,7 +332,7 @@ elsif ( $phase eq 'Save Report' ) { ); } else { - save_report( $sql, $name, $type, $notes ); + save_report( $borrowernumber, $sql, $name, $type, $notes ); $template->param( 'save_successful' => 1, ); -- 2.39.5