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 607-612
sub BatchCommitRecords {
Link Here
|
607 |
my $logged_in_patron = Koha::Patrons->find( $userenv->{number} ); |
609 |
my $logged_in_patron = Koha::Patrons->find( $userenv->{number} ); |
608 |
|
610 |
|
609 |
my $rec_num = 0; |
611 |
my $rec_num = 0; |
|
|
612 |
my @biblio_ids; |
610 |
while (my $rowref = $sth->fetchrow_hashref) { |
613 |
while (my $rowref = $sth->fetchrow_hashref) { |
611 |
$record_type = $rowref->{'record_type'}; |
614 |
$record_type = $rowref->{'record_type'}; |
612 |
$rec_num++; |
615 |
$rec_num++; |
Lines 646-652
sub BatchCommitRecords {
Link Here
|
646 |
$num_added++; |
649 |
$num_added++; |
647 |
if ($record_type eq 'biblio') { |
650 |
if ($record_type eq 'biblio') { |
648 |
my $biblioitemnumber; |
651 |
my $biblioitemnumber; |
649 |
($recordid, $biblioitemnumber) = AddBiblio($marc_record, $framework); |
652 |
($recordid, $biblioitemnumber) = AddBiblio($marc_record, $framework, { skip_record_index => 1 }); |
|
|
653 |
push @biblio_ids, $recordid; |
650 |
$query = "UPDATE import_biblios SET matched_biblionumber = ? WHERE import_record_id = ?"; # FIXME call SetMatchedBiblionumber instead |
654 |
$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') { |
655 |
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); |
656 |
my ($bib_items_added, $bib_items_replaced, $bib_items_errored) = BatchCommitItems($rowref->{'import_record_id'}, $recordid, $item_result); |
Lines 685-693
sub BatchCommitRecords {
Link Here
|
685 |
$context->{userid} = $logged_in_patron->userid; |
689 |
$context->{userid} = $logged_in_patron->userid; |
686 |
} |
690 |
} |
687 |
|
691 |
|
688 |
ModBiblio($marc_record, $recordid, $oldbiblio->frameworkcode, { |
692 |
ModBiblio( |
689 |
overlay_context => $context |
693 |
$marc_record, |
690 |
}); |
694 |
$recordid, |
|
|
695 |
$oldbiblio->frameworkcode, |
696 |
{ |
697 |
overlay_context => $context, |
698 |
skip_record_index => 1 |
699 |
} |
700 |
); |
701 |
push @biblio_ids, $recordid; |
691 |
$query = "UPDATE import_biblios SET matched_biblionumber = ? WHERE import_record_id = ?"; # FIXME call SetMatchedBiblionumber instead |
702 |
$query = "UPDATE import_biblios SET matched_biblionumber = ? WHERE import_record_id = ?"; # FIXME call SetMatchedBiblionumber instead |
692 |
|
703 |
|
693 |
if ($item_result eq 'create_new' || $item_result eq 'replace') { |
704 |
if ($item_result eq 'create_new' || $item_result eq 'replace') { |
Lines 715-720
sub BatchCommitRecords {
Link Here
|
715 |
$num_ignored++; |
726 |
$num_ignored++; |
716 |
if ($record_type eq 'biblio' and defined $recordid and ( $item_result eq 'create_new' || $item_result eq 'replace' ) ) { |
727 |
if ($record_type eq 'biblio' and defined $recordid and ( $item_result eq 'create_new' || $item_result eq 'replace' ) ) { |
717 |
my ($bib_items_added, $bib_items_replaced, $bib_items_errored) = BatchCommitItems($rowref->{'import_record_id'}, $recordid, $item_result); |
728 |
my ($bib_items_added, $bib_items_replaced, $bib_items_errored) = BatchCommitItems($rowref->{'import_record_id'}, $recordid, $item_result); |
|
|
729 |
push @biblio_ids, $recordid if $bib_items_added || $bib_items_replaced; |
718 |
$num_items_added += $bib_items_added; |
730 |
$num_items_added += $bib_items_added; |
719 |
$num_items_replaced += $bib_items_replaced; |
731 |
$num_items_replaced += $bib_items_replaced; |
720 |
$num_items_errored += $bib_items_errored; |
732 |
$num_items_errored += $bib_items_errored; |
Lines 728-733
sub BatchCommitRecords {
Link Here
|
728 |
} |
740 |
} |
729 |
} |
741 |
} |
730 |
$sth->finish(); |
742 |
$sth->finish(); |
|
|
743 |
|
744 |
if ( @biblio_ids ) { |
745 |
my $indexer = Koha::SearchEngine::Indexer->new({ index => $Koha::SearchEngine::BIBLIOS_INDEX }); |
746 |
$indexer->index_records( \@biblio_ids, "specialUpdate", "biblioserver" ); |
747 |
} |
748 |
|
731 |
SetImportBatchStatus($batch_id, 'imported'); |
749 |
SetImportBatchStatus($batch_id, 'imported'); |
732 |
return ($num_added, $num_updated, $num_items_added, $num_items_replaced, $num_items_errored, $num_ignored); |
750 |
return ($num_added, $num_updated, $num_items_added, $num_items_replaced, $num_items_errored, $num_ignored); |
733 |
} |
751 |
} |
Lines 773-779
sub BatchCommitItems {
Link Here
|
773 |
my $updsth = $dbh->prepare("UPDATE import_items SET status = ?, itemnumber = ? WHERE import_items_id = ?"); |
791 |
my $updsth = $dbh->prepare("UPDATE import_items SET status = ?, itemnumber = ? WHERE import_items_id = ?"); |
774 |
if ( $action eq "replace" && $duplicate_itemnumber ) { |
792 |
if ( $action eq "replace" && $duplicate_itemnumber ) { |
775 |
# Duplicate itemnumbers have precedence, that way we can update barcodes by overlaying |
793 |
# Duplicate itemnumbers have precedence, that way we can update barcodes by overlaying |
776 |
ModItemFromMarc( $item_marc, $biblionumber, $item->{itemnumber} ); |
794 |
ModItemFromMarc( $item_marc, $biblionumber, $item->{itemnumber}, { skip_record_index => 1 } ); |
777 |
$updsth->bind_param( 1, 'imported' ); |
795 |
$updsth->bind_param( 1, 'imported' ); |
778 |
$updsth->bind_param( 2, $item->{itemnumber} ); |
796 |
$updsth->bind_param( 2, $item->{itemnumber} ); |
779 |
$updsth->bind_param( 3, $row->{'import_items_id'} ); |
797 |
$updsth->bind_param( 3, $row->{'import_items_id'} ); |
Lines 782-788
sub BatchCommitItems {
Link Here
|
782 |
$num_items_replaced++; |
800 |
$num_items_replaced++; |
783 |
} elsif ( $action eq "replace" && $duplicate_barcode ) { |
801 |
} elsif ( $action eq "replace" && $duplicate_barcode ) { |
784 |
my $itemnumber = $duplicate_barcode->itemnumber; |
802 |
my $itemnumber = $duplicate_barcode->itemnumber; |
785 |
ModItemFromMarc( $item_marc, $biblionumber, $itemnumber ); |
803 |
ModItemFromMarc( $item_marc, $biblionumber, $itemnumber, { skip_record_index => 1 } ); |
786 |
$updsth->bind_param( 1, 'imported' ); |
804 |
$updsth->bind_param( 1, 'imported' ); |
787 |
$updsth->bind_param( 2, $item->{itemnumber} ); |
805 |
$updsth->bind_param( 2, $item->{itemnumber} ); |
788 |
$updsth->bind_param( 3, $row->{'import_items_id'} ); |
806 |
$updsth->bind_param( 3, $row->{'import_items_id'} ); |
Lines 800-806
sub BatchCommitItems {
Link Here
|
800 |
my ( $itemtag, $itemsubfield ) = GetMarcFromKohaField( "items.itemnumber" ); |
818 |
my ( $itemtag, $itemsubfield ) = GetMarcFromKohaField( "items.itemnumber" ); |
801 |
$item_marc->field($itemtag)->delete_subfield( code => $itemsubfield ); |
819 |
$item_marc->field($itemtag)->delete_subfield( code => $itemsubfield ); |
802 |
|
820 |
|
803 |
my ( $item_biblionumber, $biblioitemnumber, $itemnumber ) = AddItemFromMarc( $item_marc, $biblionumber ); |
821 |
my ( $item_biblionumber, $biblioitemnumber, $itemnumber ) = AddItemFromMarc( $item_marc, $biblionumber, { skip_record_index => 1 } ); |
804 |
if( $itemnumber ) { |
822 |
if( $itemnumber ) { |
805 |
$updsth->bind_param( 1, 'imported' ); |
823 |
$updsth->bind_param( 1, 'imported' ); |
806 |
$updsth->bind_param( 2, $itemnumber ); |
824 |
$updsth->bind_param( 2, $itemnumber ); |
807 |
- |
|
|