Lines 29-34
use base qw(Koha::Object);
Link Here
|
29 |
use Koha::Exceptions::ClubHold; |
29 |
use Koha::Exceptions::ClubHold; |
30 |
use Koha::Club::Hold::PatronHold; |
30 |
use Koha::Club::Hold::PatronHold; |
31 |
use Koha::Clubs; |
31 |
use Koha::Clubs; |
|
|
32 |
use Koha::Patrons; |
32 |
|
33 |
|
33 |
use List::Util 'shuffle'; |
34 |
use List::Util 'shuffle'; |
34 |
|
35 |
|
Lines 72-82
sub add {
Link Here
|
72 |
|
73 |
|
73 |
foreach my $enrollment (@enrollments) { |
74 |
foreach my $enrollment (@enrollments) { |
74 |
my $patron_id = $enrollment->borrowernumber; |
75 |
my $patron_id = $enrollment->borrowernumber; |
|
|
76 |
my $pickup_id = $params->{pickup_library_id}; |
77 |
|
78 |
my $can_place_hold; |
79 |
if($params->{default_patron_home}) { |
80 |
my $patron = Koha::Patrons->find($patron_id); |
81 |
my $patron_home = $patron->branchcode; |
82 |
$can_place_hold = $params->{item_id} |
83 |
? C4::Reserves::CanItemBeReserved( $patron_id, $params->{item_id}, $patron_home ) |
84 |
: C4::Reserves::CanBookBeReserved( $patron_id, $params->{biblio_id}, $patron_home ); |
85 |
$pickup_id = $patron_home if $can_place_hold->{status} eq 'OK'; |
86 |
unless ( $can_place_hold->{status} eq 'OK' ) { |
87 |
warn "Patron(".$patron_id.") Hold cannot be placed with patron's homebranch ($patron_home). Reason: " . $can_place_hold->{status}; |
88 |
} |
89 |
} |
75 |
|
90 |
|
76 |
my $can_place_hold |
91 |
unless ( defined $can_place_hold && $can_place_hold->{status} eq 'OK' ) { |
77 |
= $params->{item_id} |
92 |
$can_place_hold = $params->{item_id} |
78 |
? C4::Reserves::CanItemBeReserved( $patron_id, $params->{club_id} ) |
93 |
? C4::Reserves::CanItemBeReserved( $patron_id, $params->{item_id}, $pickup_id ) |
79 |
: C4::Reserves::CanBookBeReserved( $patron_id, $params->{biblio_id} ); |
94 |
: C4::Reserves::CanBookBeReserved( $patron_id, $params->{biblio_id}, $pickup_id ); |
|
|
95 |
} |
80 |
|
96 |
|
81 |
unless ( $can_place_hold->{status} eq 'OK' ) { |
97 |
unless ( $can_place_hold->{status} eq 'OK' ) { |
82 |
warn "Patron(".$patron_id.") Hold cannot be placed. Reason: " . $can_place_hold->{status}; |
98 |
warn "Patron(".$patron_id.") Hold cannot be placed. Reason: " . $can_place_hold->{status}; |
Lines 92-98
sub add {
Link Here
|
92 |
|
108 |
|
93 |
my $hold_id = C4::Reserves::AddReserve( |
109 |
my $hold_id = C4::Reserves::AddReserve( |
94 |
{ |
110 |
{ |
95 |
branchcode => $params->{pickup_library_id}, |
111 |
branchcode => $pickup_id, |
96 |
borrowernumber => $patron_id, |
112 |
borrowernumber => $patron_id, |
97 |
biblionumber => $params->{biblio_id}, |
113 |
biblionumber => $params->{biblio_id}, |
98 |
priority => $priority, |
114 |
priority => $priority, |
Lines 118-124
sub add {
Link Here
|
118 |
error_message => "Could not create hold for Patron(".$patron_id.")" |
134 |
error_message => "Could not create hold for Patron(".$patron_id.")" |
119 |
})->store(); |
135 |
})->store(); |
120 |
} |
136 |
} |
121 |
|
|
|
122 |
} |
137 |
} |
123 |
|
138 |
|
124 |
return $club_hold; |
139 |
return $club_hold; |