Line 0
Link Here
|
0 |
- |
1 |
#!/usr/bin/perl |
|
|
2 |
|
3 |
#----------------------------------- |
4 |
# Copyright 2013 ByWater Solutions |
5 |
# |
6 |
# This file is part of Koha. |
7 |
# |
8 |
# Koha is free software; you can redistribute it and/or modify it under the |
9 |
# terms of the GNU General Public License as published by the Free Software |
10 |
# Foundation; either version 2 of the License, or (at your option) any later |
11 |
# version. |
12 |
# |
13 |
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY |
14 |
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR |
15 |
# A PARTICULAR PURPOSE. See the GNU General Public License for more details. |
16 |
# |
17 |
# You should have received a copy of the GNU General Public License along |
18 |
# with Koha; if not, write to the Free Software Foundation, Inc., |
19 |
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
20 |
#----------------------------------- |
21 |
|
22 |
use Modern::Perl; |
23 |
|
24 |
BEGIN { |
25 |
|
26 |
# find Koha's Perl modules |
27 |
# test carefully before changing this |
28 |
use FindBin; |
29 |
eval { require "$FindBin::Bin/../kohalib.pl" }; |
30 |
} |
31 |
|
32 |
use Getopt::Long; |
33 |
|
34 |
use C4::Biblio; |
35 |
use Koha::Database; |
36 |
|
37 |
my $confirm; |
38 |
my $verbose; |
39 |
my $help; |
40 |
|
41 |
GetOptions( |
42 |
'c|confirm' => \$confirm, |
43 |
'v|verbose' => \$verbose, |
44 |
'h|help' => \$help, |
45 |
); |
46 |
|
47 |
if ( $help || !$confirm ) { |
48 |
say q{delete_fixed_field_5.pl - Attempt to delete any records with the leader character 5 equals 'd'}; |
49 |
say q{usage: delete_fixec_field_5.pl --confirm --verbose}; |
50 |
exit(); |
51 |
} |
52 |
|
53 |
my $schema = Koha::Database->new()->schema(); |
54 |
my @biblioitems = |
55 |
$schema->resultset('Biblioitem')->search( { marc => { LIKE => '_____d%' } } ); |
56 |
|
57 |
foreach my $biblioitem ( @biblioitems ) { |
58 |
my $biblionumber = $biblioitem->get_column('biblionumber'); |
59 |
say "Working on biblionumber $biblionumber" if $verbose; |
60 |
my $error = DelBiblio( $biblionumber ); |
61 |
say "ERROR - Cannot delete biblionumber $biblionumber: $error" if $error; |
62 |
} |