X-Git-Url: http://koha-dev.rot13.org:8081/gitweb/?a=blobdiff_plain;ds=sidebyside;f=svc%2Fbib;h=8f6a168e2deec4445c4978429f07e7b1b5c3d496;hb=4132ac28bf088960d25766fccc60ba1535a0e8ef;hp=ac7e4b06a1643a3dc3445eb9eddbd70325a29722;hpb=4747ea7462c04770484386538b1594c1760bc75b;p=koha_fer diff --git a/svc/bib b/svc/bib index ac7e4b06a1..8f6a168e2d 100755 --- a/svc/bib +++ b/svc/bib @@ -1,6 +1,7 @@ #!/usr/bin/perl # Copyright 2007 LibLime +# Copyright 2012 software.coop and MJ Ray # # This file is part of Koha. # @@ -13,9 +14,9 @@ # 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., 59 Temple Place, -# Suite 330, Boston, MA 02111-1307 USA +# 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 strict; @@ -24,10 +25,11 @@ use warnings; use CGI; use C4::Auth qw/check_api_auth/; use C4::Biblio; +use C4::Items; use XML::Simple; my $query = new CGI; -binmode STDOUT, ":utf8"; +binmode STDOUT, ':encoding(UTF-8)'; my ($status, $cookie, $sessionID) = check_api_auth($query, { editcatalogue => 'edit_catalogue'} ); unless ($status eq "ok") { @@ -58,7 +60,7 @@ exit 0; sub fetch_bib { my $query = shift; my $biblionumber = shift; - my $record = GetMarcBiblio($biblionumber); + my $record = GetMarcBiblio( $biblionumber, $query->url_param('items') ); if (defined $record) { print $query->header(-type => 'text/xml'); print $record->as_xml_record(); @@ -86,13 +88,28 @@ sub update_bib { $result->{'status'} = "failed"; $result->{'error'} = $@; } else { + my $fullrecord = $record->clone(); + my ( $itemtag, $itemsubfield ) = + GetMarcFromKohaField( "items.itemnumber", '' ); + # delete any item tags - my ( $itemtag, $itemsubfield ) = GetMarcFromKohaField("items.itemnumber", ''); - foreach my $field ($record->field($itemtag)) { + foreach my $field ( $record->field($itemtag) ) { $record->delete_field($field); } - ModBiblio($record, $biblionumber, ''); - my $new_record = GetMarcBiblio($biblionumber); + + if ( $query->url_param('items') ) { + foreach my $field ( $fullrecord->field($itemtag) ) { + my $one_item_record = $record->clone(); + $one_item_record->add_fields($field); + ModItemFromMarc( $one_item_record, $biblionumber, + $field->subfield($itemsubfield) ); + } + } + + ModBiblio( $record, $biblionumber, '' ); + my $new_record = + GetMarcBiblio( $biblionumber, $query->url_param('items') ); + $result->{'status'} = "ok"; $result->{'biblionumber'} = $biblionumber; my $xml = $new_record->as_xml_record();