Lines 67-83
sub pickup_locations {
Link Here
|
67 |
|
67 |
|
68 |
my $item = $params->{'item'}; |
68 |
my $item = $params->{'item'}; |
69 |
my $biblio = $params->{'biblio'}; |
69 |
my $biblio = $params->{'biblio'}; |
70 |
my $patron = $params->{'patron'}; |
|
|
71 |
|
72 |
if ($biblio && $item) { |
70 |
if ($biblio && $item) { |
73 |
Koha::Exceptions::BadParameter->throw( |
71 |
Koha::Exceptions::BadParameter->throw( |
74 |
error => "Koha::Libraries->pickup_locations takes either 'biblio' or " |
72 |
error => "Koha::Libraries->pickup_locations takes either 'biblio' or " |
75 |
." 'item' as parameter, but not both." |
73 |
." 'item' as parameter, but not both." |
76 |
); |
74 |
); |
77 |
} |
75 |
} |
78 |
unless (! defined $patron || ref($patron) eq 'Koha::Patron') { |
|
|
79 |
$patron = Koha::Patrons->find($patron); |
80 |
} |
81 |
|
76 |
|
82 |
# Select libraries that are configured as pickup locations |
77 |
# Select libraries that are configured as pickup locations |
83 |
my $libraries = $self->search({ |
78 |
my $libraries = $self->search({ |
Lines 86-105
sub pickup_locations {
Link Here
|
86 |
order_by => ['branchname'] |
81 |
order_by => ['branchname'] |
87 |
}); |
82 |
}); |
88 |
|
83 |
|
89 |
return $libraries unless $item or $biblio; |
84 |
return $libraries->unblessed unless $item or $biblio; |
90 |
if($item) { |
85 |
return $libraries->unblessed |
|
|
86 |
unless C4::Context->preference('UseBranchTransferLimits'); |
87 |
my $limittype = C4::Context->preference('BranchTransferLimitsType'); |
88 |
|
89 |
if ($item) { |
91 |
unless (ref($item) eq 'Koha::Item') { |
90 |
unless (ref($item) eq 'Koha::Item') { |
92 |
$item = Koha::Items->find($item); |
91 |
$item = Koha::Items->find($item); |
93 |
return $libraries unless $item; |
92 |
return $libraries->unblessed unless $item; |
94 |
} |
93 |
} |
95 |
return $item->pickup_locations( {patron => $patron} ); |
|
|
96 |
} else { |
94 |
} else { |
97 |
unless (ref($biblio) eq 'Koha::Biblio') { |
95 |
unless (ref($biblio) eq 'Koha::Biblio') { |
98 |
$biblio = Koha::Biblios->find($biblio); |
96 |
$biblio = Koha::Biblios->find($biblio); |
99 |
return $libraries unless $biblio; |
97 |
return $libraries->unblessed unless $biblio; |
100 |
} |
98 |
} |
101 |
return $biblio->pickup_locations( {patron => $patron} ); |
|
|
102 |
} |
99 |
} |
|
|
100 |
|
101 |
my @pickup_locations; |
102 |
foreach my $library ($libraries->as_list) { |
103 |
if ($item && $item->can_be_transferred({ to => $library })) { |
104 |
push @pickup_locations, $library->unblessed; |
105 |
} elsif ($biblio && $biblio->can_be_transferred({ to => $library })) { |
106 |
push @pickup_locations, $library->unblessed; |
107 |
} |
108 |
} |
109 |
|
110 |
return wantarray ? @pickup_locations : \@pickup_locations; |
103 |
} |
111 |
} |
104 |
|
112 |
|
105 |
=head3 search_filtered |
113 |
=head3 search_filtered |