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

(-)a/C4/Circulation.pm (-2 / +2 lines)
Lines 2701-2707 sub GetUpcomingDueIssues { Link Here
2701
    my $dbh = C4::Context->dbh;
2701
    my $dbh = C4::Context->dbh;
2702
    my $statement;
2702
    my $statement;
2703
    if($params->{'owning_library'}) {
2703
    if($params->{'owning_library'}) {
2704
	$statement = <<"END_SQL";
2704
    $statement = <<"END_SQL";
2705
SELECT *
2705
SELECT *
2706
FROM (
2706
FROM (
2707
    SELECT issues.*, items.itype as itemtype, items.homebranch, TO_DAYS( date_due )-TO_DAYS( NOW() ) as days_until_due, branches.branchemail
2707
    SELECT issues.*, items.itype as itemtype, items.homebranch, TO_DAYS( date_due )-TO_DAYS( NOW() ) as days_until_due, branches.branchemail
Lines 2713-2719 FROM ( Link Here
2713
WHERE days_until_due >= 0 AND days_until_due <= ?
2713
WHERE days_until_due >= 0 AND days_until_due <= ?
2714
END_SQL
2714
END_SQL
2715
    } else {
2715
    } else {
2716
	$statement = <<"END_SQL";
2716
    $statement = <<"END_SQL";
2717
SELECT *
2717
SELECT *
2718
FROM (
2718
FROM (
2719
    SELECT issues.*, items.itype as itemtype, items.homebranch, TO_DAYS( date_due )-TO_DAYS( NOW() ) as days_until_due, branches.branchemail
2719
    SELECT issues.*, items.itype as itemtype, items.homebranch, TO_DAYS( date_due )-TO_DAYS( NOW() ) as days_until_due, branches.branchemail
(-)a/misc/cronjobs/advance_notices.pl (-18 / +21 lines)
Lines 125-131 Enabling this flag ensures that the issuing library is the sender of Link Here
125
the digested message.  It has no effect unless the borrower has
125
the digested message.  It has no effect unless the borrower has
126
chosen 'Digests only' on the advance messages.
126
chosen 'Digests only' on the advance messages.
127
127
128
=item B<-library>
128
=item B<--library>
129
129
130
select notices for one specific library. Use the value in the
130
select notices for one specific library. Use the value in the
131
branches.branchcode table. This option can be repeated in order
131
branches.branchcode table. This option can be repeated in order
Lines 240-246 unless ($confirm) { Link Here
240
}
240
}
241
cronlogaction();
241
cronlogaction();
242
242
243
my %branches = map { $_ => 1 } @branchcodes if @branchcodes;
243
my %branches = {};
244
if (@branchcodes) {
245
    %branches = map { $_ => 1 } @branchcodes;
246
}
244
247
245
# The fields that will be substituted into <<items.content>>
248
# The fields that will be substituted into <<items.content>>
246
my @item_content_fields = split(/,/,$itemscontent);
249
my @item_content_fields = split(/,/,$itemscontent);
Lines 294-307 UPCOMINGITEM: foreach my $upcoming ( @$upcoming_dues ) { Link Here
294
                $due_digest->{ $upcoming->{borrowernumber} }->{count}++;
297
                $due_digest->{ $upcoming->{borrowernumber} }->{count}++;
295
            }
298
            }
296
        } else {
299
        } else {
297
	    my $branchcode;
300
        my $branchcode;
298
	    if($owning_library) {
301
        if($owning_library) {
299
		$branchcode = $upcoming->{'homebranch'};
302
        $branchcode = $upcoming->{'homebranch'};
300
	    } else {
303
        } else {
301
		$branchcode = $upcoming->{'branchcode'};
304
        $branchcode = $upcoming->{'branchcode'};
302
	    }
305
        }
303
	    # Skip this DUE if we specify list of libraries and this one is not part of it
306
        # Skip this DUE if we specify list of libraries and this one is not part of it
304
	    next if (@branchcodes && !$branches{$branchcode});
307
        next if (@branchcodes && !$branches{$branchcode});
305
308
306
            my $item = Koha::Items->find( $upcoming->{itemnumber} );
309
            my $item = Koha::Items->find( $upcoming->{itemnumber} );
307
            my $letter_type = 'DUE';
310
            my $letter_type = 'DUE';
Lines 341-354 UPCOMINGITEM: foreach my $upcoming ( @$upcoming_dues ) { Link Here
341
                $upcoming_digest->{ $upcoming->{borrowernumber} }->{count}++;
344
                $upcoming_digest->{ $upcoming->{borrowernumber} }->{count}++;
342
            }
345
            }
343
        } else {
346
        } else {
344
	    my $branchcode;
347
        my $branchcode;
345
	    if($owning_library) {
348
        if($owning_library) {
346
		$branchcode = $upcoming->{'homebranch'};
349
        $branchcode = $upcoming->{'homebranch'};
347
	    } else {
350
        } else {
348
		$branchcode = $upcoming->{'branchcode'};
351
        $branchcode = $upcoming->{'branchcode'};
349
	    }
352
        }
350
	    # Skip this PREDUE if we specify list of libraries and this one is not part of it
353
        # Skip this PREDUE if we specify list of libraries and this one is not part of it
351
	    next if (@branchcodes && !$branches{$branchcode});
354
        next if (@branchcodes && !$branches{$branchcode});
352
355
353
            my $item = Koha::Items->find( $upcoming->{itemnumber} );
356
            my $item = Koha::Items->find( $upcoming->{itemnumber} );
354
            my $letter_type = 'PREDUE';
357
            my $letter_type = 'PREDUE';
(-)a/misc/cronjobs/overdue_notices.pl (-12 / +11 lines)
Lines 339-346 if ( defined $csvfilename && $csvfilename =~ /^-/ ) { Link Here
339
    warn qq(using "$csvfilename" as filename, that seems odd);
339
    warn qq(using "$csvfilename" as filename, that seems odd);
340
}
340
}
341
341
342
my @overduebranches    = C4::Overdues::GetBranchcodesWithOverdueRules();	# Branches with overdue rules
342
my @overduebranches    = C4::Overdues::GetBranchcodesWithOverdueRules();    # Branches with overdue rules
343
my @branches;									# Branches passed as parameter with overdue rules
343
my @branches;                                    # Branches passed as parameter with overdue rules
344
my $branchcount = scalar(@overduebranches);
344
my $branchcount = scalar(@overduebranches);
345
345
346
my $overduebranch_word = scalar @overduebranches > 1 ? 'branches' : 'branch';
346
my $overduebranch_word = scalar @overduebranches > 1 ? 'branches' : 'branch';
Lines 364-371 if (@branchcodes) { Link Here
364
    
364
    
365
    if (@branches) {
365
    if (@branches) {
366
366
367
    	my $branch_word = scalar @branches > 1 ? 'branches' : 'branch';
367
        my $branch_word = scalar @branches > 1 ? 'branches' : 'branch';
368
	$verbose and warn "$branch_word @branches have overdue rules\n";
368
    $verbose and warn "$branch_word @branches have overdue rules\n";
369
369
370
    } else {
370
    } else {
371
    
371
    
Lines 527-533 END_SQL Link Here
527
            # $letter->{'content'} is the text of the mail that is sent.
527
            # $letter->{'content'} is the text of the mail that is sent.
528
            # this text contains fields that are replaced by their value. Those fields must be written between brackets
528
            # this text contains fields that are replaced by their value. Those fields must be written between brackets
529
            # The following fields are available :
529
            # The following fields are available :
530
	    # itemcount is interpreted here as the number of items in the overdue range defined by the current notice or all overdues < max if(-list-all).
530
        # itemcount is interpreted here as the number of items in the overdue range defined by the current notice or all overdues < max if(-list-all).
531
            # <date> <itemcount> <firstname> <lastname> <address1> <address2> <address3> <city> <postcode> <country>
531
            # <date> <itemcount> <firstname> <lastname> <address1> <address2> <address3> <city> <postcode> <country>
532
532
533
            my $borrower_sql = <<"END_SQL";
533
            my $borrower_sql = <<"END_SQL";
Lines 541-551 AND TO_DAYS($date)-TO_DAYS(issues.date_due) >= 0 Link Here
541
END_SQL
541
END_SQL
542
            my @borrower_parameters;
542
            my @borrower_parameters;
543
            if ($branchcode) {
543
            if ($branchcode) {
544
		if($owning_library) {
544
        if($owning_library) {
545
		    $borrower_sql .= ' AND items.homebranch=? ';
545
            $borrower_sql .= ' AND items.homebranch=? ';
546
		} else {
546
        } else {
547
		    $borrower_sql .= ' AND issues.branchcode=? ';
547
            $borrower_sql .= ' AND issues.branchcode=? ';
548
		}
548
        }
549
                push @borrower_parameters, $branchcode;
549
                push @borrower_parameters, $branchcode;
550
            }
550
            }
551
            if ( $overdue_rules->{categorycode} ) {
551
            if ( $overdue_rules->{categorycode} ) {
Lines 555-561 END_SQL Link Here
555
            $borrower_sql .= '  AND categories.overduenoticerequired=1 ORDER BY issues.borrowernumber';
555
            $borrower_sql .= '  AND categories.overduenoticerequired=1 ORDER BY issues.borrowernumber';
556
556
557
            # $sth gets borrower info iff at least one overdue item has triggered the overdue action.
557
            # $sth gets borrower info iff at least one overdue item has triggered the overdue action.
558
	        my $sth = $dbh->prepare($borrower_sql);
558
            my $sth = $dbh->prepare($borrower_sql);
559
            $sth->execute(@borrower_parameters);
559
            $sth->execute(@borrower_parameters);
560
560
561
            $verbose and warn $borrower_sql . "\n $branchcode | " . $overdue_rules->{'categorycode'} . "\n ($mindays, $maxdays, ".  $date_to_run->datetime() .")\nreturns " . $sth->rows . " rows";
561
            $verbose and warn $borrower_sql . "\n $branchcode | " . $overdue_rules->{'categorycode'} . "\n ($mindays, $maxdays, ".  $date_to_run->datetime() .")\nreturns " . $sth->rows . " rows";
562
- 

Return to bug 21886