Bug 32518: Add reason option to cancel_unfilled_holds cronjob
This adds a reaosn parameter and passes it into the cancellation if supplied To test: 1 - Place a hold for a patron in your system 2 - Run script with --days 0 -v 3 - verify that it would cancel the reserves (and that you are okay with cancelling the ones it found) 4 - Make sure you have a notice in the holds module with code 'HOLD_CANCELLATION' 5 - Set content of the notice like: [% IF hold.cancellation_reason=='too_old' %] Canceled old [% END %] 6 - Run script with --days 0 -v --reason too_bad -c 7 - Confirm hold cancelled, no notice sent to patron 8 - Place another hold 9 - Run script with --days 0 -v --reason too_old -c 10 - Confirm hold cancelled, notice sent to patron Signed-off-by: Andrew Fuerste-Henry <andrewfh@dubcolib.org> Signed-off-by: Victor Grousset/tuxayo <victor@tuxayo.net> Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
This commit is contained in:
parent
9e19a88f02
commit
406d61cbb2
1 changed files with 11 additions and 2 deletions
|
@ -37,7 +37,7 @@ number of days.
|
|||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
cancel_unfilled_holds.pl [--days][--library][--holidays][--confirm][--verbose]
|
||||
cancel_unfilled_holds.pl [--days][--library][--holidays][--confirm][--verbose][--reason]
|
||||
|
||||
=head1 OPTIONS
|
||||
|
||||
|
@ -69,6 +69,10 @@ would have done if it were not running in test mode.
|
|||
|
||||
More verbose output.
|
||||
|
||||
=item B<--reason>
|
||||
|
||||
Optionally adds a reason for cancellation (which will trigger a notice to be sent to the patron)
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
||||
|
@ -79,6 +83,7 @@ my @branchcodes;
|
|||
my $use_calendar = 0;
|
||||
my $verbose = 0;
|
||||
my $confirm = 0;
|
||||
my $reason;
|
||||
|
||||
my $command_line_options = join(" ",@ARGV);
|
||||
|
||||
|
@ -89,6 +94,7 @@ GetOptions(
|
|||
'holidays' => \$use_calendar,
|
||||
'v|verbose' => \$verbose,
|
||||
'confirm' => \$confirm,
|
||||
'reason=s' => \$reason
|
||||
) or pod2usage(1);
|
||||
pod2usage(1) if $help;
|
||||
|
||||
|
@ -111,6 +117,9 @@ $verbose and warn "Looking for unfilled holds placed $days or more days ago\n";
|
|||
@branchcodes = Koha::Libraries->search->get_column('branchcode') if !@branchcodes;
|
||||
$verbose and warn "Running for branch(es): " . join( "|", @branchcodes ) . "\n";
|
||||
|
||||
my $cancellation_params = {};
|
||||
$cancellation_params->{cancellation_reason} = $reason if $reason;
|
||||
|
||||
foreach my $branch (@branchcodes) {
|
||||
|
||||
my $holds =
|
||||
|
@ -135,7 +144,7 @@ foreach my $branch (@branchcodes) {
|
|||
. $hold->borrowernumber
|
||||
. " on biblio: "
|
||||
. $hold->biblionumber . "\n";
|
||||
$hold->cancel if $confirm;
|
||||
$hold->cancel( $cancellation_params ) if $confirm;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue