|
Lines 78-83
overdue_notices.pl
Link Here
|
| 78 |
-email <email_type> Type of email that will be used. |
78 |
-email <email_type> Type of email that will be used. |
| 79 |
Can be 'email', 'emailpro' or 'B_email'. Repeatable. |
79 |
Can be 'email', 'emailpro' or 'B_email'. Repeatable. |
| 80 |
--frombranch Set the from address for the notice to one of 'item-homebranch' or 'item-issuebranch'. |
80 |
--frombranch Set the from address for the notice to one of 'item-homebranch' or 'item-issuebranch'. |
|
|
81 |
-a <branchcode> Create only one message per borrower and delay level including overdues from all branches. |
| 81 |
|
82 |
|
| 82 |
=head1 OPTIONS |
83 |
=head1 OPTIONS |
| 83 |
|
84 |
|
|
Lines 192-197
Use the address information from the item homebranch library instead of the issu
Link Here
|
| 192 |
|
193 |
|
| 193 |
Defaults to 'item-issuebranch' |
194 |
Defaults to 'item-issuebranch' |
| 194 |
|
195 |
|
|
|
196 |
=item B<-a> | B<--all_in_one> |
| 197 |
|
| 198 |
Create only one message per borrower and for each delay level including overdues from all branches. |
| 199 |
Branchcode value (branches.branchcode) has to be given to choose which sender address will be set. |
| 200 |
It's recommended to use this option only with default notice(s) defined for 'All branches' |
| 201 |
in Notices & Slips and no specific ones. |
| 202 |
|
| 195 |
=back |
203 |
=back |
| 196 |
|
204 |
|
| 197 |
=head1 DESCRIPTION |
205 |
=head1 DESCRIPTION |
|
Lines 314-319
my $itemscontent = join( ',', qw( date_due title barcode author itemnumber ) );
Link Here
|
| 314 |
my @myborcat; |
322 |
my @myborcat; |
| 315 |
my @myborcatout; |
323 |
my @myborcatout; |
| 316 |
my ( $date_input, $today ); |
324 |
my ( $date_input, $today ); |
|
|
325 |
my $all_in_one; |
| 317 |
|
326 |
|
| 318 |
GetOptions( |
327 |
GetOptions( |
| 319 |
'help|?' => \$help, |
328 |
'help|?' => \$help, |
|
Lines 334-339
GetOptions(
Link Here
|
| 334 |
'borcatout=s' => \@myborcatout, |
343 |
'borcatout=s' => \@myborcatout, |
| 335 |
'email=s' => \@emails, |
344 |
'email=s' => \@emails, |
| 336 |
'frombranch=s' => \$frombranch, |
345 |
'frombranch=s' => \$frombranch, |
|
|
346 |
'a|all_in_one=s' => \$all_in_one, |
| 337 |
) or pod2usage(2); |
347 |
) or pod2usage(2); |
| 338 |
pod2usage(1) if $help; |
348 |
pod2usage(1) if $help; |
| 339 |
pod2usage( -verbose => 2 ) if $man; |
349 |
pod2usage( -verbose => 2 ) if $man; |
|
Lines 459-464
elsif ( defined $text_filename ) {
Link Here
|
| 459 |
} |
469 |
} |
| 460 |
} |
470 |
} |
| 461 |
|
471 |
|
|
|
472 |
my %already_queued; |
| 473 |
my %seen = map { $_ => 1 } @branches; |
| 462 |
foreach my $branchcode (@branches) { |
474 |
foreach my $branchcode (@branches) { |
| 463 |
my $calendar; |
475 |
my $calendar; |
| 464 |
if ( C4::Context->preference('OverdueNoticeCalendar') ) { |
476 |
if ( C4::Context->preference('OverdueNoticeCalendar') ) { |
|
Lines 468-474
foreach my $branchcode (@branches) {
Link Here
|
| 468 |
} |
480 |
} |
| 469 |
} |
481 |
} |
| 470 |
|
482 |
|
| 471 |
my $library = Koha::Libraries->find($branchcode); |
483 |
my $library = $all_in_one ? Koha::Libraries->find($all_in_one) : Koha::Libraries->find($branchcode); |
| 472 |
my $admin_email_address = $library->from_email_address; |
484 |
my $admin_email_address = $library->from_email_address; |
| 473 |
my $branch_email_address = C4::Context->preference('AddressForFailedOverdueNotices') |
485 |
my $branch_email_address = C4::Context->preference('AddressForFailedOverdueNotices') |
| 474 |
|| $library->inbound_email_address; |
486 |
|| $library->inbound_email_address; |
|
Lines 487-492
SELECT biblio.*, items.*, issues.*, biblioitems.itemtype, branchname
Link Here
|
| 487 |
AND items.itemlost = 0 |
499 |
AND items.itemlost = 0 |
| 488 |
AND TO_DAYS($date)-TO_DAYS(issues.date_due) >= 0 |
500 |
AND TO_DAYS($date)-TO_DAYS(issues.date_due) >= 0 |
| 489 |
END_SQL |
501 |
END_SQL |
|
|
502 |
$sql2.= " AND issues.branchcode = ?" unless $all_in_one; |
| 503 |
my $sth2 = $dbh->prepare($sql2); |
| 490 |
|
504 |
|
| 491 |
if($owning_library) { |
505 |
if($owning_library) { |
| 492 |
$sql2 .= ' AND items.homebranch = ? '; |
506 |
$sql2 .= ' AND items.homebranch = ? '; |
|
Lines 601-606
END_SQL
Link Here
|
| 601 |
next; |
615 |
next; |
| 602 |
} |
616 |
} |
| 603 |
$borrowernumber = $data->{'borrowernumber'}; |
617 |
$borrowernumber = $data->{'borrowernumber'}; |
|
|
618 |
next if ($all_in_one && $already_queued{"$borrowernumber$i"}); |
| 604 |
my $borr = sprintf( "%s%s%s (%s)", |
619 |
my $borr = sprintf( "%s%s%s (%s)", |
| 605 |
$data->{'surname'} || '', |
620 |
$data->{'surname'} || '', |
| 606 |
$data->{'firstname'} && $data->{'surname'} ? ', ' : '', |
621 |
$data->{'firstname'} && $data->{'surname'} ? ', ' : '', |
|
Lines 652-658
END_SQL
Link Here
|
| 652 |
) unless $test_mode; |
667 |
) unless $test_mode; |
| 653 |
$verbose and warn "debarring $borr\n"; |
668 |
$verbose and warn "debarring $borr\n"; |
| 654 |
} |
669 |
} |
| 655 |
my @params = ($borrowernumber,$branchcode); |
670 |
my @params = $all_in_one ? ($borrowernumber) : ($borrowernumber, $branchcode); |
| 656 |
$verbose and warn "STH2 PARAMS: borrowernumber = $borrowernumber"; |
671 |
$verbose and warn "STH2 PARAMS: borrowernumber = $borrowernumber"; |
| 657 |
|
672 |
|
| 658 |
$sth2->execute(@params); |
673 |
$sth2->execute(@params); |
|
Lines 698-703
END_SQL
Link Here
|
| 698 |
$exceededPrintNoticesMaxLines = 1; |
713 |
$exceededPrintNoticesMaxLines = 1; |
| 699 |
last; |
714 |
last; |
| 700 |
} |
715 |
} |
|
|
716 |
next if $all_in_one and ! grep {$seen{$item_info->{branchcode}}} @branches; |
| 701 |
$j++; |
717 |
$j++; |
| 702 |
|
718 |
|
| 703 |
$titles .= C4::Letters::get_item_content( { item => $item_info, item_content_fields => \@item_content_fields, dateonly => 1 } ); |
719 |
$titles .= C4::Letters::get_item_content( { item => $item_info, item_content_fields => \@item_content_fields, dateonly => 1 } ); |
|
Lines 819-824
END_SQL
Link Here
|
| 819 |
} |
835 |
} |
| 820 |
} |
836 |
} |
| 821 |
} |
837 |
} |
|
|
838 |
$already_queued{"$borrowernumber$i"} = 1; |
| 822 |
} |
839 |
} |
| 823 |
$sth->finish; |
840 |
$sth->finish; |
| 824 |
} |
841 |
} |
| 825 |
- |
|
|