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 |
|