Lines 654-661
sub BatchCommitRecords {
Link Here
|
654 |
SetImportRecordOverlayStatus($rowref->{'import_record_id'}, 'match_applied'); |
654 |
SetImportRecordOverlayStatus($rowref->{'import_record_id'}, 'match_applied'); |
655 |
SetImportRecordStatus($rowref->{'import_record_id'}, 'imported'); |
655 |
SetImportRecordStatus($rowref->{'import_record_id'}, 'imported'); |
656 |
} elsif ($record_result eq 'ignore') { |
656 |
} elsif ($record_result eq 'ignore') { |
|
|
657 |
$recordid = $record_match; |
657 |
$num_ignored++; |
658 |
$num_ignored++; |
658 |
if ($record_type eq 'biblio' and defined $recordid and $item_result eq 'create_new') { |
659 |
if ($record_type eq 'biblio' and defined $recordid and ( $item_result eq 'create_new' || $item_result eq 'replace' ) ) { |
659 |
my ($bib_items_added, $bib_items_replaced, $bib_items_errored) = BatchCommitItems($rowref->{'import_record_id'}, $recordid, $item_result); |
660 |
my ($bib_items_added, $bib_items_replaced, $bib_items_errored) = BatchCommitItems($rowref->{'import_record_id'}, $recordid, $item_result); |
660 |
$num_items_added += $bib_items_added; |
661 |
$num_items_added += $bib_items_added; |
661 |
$num_items_replaced += $bib_items_replaced; |
662 |
$num_items_replaced += $bib_items_replaced; |
Lines 687-705
sub BatchCommitItems {
Link Here
|
687 |
my $dbh = C4::Context->dbh; |
688 |
my $dbh = C4::Context->dbh; |
688 |
|
689 |
|
689 |
my ( $num_items_added, $num_items_errored, $num_items_replaced ) = 0; |
690 |
my ( $num_items_added, $num_items_errored, $num_items_replaced ) = 0; |
690 |
my $sth = $dbh->prepare(" |
691 |
my $sth = $dbh->prepare( " |
691 |
SELECT import_items_id, import_items.marcxml, encoding |
692 |
SELECT import_items_id, import_items.marcxml, encoding |
692 |
FROM import_items |
693 |
FROM import_items |
693 |
JOIN import_records USING (import_record_id) |
694 |
JOIN import_records USING (import_record_id) |
694 |
WHERE import_record_id = ? |
695 |
WHERE import_record_id = ? |
695 |
ORDER BY import_items_id |
696 |
ORDER BY import_items_id |
696 |
"); |
697 |
" ); |
697 |
$sth->bind_param( 1, $import_record_id ); |
698 |
$sth->bind_param( 1, $import_record_id ); |
698 |
$sth->execute(); |
699 |
$sth->execute(); |
|
|
700 |
|
699 |
while ( my $row = $sth->fetchrow_hashref() ) { |
701 |
while ( my $row = $sth->fetchrow_hashref() ) { |
700 |
my $item_marc = MARC::Record->new_from_xml( StripNonXmlChars( $row->{'marcxml'} ), 'UTF-8', $row->{'encoding'} ); |
702 |
my $item_marc = MARC::Record->new_from_xml( StripNonXmlChars( $row->{'marcxml'} ), 'UTF-8', $row->{'encoding'} ); |
701 |
|
703 |
|
702 |
#delete date_due subfield as to not accidentally delete item checkout due dates |
704 |
# Delete date_due subfield as to not accidentally delete item checkout due dates |
703 |
my ( $MARCfield, $MARCsubfield ) = GetMarcFromKohaField( 'items.onloan', GetFrameworkCode($biblionumber) ); |
705 |
my ( $MARCfield, $MARCsubfield ) = GetMarcFromKohaField( 'items.onloan', GetFrameworkCode($biblionumber) ); |
704 |
$item_marc->field($MARCfield)->delete_subfield( code => $MARCsubfield ); |
706 |
$item_marc->field($MARCfield)->delete_subfield( code => $MARCsubfield ); |
705 |
|
707 |
|
Lines 710-715
sub BatchCommitItems {
Link Here
|
710 |
|
712 |
|
711 |
my $updsth = $dbh->prepare("UPDATE import_items SET status = ?, itemnumber = ? WHERE import_items_id = ?"); |
713 |
my $updsth = $dbh->prepare("UPDATE import_items SET status = ?, itemnumber = ? WHERE import_items_id = ?"); |
712 |
if ( $action eq "replace" && $duplicate_itemnumber ) { |
714 |
if ( $action eq "replace" && $duplicate_itemnumber ) { |
|
|
715 |
# Duplicate itemnumbers have precedence, that way we can update barcodes by overlaying |
713 |
ModItemFromMarc( $item_marc, $biblionumber, $item->{itemnumber} ); |
716 |
ModItemFromMarc( $item_marc, $biblionumber, $item->{itemnumber} ); |
714 |
$updsth->bind_param( 1, 'imported' ); |
717 |
$updsth->bind_param( 1, 'imported' ); |
715 |
$updsth->bind_param( 2, $item->{itemnumber} ); |
718 |
$updsth->bind_param( 2, $item->{itemnumber} ); |
Lines 717-722
sub BatchCommitItems {
Link Here
|
717 |
$updsth->execute(); |
720 |
$updsth->execute(); |
718 |
$updsth->finish(); |
721 |
$updsth->finish(); |
719 |
$num_items_replaced++; |
722 |
$num_items_replaced++; |
|
|
723 |
} elsif ( $action eq "replace" && $duplicate_barcode ) { |
724 |
my $itemnumber = GetItemnumberFromBarcode( $item->{'barcode'} ); |
725 |
ModItemFromMarc( $item_marc, $biblionumber, $itemnumber ); |
726 |
$updsth->bind_param( 1, 'imported' ); |
727 |
$updsth->bind_param( 2, $item->{itemnumber} ); |
728 |
$updsth->bind_param( 3, $row->{'import_items_id'} ); |
729 |
$updsth->execute(); |
730 |
$updsth->finish(); |
731 |
$num_items_replaced++; |
720 |
} elsif ($duplicate_barcode) { |
732 |
} elsif ($duplicate_barcode) { |
721 |
$updsth->bind_param( 1, 'error' ); |
733 |
$updsth->bind_param( 1, 'error' ); |
722 |
$updsth->bind_param( 2, 'duplicate item barcode' ); |
734 |
$updsth->bind_param( 2, 'duplicate item barcode' ); |