From b24611936a346a62ef7338145eab8bf153b6fa8c Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Thu, 15 Sep 2022 12:47:37 +0000 Subject: [PATCH] Bug 31569: Remove GetImportRecordsRange from import_biblios_list This patch changes the way records are loaded for display when adding to a basket from a staged file To test: 1 - Stage a file of records for import 2 - Go to Acquisitions, find a vendor, create or find a basket 3 - Add to basket from staged file 4 - Choose the file 5 - Note the display of records 6 - Cancel 7 - Apply patch 8 - Stage from same file 9 - Note the display is unchanged Signed-off-by: Andrew Fuerste-Henry Signed-off-by: Katrin Fischer Signed-off-by: Tomas Cohen Arazi --- acqui/addorderiso2709.pl | 32 ++++++++----------- .../prog/en/modules/acqui/addorderiso2709.tt | 13 ++++++-- 2 files changed, 25 insertions(+), 20 deletions(-) diff --git a/acqui/addorderiso2709.pl b/acqui/addorderiso2709.pl index aecb0ef8eb..0a85ca6c9a 100755 --- a/acqui/addorderiso2709.pl +++ b/acqui/addorderiso2709.pl @@ -51,6 +51,7 @@ use Koha::Acquisition::Baskets; use Koha::Acquisition::Currencies; use Koha::Acquisition::Orders; use Koha::Acquisition::Booksellers; +use Koha::Import::Records; use Koha::Patrons; my $input = CGI->new; @@ -442,7 +443,10 @@ sub import_biblios_list { my ($template, $import_batch_id) = @_; my $batch = GetImportBatch($import_batch_id,'staged'); return () unless $batch and $batch->{import_status} =~ /^staged$|^reverted$/; - my $biblios = GetImportRecordsRange($import_batch_id,'','',$batch->{import_status}); + my $import_records = Koha::Import::Records->search({ + import_batch_id => $import_batch_id, + status => $batch->{import_status} + }); my @list = (); my $item_error = 0; @@ -464,30 +468,22 @@ sub import_biblios_list { } my $biblio_count = 0; - foreach my $biblio (@$biblios) { + while ( my $import_record = $import_records->next ) { my $item_id = 1; $biblio_count++; - my $citation = $biblio->{'title'}; - $citation .= " $biblio->{'author'}" if $biblio->{'author'}; - $citation .= " (" if $biblio->{'issn'} or $biblio->{'isbn'}; - $citation .= $biblio->{'isbn'} if $biblio->{'isbn'}; - $citation .= ", " if $biblio->{'issn'} and $biblio->{'isbn'}; - $citation .= $biblio->{'issn'} if $biblio->{'issn'}; - $citation .= ")" if $biblio->{'issn'} or $biblio->{'isbn'}; - my $match = GetImportRecordMatches($biblio->{'import_record_id'}, 1); + my $match = GetImportRecordMatches($import_record->import_record_id, 1); my %cellrecord = ( - import_record_id => $biblio->{'import_record_id'}, - citation => $citation, + import_record_id => $import_record->import_record_id, + import_biblio => $import_record->import_biblio, import => 1, - status => $biblio->{'status'}, - record_sequence => $biblio->{'record_sequence'}, - overlay_status => $biblio->{'overlay_status'}, + status => $import_record->status, + record_sequence => $import_record->record_sequence, + overlay_status => $import_record->overlay_status, match_biblionumber => $#$match > -1 ? $match->[0]->{'biblionumber'} : 0, match_citation => $#$match > -1 ? $match->[0]->{'title'} || '' . ' ' . $match->[0]->{'author'} || '': '', match_score => $#$match > -1 ? $match->[0]->{'score'} : 0, ); - my ( $marcblob, $encoding ) = GetImportRecordMarc( $biblio->{'import_record_id'} ); - my $marcrecord = MARC::Record->new_from_usmarc($marcblob) || die "couldn't translate marc information"; + my $marcrecord = $import_record->get_marc_record || die "couldn't translate marc information"; my $infos = get_infos_syspref('MarcFieldsToOrder', $marcrecord, ['price', 'quantity', 'budget_code', 'discount', 'sort1', 'sort2','replacementprice']); my $price = $infos->{price}; @@ -584,7 +580,7 @@ sub import_biblios_list { my $overlay_action = GetImportBatchOverlayAction($import_batch_id); my $nomatch_action = GetImportBatchNoMatchAction($import_batch_id); my $item_action = GetImportBatchItemAction($import_batch_id); - $template->param(biblio_list => \@list, + $template->param(import_biblio_list => \@list, num_results => $num_records, import_batch_id => $import_batch_id, "overlay_action_${overlay_action}" => 1, diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/addorderiso2709.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/addorderiso2709.tt index 68e0de4857..946c51c358 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/addorderiso2709.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/addorderiso2709.tt @@ -112,12 +112,21 @@ - [% FOREACH biblio IN biblio_list %] + [% FOREACH biblio IN import_biblio_list %]
( MARC | Card | Add order ) -- 2.39.5