Lines 222-234
END_SQL
Link Here
|
222 |
|
222 |
|
223 |
my $admin_adress = C4::Context->preference('KohaAdminEmailAddress'); |
223 |
my $admin_adress = C4::Context->preference('KohaAdminEmailAddress'); |
224 |
|
224 |
|
|
|
225 |
my @letters; |
225 |
UPCOMINGITEM: foreach my $upcoming ( @$upcoming_dues ) { |
226 |
UPCOMINGITEM: foreach my $upcoming ( @$upcoming_dues ) { |
226 |
warn 'examining ' . $upcoming->{'itemnumber'} . ' upcoming due items' if $verbose; |
227 |
warn 'examining ' . $upcoming->{'itemnumber'} . ' upcoming due items' if $verbose; |
227 |
# warn( Data::Dumper->Dump( [ $upcoming ], [ 'overdue' ] ) ); |
228 |
# warn( Data::Dumper->Dump( [ $upcoming ], [ 'overdue' ] ) ); |
228 |
|
229 |
|
229 |
my $from_address = $upcoming->{branchemail} || $admin_adress; |
230 |
my $from_address = $upcoming->{branchemail} || $admin_adress; |
230 |
|
231 |
|
231 |
my $letter; |
|
|
232 |
my $borrower_preferences; |
232 |
my $borrower_preferences; |
233 |
if ( 0 == $upcoming->{'days_until_due'} ) { |
233 |
if ( 0 == $upcoming->{'days_until_due'} ) { |
234 |
# This item is due today. Send an 'item due' message. |
234 |
# This item is due today. Send an 'item due' message. |
Lines 253-266
UPCOMINGITEM: foreach my $upcoming ( @$upcoming_dues ) {
Link Here
|
253 |
} |
253 |
} |
254 |
|
254 |
|
255 |
## Get branch info for borrowers home library. |
255 |
## Get branch info for borrowers home library. |
256 |
$letter = parse_letter( { letter_code => $letter_type, |
256 |
foreach my $transport ( keys %{$borrower_preferences->{'transports'}} ) { |
|
|
257 |
my $letter = parse_letter( { letter_code => $letter_type, |
257 |
borrowernumber => $upcoming->{'borrowernumber'}, |
258 |
borrowernumber => $upcoming->{'borrowernumber'}, |
258 |
branchcode => $upcoming->{'branchcode'}, |
259 |
branchcode => $upcoming->{'branchcode'}, |
259 |
biblionumber => $biblio->{'biblionumber'}, |
260 |
biblionumber => $biblio->{'biblionumber'}, |
260 |
itemnumber => $upcoming->{'itemnumber'}, |
261 |
itemnumber => $upcoming->{'itemnumber'}, |
261 |
substitute => { 'items.content' => $titles } |
262 |
substitute => { 'items.content' => $titles }, |
|
|
263 |
message_transport_type => $transport, |
262 |
} ) |
264 |
} ) |
263 |
or die "no letter of type '$letter_type' found. Please see sample_notices.sql"; |
265 |
or die "no letter of type '$letter_type' found. Please see sample_notices.sql"; |
|
|
266 |
push @letters, $letter; |
267 |
} |
264 |
} |
268 |
} |
265 |
} else { |
269 |
} else { |
266 |
$borrower_preferences = C4::Members::Messaging::GetMessagingPreferences( { borrowernumber => $upcoming->{'borrowernumber'}, |
270 |
$borrower_preferences = C4::Members::Messaging::GetMessagingPreferences( { borrowernumber => $upcoming->{'borrowernumber'}, |
Lines 285-313
UPCOMINGITEM: foreach my $upcoming ( @$upcoming_dues ) {
Link Here
|
285 |
} |
289 |
} |
286 |
|
290 |
|
287 |
## Get branch info for borrowers home library. |
291 |
## Get branch info for borrowers home library. |
288 |
$letter = parse_letter( { letter_code => $letter_type, |
292 |
foreach my $transport ( keys %{$borrower_preferences->{'transports'}} ) { |
|
|
293 |
my $letter = parse_letter( { letter_code => $letter_type, |
289 |
borrowernumber => $upcoming->{'borrowernumber'}, |
294 |
borrowernumber => $upcoming->{'borrowernumber'}, |
290 |
branchcode => $upcoming->{'branchcode'}, |
295 |
branchcode => $upcoming->{'branchcode'}, |
291 |
biblionumber => $biblio->{'biblionumber'}, |
296 |
biblionumber => $biblio->{'biblionumber'}, |
292 |
itemnumber => $upcoming->{'itemnumber'}, |
297 |
itemnumber => $upcoming->{'itemnumber'}, |
293 |
substitute => { 'items.content' => $titles } |
298 |
substitute => { 'items.content' => $titles }, |
|
|
299 |
message_transport_type => $transport, |
294 |
} ) |
300 |
} ) |
295 |
or die "no letter of type '$letter_type' found. Please see sample_notices.sql"; |
301 |
or die "no letter of type '$letter_type' found. Please see sample_notices.sql"; |
|
|
302 |
push @letters, $letter; |
303 |
} |
296 |
} |
304 |
} |
297 |
} |
305 |
} |
298 |
|
306 |
|
299 |
# If we have prepared a letter, send it. |
307 |
# If we have prepared a letter, send it. |
300 |
if ($letter) { |
308 |
if ( @letters ) { |
301 |
if ($nomail) { |
309 |
if ($nomail) { |
302 |
local $, = "\f"; |
310 |
for my $letter ( @letters ) { |
303 |
print $letter->{'content'}; |
311 |
local $, = "\f"; |
|
|
312 |
print $letter->{'content'}; |
313 |
} |
304 |
} |
314 |
} |
305 |
else { |
315 |
else { |
306 |
foreach my $transport ( keys %{$borrower_preferences->{'transports'}} ) { |
316 |
for my $letter ( @letters ) { |
307 |
C4::Letters::EnqueueLetter( { letter => $letter, |
317 |
C4::Letters::EnqueueLetter( { letter => $letter, |
308 |
borrowernumber => $upcoming->{'borrowernumber'}, |
318 |
borrowernumber => $upcoming->{'borrowernumber'}, |
309 |
from_address => $from_address, |
319 |
from_address => $from_address, |
310 |
message_transport_type => $transport } ); |
320 |
message_transport_type => $letter->{message_transport_type} } ); |
311 |
} |
321 |
} |
312 |
} |
322 |
} |
313 |
} |
323 |
} |
Lines 326-332
SELECT biblio.*, items.*, issues.*
Link Here
|
326 |
AND issues.borrowernumber = ? |
336 |
AND issues.borrowernumber = ? |
327 |
AND (TO_DAYS(date_due)-TO_DAYS(NOW()) = ?) |
337 |
AND (TO_DAYS(date_due)-TO_DAYS(NOW()) = ?) |
328 |
END_SQL |
338 |
END_SQL |
329 |
|
339 |
@letters = (); |
330 |
PATRON: while ( my ( $borrowernumber, $digest ) = each %$upcoming_digest ) { |
340 |
PATRON: while ( my ( $borrowernumber, $digest ) = each %$upcoming_digest ) { |
331 |
my $count = $digest->{count}; |
341 |
my $count = $digest->{count}; |
332 |
my $from_address = $digest->{email}; |
342 |
my $from_address = $digest->{email}; |
Lines 349-377
PATRON: while ( my ( $borrowernumber, $digest ) = each %$upcoming_digest ) {
Link Here
|
349 |
## Get branch info for borrowers home library. |
359 |
## Get branch info for borrowers home library. |
350 |
my %branch_info = get_branch_info( $borrowernumber ); |
360 |
my %branch_info = get_branch_info( $borrowernumber ); |
351 |
|
361 |
|
352 |
my $letter = parse_letter( { letter_code => $letter_type, |
362 |
foreach my $transport ( keys %{$borrower_preferences->{'transports'}} ) { |
|
|
363 |
my $letter = parse_letter( { letter_code => $letter_type, |
353 |
borrowernumber => $borrowernumber, |
364 |
borrowernumber => $borrowernumber, |
354 |
substitute => { count => $count, |
365 |
substitute => { count => $count, |
355 |
'items.content' => $titles, |
366 |
'items.content' => $titles, |
356 |
%branch_info, |
367 |
%branch_info, |
357 |
} |
368 |
}, |
|
|
369 |
message_transport_type => $transport, |
358 |
} ) |
370 |
} ) |
359 |
or die "no letter of type '$letter_type' found. Please see sample_notices.sql"; |
371 |
or die "no letter of type '$letter_type' found. Please see sample_notices.sql"; |
360 |
if ($nomail) { |
372 |
push @letters, $letter; |
361 |
local $, = "\f"; |
|
|
362 |
print $letter->{'content'}; |
363 |
} |
373 |
} |
364 |
else { |
374 |
|
365 |
foreach my $transport ( keys %{$borrower_preferences->{'transports'}} ) { |
375 |
if ( @letters ) { |
366 |
C4::Letters::EnqueueLetter( { letter => $letter, |
376 |
if ($nomail) { |
367 |
borrowernumber => $borrowernumber, |
377 |
for my $letter ( @letters ) { |
368 |
from_address => $from_address, |
378 |
local $, = "\f"; |
369 |
message_transport_type => $transport } ); |
379 |
print $letter->{'content'}; |
|
|
380 |
} |
381 |
} |
382 |
else { |
383 |
for my $letter ( @letters ) { |
384 |
C4::Letters::EnqueueLetter( { letter => $letter, |
385 |
borrowernumber => $borrowernumber, |
386 |
from_address => $from_address, |
387 |
message_transport_type => $letter->{message_transport_type} } ); |
388 |
} |
370 |
} |
389 |
} |
371 |
} |
390 |
} |
372 |
} |
391 |
} |
373 |
|
392 |
|
374 |
# Now, run through all the people that want digests and send them |
393 |
# Now, run through all the people that want digests and send them |
|
|
394 |
@letters = (); |
375 |
PATRON: while ( my ( $borrowernumber, $digest ) = each %$due_digest ) { |
395 |
PATRON: while ( my ( $borrowernumber, $digest ) = each %$due_digest ) { |
376 |
my $count = $digest->{count}; |
396 |
my $count = $digest->{count}; |
377 |
my $from_address = $digest->{email}; |
397 |
my $from_address = $digest->{email}; |
Lines 392-418
PATRON: while ( my ( $borrowernumber, $digest ) = each %$due_digest ) {
Link Here
|
392 |
## Get branch info for borrowers home library. |
412 |
## Get branch info for borrowers home library. |
393 |
my %branch_info = get_branch_info( $borrowernumber ); |
413 |
my %branch_info = get_branch_info( $borrowernumber ); |
394 |
|
414 |
|
395 |
my $letter = parse_letter( { letter_code => $letter_type, |
415 |
for my $transport ( keys %{$borrower_preferences->{'transports'}} ) { |
|
|
416 |
my $letter = parse_letter( { letter_code => $letter_type, |
396 |
borrowernumber => $borrowernumber, |
417 |
borrowernumber => $borrowernumber, |
397 |
substitute => { count => $count, |
418 |
substitute => { count => $count, |
398 |
'items.content' => $titles, |
419 |
'items.content' => $titles, |
399 |
%branch_info, |
420 |
%branch_info, |
400 |
} |
421 |
}, |
|
|
422 |
message_transport_type => $transport, |
401 |
} ) |
423 |
} ) |
402 |
or die "no letter of type '$letter_type' found. Please see sample_notices.sql"; |
424 |
or die "no letter of type '$letter_type' found. Please see sample_notices.sql"; |
403 |
|
425 |
push @letters, $letter; |
404 |
if ($nomail) { |
|
|
405 |
local $, = "\f"; |
406 |
print $letter->{'content'}; |
407 |
} |
426 |
} |
408 |
else { |
427 |
|
409 |
foreach my $transport ( keys %{$borrower_preferences->{'transports'}} ) { |
428 |
if ( @letters ) { |
410 |
C4::Letters::EnqueueLetter( { letter => $letter, |
429 |
if ($nomail) { |
411 |
borrowernumber => $borrowernumber, |
430 |
for my $letter ( @letters ) { |
412 |
from_address => $from_address, |
431 |
local $, = "\f"; |
413 |
message_transport_type => $transport } ); |
432 |
print $letter->{'content'}; |
|
|
433 |
} |
434 |
} |
435 |
else { |
436 |
for my $letter ( @letters ) { |
437 |
C4::Letters::EnqueueLetter( { letter => $letter, |
438 |
borrowernumber => $borrowernumber, |
439 |
from_address => $from_address, |
440 |
message_transport_type => $letter->{message_transport_type} } ); |
441 |
} |
414 |
} |
442 |
} |
415 |
} |
443 |
} |
|
|
444 |
|
416 |
} |
445 |
} |
417 |
|
446 |
|
418 |
=head1 METHODS |
447 |
=head1 METHODS |
Lines 447-452
sub parse_letter {
Link Here
|
447 |
branchcode => $table_params{'branches'}, |
476 |
branchcode => $table_params{'branches'}, |
448 |
substitute => $params->{'substitute'}, |
477 |
substitute => $params->{'substitute'}, |
449 |
tables => \%table_params, |
478 |
tables => \%table_params, |
|
|
479 |
message_transport_type => $params->{message_transport_type}, |
450 |
); |
480 |
); |
451 |
} |
481 |
} |
452 |
|
482 |
|
453 |
- |
|
|