Lines 69-75
overdue_notices.pl
Link Here
|
69 |
--date <yyyy-mm-dd> Emulate overdues run for this date. |
69 |
--date <yyyy-mm-dd> Emulate overdues run for this date. |
70 |
--email <email_type> Type of email that will be used. |
70 |
--email <email_type> Type of email that will be used. |
71 |
Can be 'email', 'emailpro' or 'B_email'. Repeatable. |
71 |
Can be 'email', 'emailpro' or 'B_email'. Repeatable. |
72 |
--frombranch Organize and send overdue notices by home library (item-homebranch) or checkout library (item-issuebranch). |
72 |
--frombranch Organize and send overdue notices by home library (item-homebranch) or checkout library (item-issuebranch) or patron home library (patron-homebranch). |
73 |
This option is only used, if the OverdueNoticeFrom system preference is set to 'command-line option'. |
73 |
This option is only used, if the OverdueNoticeFrom system preference is set to 'command-line option'. |
74 |
Defaults to item-issuebranch. |
74 |
Defaults to item-issuebranch. |
75 |
|
75 |
|
Lines 184-190
Allows to specify which type of email will be used. Can be email, emailpro or B_
Link Here
|
184 |
|
184 |
|
185 |
=item B<--frombranch> |
185 |
=item B<--frombranch> |
186 |
|
186 |
|
187 |
Organize overdue notices either by checkout library (item-issuebranch) or item home library (item-homebranch). |
187 |
Organize overdue notices either by checkout library (item-issuebranch) or item home library (item-homebranch) or patron home library (patron-homebranch). |
188 |
This option is only used, if the OverdueNoticeFrom system preference is set to use 'command-line option'. |
188 |
This option is only used, if the OverdueNoticeFrom system preference is set to use 'command-line option'. |
189 |
Defaults to checkout library (item-issuebranch). |
189 |
Defaults to checkout library (item-issuebranch). |
190 |
|
190 |
|
Lines 341-351
if ( defined $csvfilename && $csvfilename =~ /^-/ ) {
Link Here
|
341 |
warn qq(using "$csvfilename" as filename, that seems odd); |
341 |
warn qq(using "$csvfilename" as filename, that seems odd); |
342 |
} |
342 |
} |
343 |
|
343 |
|
344 |
die "--frombranch takes item-homebranch or item-issuebranch only" |
344 |
die "--frombranch takes item-homebranch or item-issuebranch or patron-homebranch only" |
345 |
unless ( $frombranch eq 'item-issuebranch' |
345 |
unless ( $frombranch eq 'item-issuebranch' |
346 |
|| $frombranch eq 'item-homebranch' ); |
346 |
|| $frombranch eq 'item-homebranch' || $frombranch eq 'patron-homebranch'); |
347 |
$frombranch = C4::Context->preference('OverdueNoticeFrom') ne 'cron' ? C4::Context->preference('OverdueNoticeFrom') : $frombranch; |
347 |
$frombranch = C4::Context->preference('OverdueNoticeFrom') ne 'cron' ? C4::Context->preference('OverdueNoticeFrom') : $frombranch; |
348 |
my $owning_library = ( $frombranch eq 'item-homebranch' ) ? 1 : 0; |
348 |
my $owning_library = ( $frombranch eq 'item-homebranch' ) ? 1 : 0; |
|
|
349 |
my $patron_homelibrary = ( $frombranch eq 'patron-homebranch' ) ? 1 : 0; |
349 |
|
350 |
|
350 |
my @overduebranches = C4::Overdues::GetBranchcodesWithOverdueRules(); # Branches with overdue rules |
351 |
my @overduebranches = C4::Overdues::GetBranchcodesWithOverdueRules(); # Branches with overdue rules |
351 |
my @branches; # Branches passed as parameter with overdue rules |
352 |
my @branches; # Branches passed as parameter with overdue rules |
Lines 457-462
elsif ( defined $text_filename ) {
Link Here
|
457 |
} |
458 |
} |
458 |
} |
459 |
} |
459 |
|
460 |
|
|
|
461 |
my %already_queued; |
462 |
my %seen = map { $_ => 1 } @branches; |
460 |
foreach my $branchcode (@branches) { |
463 |
foreach my $branchcode (@branches) { |
461 |
my $calendar; |
464 |
my $calendar; |
462 |
if ( C4::Context->preference('OverdueNoticeCalendar') ) { |
465 |
if ( C4::Context->preference('OverdueNoticeCalendar') ) { |
Lines 488-496
SELECT biblio.*, items.*, issues.*, biblioitems.itemtype, branchname
Link Here
|
488 |
END_SQL |
491 |
END_SQL |
489 |
|
492 |
|
490 |
if($owning_library) { |
493 |
if($owning_library) { |
491 |
$sql2 .= ' AND items.homebranch = ? '; |
494 |
$sql2 .= ' AND items.homebranch = ? ' unless($patron_homelibrary); |
492 |
} else { |
495 |
} else { |
493 |
$sql2 .= ' AND issues.branchcode = ? '; |
496 |
$sql2 .= ' AND issues.branchcode = ? ' unless($patron_homelibrary); |
494 |
} |
497 |
} |
495 |
my $sth2 = $dbh->prepare($sql2); |
498 |
my $sth2 = $dbh->prepare($sql2); |
496 |
|
499 |
|
Lines 606-611
END_SQL
Link Here
|
606 |
next; |
609 |
next; |
607 |
} |
610 |
} |
608 |
$borrowernumber = $data->{'borrowernumber'}; |
611 |
$borrowernumber = $data->{'borrowernumber'}; |
|
|
612 |
next if ($patron_homelibrary && $already_queued{"$borrowernumber$i"}); |
609 |
my $borr = sprintf( "%s%s%s (%s)", |
613 |
my $borr = sprintf( "%s%s%s (%s)", |
610 |
$data->{'surname'} || '', |
614 |
$data->{'surname'} || '', |
611 |
$data->{'firstname'} && $data->{'surname'} ? ', ' : '', |
615 |
$data->{'firstname'} && $data->{'surname'} ? ', ' : '', |
Lines 614-619
END_SQL
Link Here
|
614 |
$verbose and warn "borrower $borr has items triggering level $i.\n"; |
618 |
$verbose and warn "borrower $borr has items triggering level $i.\n"; |
615 |
|
619 |
|
616 |
my $patron = Koha::Patrons->find( $borrowernumber ); |
620 |
my $patron = Koha::Patrons->find( $borrowernumber ); |
|
|
621 |
if($patron_homelibrary){ |
622 |
$branchcode = $patron->branchcode; |
623 |
$library = Koha::Libraries->find($branchcode); |
624 |
$admin_email_address = $library->from_email_address; |
625 |
$branch_email_address = C4::Context->preference('AddressForFailedOverdueNotices') |
626 |
|| $library->inbound_email_address; |
627 |
} |
617 |
@emails_to_use = (); |
628 |
@emails_to_use = (); |
618 |
my $notice_email = $patron->notice_email_address; |
629 |
my $notice_email = $patron->notice_email_address; |
619 |
unless ($nomail) { |
630 |
unless ($nomail) { |
Lines 656-662
END_SQL
Link Here
|
656 |
) unless $test_mode; |
667 |
) unless $test_mode; |
657 |
$verbose and warn "debarring $borr\n"; |
668 |
$verbose and warn "debarring $borr\n"; |
658 |
} |
669 |
} |
659 |
my @params = ($borrowernumber,$branchcode); |
670 |
my @params = $patron_homelibrary ? ($borrowernumber) : ($borrowernumber, $branchcode); |
660 |
|
671 |
|
661 |
$sth2->execute(@params); |
672 |
$sth2->execute(@params); |
662 |
my $itemcount = 0; |
673 |
my $itemcount = 0; |
Lines 701-706
END_SQL
Link Here
|
701 |
$exceededPrintNoticesMaxLines = 1; |
712 |
$exceededPrintNoticesMaxLines = 1; |
702 |
last; |
713 |
last; |
703 |
} |
714 |
} |
|
|
715 |
next if $patron_homelibrary and ! grep {$seen{$item_info->{branchcode}}} @branches; |
704 |
$j++; |
716 |
$j++; |
705 |
|
717 |
|
706 |
$titles .= C4::Letters::get_item_content( { item => $item_info, item_content_fields => \@item_content_fields, dateonly => 1 } ); |
718 |
$titles .= C4::Letters::get_item_content( { item => $item_info, item_content_fields => \@item_content_fields, dateonly => 1 } ); |
Lines 824-829
END_SQL
Link Here
|
824 |
} |
836 |
} |
825 |
} |
837 |
} |
826 |
} |
838 |
} |
|
|
839 |
$already_queued{"$borrowernumber$i"} = 1; |
827 |
} |
840 |
} |
828 |
$sth->finish; |
841 |
$sth->finish; |
829 |
} |
842 |
} |
830 |
- |
|
|