View | Details | Raw Unified | Return to bug 32748
Collapse All | Expand All

(-)a/Koha/UI/Form/Builder/Item.pm (-9 / +14 lines)
Lines 169-175 sub generate_subfield_form { Link Here
169
    if ( $subfield->{authorised_value} ) {
169
    if ( $subfield->{authorised_value} ) {
170
        my @authorised_values;
170
        my @authorised_values;
171
        my %authorised_lib;
171
        my %authorised_lib;
172
        my %authorised_restricted;
172
        my %restricted_values;
173
173
174
        # builds list, depending on authorised value...
174
        # builds list, depending on authorised value...
175
        if ( $subfield->{authorised_value} eq "LOST" ) {
175
        if ( $subfield->{authorised_value} eq "LOST" ) {
Lines 203-218 sub generate_subfield_form { Link Here
203
            }
203
            }
204
        } elsif ( $subfield->{authorised_value} eq "itemtypes" ) {
204
        } elsif ( $subfield->{authorised_value} eq "itemtypes" ) {
205
            push @authorised_values, "";
205
            push @authorised_values, "";
206
            my $itemtypes;
206
            my $all_itemtypes = Koha::ItemTypes->search_with_localization;
207
            my $filtered_itemtypes;
207
            if ($branch_limit) {
208
            if ($branch_limit) {
208
                $itemtypes = Koha::ItemTypes->search_with_localization( { branchcode => $branch_limit } );
209
                $filtered_itemtypes = Koha::ItemTypes->search_with_localization( { branchcode => $branch_limit } );
209
            } else {
210
            } else {
210
                $itemtypes = Koha::ItemTypes->search_with_localization;
211
                $filtered_itemtypes = $all_itemtypes;
211
            }
212
            }
212
            while ( my $itemtype = $itemtypes->next ) {
213
            while (my $itemtype = $filtered_itemtypes->next) {
213
                push @authorised_values, $itemtype->itemtype;
214
                push @authorised_values, $itemtype->itemtype;
214
                $authorised_lib{ $itemtype->itemtype } = $itemtype->translated_description;
215
                $authorised_lib{ $itemtype->itemtype } = $itemtype->translated_description;
215
            }
216
            }
217
            while (my $itemtype = $all_itemtypes->next) {
218
                if (!grep { $_ eq $itemtype->itemtype } @authorised_values) {
219
                    $restricted_values{ $itemtype->itemtype } = $itemtype->translated_description;
220
                }
221
            }
216
222
217
            if ( !$value && $biblionumber ) {
223
            if ( !$value && $biblionumber ) {
218
                my $itype_sth = $dbh->prepare("SELECT itemtype FROM biblioitems WHERE biblionumber = ?");
224
                my $itype_sth = $dbh->prepare("SELECT itemtype FROM biblioitems WHERE biblionumber = ?");
Lines 249-257 sub generate_subfield_form { Link Here
249
            my $av = GetAuthorisedValues( $subfield->{authorised_value}, undef, { 'no_limit' => 1 } );
255
            my $av = GetAuthorisedValues( $subfield->{authorised_value}, undef, { 'no_limit' => 1 } );
250
            for my $r (@$av) {
256
            for my $r (@$av) {
251
                push @authorised_values, $r->{authorised_value};
257
                push @authorised_values, $r->{authorised_value};
252
258
                $authorised_lib{ $r->{authorised_value} } = $r->{lib};
253
                $authorised_lib{ $r->{authorised_value} }        = $r->{lib};
259
                $restricted_values{ $r->{authorised_value} } = $r->{restricted};
254
                $authorised_restricted{ $r->{authorised_value} } = $r->{restricted};
255
            }
260
            }
256
        }
261
        }
257
262
Lines 273-279 sub generate_subfield_form { Link Here
273
                id         => "tag_" . $tag . "_subfield_" . $subfieldtag . "_" . $index_subfield,
278
                id         => "tag_" . $tag . "_subfield_" . $subfieldtag . "_" . $index_subfield,
274
                values     => \@authorised_values,
279
                values     => \@authorised_values,
275
                labels     => \%authorised_lib,
280
                labels     => \%authorised_lib,
276
                restricted => \%authorised_restricted,
281
                restricted => \%restricted_values,
277
                default    => $value,
282
                default    => $value,
278
                (
283
                (
279
                      ( grep { $_ eq $subfield->{authorised_value} } (qw(branches itemtypes cn_source)) )
284
                      ( grep { $_ eq $subfield->{authorised_value} } (qw(branches itemtypes cn_source)) )
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/html_helpers.inc (-3 / +10 lines)
Lines 135-147 Link Here
135
                                    [% ELSIF subfield.IS_LOST_AV && Koha.Preference("BundleLostValue") && aval == Koha.Preference("BundleLostValue") %]
135
                                    [% ELSIF subfield.IS_LOST_AV && Koha.Preference("BundleLostValue") && aval == Koha.Preference("BundleLostValue") %]
136
                                        <option disabled="disabled" value="[%- aval | html -%]" title="Bundle losses are set at checkin automatically">[%- mv.labels.$aval | html -%]</option>
136
                                        <option disabled="disabled" value="[%- aval | html -%]" title="Bundle losses are set at checkin automatically">[%- mv.labels.$aval | html -%]</option>
137
                                    [% ELSE %]
137
                                    [% ELSE %]
138
                                        <option value="[%- aval | html -%]">[%- mv.labels.$aval | html -%]</option>
138
                                        [% UNLESS mv.restricted.$aval %]
139
                                            <option value="[%- aval | html -%]">[%- mv.labels.$aval | html -%]</option>
140
                                        [% END %]
139
                                    [% END %]
141
                                    [% END %]
140
                                [% END %]
142
                                [% END %]
141
                            [% END %]
143
                            [% END %]
142
                            [% UNLESS matched || ( ( kohafield == 'items.damaged' || kohafield == 'items.itemlost' || kohafield == 'items.withdrawn' || kohafield == 'items.notforloan' ) && mv.default == '0' ) %]
144
                            [% UNLESS matched || ( ( kohafield == 'items.damaged' || kohafield == 'items.itemlost' || kohafield == 'items.withdrawn' || kohafield == 'items.notforloan' ) && mv.default == '0' ) %]
143
                                [%# If the current value is not in the authorised list  and is not a field where 0 means unset #%]
145
                                [%# If the current value is not in the authorised list  and is not a field where 0 means unset #%]
144
                                <option value="[%- mv.default | html -%]" selected="selected">[%- mv.default | html -%] (Not an authorised value)</option>
146
                                [% IF mv.restricted %]
147
                                    [% FOREACH code IN mv.restricted.keys %]
148
                                        [% IF mv.default == code %]
149
                                            <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 -%] &#9888;</option>
150
                                        [% END %]
151
                                    [% END %]
152
                                [% END %]
145
                            [% END %]
153
                            [% END %]
146
                        </select>
154
                        </select>
147
                        [% UNLESS matched || ( ( kohafield == 'items.damaged' || kohafield == 'items.itemlost' || kohafield == 'items.withdrawn' || kohafield == 'items.notforloan' ) && mv.default == '0' ) %]
155
                        [% UNLESS matched || ( ( kohafield == 'items.damaged' || kohafield == 'items.itemlost' || kohafield == 'items.withdrawn' || kohafield == 'items.notforloan' ) && mv.default == '0' ) %]
148
- 

Return to bug 32748