From f06f90306ae6e0c081355c6a01f7a6032f6338fd Mon Sep 17 00:00:00 2001 From: Jesse Weaver Date: Tue, 9 Sep 2008 19:31:31 -0500 Subject: [PATCH] fix for bug 2543: report output by tabulation a bit too literal This repurposes the Reports module for general reports, and moves its functionality to a different module, Reports::Guided. It also updates all of the reports that can export to correctly treat the 'tabulation' value of the 'delimiter' syspref. Signed-off-by: Galen Charlton --- C4/Reports/Guided.pm | 1 + tools/runreport.pl | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+) create mode 100755 tools/runreport.pl diff --git a/C4/Reports/Guided.pm b/C4/Reports/Guided.pm index 509acd1bd2..847baffd9e 100644 --- a/C4/Reports/Guided.pm +++ b/C4/Reports/Guided.pm @@ -646,6 +646,7 @@ sub get_from_dictionary { push @loop,$data; } + $sth->finish(); return (\@loop); } diff --git a/tools/runreport.pl b/tools/runreport.pl new file mode 100755 index 0000000000..9801a4ae25 --- /dev/null +++ b/tools/runreport.pl @@ -0,0 +1,38 @@ +#!/usr/bin/perl + +# fix this line +use C4::Reports::Guided; +use C4::Context; + +use Mail::Sendmail; + + +my ($report,$format,$email) = @ARGV; + +my ($sql,$type) = get_saved_report($report); +my $results = execute_query($sql,$type,$format,$report); +my $message; +if ($format eq 'text'){ + $message="$results
"; +} +if ($format eq 'url'){ + $message="$results"; +} + +if ($email){ + my $to = $email; + # should be koha admin email + my $from = C4::Context->preference('KohaAdminEmailAddress'); + my $subject = 'Automated job run'; + my %mail = ( + To => $to, + From => $from, + Subject => $subject, + Message => $message + ); + + + if (not(sendmail %mail)) { + warn "mail not sent"; + } + } -- 2.39.5