Bugzilla – Attachment 186303 Details for
Bug 32748
Library limitations will cause data loss when editing items
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 32748: (follow-up) Fix list behavior if AV is restricted and add itemtype restricted values
Bug-32748-follow-up-Fix-list-behavior-if-AV-is-res.patch (text/plain), 6.03 KB, created by
Thibaud Guillot (thibaud_g)
on 2025-09-09 14:29:47 UTC
(
hide
)
Description:
Bug 32748: (follow-up) Fix list behavior if AV is restricted and add itemtype restricted values
Filename:
MIME Type:
Creator:
Thibaud Guillot (thibaud_g)
Created:
2025-09-09 14:29:47 UTC
Size:
6.03 KB
patch
obsolete
>From 13ca0af451ebbd75857b63a32e94459848d1d0d3 Mon Sep 17 00:00:00 2001 >From: Thibaud Guillot <thibaud.guillot@biblibre.com> >Date: Tue, 9 Sep 2025 16:19:24 +0200 >Subject: [PATCH] Bug 32748: (follow-up) Fix list behavior if AV is restricted > and add itemtype restricted values > >--- > Koha/UI/Form/Builder/Item.pm | 23 +++++++++++-------- > .../prog/en/includes/html_helpers.inc | 12 ++++++++-- > 2 files changed, 24 insertions(+), 11 deletions(-) > >diff --git a/Koha/UI/Form/Builder/Item.pm b/Koha/UI/Form/Builder/Item.pm >index a71b563c0b6..3b0ec1be115 100644 >--- a/Koha/UI/Form/Builder/Item.pm >+++ b/Koha/UI/Form/Builder/Item.pm >@@ -169,7 +169,7 @@ sub generate_subfield_form { > if ( $subfield->{authorised_value} ) { > my @authorised_values; > my %authorised_lib; >- my %authorised_restricted; >+ my %restricted_values; > > # builds list, depending on authorised value... > if ( $subfield->{authorised_value} eq "LOST" ) { >@@ -203,16 +203,22 @@ sub generate_subfield_form { > } > } elsif ( $subfield->{authorised_value} eq "itemtypes" ) { > push @authorised_values, ""; >- my $itemtypes; >+ my $all_itemtypes = Koha::ItemTypes->search_with_localization; >+ my $filtered_itemtypes; > if ($branch_limit) { >- $itemtypes = Koha::ItemTypes->search_with_localization( { branchcode => $branch_limit } ); >+ $filtered_itemtypes = Koha::ItemTypes->search_with_localization( { branchcode => $branch_limit } ); > } else { >- $itemtypes = Koha::ItemTypes->search_with_localization; >+ $filtered_itemtypes = $all_itemtypes; > } >- while ( my $itemtype = $itemtypes->next ) { >+ while (my $itemtype = $filtered_itemtypes->next) { > push @authorised_values, $itemtype->itemtype; > $authorised_lib{ $itemtype->itemtype } = $itemtype->translated_description; > } >+ while (my $itemtype = $all_itemtypes->next) { >+ if (!grep { $_ eq $itemtype->itemtype } @authorised_values) { >+ $restricted_values{ $itemtype->itemtype } = $itemtype->translated_description; >+ } >+ } > > if ( !$value && $biblionumber ) { > my $itype_sth = $dbh->prepare("SELECT itemtype FROM biblioitems WHERE biblionumber = ?"); >@@ -249,9 +255,8 @@ sub generate_subfield_form { > my $av = GetAuthorisedValues( $subfield->{authorised_value}, undef, { 'no_limit' => 1 } ); > for my $r (@$av) { > push @authorised_values, $r->{authorised_value}; >- >- $authorised_lib{ $r->{authorised_value} } = $r->{lib}; >- $authorised_restricted{ $r->{authorised_value} } = $r->{restricted}; >+ $authorised_lib{ $r->{authorised_value} } = $r->{lib}; >+ $restricted_values{ $r->{authorised_value} } = $r->{restricted}; > } > } > >@@ -273,7 +278,7 @@ sub generate_subfield_form { > id => "tag_" . $tag . "_subfield_" . $subfieldtag . "_" . $index_subfield, > values => \@authorised_values, > labels => \%authorised_lib, >- restricted => \%authorised_restricted, >+ restricted => \%restricted_values, > default => $value, > ( > ( grep { $_ eq $subfield->{authorised_value} } (qw(branches itemtypes cn_source)) ) >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/html_helpers.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/html_helpers.inc >index a0716f84167..f94e3307ab1 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/html_helpers.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/html_helpers.inc >@@ -135,13 +135,21 @@ > [% ELSIF subfield.IS_LOST_AV && Koha.Preference("BundleLostValue") && aval == Koha.Preference("BundleLostValue") %] > <option disabled="disabled" value="[%- aval | html -%]" title="Bundle losses are set at checkin automatically">[%- mv.labels.$aval | html -%]</option> > [% ELSE %] >- <option value="[%- aval | html -%]">[%- mv.labels.$aval | html -%]</option> >+ [% UNLESS mv.restricted.$aval %] >+ <option value="[%- aval | html -%]">[%- mv.labels.$aval | html -%]</option> >+ [% END %] > [% END %] > [% END %] > [% END %] > [% UNLESS matched || ( ( kohafield == 'items.damaged' || kohafield == 'items.itemlost' || kohafield == 'items.withdrawn' || kohafield == 'items.notforloan' ) && mv.default == '0' ) %] > [%# If the current value is not in the authorised list and is not a field where 0 means unset #%] >- <option value="[%- mv.default | html -%]" selected="selected">[%- mv.default | html -%] (Not an authorised value)</option> >+ [% IF mv.restricted %] >+ [% FOREACH code IN mv.restricted.keys %] >+ [% IF mv.default == code %] >+ <option value="[%- code | html -%]" selected="selected" style="float:right" title="This value ([%- mv.restricted.$code | html -%]) is limited to other librairies">[%- mv.restricted.$code | html -%] ⚠</option> >+ [% END %] >+ [% END %] >+ [% END %] > [% END %] > </select> > [% UNLESS matched || ( ( kohafield == 'items.damaged' || kohafield == 'items.itemlost' || kohafield == 'items.withdrawn' || kohafield == 'items.notforloan' ) && mv.default == '0' ) %] >-- >2.39.5
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 32748
:
148409
|
148491
|
150155
|
151989
|
154039
|
154040
|
154041
|
154042
|
186006
|
186007
|
186008
|
186009
|
186303
|
186307
|
186308
|
186312
|
186313
|
186314
|
186315
|
186316
|
186317