|
Lines 101-109
Defines the maximum number of days in advance to send advance notices.
Link Here
|
| 101 |
Confirm flag: Add this option. The script will only print a usage |
101 |
Confirm flag: Add this option. The script will only print a usage |
| 102 |
statement otherwise. |
102 |
statement otherwise. |
| 103 |
|
103 |
|
|
|
104 |
=item B<-library> |
| 105 |
|
| 106 |
Select notices for one specific library. Use the value in the |
| 107 |
branches.branchcode table. This option can be repeated in order |
| 108 |
to select notices for a group of libraries. |
| 109 |
|
| 104 |
=item B<--itemscontent> |
110 |
=item B<--itemscontent> |
| 105 |
|
111 |
|
| 106 |
comma separated list of fields that get substituted into templates in |
112 |
Comma separated list of fields that get substituted into templates in |
| 107 |
places of the E<lt>E<lt>items.contentE<gt>E<gt> placeholder. This |
113 |
places of the E<lt>E<lt>items.contentE<gt>E<gt> placeholder. This |
| 108 |
defaults to date_due,title,author,barcode |
114 |
defaults to date_due,title,author,barcode |
| 109 |
|
115 |
|
|
Lines 125-130
Enabling this flag ensures that the issuing library is the sender of
Link Here
|
| 125 |
the digested message. It has no effect unless the borrower has |
131 |
the digested message. It has no effect unless the borrower has |
| 126 |
chosen 'Digests only' on the advance messages. |
132 |
chosen 'Digests only' on the advance messages. |
| 127 |
|
133 |
|
|
|
134 |
=item B<--owning> |
| 135 |
|
| 136 |
Use the address information from the item homebranch library instead of the issuing library. |
| 137 |
|
| 128 |
=back |
138 |
=back |
| 129 |
|
139 |
|
| 130 |
=head1 DESCRIPTION |
140 |
=head1 DESCRIPTION |
|
Lines 190-196
my $nomail; # -n: No mai
Link Here
|
| 190 |
my $mindays = 0; # -m: Maximum number of days in advance to send notices |
200 |
my $mindays = 0; # -m: Maximum number of days in advance to send notices |
| 191 |
my $maxdays = 30; # -e: the End of the time period |
201 |
my $maxdays = 30; # -e: the End of the time period |
| 192 |
my $verbose = 0; # -v: verbose |
202 |
my $verbose = 0; # -v: verbose |
|
|
203 |
<<<<<<< HEAD |
| 193 |
my $digest_per_branch = 0; # -digest-per-branch: Prepare and send digests per branch |
204 |
my $digest_per_branch = 0; # -digest-per-branch: Prepare and send digests per branch |
|
|
205 |
======= |
| 206 |
my @branchcodes; # Branch(es) passed as parameter |
| 207 |
my $owning_library = 0; |
| 208 |
>>>>>>> Bug 21886: Add option to send notices from owning library instead of issuing library |
| 194 |
my $itemscontent = join(',',qw( date_due title author barcode )); |
209 |
my $itemscontent = join(',',qw( date_due title author barcode )); |
| 195 |
|
210 |
|
| 196 |
my $help = 0; |
211 |
my $help = 0; |
|
Lines 199-204
my $man = 0;
Link Here
|
| 199 |
GetOptions( |
214 |
GetOptions( |
| 200 |
'help|?' => \$help, |
215 |
'help|?' => \$help, |
| 201 |
'man' => \$man, |
216 |
'man' => \$man, |
|
|
217 |
'library=s' => \@branchcodes, |
| 218 |
'owning' => \$owning_library, |
| 202 |
'c' => \$confirm, |
219 |
'c' => \$confirm, |
| 203 |
'n' => \$nomail, |
220 |
'n' => \$nomail, |
| 204 |
'm:i' => \$maxdays, |
221 |
'm:i' => \$maxdays, |
|
Lines 226-236
unless ($confirm) {
Link Here
|
| 226 |
} |
243 |
} |
| 227 |
cronlogaction(); |
244 |
cronlogaction(); |
| 228 |
|
245 |
|
|
|
246 |
my %branches = map { $_ => 1 } @branchcodes if @branchcodes; |
| 247 |
|
| 229 |
# The fields that will be substituted into <<items.content>> |
248 |
# The fields that will be substituted into <<items.content>> |
| 230 |
my @item_content_fields = split(/,/,$itemscontent); |
249 |
my @item_content_fields = split(/,/,$itemscontent); |
| 231 |
|
250 |
|
| 232 |
warn 'getting upcoming due issues' if $verbose; |
251 |
warn 'getting upcoming due issues' if $verbose; |
| 233 |
my $upcoming_dues = C4::Circulation::GetUpcomingDueIssues( { days_in_advance => $maxdays } ); |
252 |
my $upcoming_dues = C4::Circulation::GetUpcomingDueIssues( { |
|
|
253 |
days_in_advance => $maxdays, |
| 254 |
owning_library => $owning_library |
| 255 |
} ); |
| 234 |
warn 'found ' . scalar( @$upcoming_dues ) . ' issues' if $verbose; |
256 |
warn 'found ' . scalar( @$upcoming_dues ) . ' issues' if $verbose; |
| 235 |
|
257 |
|
| 236 |
# hash of borrowernumber to number of items upcoming |
258 |
# hash of borrowernumber to number of items upcoming |
|
Lines 275-280
UPCOMINGITEM: foreach my $upcoming ( @$upcoming_dues ) {
Link Here
|
| 275 |
$due_digest->{ $upcoming->{borrowernumber} }->{count}++; |
297 |
$due_digest->{ $upcoming->{borrowernumber} }->{count}++; |
| 276 |
} |
298 |
} |
| 277 |
} else { |
299 |
} else { |
|
|
300 |
my $branchcode; |
| 301 |
if($owning_library) { |
| 302 |
$branchcode = $upcoming->{'homebranch'}; |
| 303 |
} else { |
| 304 |
$branchcode = $upcoming->{'branchcode'}; |
| 305 |
} |
| 306 |
# Skip this DUE if we specify list of libraries and this one is not part of it |
| 307 |
next if (@branchcodes && !$branches{$branchcode}); |
| 308 |
|
| 278 |
my $item = Koha::Items->find( $upcoming->{itemnumber} ); |
309 |
my $item = Koha::Items->find( $upcoming->{itemnumber} ); |
| 279 |
my $letter_type = 'DUE'; |
310 |
my $letter_type = 'DUE'; |
| 280 |
$sth->execute($upcoming->{'borrowernumber'},$upcoming->{'itemnumber'},'0'); |
311 |
$sth->execute($upcoming->{'borrowernumber'},$upcoming->{'itemnumber'},'0'); |
|
Lines 287-293
UPCOMINGITEM: foreach my $upcoming ( @$upcoming_dues ) {
Link Here
|
| 287 |
foreach my $transport ( keys %{$borrower_preferences->{'transports'}} ) { |
318 |
foreach my $transport ( keys %{$borrower_preferences->{'transports'}} ) { |
| 288 |
my $letter = parse_letter( { letter_code => $letter_type, |
319 |
my $letter = parse_letter( { letter_code => $letter_type, |
| 289 |
borrowernumber => $upcoming->{'borrowernumber'}, |
320 |
borrowernumber => $upcoming->{'borrowernumber'}, |
| 290 |
branchcode => $upcoming->{'branchcode'}, |
321 |
branchcode => $branchcode, |
| 291 |
biblionumber => $item->biblionumber, |
322 |
biblionumber => $item->biblionumber, |
| 292 |
itemnumber => $upcoming->{'itemnumber'}, |
323 |
itemnumber => $upcoming->{'itemnumber'}, |
| 293 |
substitute => { 'items.content' => $titles }, |
324 |
substitute => { 'items.content' => $titles }, |
|
Lines 313-318
UPCOMINGITEM: foreach my $upcoming ( @$upcoming_dues ) {
Link Here
|
| 313 |
$upcoming_digest->{ $upcoming->{borrowernumber} }->{count}++; |
344 |
$upcoming_digest->{ $upcoming->{borrowernumber} }->{count}++; |
| 314 |
} |
345 |
} |
| 315 |
} else { |
346 |
} else { |
|
|
347 |
my $branchcode; |
| 348 |
if($owning_library) { |
| 349 |
$branchcode = $upcoming->{'homebranch'}; |
| 350 |
} else { |
| 351 |
$branchcode = $upcoming->{'branchcode'}; |
| 352 |
} |
| 353 |
# Skip this PREDUE if we specify list of libraries and this one is not part of it |
| 354 |
next if (@branchcodes && !$branches{$branchcode}); |
| 355 |
|
| 316 |
my $item = Koha::Items->find( $upcoming->{itemnumber} ); |
356 |
my $item = Koha::Items->find( $upcoming->{itemnumber} ); |
| 317 |
my $letter_type = 'PREDUE'; |
357 |
my $letter_type = 'PREDUE'; |
| 318 |
$sth->execute($upcoming->{'borrowernumber'},$upcoming->{'itemnumber'},$borrower_preferences->{'days_in_advance'}); |
358 |
$sth->execute($upcoming->{'borrowernumber'},$upcoming->{'itemnumber'},$borrower_preferences->{'days_in_advance'}); |
|
Lines 325-331
UPCOMINGITEM: foreach my $upcoming ( @$upcoming_dues ) {
Link Here
|
| 325 |
foreach my $transport ( keys %{$borrower_preferences->{'transports'}} ) { |
365 |
foreach my $transport ( keys %{$borrower_preferences->{'transports'}} ) { |
| 326 |
my $letter = parse_letter( { letter_code => $letter_type, |
366 |
my $letter = parse_letter( { letter_code => $letter_type, |
| 327 |
borrowernumber => $upcoming->{'borrowernumber'}, |
367 |
borrowernumber => $upcoming->{'borrowernumber'}, |
| 328 |
branchcode => $upcoming->{'branchcode'}, |
368 |
branchcode => $branchcode, |
| 329 |
biblionumber => $item->biblionumber, |
369 |
biblionumber => $item->biblionumber, |
| 330 |
itemnumber => $upcoming->{'itemnumber'}, |
370 |
itemnumber => $upcoming->{'itemnumber'}, |
| 331 |
substitute => { 'items.content' => $titles }, |
371 |
substitute => { 'items.content' => $titles }, |