Lines 109-114
defaults to date_due,title,author,barcode
Link Here
|
109 |
Other possible values come from fields in the biblios, items and |
109 |
Other possible values come from fields in the biblios, items and |
110 |
issues tables. |
110 |
issues tables. |
111 |
|
111 |
|
|
|
112 |
=item B<-library> |
113 |
|
114 |
select notices for one specific library. Use the value in the |
115 |
branches.branchcode table. This option can be repeated in order |
116 |
to select notices for a group of libraries. |
117 |
|
118 |
=item B<-owning> |
119 |
|
120 |
Use the address information from the item homebranch library instead of the issuing library. |
121 |
|
112 |
=back |
122 |
=back |
113 |
|
123 |
|
114 |
=head1 DESCRIPTION |
124 |
=head1 DESCRIPTION |
Lines 174-179
my $nomail; # -n: No mai
Link Here
|
174 |
my $mindays = 0; # -m: Maximum number of days in advance to send notices |
184 |
my $mindays = 0; # -m: Maximum number of days in advance to send notices |
175 |
my $maxdays = 30; # -e: the End of the time period |
185 |
my $maxdays = 30; # -e: the End of the time period |
176 |
my $verbose = 0; # -v: verbose |
186 |
my $verbose = 0; # -v: verbose |
|
|
187 |
my @branchcodes; # Branch(es) passed as parameter |
188 |
my $owning_library = 0; |
177 |
my $itemscontent = join(',',qw( date_due title author barcode )); |
189 |
my $itemscontent = join(',',qw( date_due title author barcode )); |
178 |
|
190 |
|
179 |
my $help = 0; |
191 |
my $help = 0; |
Lines 182-187
my $man = 0;
Link Here
|
182 |
GetOptions( |
194 |
GetOptions( |
183 |
'help|?' => \$help, |
195 |
'help|?' => \$help, |
184 |
'man' => \$man, |
196 |
'man' => \$man, |
|
|
197 |
'library=s' => \@branchcodes, |
198 |
'owning' => \$owning_library, |
185 |
'c' => \$confirm, |
199 |
'c' => \$confirm, |
186 |
'n' => \$nomail, |
200 |
'n' => \$nomail, |
187 |
'm:i' => \$maxdays, |
201 |
'm:i' => \$maxdays, |
Lines 209-219
unless ($confirm) {
Link Here
|
209 |
|
223 |
|
210 |
cronlogaction(); |
224 |
cronlogaction(); |
211 |
|
225 |
|
|
|
226 |
my %branches = map { $_ => 1 } @branchcodes if @branchcodes; |
227 |
|
212 |
# The fields that will be substituted into <<items.content>> |
228 |
# The fields that will be substituted into <<items.content>> |
213 |
my @item_content_fields = split(/,/,$itemscontent); |
229 |
my @item_content_fields = split(/,/,$itemscontent); |
214 |
|
230 |
|
215 |
warn 'getting upcoming due issues' if $verbose; |
231 |
warn 'getting upcoming due issues' if $verbose; |
216 |
my $upcoming_dues = C4::Circulation::GetUpcomingDueIssues( { days_in_advance => $maxdays } ); |
232 |
my $upcoming_dues = C4::Circulation::GetUpcomingDueIssues( { |
|
|
233 |
days_in_advance => $maxdays, |
234 |
owning_library => $owning_library |
235 |
} ); |
217 |
warn 'found ' . scalar( @$upcoming_dues ) . ' issues' if $verbose; |
236 |
warn 'found ' . scalar( @$upcoming_dues ) . ' issues' if $verbose; |
218 |
|
237 |
|
219 |
# hash of borrowernumber to number of items upcoming |
238 |
# hash of borrowernumber to number of items upcoming |
Lines 253-258
UPCOMINGITEM: foreach my $upcoming ( @$upcoming_dues ) {
Link Here
|
253 |
$due_digest->{ $upcoming->{borrowernumber} }->{email} = $from_address; |
272 |
$due_digest->{ $upcoming->{borrowernumber} }->{email} = $from_address; |
254 |
$due_digest->{ $upcoming->{borrowernumber} }->{count}++; |
273 |
$due_digest->{ $upcoming->{borrowernumber} }->{count}++; |
255 |
} else { |
274 |
} else { |
|
|
275 |
my $branchcode; |
276 |
if($owning_library) { |
277 |
$branchcode = $upcoming->{'homebranch'}; |
278 |
} else { |
279 |
$branchcode = $upcoming->{'branchcode'}; |
280 |
} |
281 |
# Skip this DUE if we specify list of libraries and this one is not part of it |
282 |
next if (@branchcodes && !$branches{$branchcode}); |
283 |
|
256 |
my $item = Koha::Items->find( $upcoming->{itemnumber} ); |
284 |
my $item = Koha::Items->find( $upcoming->{itemnumber} ); |
257 |
my $letter_type = 'DUE'; |
285 |
my $letter_type = 'DUE'; |
258 |
$sth->execute($upcoming->{'borrowernumber'},$upcoming->{'itemnumber'},'0'); |
286 |
$sth->execute($upcoming->{'borrowernumber'},$upcoming->{'itemnumber'},'0'); |
Lines 265-271
UPCOMINGITEM: foreach my $upcoming ( @$upcoming_dues ) {
Link Here
|
265 |
foreach my $transport ( keys %{$borrower_preferences->{'transports'}} ) { |
293 |
foreach my $transport ( keys %{$borrower_preferences->{'transports'}} ) { |
266 |
my $letter = parse_letter( { letter_code => $letter_type, |
294 |
my $letter = parse_letter( { letter_code => $letter_type, |
267 |
borrowernumber => $upcoming->{'borrowernumber'}, |
295 |
borrowernumber => $upcoming->{'borrowernumber'}, |
268 |
branchcode => $upcoming->{'branchcode'}, |
296 |
branchcode => $branchcode, |
269 |
biblionumber => $item->biblionumber, |
297 |
biblionumber => $item->biblionumber, |
270 |
itemnumber => $upcoming->{'itemnumber'}, |
298 |
itemnumber => $upcoming->{'itemnumber'}, |
271 |
substitute => { 'items.content' => $titles }, |
299 |
substitute => { 'items.content' => $titles }, |
Lines 286-291
UPCOMINGITEM: foreach my $upcoming ( @$upcoming_dues ) {
Link Here
|
286 |
$upcoming_digest->{ $upcoming->{borrowernumber} }->{email} = $from_address; |
314 |
$upcoming_digest->{ $upcoming->{borrowernumber} }->{email} = $from_address; |
287 |
$upcoming_digest->{ $upcoming->{borrowernumber} }->{count}++; |
315 |
$upcoming_digest->{ $upcoming->{borrowernumber} }->{count}++; |
288 |
} else { |
316 |
} else { |
|
|
317 |
my $branchcode; |
318 |
if($owning_library) { |
319 |
$branchcode = $upcoming->{'homebranch'}; |
320 |
} else { |
321 |
$branchcode = $upcoming->{'branchcode'}; |
322 |
} |
323 |
# Skip this PREDUE if we specify list of libraries and this one is not part of it |
324 |
next if (@branchcodes && !$branches{$branchcode}); |
325 |
|
289 |
my $item = Koha::Items->find( $upcoming->{itemnumber} ); |
326 |
my $item = Koha::Items->find( $upcoming->{itemnumber} ); |
290 |
my $letter_type = 'PREDUE'; |
327 |
my $letter_type = 'PREDUE'; |
291 |
$sth->execute($upcoming->{'borrowernumber'},$upcoming->{'itemnumber'},$borrower_preferences->{'days_in_advance'}); |
328 |
$sth->execute($upcoming->{'borrowernumber'},$upcoming->{'itemnumber'},$borrower_preferences->{'days_in_advance'}); |
Lines 298-304
UPCOMINGITEM: foreach my $upcoming ( @$upcoming_dues ) {
Link Here
|
298 |
foreach my $transport ( keys %{$borrower_preferences->{'transports'}} ) { |
335 |
foreach my $transport ( keys %{$borrower_preferences->{'transports'}} ) { |
299 |
my $letter = parse_letter( { letter_code => $letter_type, |
336 |
my $letter = parse_letter( { letter_code => $letter_type, |
300 |
borrowernumber => $upcoming->{'borrowernumber'}, |
337 |
borrowernumber => $upcoming->{'borrowernumber'}, |
301 |
branchcode => $upcoming->{'branchcode'}, |
338 |
branchcode => $branchcode, |
302 |
biblionumber => $item->biblionumber, |
339 |
biblionumber => $item->biblionumber, |
303 |
itemnumber => $upcoming->{'itemnumber'}, |
340 |
itemnumber => $upcoming->{'itemnumber'}, |
304 |
substitute => { 'items.content' => $titles }, |
341 |
substitute => { 'items.content' => $titles }, |