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 |
125 |
the digested message. It has no effect unless the borrower has |
126 |
chosen 'Digests only' on the advance messages. |
126 |
chosen 'Digests only' on the advance messages. |
127 |
|
127 |
|
|
|
128 |
=item B<-library> |
129 |
|
130 |
select notices for one specific library. Use the value in the |
131 |
branches.branchcode table. This option can be repeated in order |
132 |
to select notices for a group of libraries. |
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 191-196
my $mindays = 0; # -m: Maximu
Link Here
|
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 |
193 |
my $digest_per_branch = 0; # -digest-per-branch: Prepare and send digests per branch |
203 |
my $digest_per_branch = 0; # -digest-per-branch: Prepare and send digests per branch |
|
|
204 |
my @branchcodes; # Branch(es) passed as parameter |
205 |
my $owning_library = 0; |
194 |
my $itemscontent = join(',',qw( date_due title author barcode )); |
206 |
my $itemscontent = join(',',qw( date_due title author barcode )); |
195 |
|
207 |
|
196 |
my $help = 0; |
208 |
my $help = 0; |
Lines 199-204
my $man = 0;
Link Here
|
199 |
GetOptions( |
211 |
GetOptions( |
200 |
'help|?' => \$help, |
212 |
'help|?' => \$help, |
201 |
'man' => \$man, |
213 |
'man' => \$man, |
|
|
214 |
'library=s' => \@branchcodes, |
215 |
'owning' => \$owning_library, |
202 |
'c' => \$confirm, |
216 |
'c' => \$confirm, |
203 |
'n' => \$nomail, |
217 |
'n' => \$nomail, |
204 |
'm:i' => \$maxdays, |
218 |
'm:i' => \$maxdays, |
Lines 226-236
unless ($confirm) {
Link Here
|
226 |
} |
240 |
} |
227 |
cronlogaction(); |
241 |
cronlogaction(); |
228 |
|
242 |
|
|
|
243 |
my %branches = map { $_ => 1 } @branchcodes if @branchcodes; |
244 |
|
229 |
# The fields that will be substituted into <<items.content>> |
245 |
# The fields that will be substituted into <<items.content>> |
230 |
my @item_content_fields = split(/,/,$itemscontent); |
246 |
my @item_content_fields = split(/,/,$itemscontent); |
231 |
|
247 |
|
232 |
warn 'getting upcoming due issues' if $verbose; |
248 |
warn 'getting upcoming due issues' if $verbose; |
233 |
my $upcoming_dues = C4::Circulation::GetUpcomingDueIssues( { days_in_advance => $maxdays } ); |
249 |
my $upcoming_dues = C4::Circulation::GetUpcomingDueIssues( { |
|
|
250 |
days_in_advance => $maxdays, |
251 |
owning_library => $owning_library |
252 |
} ); |
234 |
warn 'found ' . scalar( @$upcoming_dues ) . ' issues' if $verbose; |
253 |
warn 'found ' . scalar( @$upcoming_dues ) . ' issues' if $verbose; |
235 |
|
254 |
|
236 |
# hash of borrowernumber to number of items upcoming |
255 |
# 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}++; |
294 |
$due_digest->{ $upcoming->{borrowernumber} }->{count}++; |
276 |
} |
295 |
} |
277 |
} else { |
296 |
} else { |
|
|
297 |
my $branchcode; |
298 |
if($owning_library) { |
299 |
$branchcode = $upcoming->{'homebranch'}; |
300 |
} else { |
301 |
$branchcode = $upcoming->{'branchcode'}; |
302 |
} |
303 |
# Skip this DUE if we specify list of libraries and this one is not part of it |
304 |
next if (@branchcodes && !$branches{$branchcode}); |
305 |
|
278 |
my $item = Koha::Items->find( $upcoming->{itemnumber} ); |
306 |
my $item = Koha::Items->find( $upcoming->{itemnumber} ); |
279 |
my $letter_type = 'DUE'; |
307 |
my $letter_type = 'DUE'; |
280 |
$sth->execute($upcoming->{'borrowernumber'},$upcoming->{'itemnumber'},'0'); |
308 |
$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'}} ) { |
315 |
foreach my $transport ( keys %{$borrower_preferences->{'transports'}} ) { |
288 |
my $letter = parse_letter( { letter_code => $letter_type, |
316 |
my $letter = parse_letter( { letter_code => $letter_type, |
289 |
borrowernumber => $upcoming->{'borrowernumber'}, |
317 |
borrowernumber => $upcoming->{'borrowernumber'}, |
290 |
branchcode => $upcoming->{'branchcode'}, |
318 |
branchcode => $branchcode, |
291 |
biblionumber => $item->biblionumber, |
319 |
biblionumber => $item->biblionumber, |
292 |
itemnumber => $upcoming->{'itemnumber'}, |
320 |
itemnumber => $upcoming->{'itemnumber'}, |
293 |
substitute => { 'items.content' => $titles }, |
321 |
substitute => { 'items.content' => $titles }, |
Lines 313-318
UPCOMINGITEM: foreach my $upcoming ( @$upcoming_dues ) {
Link Here
|
313 |
$upcoming_digest->{ $upcoming->{borrowernumber} }->{count}++; |
341 |
$upcoming_digest->{ $upcoming->{borrowernumber} }->{count}++; |
314 |
} |
342 |
} |
315 |
} else { |
343 |
} else { |
|
|
344 |
my $branchcode; |
345 |
if($owning_library) { |
346 |
$branchcode = $upcoming->{'homebranch'}; |
347 |
} else { |
348 |
$branchcode = $upcoming->{'branchcode'}; |
349 |
} |
350 |
# Skip this PREDUE if we specify list of libraries and this one is not part of it |
351 |
next if (@branchcodes && !$branches{$branchcode}); |
352 |
|
316 |
my $item = Koha::Items->find( $upcoming->{itemnumber} ); |
353 |
my $item = Koha::Items->find( $upcoming->{itemnumber} ); |
317 |
my $letter_type = 'PREDUE'; |
354 |
my $letter_type = 'PREDUE'; |
318 |
$sth->execute($upcoming->{'borrowernumber'},$upcoming->{'itemnumber'},$borrower_preferences->{'days_in_advance'}); |
355 |
$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'}} ) { |
362 |
foreach my $transport ( keys %{$borrower_preferences->{'transports'}} ) { |
326 |
my $letter = parse_letter( { letter_code => $letter_type, |
363 |
my $letter = parse_letter( { letter_code => $letter_type, |
327 |
borrowernumber => $upcoming->{'borrowernumber'}, |
364 |
borrowernumber => $upcoming->{'borrowernumber'}, |
328 |
branchcode => $upcoming->{'branchcode'}, |
365 |
branchcode => $branchcode, |
329 |
biblionumber => $item->biblionumber, |
366 |
biblionumber => $item->biblionumber, |
330 |
itemnumber => $upcoming->{'itemnumber'}, |
367 |
itemnumber => $upcoming->{'itemnumber'}, |
331 |
substitute => { 'items.content' => $titles }, |
368 |
substitute => { 'items.content' => $titles }, |