From cef55b1409c40b34b459aae9e09187ce354f159b Mon Sep 17 00:00:00 2001 From: Andrew Nugged Date: Mon, 6 Dec 2021 12:03:36 +0200 Subject: [PATCH] Bug 20447: (QA follow-up) bugfix: holding_id not sent down from params and was not taken into account Signed-off-by: Nick Clemens --- Koha/Holdings.pm | 5 ++++- Koha/UI/Form/Builder/Item.pm | 10 ++++++++++ catalogue/showmarc.pl | 2 +- cataloguing/additem.pl | 3 +++ 4 files changed, 18 insertions(+), 2 deletions(-) diff --git a/Koha/Holdings.pm b/Koha/Holdings.pm index 0c6eed8907..e47fc4be0d 100644 --- a/Koha/Holdings.pm +++ b/Koha/Holdings.pm @@ -74,7 +74,10 @@ sub get_embeddable_marc_fields { } my ($holdingstag, $holdingssubfield) = Koha::Holding->get_marc_field_mapping({ field => 'holdings.holdingbranch' }); - my $holdings = $class->search({ biblionumber => $params->{biblionumber}, deleted_on => undef })->unblessed(); + my $holdings = $class->search({ + biblionumber => $params->{biblionumber}, + ($params->{holding_id} ? (holding_id => $params->{holding_id}) : ()), + deleted_on => undef })->unblessed(); foreach my $holding (@$holdings) { my $mungedholding = { map { diff --git a/Koha/UI/Form/Builder/Item.pm b/Koha/UI/Form/Builder/Item.pm index c003879d35..b6d35f0636 100644 --- a/Koha/UI/Form/Builder/Item.pm +++ b/Koha/UI/Form/Builder/Item.pm @@ -85,6 +85,7 @@ sub generate_subfield_form { my $branch_limit = $params->{branch_limit}; my $default_branches_empty = $params->{default_branches_empty}; my $readonly = $params->{readonly}; + my $holding_id = $params->{holding_id}; my $item = $self->{item}; my $subfield = $tagslib->{$tag}{$subfieldtag}; @@ -503,6 +504,7 @@ sub edit_form { my $branch_limit = $params->{branch_limit}; my $default_branches_empty = $params->{default_branches_empty}; my $ignore_invisible_subfields = $params->{ignore_invisible_subfields} || 0; + my $holding_id = $params->{holding_id}; my $libraries = Koha::Libraries->search( {}, { order_by => ['branchname'] } )->unblessed; @@ -520,6 +522,14 @@ sub edit_form { my $biblionumber = $self->{biblionumber}; my $frameworkcode = $biblionumber ? GetFrameworkCode($biblionumber) : q{}; my $marc_record = $biblionumber ? GetMarcBiblio( { biblionumber => $biblionumber } ) : undef; + + # Overlay/add holdings defaults: + if ( C4::Context->preference('SummaryHoldings') && $holding_id ) { + my $holdings_fields = Koha::Holdings->get_embeddable_marc_fields({ biblionumber => $biblionumber, holding_id => $holding_id }); + $marc_record->append_fields(@$holdings_fields) if @$holdings_fields; + } + + my @subfields; my $tagslib = GetMarcStructure( 1, $frameworkcode ); foreach my $tag ( keys %{$tagslib} ) { diff --git a/catalogue/showmarc.pl b/catalogue/showmarc.pl index d92aa7f3bc..6fa7ec7ef4 100755 --- a/catalogue/showmarc.pl +++ b/catalogue/showmarc.pl @@ -48,7 +48,7 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user( my $biblionumber= $input->param('id'); my $importid= $input->param('importid'); my $view= $input->param('viewas')||''; -my $holding_id= $input->param('holding_id')||''; +my $holding_id = $input->param('holding_id') // ''; my $record; if ($holding_id) { diff --git a/cataloguing/additem.pl b/cataloguing/additem.pl index e8a64c1015..b2d25d9636 100755 --- a/cataloguing/additem.pl +++ b/cataloguing/additem.pl @@ -103,6 +103,8 @@ my $fa_branch = $input->param('branch'); my $fa_stickyduedate = $input->param('stickyduedate'); my $fa_duedatespec = $input->param('duedatespec'); +my $holding_id = $input->param('holding_id') // ''; + our $frameworkcode = &GetFrameworkCode($biblionumber); # Defining which userflag is needing according to the framework currently used @@ -598,6 +600,7 @@ my $subfields = ? ( ignore_invisible_subfields => 1 ) : () ), + holding_id => $holding_id, } ); -- 2.37.2