3 # Copyright 2007 Liblime Ltd
5 # This file is part of Koha.
7 # Koha is free software; you can redistribute it and/or modify it under the
8 # terms of the GNU General Public License as published by the Free Software
9 # Foundation; either version 2 of the License, or (at your option) any later
12 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License along with
17 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
18 # Suite 330, Boston, MA 02111-1307 USA
30 my $base = C4
::Context
->config('intranetdir');
31 my $CONFIG_NAME="/home/crc/koha/etc/koha-production.xml";
33 my ( $template, $borrowernumber, $cookie ) = get_template_and_user
(
35 template_name
=> "tools/scheduler.tmpl",
39 flagsrequired
=> { tools
=> 'schedule_tasks' },
44 my $mode=$input->param('mode');
46 if ($mode eq 'job_add') {
47 my $startday = $input->param('startday');
48 my $startmonth = $input->param('startmonth');
49 my $startyear = $input->param('startyear');
50 my $starttime = $input->param('starttime');
51 my $recurring = $input->param('recurring');
52 $starttime =~ s/\://g;
53 my $start = $startyear . $startmonth . $startday . $starttime;
54 my $report=$input->param('report');
55 my $format=$input->param('format');
56 my $email=$input->param('email');
57 my $command = "EXPORT KOHA_CONF=\"$CONFIG_NAME\"; ".$base."/tools/runreport.pl $report $format $email";
59 my $frequency = $input->param('frequency');
60 add_cron_job
($start,$command);
63 add_at_job
($start,$command);
67 if ($mode eq 'job_change'){
68 my $jobid = $input->param('jobid');
69 if ($input->param('delete')){
70 remove_at_job
($jobid);
74 my $jobs = get_jobs
();
76 foreach my $job (values %$jobs) {
80 @jobloop = sort {$a->{TIME
} cmp $b->{TIME
}} @jobloop;
81 my $reports = get_saved_reports
();
82 $template->param( 'savedreports' => $reports );
83 $template->param(JOBS
=> \
@jobloop);
84 my $time = localtime(time);
85 $template->param('time' => $time);
86 output_html_with_http_headers
$input, $cookie, $template->output;