(bug #3174) fill borrower number, and show author and creation date in saved reports
authorNahuel ANGELINETTI <nahuel.angelinetti@biblibre.com>
Thu, 30 Apr 2009 09:36:52 +0000 (11:36 +0200)
committerHenri-Damien LAURENT <henridamien.laurent@biblibre.com>
Tue, 26 May 2009 19:15:22 +0000 (21:15 +0200)
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 <galen.charlton@liblime.com>
Signed-off-by: Henri-Damien LAURENT <henridamien.laurent@biblibre.com>
C4/Reports/Guided.pm
koha-tmpl/intranet-tmpl/prog/en/modules/reports/guided_reports_start.tmpl
reports/guided_reports.pl

index 6e34b95..959c06d 100644 (file)
@@ -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;
@@ -436,13 +437,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 {
@@ -515,7 +516,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 {
index b205bc7..bd43efc 100644 (file)
@@ -103,11 +103,13 @@ canned reports and writing custom SQL reports.</p>
 <p>Choose the report to run from the list</p>
 <form action="/cgi-bin/koha/reports/guided_reports.pl">
 <table>
-<tr><th>Report Name</th><th>Type</th><th>Notes</th><th>Saved Results</th><th>Saved SQL</th><th colspan="3">&nbsp;</th></tr>
+<tr><th>Report Name</th><th>Type</th><th>Notes</th><th>Author</th><th>Creation Date</th><th>Saved Results</th><th>Saved SQL</th><th colspan="3">&nbsp;</th></tr>
 <!-- TMPL_LOOP NAME="savedreports" -->
 <tr><td><!-- TMPL_VAR NAME="report_name" --></td>
 <td><!-- TMPL_VAR NAME="type" --></td>
 <td><!-- TMPL_VAR NAME="notes" --></td>
+<td><!-- TMPL_VAR NAME="borrowernumber" --></td>
+<td><!-- TMPL_VAR NAME="date_created" --></td>
 <td><!-- TMPL_IF NAME="date_run" --><a href="/cgi-bin/koha/reports/guided_reports.pl?phase=retrieve%20results&id=<!-- TMPL_VAR NAME="id" -->"><!-- TMPL_VAR NAME="date_run" --></a><!-- /TMPL_IF -->
 </td>
 <td><a href="/cgi-bin/koha/reports/guided_reports.pl?reports=<!-- TMPL_VAR NAME="id" -->&amp;phase=Show%20SQL">Show SQL</a> 
index 8dbe1a2..89b4bfc 100755 (executable)
@@ -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,
         );