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

(-)a/Koha/UI/Form/Builder/Biblio.pm (-3 / +14 lines)
Lines 21-26 use C4::ClassSource qw( GetClassSources ); Link Here
21
use Koha::DateUtils qw( dt_from_string );
21
use Koha::DateUtils qw( dt_from_string );
22
use Koha::ItemTypes;
22
use Koha::ItemTypes;
23
use Koha::Libraries;
23
use Koha::Libraries;
24
use Koha::AuthorisedValueCategories;
24
25
25
=head1 NAME
26
=head1 NAME
26
27
Lines 298-313 sub build_authorized_values_list { Link Here
298
299
299
    my @authorised_values;
300
    my @authorised_values;
300
    my %authorised_lib;
301
    my %authorised_lib;
302
    my %authorised_category;
301
303
302
    # builds list, depending on authorised value...
304
    # builds list, depending on authorised value...
303
305
304
    #---- branch
306
    #---- branch
305
    my $category = $tagslib->{$tag}->{$subfield}->{authorised_value};
307
    my $category = $tagslib->{$tag}->{$subfield}->{authorised_value};
308
    my $avc = Koha::AuthorisedValueCategories->find( $category );
306
    if ( $category eq "branches" ) {
309
    if ( $category eq "branches" ) {
307
        my $libraries = Koha::Libraries->search_filtered({}, {order_by => ['branchname']});
310
        my $libraries = Koha::Libraries->search_filtered({}, {order_by => ['branchname']});
308
        while ( my $l = $libraries->next ) {
311
        while ( my $l = $libraries->next ) {
309
            push @authorised_values, $l->branchcode;
312
            push @authorised_values, $l->branchcode;
310
            $authorised_lib{$l->branchcode} = $l->branchname;
313
            $authorised_lib{$l->branchcode} = $l->branchname;
314
            $authorised_category{$l->branchcode} = $category;
311
        }
315
        }
312
    }
316
    }
313
    elsif ( $category eq "itemtypes" ) {
317
    elsif ( $category eq "itemtypes" ) {
Lines 318-323 sub build_authorized_values_list { Link Here
318
        while ( $itemtype = $itemtypes->next ) {
322
        while ( $itemtype = $itemtypes->next ) {
319
            push @authorised_values, $itemtype->itemtype;
323
            push @authorised_values, $itemtype->itemtype;
320
            $authorised_lib{$itemtype->itemtype} = $itemtype->translated_description;
324
            $authorised_lib{$itemtype->itemtype} = $itemtype->translated_description;
325
            $authorised_category{$itemtype->itemtype} = $category;
321
        }
326
        }
322
        $value = $itemtype unless ($value);
327
        $value = $itemtype unless ($value);
323
    }
328
    }
Lines 334-361 sub build_authorized_values_list { Link Here
334
                        ($class_source eq $default_source);
339
                        ($class_source eq $default_source);
335
            push @authorised_values, $class_source;
340
            push @authorised_values, $class_source;
336
            $authorised_lib{$class_source} = $class_sources->{$class_source}->{'description'};
341
            $authorised_lib{$class_source} = $class_sources->{$class_source}->{'description'};
342
            $authorised_category{$class_source} = $category;
337
        }
343
        }
338
        $value = $default_source unless $value;
344
        $value = $default_source unless $value;
339
    }
345
    }
340
    else {
346
    else {
341
        my $branch_limit = C4::Context->userenv ? C4::Context->userenv->{branch} : '';
347
        my $branch_limit = C4::Context->userenv ? C4::Context->userenv->{branch} : '';
342
        my $query = 'SELECT authorised_value, lib FROM authorised_values';
348
        my $query = 'SELECT authorised_value, lib, category FROM authorised_values';
343
        $query .= ' LEFT JOIN authorised_values_branches ON ( id = av_id )' if $branch_limit;
349
        $query .= ' LEFT JOIN authorised_values_branches ON ( id = av_id )' if $branch_limit;
344
        $query .= ' WHERE category = ?';
350
        $query .= ' WHERE category = ?';
345
        $query .= ' AND ( branchcode = ? OR branchcode IS NULL )' if $branch_limit;
351
        $query .= ' AND ( branchcode = ? OR branchcode IS NULL )' if $branch_limit;
346
        $query .= ' GROUP BY authorised_value,lib ORDER BY lib, lib_opac';
352
        $query .= ' OR category = ?' if $avc->parent;
353
        $query .= ' GROUP BY authorised_value,lib, category ORDER BY lib, lib_opac';
347
        my $authorised_values_sth = C4::Context->dbh->prepare($query);
354
        my $authorised_values_sth = C4::Context->dbh->prepare($query);
348
355
349
        $authorised_values_sth->execute(
356
        $authorised_values_sth->execute(
350
            $tagslib->{$tag}->{$subfield}->{authorised_value},
357
            $tagslib->{$tag}->{$subfield}->{authorised_value},
351
            $branch_limit ? $branch_limit : (),
358
            $branch_limit ? $branch_limit : (),
359
            $avc->parent ? $avc->parent : (),
352
        );
360
        );
353
361
354
        push @authorised_values, "";
362
        push @authorised_values, "";
355
363
356
        while ( my ( $value, $lib ) = $authorised_values_sth->fetchrow_array ) {
364
        while ( my ( $value, $lib, $this_category ) = $authorised_values_sth->fetchrow_array ) {
357
            push @authorised_values, $value;
365
            push @authorised_values, $value;
358
            $authorised_lib{$value} = $lib;
366
            $authorised_lib{$value} = $lib;
367
            $authorised_category{$value} = $this_category;
359
        }
368
        }
360
    }
369
    }
