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

(-)a/misc/cronjobs/overdue_notices.pl (-3 / +17 lines)
Lines 73-79 overdue_notices.pl Link Here
73
   -list-all                      list all overdues
73
   -list-all                      list all overdues
74
   -date         <yyyy-mm-dd>     emulate overdues run for this date
74
   -date         <yyyy-mm-dd>     emulate overdues run for this date
75
   -email        <email_type>     type of email that will be used. Can be 'email', 'emailpro' or 'B_email'. Repeatable.
75
   -email        <email_type>     type of email that will be used. Can be 'email', 'emailpro' or 'B_email'. Repeatable.
76
76
   -a           <branchcode>      Create only one message per borrower and delay level including overdues from all branches.
77
=head1 OPTIONS
77
=head1 OPTIONS
78
78
79
=over 8
79
=over 8
Lines 181-186 use it in order to send overdues on a specific date and not Now. Format: YYYY-MM Link Here
181
181
182
Allows to specify which type of email will be used. Can be email, emailpro or B_email. Repeatable.
182
Allows to specify which type of email will be used. Can be email, emailpro or B_email. Repeatable.
183
183
184
=item B<-a> | B<--all_in_one>
185
186
Create only one message per borrower and for each delay level including overdues from all branches.
187
Branchcode value (branches.branchcode) has to be given to choose which sender address will be set.
188
It's recommended to use this option only with default notice(s) defined for 'All branches'
189
in Notices & Slips and no specific ones.
190
184
=back
191
=back
185
192
186
=head1 DESCRIPTION
193
=head1 DESCRIPTION
Lines 302-307 my $itemscontent = join( ',', qw( date_due title barcode author itemnumber ) ); Link Here
302
my @myborcat;
309
my @myborcat;
303
my @myborcatout;
310
my @myborcatout;
304
my ( $date_input, $today );
311
my ( $date_input, $today );
312
my $all_in_one;
305
313
306
GetOptions(
314
GetOptions(
307
    'help|?'         => \$help,
315
    'help|?'         => \$help,
Lines 321-326 GetOptions( Link Here
321
    'borcat=s'       => \@myborcat,
329
    'borcat=s'       => \@myborcat,
322
    'borcatout=s'    => \@myborcatout,
330
    'borcatout=s'    => \@myborcatout,
323
    'email=s'        => \@emails,
331
    'email=s'        => \@emails,
332
    'a|all_in_one=s'   => \$all_in_one,
324
) or pod2usage(2);
333
) or pod2usage(2);
325
pod2usage(1) if $help;
334
pod2usage(1) if $help;
326
pod2usage( -verbose => 2 ) if $man;
335
pod2usage( -verbose => 2 ) if $man;
Lines 442-447 elsif ( defined $text_filename ) { Link Here
442
  }
451
  }
443
}
452
}
444
453
454
my %already_queued;
455
my %seen = map { $_ => 1 } @branches;
445
foreach my $branchcode (@branches) {
456
foreach my $branchcode (@branches) {
446
    if ( C4::Context->preference('OverdueNoticeCalendar') ) {
457
    if ( C4::Context->preference('OverdueNoticeCalendar') ) {
447
        my $calendar = Koha::Calendar->new( branchcode => $branchcode );
458
        my $calendar = Koha::Calendar->new( branchcode => $branchcode );
Lines 450-456 foreach my $branchcode (@branches) { Link Here
450
        }
461
        }
451
    }
462
    }
452
463
453
    my $library             = Koha::Libraries->find($branchcode);
464
    my $library             = $all_in_one ? Koha::Libraries->find($all_in_one) : Koha::Libraries->find($branchcode);
454
    my $admin_email_address = $library->branchemail
465
    my $admin_email_address = $library->branchemail
455
      || C4::Context->preference('KohaAdminEmailAddress');
466
      || C4::Context->preference('KohaAdminEmailAddress');
456
    my @output_chunks;    # may be sent to mail or stdout or csv file.
467
    my @output_chunks;    # may be sent to mail or stdout or csv file.
Lines 468-473 SELECT biblio.*, items.*, issues.*, biblioitems.itemtype, branchname Link Here
468
    AND TO_DAYS($date)-TO_DAYS(issues.date_due) >= 0
479
    AND TO_DAYS($date)-TO_DAYS(issues.date_due) >= 0
469
END_SQL
480
END_SQL
470
481
482
471
    my $query = "SELECT * FROM overduerules WHERE delay1 IS NOT NULL AND branchcode = ? ";
483
    my $query = "SELECT * FROM overduerules WHERE delay1 IS NOT NULL AND branchcode = ? ";
472
    $query .= " AND categorycode IN (".join( ',' , ('?') x @myborcat ).") " if (@myborcat);
484
    $query .= " AND categorycode IN (".join( ',' , ('?') x @myborcat ).") " if (@myborcat);
473
    $query .= " AND categorycode NOT IN (".join( ',' , ('?') x @myborcatout ).") " if (@myborcatout);
485
    $query .= " AND categorycode NOT IN (".join( ',' , ('?') x @myborcatout ).") " if (@myborcatout);
Lines 570-575 END_SQL Link Here
570
                    next;
582
                    next;
571
                }
583
                }
572
                $borrowernumber = $data->{'borrowernumber'};
584
                $borrowernumber = $data->{'borrowernumber'};
585
                next if ($all_in_one && $already_queued{"$borrowernumber$i"});
573
                my $borr =
586
                my $borr =
574
                    $data->{'firstname'} . ', '
587
                    $data->{'firstname'} . ', '
575
                  . $data->{'surname'} . ' ('
588
                  . $data->{'surname'} . ' ('
Lines 661-666 END_SQL Link Here
661
                      $exceededPrintNoticesMaxLines = 1;
674
                      $exceededPrintNoticesMaxLines = 1;
662
                      last;
675
                      last;
663
                    }
676
                    }
677
                    next if $all_in_one and ! grep {$seen{$item_info->{branchcode}}} @branches;
664
                    $j++;
678
                    $j++;
665
                    my @item_info = map { $_ =~ /^date|date$/ ?
679
                    my @item_info = map { $_ =~ /^date|date$/ ?
666
                                           eval { output_pref( { dt => dt_from_string( $item_info->{$_} ), dateonly => 1 } ); }
680
                                           eval { output_pref( { dt => dt_from_string( $item_info->{$_} ), dateonly => 1 } ); }
Lines 774-779 END_SQL Link Here
774
                        }
788
                        }
775
                    }
789
                    }
776
                }
790
                }
791
                $already_queued{"$borrowernumber$i"} = 1;
777
            }
792
            }
778
            $sth->finish;
793
            $sth->finish;
779
        }
794
        }
780
- 

Return to bug 17649