Lines 35-40
use C4::Charset qw( MarcToUTF8Record SetUTF8Flag StripNonXmlChars );
Link Here
|
35 |
use C4::AuthoritiesMarc qw( AddAuthority GuessAuthTypeCode GetAuthorityXML ModAuthority DelAuthority ); |
35 |
use C4::AuthoritiesMarc qw( AddAuthority GuessAuthTypeCode GetAuthorityXML ModAuthority DelAuthority ); |
36 |
use C4::MarcModificationTemplates qw( ModifyRecordWithTemplate ); |
36 |
use C4::MarcModificationTemplates qw( ModifyRecordWithTemplate ); |
37 |
use Koha::Items; |
37 |
use Koha::Items; |
|
|
38 |
use Koha::SearchEngine; |
39 |
use Koha::SearchEngine::Indexer; |
38 |
use Koha::Plugins::Handler; |
40 |
use Koha::Plugins::Handler; |
39 |
use Koha::Logger; |
41 |
use Koha::Logger; |
40 |
|
42 |
|
Lines 578-583
sub BatchCommitRecords {
Link Here
|
578 |
my $logged_in_patron = Koha::Patrons->find( $userenv->{number} ); |
580 |
my $logged_in_patron = Koha::Patrons->find( $userenv->{number} ); |
579 |
|
581 |
|
580 |
my $rec_num = 0; |
582 |
my $rec_num = 0; |
|
|
583 |
my @biblio_ids; |
581 |
while (my $rowref = $sth->fetchrow_hashref) { |
584 |
while (my $rowref = $sth->fetchrow_hashref) { |
582 |
$record_type = $rowref->{'record_type'}; |
585 |
$record_type = $rowref->{'record_type'}; |
583 |
$rec_num++; |
586 |
$rec_num++; |
Lines 617-623
sub BatchCommitRecords {
Link Here
|
617 |
$num_added++; |
620 |
$num_added++; |
618 |
if ($record_type eq 'biblio') { |
621 |
if ($record_type eq 'biblio') { |
619 |
my $biblioitemnumber; |
622 |
my $biblioitemnumber; |
620 |
($recordid, $biblioitemnumber) = AddBiblio($marc_record, $framework); |
623 |
($recordid, $biblioitemnumber) = AddBiblio($marc_record, $framework, { skip_record_index => 1 }); |
|
|
624 |
push @biblio_ids, $recordid; |
621 |
$query = "UPDATE import_biblios SET matched_biblionumber = ? WHERE import_record_id = ?"; # FIXME call SetMatchedBiblionumber instead |
625 |
$query = "UPDATE import_biblios SET matched_biblionumber = ? WHERE import_record_id = ?"; # FIXME call SetMatchedBiblionumber instead |
622 |
if ($item_result eq 'create_new' || $item_result eq 'replace') { |
626 |
if ($item_result eq 'create_new' || $item_result eq 'replace') { |
623 |
my ($bib_items_added, $bib_items_replaced, $bib_items_errored) = BatchCommitItems($rowref->{'import_record_id'}, $recordid, $item_result, $biblioitemnumber); |
627 |
my ($bib_items_added, $bib_items_replaced, $bib_items_errored) = BatchCommitItems($rowref->{'import_record_id'}, $recordid, $item_result, $biblioitemnumber); |
Lines 656-664
sub BatchCommitRecords {
Link Here
|
656 |
$context->{userid} = $logged_in_patron->userid; |
660 |
$context->{userid} = $logged_in_patron->userid; |
657 |
} |
661 |
} |
658 |
|
662 |
|
659 |
ModBiblio($marc_record, $recordid, $oldbiblio->frameworkcode, { |
663 |
ModBiblio( |
660 |
overlay_context => $context |
664 |
$marc_record, |
661 |
}); |
665 |
$recordid, |
|
|
666 |
$oldbiblio->frameworkcode, |
667 |
{ |
668 |
overlay_context => $context, |
669 |
skip_record_index => 1 |
670 |
} |
671 |
); |
672 |
push @biblio_ids, $recordid; |
662 |
$query = "UPDATE import_biblios SET matched_biblionumber = ? WHERE import_record_id = ?"; # FIXME call SetMatchedBiblionumber instead |
673 |
$query = "UPDATE import_biblios SET matched_biblionumber = ? WHERE import_record_id = ?"; # FIXME call SetMatchedBiblionumber instead |
663 |
|
674 |
|
664 |
if ($item_result eq 'create_new' || $item_result eq 'replace') { |
675 |
if ($item_result eq 'create_new' || $item_result eq 'replace') { |
Lines 686-691
sub BatchCommitRecords {
Link Here
|
686 |
$num_ignored++; |
697 |
$num_ignored++; |
687 |
if ($record_type eq 'biblio' and defined $recordid and ( $item_result eq 'create_new' || $item_result eq 'replace' ) ) { |
698 |
if ($record_type eq 'biblio' and defined $recordid and ( $item_result eq 'create_new' || $item_result eq 'replace' ) ) { |
688 |
my ($bib_items_added, $bib_items_replaced, $bib_items_errored) = BatchCommitItems($rowref->{'import_record_id'}, $recordid, $item_result); |
699 |
my ($bib_items_added, $bib_items_replaced, $bib_items_errored) = BatchCommitItems($rowref->{'import_record_id'}, $recordid, $item_result); |
|
|
700 |
push @biblio_ids, $recordid if $bib_items_added || $bib_items_replaced; |
689 |
$num_items_added += $bib_items_added; |
701 |
$num_items_added += $bib_items_added; |
690 |
$num_items_replaced += $bib_items_replaced; |
702 |
$num_items_replaced += $bib_items_replaced; |
691 |
$num_items_errored += $bib_items_errored; |
703 |
$num_items_errored += $bib_items_errored; |
Lines 699-704
sub BatchCommitRecords {
Link Here
|
699 |
} |
711 |
} |
700 |
} |
712 |
} |
701 |
$sth->finish(); |
713 |
$sth->finish(); |
|
|
714 |
|
715 |
if ( @biblio_ids ) { |
716 |
my $indexer = Koha::SearchEngine::Indexer->new({ index => $Koha::SearchEngine::BIBLIOS_INDEX }); |
717 |
$indexer->index_records( \@biblio_ids, "specialUpdate", "biblioserver" ); |
718 |
} |
719 |
|
702 |
SetImportBatchStatus($batch_id, 'imported'); |
720 |
SetImportBatchStatus($batch_id, 'imported'); |
703 |
return ($num_added, $num_updated, $num_items_added, $num_items_replaced, $num_items_errored, $num_ignored); |
721 |
return ($num_added, $num_updated, $num_items_added, $num_items_replaced, $num_items_errored, $num_ignored); |
704 |
} |
722 |
} |
Lines 744-750
sub BatchCommitItems {
Link Here
|
744 |
my $updsth = $dbh->prepare("UPDATE import_items SET status = ?, itemnumber = ?, import_error = ? WHERE import_items_id = ?"); |
762 |
my $updsth = $dbh->prepare("UPDATE import_items SET status = ?, itemnumber = ?, import_error = ? WHERE import_items_id = ?"); |
745 |
if ( $action eq "replace" && $duplicate_itemnumber ) { |
763 |
if ( $action eq "replace" && $duplicate_itemnumber ) { |
746 |
# Duplicate itemnumbers have precedence, that way we can update barcodes by overlaying |
764 |
# Duplicate itemnumbers have precedence, that way we can update barcodes by overlaying |
747 |
ModItemFromMarc( $item_marc, $biblionumber, $item->{itemnumber} ); |
765 |
ModItemFromMarc( $item_marc, $biblionumber, $item->{itemnumber}, { skip_record_index => 1 } ); |
748 |
$updsth->bind_param( 1, 'imported' ); |
766 |
$updsth->bind_param( 1, 'imported' ); |
749 |
$updsth->bind_param( 2, $item->{itemnumber} ); |
767 |
$updsth->bind_param( 2, $item->{itemnumber} ); |
750 |
$updsth->bind_param( 3, undef ); |
768 |
$updsth->bind_param( 3, undef ); |
Lines 754-760
sub BatchCommitItems {
Link Here
|
754 |
$num_items_replaced++; |
772 |
$num_items_replaced++; |
755 |
} elsif ( $action eq "replace" && $duplicate_barcode ) { |
773 |
} elsif ( $action eq "replace" && $duplicate_barcode ) { |
756 |
my $itemnumber = $duplicate_barcode->itemnumber; |
774 |
my $itemnumber = $duplicate_barcode->itemnumber; |
757 |
ModItemFromMarc( $item_marc, $biblionumber, $itemnumber ); |
775 |
ModItemFromMarc( $item_marc, $biblionumber, $itemnumber, { skip_record_index => 1 } ); |
758 |
$updsth->bind_param( 1, 'imported' ); |
776 |
$updsth->bind_param( 1, 'imported' ); |
759 |
$updsth->bind_param( 2, $item->{itemnumber} ); |
777 |
$updsth->bind_param( 2, $item->{itemnumber} ); |
760 |
$updsth->bind_param( 3, undef ); |
778 |
$updsth->bind_param( 3, undef ); |
Lines 774-780
sub BatchCommitItems {
Link Here
|
774 |
my ( $itemtag, $itemsubfield ) = GetMarcFromKohaField( "items.itemnumber" ); |
792 |
my ( $itemtag, $itemsubfield ) = GetMarcFromKohaField( "items.itemnumber" ); |
775 |
$item_marc->field($itemtag)->delete_subfield( code => $itemsubfield ); |
793 |
$item_marc->field($itemtag)->delete_subfield( code => $itemsubfield ); |
776 |
|
794 |
|
777 |
my ( $item_biblionumber, $biblioitemnumber, $itemnumber ) = AddItemFromMarc( $item_marc, $biblionumber, {biblioitemnumber => $biblioitemnumber} ); |
795 |
my ( $item_biblionumber, $biblioitemnumber, $itemnumber ) = AddItemFromMarc( $item_marc, $biblionumber, { biblioitemnumber => $biblioitemnumber, skip_record_index => 1 } ); |
778 |
if( $itemnumber ) { |
796 |
if( $itemnumber ) { |
779 |
$updsth->bind_param( 1, 'imported' ); |
797 |
$updsth->bind_param( 1, 'imported' ); |
780 |
$updsth->bind_param( 2, $itemnumber ); |
798 |
$updsth->bind_param( 2, $itemnumber ); |
781 |
- |
|
|