|
Lines 22-27
use Modern::Perl;
Link Here
|
| 22 |
|
22 |
|
| 23 |
use Carp; |
23 |
use Carp; |
| 24 |
use Data::Dumper qw(Dumper); |
24 |
use Data::Dumper qw(Dumper); |
|
|
25 |
use List::MoreUtils qw(any); |
| 25 |
|
26 |
|
| 26 |
use C4::Context qw(preference); |
27 |
use C4::Context qw(preference); |
| 27 |
use C4::Letters; |
28 |
use C4::Letters; |
|
Lines 221-226
sub set_waiting {
Link Here
|
| 221 |
return $self; |
222 |
return $self; |
| 222 |
} |
223 |
} |
| 223 |
|
224 |
|
|
|
225 |
=head3 set_pickup_location |
| 226 |
|
| 227 |
$hold->set_pickup_location({ library_id => $library->id }); |
| 228 |
|
| 229 |
Updates the hold pickup location. It throws a I<Koha::Exceptions::Hold::InvalidPickupLocation> if |
| 230 |
the passed pickup location is not valid. |
| 231 |
|
| 232 |
=cut |
| 233 |
|
| 234 |
sub set_pickup_location { |
| 235 |
my ( $self, $params ) = @_; |
| 236 |
|
| 237 |
Koha::Exceptions::MissingParameter->throw('The library_id parameter is mandatory') |
| 238 |
unless $params->{library_id}; |
| 239 |
|
| 240 |
my @pickup_locations; |
| 241 |
|
| 242 |
if ( $self->itemnumber ) { # item-level |
| 243 |
@pickup_locations = $self->item->pickup_locations({ patron => $self->patron }); |
| 244 |
} |
| 245 |
else { # biblio-level |
| 246 |
@pickup_locations = $self->biblio->pickup_locations({ patron => $self->patron }); |
| 247 |
} |
| 248 |
|
| 249 |
if ( any { $_->branchcode eq $params->{library_id} } @pickup_locations ) { |
| 250 |
# all good, set the new pickup location |
| 251 |
$self->branchcode( $params->{library_id} )->store; |
| 252 |
} |
| 253 |
else { |
| 254 |
Koha::Exceptions::Hold::InvalidPickupLocation->throw; |
| 255 |
} |
| 256 |
|
| 257 |
return $self; |
| 258 |
} |
| 259 |
|
| 224 |
=head3 set_processing |
260 |
=head3 set_processing |
| 225 |
|
261 |
|
| 226 |
$hold->set_processing; |
262 |
$hold->set_processing; |
| 227 |
- |
|
|