Lines 246-253
foreach my $branchcode (@branchcodes) { #BEGIN BRANCH LOOP
Link Here
|
246 |
my $waiting_since = $dtf->format_date( $waiting_date ); |
246 |
my $waiting_since = $dtf->format_date( $waiting_date ); |
247 |
my $reserves = Koha::Holds->search({ |
247 |
my $reserves = Koha::Holds->search({ |
248 |
waitingdate => {'<=' => $waiting_since }, |
248 |
waitingdate => {'<=' => $waiting_since }, |
249 |
branchcode => $branchcode, |
249 |
'me.branchcode' => $branchcode, |
250 |
}); |
250 |
},{ prefetch => 'patron' }); |
251 |
|
251 |
|
252 |
$verbose and warn "No reserves found for $branchcode\n" unless $reserves->count; |
252 |
$verbose and warn "No reserves found for $branchcode\n" unless $reserves->count; |
253 |
next unless $reserves->count; |
253 |
next unless $reserves->count; |
Lines 261-272
foreach my $branchcode (@branchcodes) { #BEGIN BRANCH LOOP
Link Here
|
261 |
my $sending_params = @mtts ? { message_transports => \@mtts } : { message_name => "Hold_Filled" }; |
261 |
my $sending_params = @mtts ? { message_transports => \@mtts } : { message_name => "Hold_Filled" }; |
262 |
|
262 |
|
263 |
|
263 |
|
|
|
264 |
my %patrons; |
264 |
while ( my $reserve = $reserves->next ) { |
265 |
while ( my $reserve = $reserves->next ) { |
|
|
266 |
$patrons{$reserve->borrowernumber}->{patron} = $reserve->patron unless exists $patrons{$reserve->borrowernumber}; |
267 |
push @{$patrons{$reserve->borrowernumber}->{reserves}}, $reserve->reserve_id; |
268 |
} |
265 |
|
269 |
|
266 |
my $patron = $reserve->borrower; |
270 |
foreach my $borrowernumber (keys %patrons){ |
267 |
# Skip if we already dealt with this borrower |
271 |
|
268 |
next if ( $done{$patron->borrowernumber} ); |
272 |
my $patron = $patrons{$borrowernumber}->{patron}; |
269 |
$verbose and print " borrower " . $patron->surname . ", " . $patron->firstname . " has holds triggering notice.\n"; |
273 |
$verbose and print " borrower " . $patron->surname . ", " . $patron->firstname . " has " . scalar @{$patrons{$borrowernumber}->{reserves}} . " holds triggering notice.\n"; |
270 |
|
274 |
|
271 |
# Setup the notice information |
275 |
# Setup the notice information |
272 |
my $letter_params = { |
276 |
my $letter_params = { |
Lines 276-283
foreach my $branchcode (@branchcodes) { #BEGIN BRANCH LOOP
Link Here
|
276 |
branchcode => $branchcode, |
280 |
branchcode => $branchcode, |
277 |
tables => { |
281 |
tables => { |
278 |
borrowers => $patron->borrowernumber, |
282 |
borrowers => $patron->borrowernumber, |
279 |
branches => $reserve->branchcode, |
283 |
branches => $branchcode, |
280 |
reserves => $reserve->unblessed |
284 |
}, |
|
|
285 |
loops => { |
286 |
reserves => $patrons{$borrowernumber}->{reserves} |
281 |
}, |
287 |
}, |
282 |
}; |
288 |
}; |
283 |
$sending_params->{letter_params} = $letter_params; |
289 |
$sending_params->{letter_params} = $letter_params; |
284 |
- |
|
|