From 924058fbeffb5f95646163737ff7bcb08475de62 Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Sun, 20 Oct 2013 14:02:52 -0400 Subject: [PATCH] Bug 11084 - Delete biblios on Leader 05 =d --- misc/cronjobs/delete_fixed_field_5.pl | 62 +++++++++++++++++++++++++++++++++ 1 files changed, 62 insertions(+), 0 deletions(-) create mode 100755 misc/cronjobs/delete_fixed_field_5.pl diff --git a/misc/cronjobs/delete_fixed_field_5.pl b/misc/cronjobs/delete_fixed_field_5.pl new file mode 100755 index 0000000..14b0891 --- /dev/null +++ b/misc/cronjobs/delete_fixed_field_5.pl @@ -0,0 +1,62 @@ +#!/usr/bin/perl + +#----------------------------------- +# Copyright 2013 ByWater Solutions +# +# 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. +#----------------------------------- + +use Modern::Perl; + +BEGIN { + + # find Koha's Perl modules + # test carefully before changing this + use FindBin; + eval { require "$FindBin::Bin/../kohalib.pl" }; +} + +use Getopt::Long; + +use C4::Biblio; +use Koha::Database; + +my $confirm; +my $verbose; +my $help; + +GetOptions( + 'c|confirm' => \$confirm, + 'v|verbose' => \$verbose, + 'h|help' => \$help, +); + +if ( $help || !$confirm ) { + say q{delete_fixed_field_5.pl - Attempt to delete any records with the leader character 5 equals 'd'}; + say q{usage: delete_fixec_field_5.pl --confirm --verbose}; + exit(); +} + +my $schema = Koha::Database->new()->schema(); +my @biblioitems = + $schema->resultset('Biblioitem')->search( { marc => { LIKE => '_____d%' } } ); + +foreach my $biblioitem ( @biblioitems ) { + my $biblionumber = $biblioitem->get_column('biblionumber'); + say "Working on biblionumber $biblionumber" if $verbose; + my $error = DelBiblio( $biblionumber ); + say "ERROR - Cannot delete biblionumber $biblionumber: $error" if $error; +} -- 1.7.2.5