361
370
Lines 366-372 sub build_authorized_values_list { Link Here
366
        default  => $value,
375
        default  => $value,
367
        values   => \@authorised_values,
376
        values   => \@authorised_values,
368
        labels   => \%authorised_lib,
377
        labels   => \%authorised_lib,
378
        avcs     => \%authorised_category,
369
        ( ( grep { $_ eq $category } ( qw(branches itemtypes cn_source) ) ) ? () : ( category => $category ) ),
379
        ( ( grep { $_ eq $category } ( qw(branches itemtypes cn_source) ) ) ? () : ( category => $category ) ),
380
        avc      => $avc,
370
    };
381
    };
371
382
372
}
383
}
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbiblio.tt (-1 / +24 lines)
Lines 1208-1225 $(document).ready(function(){ Link Here
1208
                                                        [% ELSE %]
1208
                                                        [% ELSE %]
1209
                                                            <select name="[%- mv.name | html -%]" tabindex="1" class="input_marceditor select2" id="[%- mv.id | html -%]">
1209
                                                            <select name="[%- mv.name | html -%]" tabindex="1" class="input_marceditor select2" id="[%- mv.id | html -%]">
1210
                                                        [% END %]
1210
                                                        [% END %]
1211
                                                            [% IF mv.avc.parent %]
1212
                                                                <optgroup label="[% mv.avc.category_name | html %]">
1213
                                                            [% END %]
1214
1211
                                                            [% SET matched = 0 %]
1215
                                                            [% SET matched = 0 %]
1212
                                                            [% FOREACH aval IN mv.values %]
1216
                                                            [% FOREACH aval IN mv.values %]
1217
                                                                [% IF mv.avcs.$aval == mv.category %]
1213
                                                                [% IF aval == mv.default %]
1218
                                                                [% IF aval == mv.default %]
1214
                                                                    [% SET matched = 1 %]
1219
                                                                    [% SET matched = 1 %]
1215
                                                                <option value="[%- aval | html -%]" selected="selected">[%- mv.labels.$aval | html -%]</option>
1220
                                                                <option value="[%- aval | html -%]" selected="selected">[%- mv.labels.$aval | html -%]</option>
1216
                                                                [% ELSE %]
1221
                                                                [% ELSE %]
1217
                                                                <option value="[%- aval | html -%]">[%- mv.labels.$aval | html -%]</option>
1222
                                                                <option value="[%- aval | html -%]">[%- mv.labels.$aval | html -%]</option>
1218
                                                                [% END %]
1223
                                                                [% END %]
1224
                                                                [% END %]
1219
1225
1220
                                                            [% END %]
1226
                                                            [% END %]
1227
1228
                                                            [% IF mv.avc.parent %]
1229
                                                                </optgroup>
1230
                                                                <optgroup label="[% mv.avc.parent | html %]">
1231
                                                                [% FOREACH aval IN mv.values %]
1232
                                                                    [% IF mv.avcs.$aval != mv.category %]
1233
                                                                    [% IF aval == mv.default %]
1234
                                                                        [% SET matched = 1 %]
1235
                                                                    <option value="[%- aval | html -%]" selected="selected">[%- mv.labels.$aval | html -%]</option>
1236
                                                                    [% ELSE %]
1237
                                                                    <option value="[%- aval | html -%]">[%- mv.labels.$aval | html -%]</option>
1238
                                                                    [% END %]
1239
                                                                    [% END %]
1240
                                                                [% END %]
1241
                                                                </optgroup>
1242
                                                            [% END %]
1243
1221
                                                            [% UNLESS matched # If the current value is not in the authorised value list %]
1244
                                                            [% UNLESS matched # If the current value is not in the authorised value list %]
1222
                                                                <option value="[%- mv.default | html -%]" selected="selected">[%- mv.default | html -%] (Not an authorised value)</option>
1245
                                                                <option value="[%- mv.default | html -%]" selected="selected">[%- mv.default | html -%] (Not an authorised value)</option>
1246
1223
                                                            </select>
1247
                                                            </select>
1224
                                                            <span style="float:right;" title="The current value [% mv.default | html %] is not configured for the authorised value category controlling this subfield"><i class="fa fa-exclamation-triangle" aria-hidden="true"></i></span>
1248
                                                            <span style="float:right;" title="The current value [% mv.default | html %] is not configured for the authorised value category controlling this subfield"><i class="fa fa-exclamation-triangle" aria-hidden="true"></i></span>
1225
                                                            [% ELSE %]
1249
                                                            [% ELSE %]
1226
- 

Return to bug 35067