Don't display Acquisitions and Serials links if the user
[koha.git] / tools / scheduler.pl
blob779098bd8ee1cf4e3c19a2fb12ff92ba2af2ff54
1 #!/usr/bin/perl
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
10 # version.
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
20 use strict;
21 use C4::Context;
22 use C4::Scheduler;
23 use C4::Reports;
24 use C4::Auth;
25 use CGI;
26 use C4::Output;
28 my $input = new CGI;
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",
36 query => $input,
37 type => "intranet",
38 authnotrequired => 0,
39 flagsrequired => { tools => 'schedule_tasks' },
40 debug => 1,
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";
58 if ($recurring){
59 my $frequency = $input->param('frequency');
60 add_cron_job($start,$command);
62 else {
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();
75 my @jobloop;
76 foreach my $job (values %$jobs) {
77 push @jobloop,$job;
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;