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

(-)a/C4/Koha.pm (-4 / +11 lines)
Lines 486-517 C<$opac> If set to a true value, displays OPAC descriptions rather than normal o Link Here
486
sub GetAuthorisedValues {
486
sub GetAuthorisedValues {
487
    my $category = shift // '';  # optional parameter
487
    my $category = shift // '';  # optional parameter
488
    my $opac = shift ? 1 : 0;  # normalise to be safe
488
    my $opac = shift ? 1 : 0;  # normalise to be safe
489
    my $options = shift // '';
490
    my $no_limit = $options->{'no_limit'} if $options; #optional paramater to ignore branch limitation
489
491
490
    # Is this cached already?
492
    # Is this cached already?
491
    my $branch_limit =
493
    my $branch_limit =
492
      C4::Context->userenv ? C4::Context->userenv->{"branch"} : "";
494
      C4::Context->userenv ? C4::Context->userenv->{"branch"} : "";
493
    my $cache_key =
495
    my $cache_key =
494
      "AuthorisedValues-$category-$opac-$branch_limit";
496
      "AuthorisedValues-$category-$opac-$branch_limit-$no_limit";
495
    my $cache  = Koha::Caches->get_instance();
497
    my $cache  = Koha::Caches->get_instance();
496
    my $result = $cache->get_from_cache($cache_key);
498
    my $result = $cache->get_from_cache($cache_key);
497
    return $result if $result;
499
    return $result if $result;
498
500
499
    my @results;
501
    my @results;
500
    my $dbh      = C4::Context->dbh;
502
    my $dbh      = C4::Context->dbh;
503
    my $select_clause = 'SELECT av.*';
504
    my @where_args;
505
    if ($branch_limit && $no_limit) {
506
        $select_clause .= ', IF (branchcode = ? OR branchcode IS NULL, 0, 1) as restricted';
507
        push @where_args, $branch_limit;
508
    }
501
    my $query = qq{
509
    my $query = qq{
502
        SELECT DISTINCT av.*
510
        $select_clause
503
        FROM authorised_values av
511
        FROM authorised_values av
504
    };
512
    };
505
    $query .= qq{
513
    $query .= qq{
506
          LEFT JOIN authorised_values_branches ON ( id = av_id )
514
          LEFT JOIN authorised_values_branches ON ( id = av_id )
507
    } if $branch_limit;
515
    } if $branch_limit;
508
    my @where_strings;
516
    my @where_strings;
509
    my @where_args;
510
    if($category) {
517
    if($category) {
511
        push @where_strings, "category = ?";
518
        push @where_strings, "category = ?";
512
        push @where_args, $category;
519
        push @where_args, $category;
513
    }
520
    }
514
    if($branch_limit) {
521
    if($branch_limit && !defined $no_limit) {
515
        push @where_strings, "( branchcode = ? OR branchcode IS NULL )";
522
        push @where_strings, "( branchcode = ? OR branchcode IS NULL )";
516
        push @where_args, $branch_limit;
523
        push @where_args, $branch_limit;
517
    }
524
    }
(-)a/Koha/UI/Form/Builder/Item.pm (-2 / +6 lines)
Lines 174-179 sub generate_subfield_form { Link Here
174
    if ( $subfield->{authorised_value} ) {
174
    if ( $subfield->{authorised_value} ) {
175
        my @authorised_values;
175
        my @authorised_values;
176
        my %authorised_lib;
176
        my %authorised_lib;
177
        my %authorised_restricted;
177
178
178
        # builds list, depending on authorised value...
179
        # builds list, depending on authorised value...
179
        if ( $subfield->{authorised_value} eq "LOST" ) {
180
        if ( $subfield->{authorised_value} eq "LOST" ) {
Lines 251-260 sub generate_subfield_form { Link Here
251
        }
252
        }
252
        else {
253
        else {
253
            push @authorised_values, qq{};
254
            push @authorised_values, qq{};
254
            my $av = GetAuthorisedValues( $subfield->{authorised_value} );
255
            my $av = GetAuthorisedValues( $subfield->{authorised_value}, undef, { 'no_limit' => 1 } );
255
            for my $r (@$av) {
256
            for my $r (@$av) {
256
                push @authorised_values, $r->{authorised_value};
257
                push @authorised_values, $r->{authorised_value};
257
                $authorised_lib{ $r->{authorised_value} } = $r->{lib};
258
259
                $authorised_lib{ $r->{authorised_value} }        = $r->{lib};
260
                $authorised_restricted{ $r->{authorised_value} } = $r->{restricted};
258
            }
261
            }
259
        }
262
        }
260
263
Lines 282-287 sub generate_subfield_form { Link Here
282
                  . $index_subfield,
285
                  . $index_subfield,
283
                values  => \@authorised_values,
286
                values  => \@authorised_values,
284
                labels  => \%authorised_lib,
287
                labels  => \%authorised_lib,
288
                restricted => \%authorised_restricted,
285
                default => $value,
289
                default => $value,
286
                (
290
                (
287
                    (
291
                    (
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/html_helpers.inc (-3 / +9 lines)
Lines 113-124 Link Here
113
                        [% FOREACH aval IN mv.values %]
113
                        [% FOREACH aval IN mv.values %]
114
                            [% IF aval == mv.default %]
114
                            [% IF aval == mv.default %]
115
                                [% SET matched = 1 %]
115
                                [% SET matched = 1 %]
116
                                <option value="[%- aval | html -%]" selected="selected">[%- mv.labels.$aval | html -%]</option>
116
                                [% IF mv.restricted.$aval %]
117
                                    <option value="[%- aval | html -%]" selected="selected" style="float:right" title="This value ([%- mv.labels.$aval | html -%]) is limited to other branches">[%- mv.labels.$aval | html -%] &#9888;
118
                                    </option>
119
                                [% ELSE %]
120
                                    <option value="[%- aval | html -%]" selected="selected">[%- mv.labels.$aval | html -%]</option>
121
                                [% END %]
117
                            [% ELSE %]
122
                            [% ELSE %]
118
                                [% IF subfield.IS_LOST_AV && Koha.Preference("ClaimReturnedLostValue") && aval == Koha.Preference("ClaimReturnedLostValue") %]
123
                                [% IF subfield.IS_LOST_AV && Koha.Preference("ClaimReturnedLostValue") && aval == Koha.Preference("ClaimReturnedLostValue") %]
119
                                    <option disabled="disabled" value="[%- aval | html -%]" title="Return claims must be processed from the patron details page">[%- mv.labels.$aval | html -%]</option>
124
                                    <option disabled="disabled" value="[%- aval | html -%]" title="Return claims must be processed from the patron details page">[%- mv.labels.$aval | html -%]</option>
120
                                [% ELSIF subfield.IS_LOST_AV && Koha.Preference("BundleLostValue") && aval == Koha.Preference("BundleLostValue") %]
125
                                [% ELSIF subfield.IS_LOST_AV && Koha.Preference("BundleLostValue") && aval == Koha.Preference("BundleLostValue") %]
121
                                    <option disabled="disabled" value="[%- aval | html -%]" title="Bundle losses are set at checkin automatically">[%- mv.labels.$aval | html -%]</option>
126
                                    <option disabled="disabled" value="[%- aval | html -%]" title="Bundle losses are set at checkin automatically">[%- mv.labels.$aval | html -%]</option>
127
                                [% ELSIF mv.restricted.$aval %]
128
                                    <option value="[%- aval | html -%]" style="float:right" title="This value ([%- mv.labels.$aval | html -%]) is limited to other branches">[%- mv.labels.$aval | html -%] &#9888;
129
                                    </option>
122
                                [%  ELSE %]
130
                                [%  ELSE %]
123
                                    <option value="[%- aval | html -%]">[%- mv.labels.$aval | html -%]</option>
131
                                    <option value="[%- aval | html -%]">[%- mv.labels.$aval | html -%]</option>
124
                                [% END %]
132
                                [% END %]
Lines 210-216 Link Here
210
                    [% END %]
218
                    [% END %]
211
219
212
                    <span class="hint" id="hint[% subfield.tag | html %][% subfield.subfield | html %][% subfield.random | html %]"></span>
220
                    <span class="hint" id="hint[% subfield.tag | html %][% subfield.subfield | html %][% subfield.random | html %]"></span>
213
214
                </div>
221
                </div>
215
            </li>
222
            </li>
216
        [% END %]
223
        [% END %]
217
- 

Return to bug 32748