View | Details | Raw Unified | Return to bug 32511
Collapse All | Expand All

(-)a/misc/cronjobs/overdue_notices.pl (-4 / +18 lines)
Lines 72-77 overdue_notices.pl Link Here
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).
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
   -a           <branchcode>      Create only one message per borrower and delay level including overdues from all branches.
75
76
76
=head1 OPTIONS
77
=head1 OPTIONS
77
78
Lines 188-193 Organize overdue notices either by checkout library (item-issuebranch) or item h Link Here
188
This option is only used, if the OverdueNoticeFrom system preference is set to use 'command-line option'.
189
This option is only used, if the OverdueNoticeFrom system preference is set to use 'command-line option'.
189
Defaults to checkout library (item-issuebranch).
190
Defaults to checkout library (item-issuebranch).
190
191
192
=item B<-a> | B<--all_in_one>
193
194
Create only one message per borrower and for each delay level including overdues from all branches.
195
Branchcode value (branches.branchcode) has to be given to choose which sender address will be set.
196
It's recommended to use this option only with default notice(s) defined for 'All branches'
197
in Notices & Slips and no specific ones.
198
191
=back
199
=back
192
200
193
=head1 DESCRIPTION
201
=head1 DESCRIPTION
Lines 310-315 my $itemscontent = join( ',', qw( date_due title barcode author itemnumber ) ); Link Here
310
my @myborcat;
318
my @myborcat;
311
my @myborcatout;
319
my @myborcatout;
312
my ( $date_input, $today );
320
my ( $date_input, $today );
321
my $all_in_one;
313
322
314
my $command_line_options = join(" ",@ARGV);
323
my $command_line_options = join(" ",@ARGV);
315
324
Lines 332-337 GetOptions( Link Here
332
    'borcatout=s'    => \@myborcatout,
341
    'borcatout=s'    => \@myborcatout,
333
    'email=s'        => \@emails,
342
    'email=s'        => \@emails,
334
    'frombranch=s'   => \$frombranch,
343
    'frombranch=s'   => \$frombranch,
344
    'a|all_in_one=s' => \$all_in_one,
335
) or pod2usage(2);
345
) or pod2usage(2);
336
pod2usage(1) if $help;
346
pod2usage(1) if $help;
337
pod2usage( -verbose => 2 ) if $man;
347
pod2usage( -verbose => 2 ) if $man;
Lines 457-462 elsif ( defined $text_filename ) { Link Here
457
  }
467
  }
458
}
468
}
459
469
470
my %already_queued;
471
my %seen = map { $_ => 1 } @branches;
460
foreach my $branchcode (@branches) {
472
foreach my $branchcode (@branches) {
461
    my $calendar;
473
    my $calendar;
462
    if ( C4::Context->preference('OverdueNoticeCalendar') ) {
474
    if ( C4::Context->preference('OverdueNoticeCalendar') ) {
Lines 466-472 foreach my $branchcode (@branches) { Link Here
466
        }
478
        }
467
    }
479
    }
468
480
469
    my $library             = Koha::Libraries->find($branchcode);
481
    my $library             = $all_in_one ? Koha::Libraries->find($all_in_one) : Koha::Libraries->find($branchcode);
470
    my $admin_email_address = $library->from_email_address;
482
    my $admin_email_address = $library->from_email_address;
471
    my $branch_email_address = C4::Context->preference('AddressForFailedOverdueNotices')
483
    my $branch_email_address = C4::Context->preference('AddressForFailedOverdueNotices')
472
      || $library->inbound_email_address;
484
      || $library->inbound_email_address;
Lines 490-496 END_SQL Link Here
490
    if($owning_library) {
502
    if($owning_library) {
491
      $sql2 .= ' AND items.homebranch = ? ';
503
      $sql2 .= ' AND items.homebranch = ? ';
492
    } else {
504
    } else {
493
      $sql2 .= ' AND issues.branchcode = ? ';
505
      $sql2 .= ' AND issues.branchcode = ? ' unless $all_in_one;
494
    }
506
    }
495
    my $sth2 = $dbh->prepare($sql2);
507
    my $sth2 = $dbh->prepare($sql2);
496
508
Lines 606-611 END_SQL Link Here
606
                    next;
618
                    next;
607
                }
619
                }
608
                $borrowernumber = $data->{'borrowernumber'};
620
                $borrowernumber = $data->{'borrowernumber'};
621
                next if ($all_in_one && $already_queued{"$borrowernumber$i"});
609
                my $borr = sprintf( "%s%s%s (%s)",
622
                my $borr = sprintf( "%s%s%s (%s)",
610
                    $data->{'surname'} || '',
623
                    $data->{'surname'} || '',
611
                    $data->{'firstname'} && $data->{'surname'} ? ', ' : '',
624
                    $data->{'firstname'} && $data->{'surname'} ? ', ' : '',
Lines 656-662 END_SQL Link Here
656
                    ) unless $test_mode;
669
                    ) unless $test_mode;
657
                    $verbose and warn "debarring $borr\n";
670
                    $verbose and warn "debarring $borr\n";
658
                }
671
                }
659
                my @params = ($borrowernumber,$branchcode);
672
                my @params = $all_in_one ? ($borrowernumber) : ($borrowernumber, $branchcode);
660
673
661
                $sth2->execute(@params);
674
                $sth2->execute(@params);
662
                my $itemcount = 0;
675
                my $itemcount = 0;
Lines 701-706 END_SQL Link Here
701
                      $exceededPrintNoticesMaxLines = 1;
714
                      $exceededPrintNoticesMaxLines = 1;
702
                      last;
715
                      last;
703
                    }
716
                    }
717
                    next if $all_in_one and ! grep {$seen{$item_info->{branchcode}}} @branches;
704
                    $j++;
718
                    $j++;
705
719
706
                    $titles .= C4::Letters::get_item_content( { item => $item_info, item_content_fields => \@item_content_fields, dateonly => 1 } );
720
                    $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
                        }
838
                        }
825
                    }
839
                    }
826
                }
840
                }
841
                $already_queued{"$borrowernumber$i"} = 1;
827
            }
842
            }
828
            $sth->finish;
843
            $sth->finish;
829
        }
844
        }
830
- 

Return to bug 32511