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

(-)a/C4/Koha.pm (-7 / +14 lines)
Lines 509-516 C<$opac> If set to a true value, displays OPAC descriptions rather than normal o Link Here
509
=cut
509
=cut
510
510
511
sub GetAuthorisedValues {
511
sub GetAuthorisedValues {
512
    my $category = shift // '';      # optional parameter
512
    my $category = shift // '';             # optional parameter
513
    my $opac     = shift ? 1 : 0;    # normalise to be safe
513
    my $opac     = shift ? 1 : 0;           # normalise to be safe
514
    my $options  = shift // '';
515
    my $no_limit = $options->{'no_limit'} if $options;    #optional parameter to ignore library limitation
514
516
515
    # Is this cached already?
517
    # Is this cached already?
516
    my $branch_limit = C4::Context::mybranch();
518
    my $branch_limit = C4::Context::mybranch();
Lines 521-541 sub GetAuthorisedValues { Link Here
521
523
522
    my @results;
524
    my @results;
523
    my $dbh   = C4::Context->dbh;
525
    my $dbh   = C4::Context->dbh;
526
    
527
    my $select_clause = 'SELECT av.*';
528
    my @where_args;
529
    if ($branch_limit && $no_limit) {
530
        $select_clause .= ', IF (branchcode = ? OR branchcode IS NULL, 0, 1) as restricted';
531
        push @where_args, $branch_limit;
532
    }
524
    my $query = qq{
533
    my $query = qq{
525
        SELECT DISTINCT av.*
534
        $select_clause
526
        FROM authorised_values av
535
        FROM authorised_values av
527
    };
536
    };
528
    $query .= qq{
537
    $query .= qq{
529
          LEFT JOIN authorised_values_branches ON ( id = av_id )
538
          LEFT JOIN authorised_values_branches ON ( id = av_id )
530
    } if $branch_limit;
539
    } if $branch_limit;
531
    my @where_strings;
540
    my @where_strings;
532
    my @where_args;
541
    if($category) {
533
534
    if ($category) {
535
        push @where_strings, "category = ?";
542
        push @where_strings, "category = ?";
536
        push @where_args,    $category;
543
        push @where_args,    $category;
537
    }
544
    }
538
    if ($branch_limit) {
545
    if($branch_limit && !defined $no_limit) {
539
        push @where_strings, "( branchcode = ? OR branchcode IS NULL )";
546
        push @where_strings, "( branchcode = ? OR branchcode IS NULL )";
540
        push @where_args,    $branch_limit;
547
        push @where_args,    $branch_limit;
541
    }
548
    }
(-)a/Koha/UI/Form/Builder/Item.pm (-2 / +6 lines)
Lines 169-174 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
173
173
        # builds list, depending on authorised value...
174
        # builds list, depending on authorised value...
174
        if ( $subfield->{authorised_value} eq "LOST" ) {
175
        if ( $subfield->{authorised_value} eq "LOST" ) {
Lines 245-254 sub generate_subfield_form { Link Here
245
            #---- "true" authorised value
246
            #---- "true" authorised value
246
        } else {
247
        } else {
247
            push @authorised_values, qq{};
248
            push @authorised_values, qq{};
248
            my $av = GetAuthorisedValues( $subfield->{authorised_value} );
249
            my $av = GetAuthorisedValues( $subfield->{authorised_value}, undef, { 'no_limit' => 1 } );
249
            for my $r (@$av) {
250
            for my $r (@$av) {
250
                push @authorised_values, $r->{authorised_value};
251
                push @authorised_values, $r->{authorised_value};
251
                $authorised_lib{ $r->{authorised_value} } = $r->{lib};
252
253
                $authorised_lib{ $r->{authorised_value} }        = $r->{lib};
254
                $authorised_restricted{ $r->{authorised_value} } = $r->{restricted};
252
            }
255
            }
253
        }
256
        }
254
257
Lines 270-275 sub generate_subfield_form { Link Here
270
                id      => "tag_" . $tag . "_subfield_" . $subfieldtag . "_" . $index_subfield,
273
                id      => "tag_" . $tag . "_subfield_" . $subfieldtag . "_" . $index_subfield,
271
                values  => \@authorised_values,
274
                values  => \@authorised_values,
272
                labels  => \%authorised_lib,
275
                labels  => \%authorised_lib,
276
                restricted => \%authorised_restricted,
273
                default => $value,
277
                default => $value,
274
                (
278
                (
275
                      ( grep { $_ eq $subfield->{authorised_value} } (qw(branches itemtypes cn_source)) )
279
                      ( grep { $_ eq $subfield->{authorised_value} } (qw(branches itemtypes cn_source)) )
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/html_helpers.inc (-2 / +5 lines)
Lines 124-130 Link Here
124
                            [% FOREACH aval IN mv.values %]
124
                            [% FOREACH aval IN mv.values %]
125
                                [% IF aval == mv.default %]
125
                                [% IF aval == mv.default %]
126
                                    [% SET matched = 1 %]
126
                                    [% SET matched = 1 %]
127
                                    <option value="[%- aval | html -%]" selected="selected">[%- mv.labels.$aval | html -%]</option>
127
                                    [% IF mv.restricted.$aval %]
128
                                        <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;</option>
129
                                    [% ELSE %]
130
                                        <option value="[%- aval | html -%]" selected="selected">[%- mv.labels.$aval | html -%]</option>
131
                                    [% END %]
128
                                [% ELSE %]
132
                                [% ELSE %]
129
                                    [% IF subfield.IS_LOST_AV && Koha.Preference("ClaimReturnedLostValue") && aval == Koha.Preference("ClaimReturnedLostValue") %]
133
                                    [% IF subfield.IS_LOST_AV && Koha.Preference("ClaimReturnedLostValue") && aval == Koha.Preference("ClaimReturnedLostValue") %]
130
                                        <option disabled="disabled" value="[%- aval | html -%]" title="Return claims must be processed from the patron details page">[%- mv.labels.$aval | html -%]</option>
134
                                        <option disabled="disabled" value="[%- aval | html -%]" title="Return claims must be processed from the patron details page">[%- mv.labels.$aval | html -%]</option>
131
- 

Return to bug 32748