View | Details | Raw Unified | Return to bug 7729
Collapse All | Expand All

(-)a/svc/bib (-6 / +22 lines)
Lines 1-6 Link Here
1
#!/usr/bin/perl
1
#!/usr/bin/perl
2
2
3
# Copyright 2007 LibLime
3
# Copyright 2007 LibLime
4
# Copyright 2012 software.coop and MJ Ray
4
#
5
#
5
# This file is part of Koha.
6
# This file is part of Koha.
6
#
7
#
Lines 24-29 use warnings; Link Here
24
use CGI;
25
use CGI;
25
use C4::Auth qw/check_api_auth/;
26
use C4::Auth qw/check_api_auth/;
26
use C4::Biblio;
27
use C4::Biblio;
28
use C4::Items;
27
use XML::Simple;
29
use XML::Simple;
28
30
29
my $query = new CGI;
31
my $query = new CGI;
Lines 58-64 exit 0; Link Here
58
sub fetch_bib {
60
sub fetch_bib {
59
    my $query = shift;
61
    my $query = shift;
60
    my $biblionumber = shift;
62
    my $biblionumber = shift;
61
    my $record = GetMarcBiblio($biblionumber);
63
    my $record = GetMarcBiblio( $biblionumber, $query->url_param('items') );
62
    if  (defined $record) {
64
    if  (defined $record) {
63
        print $query->header(-type => 'text/xml');
65
        print $query->header(-type => 'text/xml');
64
        print $record->as_xml_record();
66
        print $record->as_xml_record();
Lines 86-98 sub update_bib { Link Here
86
        $result->{'status'} = "failed";
88
        $result->{'status'} = "failed";
87
        $result->{'error'} = $@;
89
        $result->{'error'} = $@;
88
    } else {
90
    } else {
91
        my $fullrecord = $record->clone();
92
        my ( $itemtag, $itemsubfield ) =
93
          GetMarcFromKohaField( "items.itemnumber", '' );
94
89
        # delete any item tags
95
        # delete any item tags
90
        my ( $itemtag, $itemsubfield ) = GetMarcFromKohaField("items.itemnumber", '');
96
        foreach my $field ( $record->field($itemtag) ) {
91
        foreach my $field ($record->field($itemtag)) {
92
            $record->delete_field($field);
97
            $record->delete_field($field);
93
        }
98
        }
94
        ModBiblio($record, $biblionumber, '');
99
95
        my $new_record = GetMarcBiblio($biblionumber);
100
        if ( $query->url_param('items') ) {
101
            foreach my $field ( $fullrecord->field($itemtag) ) {
102
                my $one_item_record = $record->clone();
103
                $one_item_record->add_fields($field);
104
                ModItemFromMarc( $one_item_record, $biblionumber,
105
                    $field->subfield($itemsubfield) );
106
            }
107
        }
108
109
        ModBiblio( $record, $biblionumber, '' );
110
        my $new_record =
111
          GetMarcBiblio( $biblionumber, $query->url_param('items') );
112
96
        $result->{'status'} = "ok";
113
        $result->{'status'} = "ok";
97
        $result->{'biblionumber'} = $biblionumber;
114
        $result->{'biblionumber'} = $biblionumber;
98
        my $xml = $new_record->as_xml_record();
115
        my $xml = $new_record->as_xml_record();
99
- 

Return to bug 7729