range of the currently processing notice.
Choose list-all to include all overdue items in the list (limited by B<-max> setting).
+=item B<-date>
+
+use it in order to send overdues on a specific date and not Now.
+
=back
=head1 DESCRIPTION
my $itemscontent = join( ',', qw( date_due title barcode author itemnumber ) );
my @myborcat;
my @myborcatout;
+my $date;
GetOptions(
'help|?' => \$help,
'max=s' => \$MAX,
'library=s' => \@branchcodes,
'csv:s' => \$csvfilename, # this optional argument gets '' if not supplied.
- 'html:s' => \$htmlfilename, # this optional argument gets '' if not supplied.
+ 'html:s' => \$htmlfilename, # this optional argument gets '' if not supplied.
'itemscontent=s' => \$itemscontent,
- 'list-all' => \$listall,
- 't|triggered' => \$triggered,
- 'borcat=s' => \@myborcat,
- 'borcatout=s' => \@myborcatout,
+ 'list-all' => \$listall,
+ 't|triggered' => \$triggered,
+ 'date' => \$date,
+ 'borcat=s' => \@myborcat,
+ 'borcatout=s' => \@myborcatout,
) or pod2usage(2);
pod2usage(1) if $help;
pod2usage( -verbose => 2 ) if $man;
}
}
+if ($date){
+ $date=$dbh->quote($date);
+}
+else {
+ $date="NOW()";
+}
+
# these are the fields that will be substituted into <<item.content>>
my @item_content_fields = split( /,/, $itemscontent );
$verbose and warn sprintf "branchcode : '%s' using %s\n", $branchcode, $admin_email_address;
- my $sth2 = $dbh->prepare( <<'END_SQL' );
-SELECT biblio.*, items.*, issues.*, biblioitems.itemtype, TO_DAYS(NOW())-TO_DAYS(date_due) AS days_overdue
+ my $sth2 = $dbh->prepare( <<"END_SQL" );
+SELECT biblio.*, items.*, issues.*, biblioitems.itemtype, TO_DAYS($date)-TO_DAYS(date_due) AS days_overdue
FROM issues,items,biblio, biblioitems
WHERE items.itemnumber=issues.itemnumber
AND biblio.biblionumber = items.biblionumber
AND biblio.biblionumber = biblioitems.biblionumber
AND issues.borrowernumber = ?
- AND TO_DAYS(NOW())-TO_DAYS(date_due) BETWEEN ? and ?
+ AND TO_DAYS($date)-TO_DAYS(date_due) BETWEEN ? and ?
END_SQL
my $query = "SELECT * FROM overduerules WHERE delay1 IS NOT NULL AND branchcode = ? ";
}
$borrower_sql .= ' AND categories.overduenoticerequired=1 ';
if($triggered) {
- $borrower_sql .= ' AND TO_DAYS(NOW())-TO_DAYS(date_due) = ?';
+ $borrower_sql .= " AND TO_DAYS($date)-TO_DAYS(date_due) = ?";
push @borrower_parameters, $mindays;
} else {
- $borrower_sql .= ' AND TO_DAYS(NOW())-TO_DAYS(date_due) BETWEEN ? and ? ' ;
+ $borrower_sql .= " AND TO_DAYS($date)-TO_DAYS(date_due) BETWEEN ? and ? " ;
push @borrower_parameters, $mindays, $maxdays;
}
my $titles = "";
my @items = ();
- my $i = 0;
+ my $j = 0;
my $exceededPrintNoticesMaxLines = 0;
while ( my $item_info = $sth2->fetchrow_hashref() ) {
- if ( ( !$email || $nomail ) && $PrintNoticesMaxLines && $i >= $PrintNoticesMaxLines ) {
+ if ( ( !$email || $nomail ) && $PrintNoticesMaxLines && $j >= $PrintNoticesMaxLines ) {
$exceededPrintNoticesMaxLines = 1;
last;
}
- $i++;
+ $j++;
my @item_info = map { $_ =~ /^date|date$/ ? format_date( $item_info->{$_} ) : $item_info->{$_} || '' } @item_content_fields;
$titles .= join("\t", @item_info) . "\n";
$itemcount++;
sub parse_letter {
my $params = shift;
foreach my $required (qw( letter_code borrowernumber )) {
- return unless exists $params->{$required};
+ return unless ( exists $params->{$required} && $params->{$required} );
}
my $substitute = $params->{'substitute'} || {};