3 # This file is part of Koha.
5 # Koha is free software; you can redistribute it and/or modify it under the
6 # terms of the GNU General Public License as published by the Free Software
7 # Foundation; either version 2 of the License, or (at your option) any later
10 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
11 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
12 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License along with
15 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
16 # Suite 330, Boston, MA 02111-1307 USA
23 This script allows you to update your database/records after a bulkmarckimport integration.
33 my ( $no_marcxml, $no_isbn, $help) = (0,0,0);
36 'noisbn' => \$no_isbn,
37 'noxml' => \$no_marcxml,
44 my $dbh = C4::Context->dbh;
50 \t-noisbn don't remove '-' in biblioitems.isbn
51 \t-noxml don't remove '-' in biblioitems.marcxml in field 010a
61 SELECT biblioitemnumber,isbn FROM biblioitems WHERE isbn IS NOT NULL
65 UPDATE biblioitems SET isbn=? WHERE biblioitemnumber = ?
68 my $sth = $dbh->prepare($query_isbn);
71 while (my $data = $sth->fetchrow_arrayref){
72 my $biblioitemnumber = $data->[0];
73 print "\rremoving '-' on isbn for biblioitemnumber $biblioitemnumber";
75 # suppression des tirets de l'isbn
76 my $isbn = $data->[1];
81 my $sth = $dbh->prepare($update_isbn);
82 $sth->execute($isbn,$biblioitemnumber);
86 print "$cpt_isbn updated";
92 SELECT biblioitemnumber,marcxml FROM biblioitems WHERE isbn IS NOT NULL
96 my $update_marcxml = "
97 UPDATE biblioitems SET marcxml=? WHERE biblioitemnumber = ?
100 my $sth = $dbh->prepare($query_marcxml);
103 while (my $data = $sth->fetchrow_arrayref){
105 my $biblioitemnumber = $data->[0];
106 print "\rremoving '-' on marcxml for biblioitemnumber $biblioitemnumber";
108 # suppression des tirets de l'isbn dans la notice
109 my $marcxml = $data->[1];
112 my $record = MARC::Record->new_from_xml($marcxml,'UTF-8','UNIMARC');
113 my @field = $record->field('010');
115 foreach my $field (@field){
116 my $subfield = $field->subfield('a');
118 my $isbn = $subfield;
120 $field->update('a' => $isbn);
125 $marcxml = $record->as_xml;
127 my $sth = $dbh->prepare($update_marcxml);
128 $sth->execute($marcxml,$biblioitemnumber);
132 print "\n /!\\ pb getting $biblioitemnumber : $@";