View | Details | Raw Unified | Return to bug 17649
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 446-451 elsif ( defined $text_filename ) { Link Here
446
  }
456
  }
447
}
457
}
448
458
459
my %already_queued;
460
my %seen = map { $_ => 1 } @branches;
449
foreach my $branchcode (@branches) {
461
foreach my $branchcode (@branches) {
450
    my $calendar;
462
    my $calendar;
451
    if ( C4::Context->preference('OverdueNoticeCalendar') ) {
463
    if ( C4::Context->preference('OverdueNoticeCalendar') ) {
Lines 455-461 foreach my $branchcode (@branches) { Link Here
455
        }
467
        }
456
    }
468
    }
457
469
458
    my $library             = Koha::Libraries->find($branchcode);
470
    my $library             = $all_in_one ? Koha::Libraries->find($all_in_one) : Koha::Libraries->find($branchcode);
459
    my $admin_email_address = $library->from_email_address;
471
    my $admin_email_address = $library->from_email_address;
460
    my $branch_email_address = C4::Context->preference('AddressForFailedOverdueNotices')
472
    my $branch_email_address = C4::Context->preference('AddressForFailedOverdueNotices')
461
      || $library->inbound_email_address;
473
      || $library->inbound_email_address;
Lines 479-485 END_SQL Link Here
479
    if($owning_library) {
491
    if($owning_library) {
480
      $sql2 .= ' AND items.homebranch = ? ';
492
      $sql2 .= ' AND items.homebranch = ? ';
481
    } else {
493
    } else {
482
      $sql2 .= ' AND issues.branchcode = ? ';
494
      $sql2 .= ' AND issues.branchcode = ? ' unless $all_in_one;
483
    }
495
    }
484
    my $sth2 = $dbh->prepare($sql2);
496
    my $sth2 = $dbh->prepare($sql2);
485
497
Lines 595-600 END_SQL Link Here
595
                    next;
607
                    next;
596
                }
608
                }
597
                $borrowernumber = $data->{'borrowernumber'};
609
                $borrowernumber = $data->{'borrowernumber'};
610
                next if ($all_in_one && $already_queued{"$borrowernumber$i"});
598
                my $borr = sprintf( "%s%s%s (%s)",
611
                my $borr = sprintf( "%s%s%s (%s)",
599
                    $data->{'surname'} || '',
612
                    $data->{'surname'} || '',
600
                    $data->{'firstname'} && $data->{'surname'} ? ', ' : '',
613
                    $data->{'firstname'} && $data->{'surname'} ? ', ' : '',
Lines 645-651 END_SQL Link Here
645
                    ) unless $test_mode;
658
                    ) unless $test_mode;
646
                    $verbose and warn "debarring $borr\n";
659
                    $verbose and warn "debarring $borr\n";
647
                }
660
                }
648
                my @params = ($borrowernumber,$branchcode);
661
                my @params = $all_in_one ? ($borrowernumber) : ($borrowernumber, $branchcode);
649
662
650
                $sth2->execute(@params);
663
                $sth2->execute(@params);
651
                my $itemcount = 0;
664
                my $itemcount = 0;
Lines 690-695 END_SQL Link Here
690
                      $exceededPrintNoticesMaxLines = 1;
703
                      $exceededPrintNoticesMaxLines = 1;
691
                      last;
704
                      last;
692
                    }
705
                    }
706
                    next if $all_in_one and ! grep {$seen{$item_info->{branchcode}}} @branches;
693
                    $j++;
707
                    $j++;
694
708
695
                    $titles .= C4::Letters::get_item_content( { item => $item_info, item_content_fields => \@item_content_fields, dateonly => 1 } );
709
                    $titles .= C4::Letters::get_item_content( { item => $item_info, item_content_fields => \@item_content_fields, dateonly => 1 } );
Lines 813-818 END_SQL Link Here
813
                        }
827
                        }
814
                    }
828
                    }
815
                }
829
                }
830
                $already_queued{"$borrowernumber$i"} = 1;
816
            }
831
            }
817
            $sth->finish;
832
            $sth->finish;
818
        }
833
        }
819
- 

Return to bug 17649