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
22 This script allows you to update your database/records after a bulkmarckimport integration.
32 my ( $no_marcxml, $no_isbn, $help) = (0,0,0);
35 'noisbn' => \$no_isbn,
36 'noxml' => \$no_marcxml,
43 my $dbh = C4::Context->dbh;
49 \t-noisbn don't remove '-' in biblioitems.isbn
50 \t-noxml don't remove '-' in biblioitems.marcxml in field 010a
60 SELECT biblioitemnumber,isbn FROM biblioitems WHERE isbn IS NOT NULL
64 UPDATE biblioitems SET isbn=? WHERE biblioitemnumber = ?
67 my $sth = $dbh->prepare($query_isbn);
70 while (my $data = $sth->fetchrow_arrayref){
71 my $biblioitemnumber = $data->[0];
72 print "\rremoving '-' on isbn for biblioitemnumber $biblioitemnumber";
74 # suppression des tirets de l'isbn
75 my $isbn = $data->[1];
80 my $sth = $dbh->prepare($update_isbn);
81 $sth->execute($isbn,$biblioitemnumber);
85 print "$cpt_isbn updated";
91 SELECT biblioitemnumber,marcxml FROM biblioitems WHERE isbn IS NOT NULL
95 my $update_marcxml = "
96 UPDATE biblioitems SET marcxml=? WHERE biblioitemnumber = ?
99 my $sth = $dbh->prepare($query_marcxml);
102 while (my $data = $sth->fetchrow_arrayref){
104 my $biblioitemnumber = $data->[0];
105 print "\rremoving '-' on marcxml for biblioitemnumber $biblioitemnumber";
107 # suppression des tirets de l'isbn dans la notice
108 my $marcxml = $data->[1];
111 my $record = MARC::Record->new_from_xml($marcxml,'UTF-8','UNIMARC');
112 my @field = $record->field('010');
114 foreach my $field (@field){
115 my $subfield = $field->subfield('a');
117 my $isbn = $subfield;
119 $field->update('a' => $isbn);
124 $marcxml = $record->as_xml;
126 my $sth = $dbh->prepare($update_marcxml);
127 $sth->execute($marcxml,$biblioitemnumber);
131 print "\n /!\\ pb getting $biblioitemnumber : $@";