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

(-)a/svc/new_bib (-4 / +17 lines)
Lines 24-29 use warnings; Link Here
24
use CGI;
24
use CGI;
25
use C4::Auth qw/check_api_auth/;
25
use C4::Auth qw/check_api_auth/;
26
use C4::Biblio;
26
use C4::Biblio;
27
use C4::Items;
27
use XML::Simple;
28
use XML::Simple;
28
use C4::Charset;
29
use C4::Charset;
29
30
Lines 65-77 sub add_bib { Link Here
65
            ($record, $guessed_charset, $charset_errors) = MarcToUTF8Record($record, $marcflavour);
66
            ($record, $guessed_charset, $charset_errors) = MarcToUTF8Record($record, $marcflavour);
66
        }
67
        }
67
68
69
        my $fullrecord = $record->clone();
70
68
        # delete any item tags
71
        # delete any item tags
69
        my ( $itemtag, $itemsubfield ) = GetMarcFromKohaField("items.itemnumber", '');
72
        my ( $itemtag, $itemsubfield ) =
70
        foreach my $field ($record->field($itemtag)) {
73
          GetMarcFromKohaField( "items.itemnumber", '' );
74
        foreach my $field ( $record->field($itemtag) ) {
71
            $record->delete_field($field);
75
            $record->delete_field($field);
72
        }
76
        }
73
        my ($biblionumber, $biblioitemnumber) = AddBiblio($record, '');
77
        my ( $biblionumber, $biblioitemnumber ) = AddBiblio( $record, '' );
74
        my $new_record = GetMarcBiblio($biblionumber);
78
        my $new_record = GetMarcBiblio($biblionumber);
79
        if ( $query->url_param('items') ) {
80
            foreach my $field ( $fullrecord->field($itemtag) ) {
81
                my $one_item_record = $new_record->clone();
82
                $one_item_record->add_fields($field);
83
                AddItemFromMarc( $one_item_record, $biblionumber );
84
            }
85
        }
86
87
        $new_record =
88
          GetMarcBiblio( $biblionumber, $query->url_param('items') );
75
        $result->{'status'} = "ok";
89
        $result->{'status'} = "ok";
76
        $result->{'biblionumber'} = $biblionumber;
90
        $result->{'biblionumber'} = $biblionumber;
77
        my $xml = $new_record->as_xml_record();
91
        my $xml = $new_record->as_xml_record();
78
- 

Return to bug 7729