Lines 25-30
use C4::Auth qw( get_template_and_user );
Link Here
|
25 |
use CGI qw ( -utf8 ); |
25 |
use CGI qw ( -utf8 ); |
26 |
use C4::Output qw( output_html_with_http_headers ); |
26 |
use C4::Output qw( output_html_with_http_headers ); |
27 |
use Koha::DateUtils qw( dt_from_string );; |
27 |
use Koha::DateUtils qw( dt_from_string );; |
|
|
28 |
use Koha::Reports; |
29 |
use Koha::Email; |
28 |
|
30 |
|
29 |
my $input = CGI->new; |
31 |
my $input = CGI->new; |
30 |
my $base; |
32 |
my $base; |
Lines 60-82
if ( $mode eq 'job_add' ) {
Link Here
|
60 |
$starttime =~ s/\://g; |
62 |
$starttime =~ s/\://g; |
61 |
my $start = $startdate . $starttime; |
63 |
my $start = $startdate . $starttime; |
62 |
my $report = $input->param('report'); |
64 |
my $report = $input->param('report'); |
|
|
65 |
if ($report) { |
66 |
my $saved_report; |
67 |
my $report_id = int($report); |
68 |
if ($report_id) { |
69 |
$saved_report = Koha::Reports->find($report_id); |
70 |
} |
71 |
if ( !$saved_report ) { |
72 |
$report = undef; |
73 |
} |
74 |
} |
63 |
my $format = $input->param('format'); |
75 |
my $format = $input->param('format'); |
64 |
my $email = $input->param('email'); |
76 |
if ($format) { |
65 |
my $command = |
77 |
unless ( $format eq 'text' || $format eq 'csv' || $format eq 'html' ) { |
66 |
"export KOHA_CONF=\"$CONFIG_NAME\"; " . |
78 |
$format = undef; |
67 |
"$base/cronjobs/runreport.pl $report --format=$format --to=$email"; |
79 |
} |
68 |
|
80 |
} |
69 |
#FIXME commit ea899bc55933cd74e4665d70b1c48cab82cd1257 added recurring parameter (it is not in template) and call to add_cron_job (undefined) |
81 |
my $email = $input->param('email'); |
70 |
# my $recurring = $input->param('recurring'); |
82 |
if ($email) { |
71 |
# if ($recurring) { |
83 |
my $is_valid = Koha::Email->is_valid($email); |
72 |
# my $frequency = $input->param('frequency'); |
84 |
if ( !$is_valid ) { |
73 |
# add_cron_job( $start, $command ); |
85 |
$email = undef; |
74 |
# } |
86 |
} |
75 |
# else { |
87 |
} |
76 |
# #here was the the unless ( add_at_job |
88 |
if ( $report && $format && $email ) { |
77 |
# } |
89 |
|
78 |
|
90 |
#NOTE: Escape any single quotes in email since we're wrapping it in single quotes in bash |
79 |
unless ( add_at_job( $start, $command ) ) { |
91 |
$email =~ s/'/'"'"'/g; |
|
|
92 |
my $command = |
93 |
"export KOHA_CONF=\"$CONFIG_NAME\"; " |
94 |
. "$base/cronjobs/runreport.pl $report --format=$format --to='$email'"; |
95 |
|
96 |
unless ( add_at_job( $start, $command ) ) { |
97 |
$template->param( job_add_failed => 1 ); |
98 |
} |
99 |
} |
100 |
else { |
80 |
$template->param( job_add_failed => 1 ); |
101 |
$template->param( job_add_failed => 1 ); |
81 |
} |
102 |
} |
82 |
} |
103 |
} |
83 |
- |
|
|