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

(-)a/misc/cronjobs/automatic_renewals.pl (-10 / +9 lines)
Lines 48-54 Note that this option does not support digest yet. Link Here
48
48
49
Print report to standard out.
49
Print report to standard out.
50
50
51
=item B<--commit>
51
=item B<--confirm>
52
52
53
Without this parameter no changes will be made
53
Without this parameter no changes will be made
54
54
Lines 69-80 use Koha::Checkouts; Link Here
69
use Koha::Libraries;
69
use Koha::Libraries;
70
use Koha::Patrons;
70
use Koha::Patrons;
71
71
72
my ( $help, $send_notices, $verbose, $commit );
72
my ( $help, $send_notices, $verbose, $confirm );
73
GetOptions(
73
GetOptions(
74
    'h|help' => \$help,
74
    'h|help' => \$help,
75
    'send-notices' => \$send_notices,
75
    'send-notices' => \$send_notices,
76
    'v|verbose'    => \$verbose,
76
    'v|verbose'    => \$verbose,
77
    'c|commit'     => \$commit,
77
    'c|confirm'     => \$confirm,
78
) || pod2usage(1);
78
) || pod2usage(1);
79
79
80
pod2usage(0) if $help;
80
pod2usage(0) if $help;
Lines 83-99 cronlogaction(); Link Here
83
my $auto_renews = Koha::Checkouts->search({ auto_renew => 1 });
83
my $auto_renews = Koha::Checkouts->search({ auto_renew => 1 });
84
84
85
my %report;
85
my %report;
86
print "Test run only\n" unless $commit;
86
print "Test run only\n" unless $confirm;
87
while ( my $auto_renew = $auto_renews->next ) {
87
while ( my $auto_renew = $auto_renews->next ) {
88
88
89
    # CanBookBeRenewed returns 'auto_renew' when the renewal should be done by this script
89
    # CanBookBeRenewed returns 'auto_renew' when the renewal should be done by this script
90
    my ( $ok, $error ) = CanBookBeRenewed( $auto_renew->borrowernumber, $auto_renew->itemnumber );
90
    my ( $ok, $error ) = CanBookBeRenewed( $auto_renew->borrowernumber, $auto_renew->itemnumber );
91
    if ( $error eq 'auto_renew' ) {
91
    if ( $error eq 'auto_renew' ) {
92
        if ($verbose) {
92
        if ($verbose) {
93
            say sprintf "Issue id: %s for borrower: %s and item: %s ". ( $commit ? 'will' : 'would') . " be renewed.",
93
            say sprintf "Issue id: %s for borrower: %s and item: %s ". ( $confirm ? 'will' : 'would') . " be renewed.",
94
              $auto_renew->issue_id, $auto_renew->borrowernumber, $auto_renew->itemnumber;
94
              $auto_renew->issue_id, $auto_renew->borrowernumber, $auto_renew->itemnumber;
95
        }
95
        }
96
        if ($commit){
96
        if ($confirm){
97
            my $date_due = AddRenewal( $auto_renew->borrowernumber, $auto_renew->itemnumber, $auto_renew->branchcode );
97
            my $date_due = AddRenewal( $auto_renew->borrowernumber, $auto_renew->itemnumber, $auto_renew->branchcode );
98
            $auto_renew->auto_renew_error(undef)->store;
98
            $auto_renew->auto_renew_error(undef)->store;
99
        }
99
        }
Lines 108-118 while ( my $auto_renew = $auto_renews->next ) { Link Here
108
        or $error eq 'auto_too_soon'
108
        or $error eq 'auto_too_soon'
109
        or $error eq 'item_denied_renewal' ) {
109
        or $error eq 'item_denied_renewal' ) {
110
        if ( $verbose ) {
110
        if ( $verbose ) {
111
            say sprintf "Issue id: %s for borrower: %s and item: %s ". ( $commit ? 'will' : 'would') . " not be renewed. (%s)",
111
            say sprintf "Issue id: %s for borrower: %s and item: %s ". ( $confirm ? 'will' : 'would') . " not be renewed. (%s)",
112
              $auto_renew->issue_id, $auto_renew->borrowernumber, $auto_renew->itemnumber, $error;
112
              $auto_renew->issue_id, $auto_renew->borrowernumber, $auto_renew->itemnumber, $error;
113
        }
113
        }
114
        if ( not $auto_renew->auto_renew_error or $error ne $auto_renew->auto_renew_error ) {
114
        if ( not $auto_renew->auto_renew_error or $error ne $auto_renew->auto_renew_error ) {
115
            $auto_renew->auto_renew_error($error)->store if $commit;
115
            $auto_renew->auto_renew_error($error)->store if $confirm;
116
            push @{ $report{ $auto_renew->borrowernumber } }, $auto_renew
116
            push @{ $report{ $auto_renew->borrowernumber } }, $auto_renew
117
              if $error ne 'auto_too_soon';    # Do not notify if it's too soon
117
              if $error ne 'auto_too_soon';    # Do not notify if it's too soon
118
        }
118
        }
Lines 145-151 if ( $send_notices ) { Link Here
145
                    message_transport_type => 'email',
145
                    message_transport_type => 'email',
146
                    from_address           => $admin_email_address,
146
                    from_address           => $admin_email_address,
147
                }
147
                }
148
            ) if $commit;
148
            ) if $confirm;
149
        }
149
        }
150
    }
150
    }
151
}
151
}
152
- 

Return to bug 24526