Bug 28445: Start form with empty library for batch mod

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
This commit is contained in:
Jonathan Druart 2021-07-20 17:44:20 +02:00
parent 86156da415
commit b52c7d7b36
2 changed files with 6 additions and 8 deletions

View File

@ -81,6 +81,7 @@ sub generate_subfield_form {
my $restricted_edition = $params->{restricted_editition};
my $prefill_with_default_values = $params->{prefill_with_default_values};
my $branch_limit = $params->{branch_limit};
my $default_branches_empty = $params->{default_branches_empty};
my $item = $self->{item};
my $subfield = $tagslib->{$tag}{$subfieldtag};
@ -190,6 +191,7 @@ sub generate_subfield_form {
}
}
elsif ( $subfield->{authorised_value} eq "branches" ) {
push @authorised_values, "" if $default_branches_empty;
foreach my $thisbranch (@$libraries) {
push @authorised_values, $thisbranch->{branchcode};
$authorised_lib{ $thisbranch->{branchcode} } =
@ -471,6 +473,7 @@ sub edit_form {
my $subfields_to_ignore= $params->{subfields_to_ignore} || [];
my $prefill_with_default_values = $params->{prefill_with_default_values};
my $branch_limit = $params->{branch_limit};
my $default_branches_empty = $params->{default_branches_empty};
my $libraries =
Koha::Libraries->search( {}, { order_by => ['branchname'] } )->unblessed;
@ -542,6 +545,7 @@ sub edit_form {
restricted_edition => $restricted_edition,
prefill_with_default_values => $prefill_with_default_values,
branch_limit => $branch_limit,
default_branches_empty => $default_branches_empty,
}
);
push @subfields, $subfield_data;

View File

@ -404,16 +404,11 @@ if ($op eq "show"){
# Even if we do not display the items, we need the itemnumbers
$template->param(itemnumbers_array => \@itemnumbers);
}
# now, build the item form for entering a new item
my @loop_data =();
my $branch_limit = C4::Context->userenv ? C4::Context->userenv->{"branch"} : "";
my $libraries = Koha::Libraries->search({}, { order_by => ['branchname'] })->unblessed;# build once ahead of time, instead of multiple times later.
# Adding a default choice, in case the user does not want to modify the branch
my $nochange_branch = { branchname => '', value => '', selected => 1 };
unshift (@$libraries, $nochange_branch);
my $pref_itemcallnumber = C4::Context->preference('itemcallnumber');
# Getting list of subfields to keep when restricted batchmod edit is enabled
@ -429,11 +424,10 @@ if ($op eq "show"){
),
subfields_to_ignore => ['items.barcode'],
prefill_with_default_values => $use_default_values,
default_branches_empty => 1,
}
);
# what's the next op ? it's what we are not in : an add if we're editing, otherwise, and edit.
$template->param(
subfields => $subfields,