b8d8a0ec5a
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 <galen.charlton@liblime.com>
38 lines
912 B
Perl
Executable file
38 lines
912 B
Perl
Executable file
#!/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="<table>$results</table>";
|
|
}
|
|
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";
|
|
}
|
|
}
|