|
Lines 39-44
use C4::Overdues;
Link Here
|
| 39 |
use Koha::Calendar; |
39 |
use Koha::Calendar; |
| 40 |
use Koha::DateUtils; |
40 |
use Koha::DateUtils; |
| 41 |
use Koha::Patrons; |
41 |
use Koha::Patrons; |
|
|
42 |
use Koha::Libraries; |
| 42 |
|
43 |
|
| 43 |
sub usage { |
44 |
sub usage { |
| 44 |
pod2usage( -verbose => 2 ); |
45 |
pod2usage( -verbose => 2 ); |
|
Lines 60-65
my $library_code;
Link Here
|
| 60 |
my $help; |
61 |
my $help; |
| 61 |
my $outfile; |
62 |
my $outfile; |
| 62 |
my $skip_patrons_with_email; |
63 |
my $skip_patrons_with_email; |
|
|
64 |
my $patron_branchcode; |
| 63 |
|
65 |
|
| 64 |
# maps to convert I-tiva terms to Koha terms |
66 |
# maps to convert I-tiva terms to Koha terms |
| 65 |
my $type_module_map = { |
67 |
my $type_module_map = { |
|
Lines 75-88
my $type_notice_map = {
Link Here
|
| 75 |
}; |
77 |
}; |
| 76 |
|
78 |
|
| 77 |
GetOptions( |
79 |
GetOptions( |
| 78 |
'o|output:s' => \$outfile, |
80 |
'o|output:s' => \$outfile, |
| 79 |
'v' => \$verbose, |
81 |
'v' => \$verbose, |
| 80 |
'lang:s' => \$language, |
82 |
'lang:s' => \$language, |
| 81 |
'type:s' => \@types, |
83 |
'type:s' => \@types, |
| 82 |
'w|waiting-hold-day:s' => \@holds_waiting_days_to_call, |
84 |
'w|waiting-hold-day:s' => \@holds_waiting_days_to_call, |
| 83 |
'c|code|library-code:s' => \$library_code, |
85 |
'c|code|library-code:s' => \$library_code, |
| 84 |
's|skip-patrons-with-email' => \$skip_patrons_with_email, |
86 |
's|skip-patrons-with-email' => \$skip_patrons_with_email, |
| 85 |
'help|h' => \$help, |
87 |
'pb|patron-branchcode:s' => \$patron_branchcode, |
|
|
88 |
'h|help' => \$help, |
| 86 |
); |
89 |
); |
| 87 |
|
90 |
|
| 88 |
$language = uc($language); |
91 |
$language = uc($language); |
|
Lines 90-95
$library_code ||= '';
Link Here
|
| 90 |
|
93 |
|
| 91 |
pod2usage( -verbose => 1 ) if $help; |
94 |
pod2usage( -verbose => 1 ) if $help; |
| 92 |
|
95 |
|
|
|
96 |
if ($patron_branchcode) { |
| 97 |
die("Invalid branchcode '$patron_branchcode' passed in -pb --patron-branchcode parameter") |
| 98 |
unless Koha::Libraries->search( { branchcode => $patron_branchcode } )->count; |
| 99 |
} |
| 100 |
|
| 93 |
# output log or STDOUT |
101 |
# output log or STDOUT |
| 94 |
my $OUT; |
102 |
my $OUT; |
| 95 |
if ( defined $outfile ) { |
103 |
if ( defined $outfile ) { |
|
Lines 109-119
foreach my $type (@types) {
Link Here
|
| 109 |
|
117 |
|
| 110 |
my @loop; |
118 |
my @loop; |
| 111 |
if ( $type eq 'OVERDUE' ) { |
119 |
if ( $type eq 'OVERDUE' ) { |
| 112 |
@loop = GetOverdueIssues(); |
120 |
@loop = GetOverdueIssues( $patron_branchcode ); |
| 113 |
} elsif ( $type eq 'PREOVERDUE' ) { |
121 |
} elsif ( $type eq 'PREOVERDUE' ) { |
| 114 |
@loop = GetPredueIssues(); |
122 |
@loop = GetPredueIssues( $patron_branchcode ); |
| 115 |
} elsif ( $type eq 'RESERVE' ) { |
123 |
} elsif ( $type eq 'RESERVE' ) { |
| 116 |
@loop = GetWaitingHolds(); |
124 |
@loop = GetWaitingHolds( $patron_branchcode ); |
| 117 |
} else { |
125 |
} else { |
| 118 |
print "Unknown or unsupported message type $type; skipping...\n" |
126 |
print "Unknown or unsupported message type $type; skipping...\n" |
| 119 |
if ( defined $verbose ); |
127 |
if ( defined $verbose ); |
|
Lines 215-225
consortium purposes and apply library specific settings, such as
Link Here
|
| 215 |
prompts, to those notices. |
223 |
prompts, to those notices. |
| 216 |
This field can be blank if all messages are from a single library. |
224 |
This field can be blank if all messages are from a single library. |
| 217 |
|
225 |
|
|
|
226 |
=item B<--patron-branchcode> B<--pb> |
| 227 |
|
| 228 |
OPTIONAL |
| 229 |
|
| 230 |
Limits the the patrons to generate notices for based on the patron's home library. |
| 231 |
Items and holds from other libraries will still be included for the given patron. |
| 232 |
|
| 218 |
=back |
233 |
=back |
| 219 |
|
234 |
|
| 220 |
=cut |
235 |
=cut |
| 221 |
|
236 |
|
| 222 |
sub GetOverdueIssues { |
237 |
sub GetOverdueIssues { |
|
|
238 |
my ( $patron_branchcode ) = @_; |
| 239 |
|
| 240 |
my $patron_branchcode_filter = $patron_branchcode ? "AND borrowers.branchcode = '$patron_branchcode'" : q{}; |
| 241 |
|
| 223 |
my $query = "SELECT borrowers.borrowernumber, borrowers.cardnumber, borrowers.title as patron_title, borrowers.firstname, borrowers.surname, |
242 |
my $query = "SELECT borrowers.borrowernumber, borrowers.cardnumber, borrowers.title as patron_title, borrowers.firstname, borrowers.surname, |
| 224 |
borrowers.phone, borrowers.email, borrowers.branchcode, biblio.biblionumber, biblio.title, items.barcode, issues.date_due, |
243 |
borrowers.phone, borrowers.email, borrowers.branchcode, biblio.biblionumber, biblio.title, items.barcode, issues.date_due, |
| 225 |
max(overduerules.branchcode) as rulebranch, TO_DAYS(NOW())-TO_DAYS(date_due) as daysoverdue, delay1, delay2, delay3, |
244 |
max(overduerules.branchcode) as rulebranch, TO_DAYS(NOW())-TO_DAYS(date_due) as daysoverdue, delay1, delay2, delay3, |
|
Lines 235-240
sub GetOverdueIssues {
Link Here
|
| 235 |
AND ( (TO_DAYS(NOW())-TO_DAYS(date_due) ) = delay1 |
254 |
AND ( (TO_DAYS(NOW())-TO_DAYS(date_due) ) = delay1 |
| 236 |
OR (TO_DAYS(NOW())-TO_DAYS(date_due) ) = delay2 |
255 |
OR (TO_DAYS(NOW())-TO_DAYS(date_due) ) = delay2 |
| 237 |
OR (TO_DAYS(NOW())-TO_DAYS(date_due) ) = delay3 ) |
256 |
OR (TO_DAYS(NOW())-TO_DAYS(date_due) ) = delay3 ) |
|
|
257 |
$patron_branchcode_filter |
| 238 |
GROUP BY items.itemnumber |
258 |
GROUP BY items.itemnumber |
| 239 |
"; |
259 |
"; |
| 240 |
my $sth = $dbh->prepare($query); |
260 |
my $sth = $dbh->prepare($query); |
|
Lines 257-262
sub GetOverdueIssues {
Link Here
|
| 257 |
} |
277 |
} |
| 258 |
|
278 |
|
| 259 |
sub GetPredueIssues { |
279 |
sub GetPredueIssues { |
|
|
280 |
my ( $patron_branchcode ) = @_; |
| 281 |
|
| 282 |
my $patron_branchcode_filter = $patron_branchcode ? "AND borrowers.branchcode = '$patron_branchcode'" : q{}; |
| 283 |
|
| 260 |
my $query = "SELECT borrowers.borrowernumber, borrowers.cardnumber, borrowers.title as patron_title, borrowers.firstname, borrowers.surname, |
284 |
my $query = "SELECT borrowers.borrowernumber, borrowers.cardnumber, borrowers.title as patron_title, borrowers.firstname, borrowers.surname, |
| 261 |
borrowers.phone, borrowers.email, borrowers.branchcode, biblio.biblionumber, biblio.title, items.barcode, issues.date_due, |
285 |
borrowers.phone, borrowers.email, borrowers.branchcode, biblio.biblionumber, biblio.title, items.barcode, issues.date_due, |
| 262 |
issues.branchcode as site, branches.branchname as site_name |
286 |
issues.branchcode as site, branches.branchname as site_name |
|
Lines 270-275
sub GetPredueIssues {
Link Here
|
| 270 |
WHERE ( TO_DAYS( date_due ) - TO_DAYS( NOW() ) ) = days_in_advance |
294 |
WHERE ( TO_DAYS( date_due ) - TO_DAYS( NOW() ) ) = days_in_advance |
| 271 |
AND message_transport_type = 'phone' |
295 |
AND message_transport_type = 'phone' |
| 272 |
AND message_name = 'Advance_Notice' |
296 |
AND message_name = 'Advance_Notice' |
|
|
297 |
$patron_branchcode_filter |
| 273 |
"; |
298 |
"; |
| 274 |
my $sth = $dbh->prepare($query); |
299 |
my $sth = $dbh->prepare($query); |
| 275 |
$sth->execute(); |
300 |
$sth->execute(); |
|
Lines 282-287
sub GetPredueIssues {
Link Here
|
| 282 |
} |
307 |
} |
| 283 |
|
308 |
|
| 284 |
sub GetWaitingHolds { |
309 |
sub GetWaitingHolds { |
|
|
310 |
my ( $patron_branchcode ) = @_; |
| 311 |
|
| 312 |
my $patron_branchcode_filter = $patron_branchcode ? "AND borrowers.branchcode = '$patron_branchcode'" : q{}; |
| 313 |
|
| 285 |
my $query = "SELECT borrowers.borrowernumber, borrowers.cardnumber, borrowers.title as patron_title, borrowers.firstname, borrowers.surname, |
314 |
my $query = "SELECT borrowers.borrowernumber, borrowers.cardnumber, borrowers.title as patron_title, borrowers.firstname, borrowers.surname, |
| 286 |
borrowers.phone, borrowers.email, borrowers.branchcode, biblio.biblionumber, biblio.title, items.barcode, reserves.waitingdate, |
315 |
borrowers.phone, borrowers.email, borrowers.branchcode, biblio.biblionumber, biblio.title, items.barcode, reserves.waitingdate, |
| 287 |
reserves.branchcode AS site, branches.branchname AS site_name, |
316 |
reserves.branchcode AS site, branches.branchname AS site_name, |
|
Lines 296-301
sub GetWaitingHolds {
Link Here
|
| 296 |
WHERE ( reserves.found = 'W' ) |
325 |
WHERE ( reserves.found = 'W' ) |
| 297 |
AND message_transport_type = 'phone' |
326 |
AND message_transport_type = 'phone' |
| 298 |
AND message_name = 'Hold_Filled' |
327 |
AND message_name = 'Hold_Filled' |
|
|
328 |
$patron_branchcode_filter |
| 299 |
"; |
329 |
"; |
| 300 |
my $pickupdelay = C4::Context->preference("ReservesMaxPickUpDelay"); |
330 |
my $pickupdelay = C4::Context->preference("ReservesMaxPickUpDelay"); |
| 301 |
my $sth = $dbh->prepare($query); |
331 |
my $sth = $dbh->prepare($query); |
| 302 |
- |
|
|