From 51ad3c371abeedc6c3219957e7547dc6d5c67512 Mon Sep 17 00:00:00 2001 From: Chris Cormack Date: Mon, 29 Oct 2007 13:19:57 -0500 Subject: [PATCH] Files needed by the scheduler Signed-off-by: Chris Cormack Signed-off-by: Joshua Ferraro --- C4/Scheduler.pm | 95 +++++++++++++ .../prog/en/modules/tools/scheduler.tmpl | 130 ++++++++++++++++++ tools/runreport.pl | 34 +++++ 3 files changed, 259 insertions(+) create mode 100644 C4/Scheduler.pm create mode 100644 koha-tmpl/intranet-tmpl/prog/en/modules/tools/scheduler.tmpl create mode 100755 tools/runreport.pl diff --git a/C4/Scheduler.pm b/C4/Scheduler.pm new file mode 100644 index 0000000000..961df0eb27 --- /dev/null +++ b/C4/Scheduler.pm @@ -0,0 +1,95 @@ +package C4::Scheduler; + +# Copyright 2007 Liblime Ltd +# +# This file is part of Koha. +# +# Koha is free software; you can redistribute it and/or modify it under the +# terms of the GNU General Public License as published by the Free Software +# Foundation; either version 2 of the License, or (at your option) any later +# version. +# +# Koha is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR +# A PARTICULAR PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along with +# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place, +# Suite 330, Boston, MA 02111-1307 USA + +use strict; +require Exporter; + +use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS); +use C4::Context; +use Smart::Comments; +use Schedule::At; +# set the version for version checking +$VERSION = 0.01; + +@ISA = qw(Exporter); +@EXPORT = + qw(get_jobs get_job add_job remove_job); + +=head1 NAME + +C4::Scheduler - Module for running jobs with the unix at command + +=head1 SYNOPSIS + + use C4::Scheduler; + +=head1 DESCRIPTION + + +=head1 METHODS + +=over 2 + +=cut + +=item get_jobs(); + +This will return all scheduled jobs + +=cut + +sub get_jobs { + my %jobs = Schedule::At::getJobs(); + return (\%jobs); +} + +=item get_job($id) + +This will return the job with the given id + +=cut + +sub get_job { + my ($id)=@_; + my %jobs = chedule::At::getJobs(JOBID => $id); +} + +=item add_job ($time,$command) + +Given a timestamp and a command this will schedule the job to run at that time + +=cut + +sub add_job { + my ($time,$command) = @_; + Schedule::At::add(TIME => $time, COMMAND => $command, TAG => $command); +} + +sub remove_job { + my ($jobid)=@_; + Schedule::At::remove(JOBID => $jobid); +} + +=head1 AUTHOR + +Chris Cormack + +=cut + +1; diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/scheduler.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/scheduler.tmpl new file mode 100644 index 0000000000..3b4c2e25f7 --- /dev/null +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/scheduler.tmpl @@ -0,0 +1,130 @@ + + + + + + + +
+ +
+
+
+ +
+
+ + + + + + + + + + + + + + + + + + +
Current server time is
Time + + +
Report + +
Output Format
Email + +
+
+
+ +

Jobs already entered

+ + + + + + + +
+ + +
+ + + + +"> + + +
Date/TimeAction 
 
+ + +
+
+
+
+ +
+
+ diff --git a/tools/runreport.pl b/tools/runreport.pl new file mode 100755 index 0000000000..e920bee3c6 --- /dev/null +++ b/tools/runreport.pl @@ -0,0 +1,34 @@ +#!/usr/bin/perl + +# fix this line +use C4::Reports; + +use Mail::Sendmail; + + +my ($report,$format,$email) = @ARGV; + +my ($sql,$type) = get_saved_report($report); +my $results = execute_query($sql,$type,$format); +my $message; +if ($format eq 'text'){ + $message="$results
"; +} + +if ($email){ + my $to = $email; + # should be koha admin email + my $from = 'crc@liblime.com'; + my $subject = 'Automated job run'; + my %mail = ( + To => $to, + From => $from, + Subject => $subject, + Message => $message + ); + + + if (not(sendmail %mail)) { + warn "mail not sent"; + } + } -- 2.20.1