);
}
-our $logger = Koha::Logger->get( { category => 'C4.ImportBatch' } );
-
=head1 NAME
C4::ImportBatch - manage batches of imported MARC records
|, { Slice => {} }, $import_record_id );
my @item_fields;
for my $import_item ( @$import_items ) {
- my $item_marc = MARC::Record::new_from_xml($import_item->{marcxml});
+ my $item_marc = MARC::Record::new_from_xml($import_item->{marcxml}, 'UTF-8');
push @item_fields, $item_marc->field($itemtag);
}
$record->append_fields(@item_fields);
sub BatchRevertRecords {
my $batch_id = shift;
+ my $logger = Koha::Logger->get( { category => 'C4.ImportBatch' } );
+
$logger->trace("C4::ImportBatch::BatchRevertRecords( $batch_id )");
my $record_type;
$sth->bind_param(1, $import_record_id);
$sth->execute();
while (my $row = $sth->fetchrow_hashref()) {
- my $error = DelItemCheck( $biblionumber, $row->{'itemnumber'});
- if ($error == 1){
+ my $item = Koha::Items->find($row->{itemnumber});
+ my $error = $item->safe_delete;
+ if ($error eq '1'){
my $updsth = $dbh->prepare("UPDATE import_items SET status = ? WHERE import_items_id = ?");
$updsth->bind_param(1, 'reverted');
$updsth->bind_param(2, $row->{'import_items_id'});
my $dbh = C4::Context->dbh;
my $order_by = $parameters->{order_by} || 'import_record_id';
- ( $order_by ) = grep( /^$order_by$/, qw( import_record_id title status overlay_status ) ) ? $order_by : 'import_record_id';
+ ( $order_by ) = grep( { $_ eq $order_by } qw( import_record_id title status overlay_status ) ) ? $order_by : 'import_record_id';
my $order_by_direction =
uc( $parameters->{order_by_direction} // 'ASC' ) eq 'DESC' ? 'DESC' : 'ASC';
my $marc_type = C4::Context->preference('marcflavour');
$marc_type .= 'AUTH' if ($marc_type eq 'UNIMARC' && $record_type eq 'auth');
- open IN, "<$input_file" or die "$0: cannot open input file $input_file: $!\n";
+ open my $fh, '<', $input_file or die "$0: cannot open input file $input_file: $!\n";
my @marc_records;
$/ = "\035";
- while (<IN>) {
+ while (<$fh>) {
s/^\s+//;
s/\s+$//;
next unless $_; # skip if record has only whitespace, as might occur
"Unexpected charset $charset_guessed, expecting $encoding";
}
}
- close IN;
+ close $fh;
return ( \@errors, \@marc_records );
}
return \@return if !$input_file || !$plugin_class;
# Read input file
- open IN, "<$input_file" or die "$0: cannot open input file $input_file: $!\n";
+ open my $fh, '<', $input_file or die "$0: cannot open input file $input_file: $!\n";
$/ = "\035";
- while (<IN>) {
+ while (<$fh>) {
s/^\s+//;
s/\s+$//;
next unless $_;
$text .= $_;
}
- close IN;
+ close $fh;
# Convert to large MARC blob with plugin
$text = Koha::Plugins::Handler->run({