use C4::Charset;
use C4::AuthoritiesMarc;
use C4::MarcModificationTemplates;
+use Koha::Items;
use Koha::Plugins::Handler;
use Koha::Logger;
my $item = TransformMarcToKoha( $item_marc );
- my $duplicate_barcode = exists( $item->{'barcode'} ) && GetItemnumberFromBarcode( $item->{'barcode'} );
+ my $duplicate_barcode = exists( $item->{'barcode'} ) && Koha::Items->find({ barcode => $item->{'barcode'} });
my $duplicate_itemnumber = exists( $item->{'itemnumber'} );
my $updsth = $dbh->prepare("UPDATE import_items SET status = ?, itemnumber = ? WHERE import_items_id = ?");
$updsth->finish();
$num_items_replaced++;
} elsif ( $action eq "replace" && $duplicate_barcode ) {
- my $itemnumber = GetItemnumberFromBarcode( $item->{'barcode'} );
+ my $itemnumber = $duplicate_barcode->itemnumber;
ModItemFromMarc( $item_marc, $biblionumber, $itemnumber );
$updsth->bind_param( 1, 'imported' );
$updsth->bind_param( 2, $item->{itemnumber} );
( $order_by ) = grep( /^$order_by$/, qw( import_record_id title status overlay_status ) ) ? $order_by : 'import_record_id';
my $order_by_direction =
- uc( $parameters->{order_by_direction} ) eq 'DESC' ? 'DESC' : 'ASC';
+ uc( $parameters->{order_by_direction} // 'ASC' ) eq 'DESC' ? 'DESC' : 'ASC';
$order_by .= " $order_by_direction, authorized_heading" if $order_by eq 'title';
my ($batch_id, $record_sequence, $marc_record, $record_type, $encoding, $z3950random, $marc_type) = @_;
my $dbh = C4::Context->dbh;
- my $sth = $dbh->prepare("INSERT INTO import_records (import_batch_id, record_sequence, marc, marcxml,
+ my $sth = $dbh->prepare("INSERT INTO import_records (import_batch_id, record_sequence, marc, marcxml, marcxml_old,
record_type, encoding, z3950random)
- VALUES (?, ?, ?, ?, ?, ?, ?)");
- $sth->execute($batch_id, $record_sequence, $marc_record->as_usmarc(), $marc_record->as_xml($marc_type),
+ VALUES (?, ?, ?, ?, ?, ?, ?, ?)");
+ $sth->execute($batch_id, $record_sequence, $marc_record->as_usmarc(), $marc_record->as_xml($marc_type), '',
$record_type, $encoding, $z3950random);
my $import_record_id = $dbh->{'mysql_insertid'};
$sth->finish();