From 7214512d5b3d080a6eb850d5f100149a424b9abf Mon Sep 17 00:00:00 2001 From: Chris Cormack Date: Mon, 15 Sep 2014 14:51:49 +1200 Subject: [PATCH] [SIGNED-OFF] Bug 12919: Cronjob to create and email new or updated MARC records To test 1/ Add some new records to your Koha 2/ if you are using koha from packages run sudo koha-shell otherwise export PERL5LIB=/path/to/koha export KOHA_CONF=/path/to/koha-conf.xml 3/ run perl misc/cronjobs/newly_added_records --days 1 --address your@email.goes.here --format marc 4/ Check your email and see if you got some marc records Signed-off-by: Bernardo Gonzalez Kriegel --- misc/cronjobs/newly_added_records.pl | 101 ++++++++++++++++++++++++++++++++++ 1 file changed, 101 insertions(+) create mode 100755 misc/cronjobs/newly_added_records.pl diff --git a/misc/cronjobs/newly_added_records.pl b/misc/cronjobs/newly_added_records.pl new file mode 100755 index 0000000..a237158 --- /dev/null +++ b/misc/cronjobs/newly_added_records.pl @@ -0,0 +1,101 @@ +#!/usr/bin/perl + +# Copyright 2012 Catalyst IT +# +# 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., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +# This is script is to create a batch of MARC records that have been added to Koha in a set period +# Then email the file to a designated email + +use strict; +use warnings; +use DateTime; +use C4::RecordExporter; + +BEGIN { + + # find Koha's Perl modules + # test carefully before changing this + use FindBin; + eval { require "$FindBin::Bin/../kohalib.pl" }; +} + +use Getopt::Long; +use Pod::Usage; + +my ( + $help, $days, $months, $verbose, $export_items, + @address, $not_loan, @not_itypes, $format, $filename, +); +GetOptions( + 'help|?' => \$help, + 'days=s' => \$days, + 'months=s' => \$months, + 'v' => \$verbose, + 'items' => \$export_items, + 'address=s' => \@address, + 'not_loan=s' => \$not_loan, + 'not_itype=s' => \@not_itypes, + 'format=s' => \$format, + 'filename=s' => \$filename, +); + +if ( $help or ( not $days and not $months ) or not @address or not $format ) { + print <now()->month_name() ); +$filename =~ s/%month%/$month/g; + +my $date = DateTime->now(); +if ($days) { + $date->subtract( days => $days ); +} +elsif ($months) { + $date->set_day(1); + $date->subtract( months => $months ); +} + +export_and_mail_new( $date, \@address, $verbose, $export_items, $not_loan, + $format, $filename, @not_itypes ); -- 1.7.9.5