Lines 44-49
Send AUTO_RENEWALS notices to patrons if the auto renewal has been done.
Link Here
|
44 |
|
44 |
|
45 |
Note that this option does not support digest yet. |
45 |
Note that this option does not support digest yet. |
46 |
|
46 |
|
|
|
47 |
=item B<--verbose> |
48 |
|
49 |
Print report to standard out. |
50 |
|
51 |
=item B<--commit> |
52 |
|
53 |
Without this parameter no changes will be made |
54 |
|
47 |
=back |
55 |
=back |
48 |
|
56 |
|
49 |
=cut |
57 |
=cut |
Lines 61-70
use Koha::Checkouts;
Link Here
|
61 |
use Koha::Libraries; |
69 |
use Koha::Libraries; |
62 |
use Koha::Patrons; |
70 |
use Koha::Patrons; |
63 |
|
71 |
|
64 |
my ( $help, $send_notices ); |
72 |
my ( $help, $send_notices, $verbose, $commit ); |
65 |
GetOptions( |
73 |
GetOptions( |
66 |
'h|help' => \$help, |
74 |
'h|help' => \$help, |
67 |
'send-notices' => \$send_notices, |
75 |
'send-notices' => \$send_notices, |
|
|
76 |
'v|verbose' => \$verbose, |
77 |
'c|commit' => \$commit, |
68 |
) || pod2usage(1); |
78 |
) || pod2usage(1); |
69 |
|
79 |
|
70 |
pod2usage(0) if $help; |
80 |
pod2usage(0) if $help; |
Lines 73-85
cronlogaction();
Link Here
|
73 |
my $auto_renews = Koha::Checkouts->search({ auto_renew => 1 }); |
83 |
my $auto_renews = Koha::Checkouts->search({ auto_renew => 1 }); |
74 |
|
84 |
|
75 |
my %report; |
85 |
my %report; |
|
|
86 |
print "Test run only\n" unless $commit; |
76 |
while ( my $auto_renew = $auto_renews->next ) { |
87 |
while ( my $auto_renew = $auto_renews->next ) { |
77 |
|
88 |
|
78 |
# 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 |
79 |
my ( $ok, $error ) = CanBookBeRenewed( $auto_renew->borrowernumber, $auto_renew->itemnumber ); |
90 |
my ( $ok, $error ) = CanBookBeRenewed( $auto_renew->borrowernumber, $auto_renew->itemnumber ); |
80 |
if ( $error eq 'auto_renew' ) { |
91 |
if ( $error eq 'auto_renew' ) { |
81 |
my $date_due = AddRenewal( $auto_renew->borrowernumber, $auto_renew->itemnumber, $auto_renew->branchcode ); |
92 |
if ($commit){ |
82 |
$auto_renew->auto_renew_error(undef)->store; |
93 |
my $date_due = AddRenewal( $auto_renew->borrowernumber, $auto_renew->itemnumber, $auto_renew->branchcode ); |
|
|
94 |
$auto_renew->auto_renew_error(undef)->store; |
95 |
} |
96 |
$verbose && print "Issue id: " . $auto_renew->issue_id . " for borrower: " . $auto_renew->borrowernumber . " and item: " . $auto_renew->itemnumber; |
97 |
$verbose && $commit ? print " will be renewed.\n" : print " would be renewed.\n"; |
83 |
push @{ $report{ $auto_renew->borrowernumber } }, $auto_renew; |
98 |
push @{ $report{ $auto_renew->borrowernumber } }, $auto_renew; |
84 |
} elsif ( $error eq 'too_many' |
99 |
} elsif ( $error eq 'too_many' |
85 |
or $error eq 'on_reserve' |
100 |
or $error eq 'on_reserve' |
Lines 90-97
while ( my $auto_renew = $auto_renews->next ) {
Link Here
|
90 |
or $error eq 'auto_too_much_oweing' |
105 |
or $error eq 'auto_too_much_oweing' |
91 |
or $error eq 'auto_too_soon' |
106 |
or $error eq 'auto_too_soon' |
92 |
or $error eq 'item_denied_renewal' ) { |
107 |
or $error eq 'item_denied_renewal' ) { |
|
|
108 |
if ( $verbose ) { |
109 |
print "Issue id: " . $auto_renew->issue_id . " for borrower: " . $auto_renew->borrowernumber . " and item: " . $auto_renew->itemnumber; |
110 |
$commit ? print " will not be renewed " : print " would not be renewed "; |
111 |
print "($error)\n"; |
112 |
} |
93 |
if ( not $auto_renew->auto_renew_error or $error ne $auto_renew->auto_renew_error ) { |
113 |
if ( not $auto_renew->auto_renew_error or $error ne $auto_renew->auto_renew_error ) { |
94 |
$auto_renew->auto_renew_error($error)->store; |
114 |
$auto_renew->auto_renew_error($error)->store if $commit; |
95 |
push @{ $report{ $auto_renew->borrowernumber } }, $auto_renew |
115 |
push @{ $report{ $auto_renew->borrowernumber } }, $auto_renew |
96 |
if $error ne 'auto_too_soon'; # Do not notify if it's too soon |
116 |
if $error ne 'auto_too_soon'; # Do not notify if it's too soon |
97 |
} |
117 |
} |
Lines 124-130
if ( $send_notices ) {
Link Here
|
124 |
message_transport_type => 'email', |
144 |
message_transport_type => 'email', |
125 |
from_address => $admin_email_address, |
145 |
from_address => $admin_email_address, |
126 |
} |
146 |
} |
127 |
); |
147 |
) if $commit; |
128 |
} |
148 |
} |
129 |
} |
149 |
} |
130 |
} |
150 |
} |
131 |
- |
|
|