From 1f1d88ad32f23049f7107182e0bb0f1006d1d3bc Mon Sep 17 00:00:00 2001 From: Kyle Hall Date: Tue, 15 Mar 2022 11:34:32 -0400 Subject: [PATCH] Bug 20817: (QA follow-up) Add new parameter for PrepareItemrecordDisplay --- C4/Items.pm | 13 ++++++++----- acqui/neworderempty.pl | 2 +- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/C4/Items.pm b/C4/Items.pm index f6e74a6453..0831b8cf36 100644 --- a/C4/Items.pm +++ b/C4/Items.pm @@ -1262,7 +1262,7 @@ sub _find_value { =head2 PrepareItemrecordDisplay - PrepareItemrecordDisplay($bibnum,$itemumber,$defaultvalues,$frameworkcode); + PrepareItemrecordDisplay($bibnum,$itemumber,$defaultvalues,$frameworkcode, $use_defaults); Returns a hash with all the fields for Display a given item data in a template @@ -1270,11 +1270,13 @@ $defaultvalues should either contain a hashref of values for the new item, or be The $frameworkcode returns the item for the given frameworkcode, ONLY if bibnum is not provided +If $use_defaults is true, the returned item values will be generated from the default values only. + =cut sub PrepareItemrecordDisplay { - my ( $bibnum, $itemnum, $defaultvalues, $frameworkcode ) = @_; + my ( $bibnum, $itemnum, $defaultvalues, $frameworkcode, $use_defaults ) = @_; my $dbh = C4::Context->dbh; $frameworkcode = C4::Biblio::GetFrameworkCode($bibnum) if $bibnum; @@ -1294,11 +1296,12 @@ sub PrepareItemrecordDisplay { # return nothing if we don't have found an existing framework. return q{} unless $tagslib; my $itemrecord; - if ($itemnum) { - $itemrecord = C4::Items::GetMarcItem( $bibnum, $itemnum ); - }elsif ($defaultvalues && $defaultvalues->{'itemrecord'} ) { + if ($use_defaults) { $itemrecord = $defaultvalues->{'itemrecord'}; } + elsif ($itemnum) { + $itemrecord = C4::Items::GetMarcItem( $bibnum, $itemnum ); + } my @loop_data; my $branch_limit = C4::Context->userenv ? C4::Context->userenv->{"branch"} : ""; diff --git a/acqui/neworderempty.pl b/acqui/neworderempty.pl index ef469299b6..0ffb1eed29 100755 --- a/acqui/neworderempty.pl +++ b/acqui/neworderempty.pl @@ -675,7 +675,7 @@ sub staged_items_field { 'branchcode'=>_trim($iteminfos->{homebranch}) ); $all_items_quantity++; - my $itemprocessed = PrepareItemrecordDisplay('', '', \%defaultvalues , 'ACQ'); + my $itemprocessed = PrepareItemrecordDisplay('', '', \%defaultvalues , 'ACQ', 1); push @itemlist, $itemprocessed->{'iteminformation'}; } } -- 2.30.2