View | Details | Raw Unified | Return to bug 34349
Collapse All | Expand All

(-)a/tools/scheduler.pl (-6 / +36 lines)
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-70 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
        }
80
    }
81
    my $email = $input->param('email');
82
    if ($email) {
83
        my $is_valid = Koha::Email->is_valid($email);
84
        if ( !$is_valid ) {
85
            $email = undef;
86
        }
87
    }
88
    if ( $report && $format && $email ) {
89
90
        #NOTE: Escape any single quotes in email since we're wrapping it in single quotes in bash
91
        ($email) =~ s/'/'"'"'/g;
92
        my $command =
93
              "export KOHA_CONF=\"$CONFIG_NAME\"; "
94
            . "$base/cronjobs/runreport.pl $report --format=$format --to='$email'";
68
95
69
#FIXME commit ea899bc55933cd74e4665d70b1c48cab82cd1257 added recurring parameter (it is not in template) and call to add_cron_job (undefined)
96
#FIXME commit ea899bc55933cd74e4665d70b1c48cab82cd1257 added recurring parameter (it is not in template) and call to add_cron_job (undefined)
70
#    my $recurring = $input->param('recurring');
97
#    my $recurring = $input->param('recurring');
Lines 76-82 if ( $mode eq 'job_add' ) { Link Here
76
#        #here was the the unless ( add_at_job
103
#        #here was the the unless ( add_at_job
77
#    }
104
#    }
78
105
79
    unless ( add_at_job( $start, $command ) ) {
106
        unless ( add_at_job( $start, $command ) ) {
107
            $template->param( job_add_failed => 1 );
108
        }
109
    }
110
    else {
80
        $template->param( job_add_failed => 1 );
111
        $template->param( job_add_failed => 1 );
81
    }
112
    }
82
}
113
}
83
- 

Return to bug 34349