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