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

(-)a/C4/ImportBatch.pm (-5 / +5 lines)
Lines 649-655 sub BatchCommitRecords { Link Here
649
                ($recordid, $biblioitemnumber) = AddBiblio($marc_record, $framework);
649
                ($recordid, $biblioitemnumber) = AddBiblio($marc_record, $framework);
650
                $query = "UPDATE import_biblios SET matched_biblionumber = ? WHERE import_record_id = ?"; # FIXME call SetMatchedBiblionumber instead
650
                $query = "UPDATE import_biblios SET matched_biblionumber = ? WHERE import_record_id = ?"; # FIXME call SetMatchedBiblionumber instead
651
                if ($item_result eq 'create_new' || $item_result eq 'replace') {
651
                if ($item_result eq 'create_new' || $item_result eq 'replace') {
652
                    my ($bib_items_added, $bib_items_replaced, $bib_items_errored) = BatchCommitItems($rowref->{'import_record_id'}, $recordid, $item_result);
652
                    my ($bib_items_added, $bib_items_replaced, $bib_items_errored) = BatchCommitItems($rowref->{'import_record_id'}, $recordid, $item_result, $biblioitemnumber);
653
                    $num_items_added += $bib_items_added;
653
                    $num_items_added += $bib_items_added;
654
                    $num_items_replaced += $bib_items_replaced;
654
                    $num_items_replaced += $bib_items_replaced;
655
                    $num_items_errored += $bib_items_errored;
655
                    $num_items_errored += $bib_items_errored;
Lines 735-746 sub BatchCommitRecords { Link Here
735
=head2 BatchCommitItems
735
=head2 BatchCommitItems
736
736
737
  ($num_items_added, $num_items_errored) = 
737
  ($num_items_added, $num_items_errored) = 
738
         BatchCommitItems($import_record_id, $biblionumber);
738
         BatchCommitItems($import_record_id, $biblionumber, [$action, $biblioitemnumber]);
739
739
740
=cut
740
=cut
741
741
742
sub BatchCommitItems {
742
sub BatchCommitItems {
743
    my ( $import_record_id, $biblionumber, $action ) = @_;
743
    my ( $import_record_id, $biblionumber, $action, $biblioitemnumber ) = @_;
744
744
745
    my $dbh = C4::Context->dbh;
745
    my $dbh = C4::Context->dbh;
746
746
Lines 765-771 sub BatchCommitItems { Link Here
765
        my ( $MARCfield, $MARCsubfield ) = GetMarcFromKohaField( 'items.onloan' );
765
        my ( $MARCfield, $MARCsubfield ) = GetMarcFromKohaField( 'items.onloan' );
766
        $item_marc->field($MARCfield)->delete_subfield( code => $MARCsubfield );
766
        $item_marc->field($MARCfield)->delete_subfield( code => $MARCsubfield );
767
767
768
        my $item = TransformMarcToKoha({ record => $item_marc });
768
        my $item = TransformMarcToKoha({ record => $item_marc, kohafields => ['items.barcode','items.itemnumber'] });
769
769
770
        my $duplicate_barcode = exists( $item->{'barcode'} ) && Koha::Items->find({ barcode => $item->{'barcode'} });
770
        my $duplicate_barcode = exists( $item->{'barcode'} ) && Koha::Items->find({ barcode => $item->{'barcode'} });
771
        my $duplicate_itemnumber = exists( $item->{'itemnumber'} );
771
        my $duplicate_itemnumber = exists( $item->{'itemnumber'} );
Lines 800-806 sub BatchCommitItems { Link Here
800
            my ( $itemtag, $itemsubfield ) = GetMarcFromKohaField( "items.itemnumber" );
800
            my ( $itemtag, $itemsubfield ) = GetMarcFromKohaField( "items.itemnumber" );
801
            $item_marc->field($itemtag)->delete_subfield( code => $itemsubfield );
801
            $item_marc->field($itemtag)->delete_subfield( code => $itemsubfield );
802
802
803
            my ( $item_biblionumber, $biblioitemnumber, $itemnumber ) = AddItemFromMarc( $item_marc, $biblionumber );
803
            my ( $item_biblionumber, $biblioitemnumber, $itemnumber ) = AddItemFromMarc( $item_marc, $biblionumber, {biblioitemnumber => $biblioitemnumber} );
804
            if( $itemnumber ) {
804
            if( $itemnumber ) {
805
                $updsth->bind_param( 1, 'imported' );
805
                $updsth->bind_param( 1, 'imported' );
806
                $updsth->bind_param( 2, $itemnumber );
806
                $updsth->bind_param( 2, $itemnumber );
(-)a/C4/Items.pm (-2 / +1 lines)
Lines 162-168 sub AddItemFromMarc { Link Here
162
    # parse item hash from MARC
162
    # parse item hash from MARC
163
    my $frameworkcode = C4::Biblio::GetFrameworkCode($biblionumber);
163
    my $frameworkcode = C4::Biblio::GetFrameworkCode($biblionumber);
164
    my ( $itemtag, $itemsubfield ) = C4::Biblio::GetMarcFromKohaField( "items.itemnumber" );
164
    my ( $itemtag, $itemsubfield ) = C4::Biblio::GetMarcFromKohaField( "items.itemnumber" );
165
166
    my $localitemmarc = MARC::Record->new;
165
    my $localitemmarc = MARC::Record->new;
167
    $localitemmarc->append_fields( $source_item_marc->field($itemtag) );
166
    $localitemmarc->append_fields( $source_item_marc->field($itemtag) );
168
167
Lines 170-175 sub AddItemFromMarc { Link Here
170
    my $unlinked_item_subfields = _get_unlinked_item_subfields( $localitemmarc, $frameworkcode );
169
    my $unlinked_item_subfields = _get_unlinked_item_subfields( $localitemmarc, $frameworkcode );
171
    $item_values->{more_subfields_xml} = _get_unlinked_subfields_xml($unlinked_item_subfields);
170
    $item_values->{more_subfields_xml} = _get_unlinked_subfields_xml($unlinked_item_subfields);
172
    $item_values->{biblionumber} = $biblionumber;
171
    $item_values->{biblionumber} = $biblionumber;
172
    $item_values->{biblioitemnumber} = $params->{biblioitemnumber};
173
    $item_values->{cn_source} = delete $item_values->{'items.cn_source'}; # Because of C4::Biblio::_disambiguate
173
    $item_values->{cn_source} = delete $item_values->{'items.cn_source'}; # Because of C4::Biblio::_disambiguate
174
    $item_values->{cn_sort}   = delete $item_values->{'items.cn_sort'};   # Because of C4::Biblio::_disambiguate
174
    $item_values->{cn_sort}   = delete $item_values->{'items.cn_sort'};   # Because of C4::Biblio::_disambiguate
175
    my $item = Koha::Item->new( $item_values )->store({ skip_record_index => $params->{skip_record_index} });
175
    my $item = Koha::Item->new( $item_values )->store({ skip_record_index => $params->{skip_record_index} });
176
- 

Return to bug 30824