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

(-)a/Koha/Template/Plugin/Branches.pm (-19 / +10 lines)
Lines 58-65 sub GetURL { Link Here
58
58
59
sub all {
59
sub all {
60
    my ( $self, $params ) = @_;
60
    my ( $self, $params ) = @_;
61
    my $selected = $params->{selected};
61
    my $selected = $params->{selected} || ();
62
    my $selecteds = $params->{selecteds};
63
    my $unfiltered = $params->{unfiltered} || 0;
62
    my $unfiltered = $params->{unfiltered} || 0;
64
    my $search_params = $params->{search_params} || {};
63
    my $search_params = $params->{search_params} || {};
65
    my $do_not_select_my_library = $params->{do_not_select_my_library} || 0; # By default we select the library of the logged in user if no selected passed
64
    my $do_not_select_my_library = $params->{do_not_select_my_library} || 0; # By default we select the library of the logged in user if no selected passed
Lines 77-102 sub all { Link Here
77
      ? Koha::Libraries->search( $search_params, { order_by => ['branchname'] } )->unblessed
76
      ? Koha::Libraries->search( $search_params, { order_by => ['branchname'] } )->unblessed
78
      : Koha::Libraries->search_filtered( $search_params, { order_by => ['branchname'] } )->unblessed;
77
      : Koha::Libraries->search_filtered( $search_params, { order_by => ['branchname'] } )->unblessed;
79
78
80
    if (defined $selecteds) {
79
    for my $l (@$libraries) {
81
        # For a select multiple, must be a Koha::Libraries
80
        if ( grep { $l->{branchcode} eq $_ } @selected
82
        my @selected_branchcodes = $selecteds ? $selecteds->get_column( ['branchcode'] ) : ();
81
            or  not @selected
83
        $libraries = [ map {
82
                and not $do_not_select_my_library
84
            my $l = $_;
83
                and C4::Context->userenv
85
            $l->{selected} = 1
84
                and $l->{branchcode} eq ( C4::Context->userenv->{branch} // q{} ) )
86
              if grep { $_ eq $l->{branchcode} } @selected_branchcodes;
85
        {
87
            $l;
86
             $l->{selected} = 1;
88
        } @$libraries ];
89
    }
90
    else {
91
        for my $l ( @$libraries ) {
92
            if (       defined $selected and $l->{branchcode} eq $selected
93
                or not defined $selected and C4::Context->userenv and $l->{branchcode} eq ( C4::Context->userenv->{branch} // q{} )
94
            ) {
95
                $l->{selected} = 1;
96
            }
97
        }
87
        }
98
    }
88
    }
99
89
90
100
    return $libraries;
91
    return $libraries;
101
}
92
}
102
93
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/categories.tt (-1 / +1 lines)
Lines 218-224 Link Here
218
                <li><label for="branches">Library limitations: </label>
218
                <li><label for="branches">Library limitations: </label>
219
                    <select id="branches" name="branches" multiple size="10">
219
                    <select id="branches" name="branches" multiple size="10">
220
                        <option value="">All libraries</option>
220
                        <option value="">All libraries</option>
221
                        [% PROCESS options_for_libraries libraries => Branches.all( selecteds => category.get_library_limits, unfiltered => 1, do_not_select_my_library => 1 ) %]
221
                        [% PROCESS options_for_libraries libraries => Branches.all( selected => category.get_library_limits, unfiltered => 1, do_not_select_my_library => 1 ) %]
222
                    </select>
222
                    </select>
223
                    <span>Select <em>All libraries</em> if this category type must to be displayed all the time. Otherwise select libraries you want to associate with this value.
223
                    <span>Select <em>All libraries</em> if this category type must to be displayed all the time. Otherwise select libraries you want to associate with this value.
224
                    </span>
224
                    </span>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/itemtypes.tt (-1 / +1 lines)
Lines 377-383 Data deleted Link Here
377
                <li><label for="branches">Library limitation: </label>
377
                <li><label for="branches">Library limitation: </label>
378
                    <select id="branches" name="branches" multiple size="10">
378
                    <select id="branches" name="branches" multiple size="10">
379
                        <option value="">All libraries</option>
379
                        <option value="">All libraries</option>
380
                        [% PROCESS options_for_libraries libraries => Branches.all( selecteds => itemtype.get_library_limits, unfiltered => 1, do_not_select_my_library => 1 ) %]
380
                        [% PROCESS options_for_libraries libraries => Branches.all( selected => itemtype.get_library_limits, unfiltered => 1, do_not_select_my_library => 1 ) %]
381
                    </select>
381
                    </select>
382
                    <span class="hint">Select 'All libraries' if all libraries use this item type. Otherwise, select the specific libraries that use this item type.</span>
382
                    <span class="hint">Select 'All libraries' if all libraries use this item type. Otherwise, select the specific libraries that use this item type.</span>
383
                </li>
383
                </li>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/patron-attr-types.tt (-2 / +1 lines)
Lines 214-220 Link Here
214
        <li><label for="branches">Library limitation: </label>
214
        <li><label for="branches">Library limitation: </label>
215
            <select id="branches" name="branches" multiple size="10">
215
            <select id="branches" name="branches" multiple size="10">
216
                <option value="">All libraries</option>
216
                <option value="">All libraries</option>
217
                [% PROCESS options_for_libraries libraries => Branches.all( selecteds => attribute_type.library_limits ) %]
217
                [% PROCESS options_for_libraries libraries => Branches.all( selected => attribute_type.library_limits ) %]
218
            </select>
218
            </select>
219
            <div class="hint">Select "All libraries" if this attribute type should always be displayed. Otherwise select libraries you want to associate with this value.
219
            <div class="hint">Select "All libraries" if this attribute type should always be displayed. Otherwise select libraries you want to associate with this value.
220
            </div>
220
            </div>
221
- 

Return to bug 23271