Bugzilla – Attachment 18063 Details for
Bug 1993
Task Scheduler Needs Re-write
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 1993: Improving task scheduler
Bug-1993-Improving-task-scheduler.patch (text/plain), 4.99 KB, created by
Sophie MEYNIEUX
on 2013-05-10 13:01:04 UTC
(
hide
)
Description:
Bug 1993: Improving task scheduler
Filename:
MIME Type:
Creator:
Sophie MEYNIEUX
Created:
2013-05-10 13:01:04 UTC
Size:
4.99 KB
patch
obsolete
>From 4d0c369ae7dd32cb54737e5f154609007f410454 Mon Sep 17 00:00:00 2001 >From: Sophie Meynieux <sophie.meynieux@biblibre.com> >Date: Thu, 22 Mar 2012 15:51:43 +0100 >Subject: [PATCH] Bug 1993: Improving task scheduler > > Remove "url" as format as it is not implemented > Add csv as output format > Use MIME:Lite to send email > Call runreport.pl with right parameters > >Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> >--- > .../prog/en/modules/tools/scheduler.tt | 2 +- > misc/cronjobs/runreport.pl | 50 ++++++++++++++------ > tools/scheduler.pl | 9 ++-- > 3 files changed, 42 insertions(+), 19 deletions(-) > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/scheduler.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/scheduler.tt >index 31a0084..6f26627 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/scheduler.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/scheduler.tt >@@ -54,7 +54,7 @@ > <li><label for="format">Output format:</label> > <select name="format" id="format"> > <option value="text">Text</option> >-<option value="url">URL</option> >+<option value="csv">CSV</option> > </select> > </li> > <li><label for="email">Email:</label> >diff --git a/misc/cronjobs/runreport.pl b/misc/cronjobs/runreport.pl >index 2357ed8..fe59d92 100755 >--- a/misc/cronjobs/runreport.pl >+++ b/misc/cronjobs/runreport.pl >@@ -25,7 +25,7 @@ use C4::Context; > > use Getopt::Long qw(:config auto_help auto_version); > use Pod::Usage; >-use Mail::Sendmail; >+use MIME::Lite; > use Text::CSV_XS; > use CGI; > use Carp; >@@ -149,6 +149,9 @@ my $from = ""; > my $subject = 'Koha Saved Report'; > my $separator = ','; > my $quote = '"'; >+my $message = ""; >+my $mail; >+my $outfile; > > GetOptions( > 'help|?' => \$help, >@@ -169,11 +172,6 @@ unless ($format) { > $format = 'text'; > } > >-if ($format eq 'tsv' || $format eq 'text') { >- $format = 'csv'; >- $separator = "\t"; >-} >- > if ($to or $from or $email) { > $email = 1; > $from or $from = C4::Context->preference('KohaAdminEmailAddress'); >@@ -216,8 +214,7 @@ foreach my $report_id (@ARGV) { > } > $verbose and print "$count results from execute_query\n"; > >- my $message; >- if ($format eq 'html') { >+ if ($format eq 'text') { > my $cgi = CGI->new(); > my @rows = (); > while (my $line = $sth->fetchrow_arrayref) { >@@ -225,6 +222,15 @@ foreach my $report_id (@ARGV) { > push @rows, $cgi->TR( join('', $cgi->td($line)) ) . "\n"; > } > $message = $cgi->table(join "", @rows); >+ if ( $email ) { >+ $mail = MIME::Lite->new ( >+ To => $to, >+ From => $from, >+ Subject => $subject, >+ Data => $message, >+ Type => 'text/html' >+ ); >+ } > } elsif ($format eq 'csv') { > my $csv = Text::CSV_XS->new({ > quote_char => $quote, >@@ -240,19 +246,33 @@ foreach my $report_id (@ARGV) { > # $message .= join ($separator, @$line) . "\n"; > $message .= $csv->string() . "\n"; > } >+ if ($email) { >+ $outfile = "/tmp/report$report.csv"; >+ open( my $fh, ">:encoding(UTF-8)", $outfile ) or die "unable to open $outfile: $!"; >+ print $fh $message; >+ close $fh; >+ >+ $mail = MIME::Lite->new ( >+ From => $from, >+ To => $to, >+ Subject => $subject, >+ Type => 'multipart/mixed', >+ ); >+ $mail->attach ( >+ Type => 'application/csv', >+ Path => $outfile, >+ Filename => "report$report.csv", >+ ); >+ } > } > > if ($email){ >- my %mail = ( >- To => $to, >- From => $from, >- Subject => encode('utf8', $subject ), >- Message => encode('utf8', $message ) >- ); >- sendmail(%mail) or carp 'mail not sent:' . $Mail::Sendmail::error; >+ $mail->send or carp 'mail not sent:'; >+ unlink $outfile if ($outfile); > } else { > print $message; > } >+ > # my @xmlarray = ... ; > # my $url = "/cgi-bin/koha/reports/guided_reports.pl?phase=retrieve%20results&id=$id"; > # my $xml = XML::Dumper->new()->pl2xml( \@xmlarray ); >diff --git a/tools/scheduler.pl b/tools/scheduler.pl >index 99210ac..195674c 100755 >--- a/tools/scheduler.pl >+++ b/tools/scheduler.pl >@@ -67,9 +67,12 @@ if ( $mode eq 'job_add' ) { > my $report = $input->param('report'); > my $format = $input->param('format'); > my $email = $input->param('email'); >- my $command = >- "EXPORT KOHA_CONF=\"$CONFIG_NAME\"; " . $base >- . "/tools/runreport.pl $report $format $email"; >+ my $command = "export KOHA_CONF=\"$CONFIG_NAME\"; "; >+ $command .= $base . "/misc/cronjobs/runreport.pl"; >+ $command .= " --format $format" if ( $format ); >+ $command .= " --to $email" if ( $email ); >+ $command .= " $report"; >+ > > if ($recurring) { > my $frequency = $input->param('frequency'); >-- >1.7.10.4
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 1993
:
449
|
450
|
451
|
2259
|
2260
|
8524
|
8814
|
16721
|
17988
| 18063 |
18183