Lines 37-43
number of days.
Link Here
|
37 |
|
37 |
|
38 |
=head1 SYNOPSIS |
38 |
=head1 SYNOPSIS |
39 |
|
39 |
|
40 |
cancel_unfilled_holds.pl [--days][--library][--holidays][--confirm][--verbose] |
40 |
cancel_unfilled_holds.pl [--days][--library][--holidays][--confirm][--verbose][--reason] |
41 |
|
41 |
|
42 |
=head1 OPTIONS |
42 |
=head1 OPTIONS |
43 |
|
43 |
|
Lines 69-74
would have done if it were not running in test mode.
Link Here
|
69 |
|
69 |
|
70 |
More verbose output. |
70 |
More verbose output. |
71 |
|
71 |
|
|
|
72 |
=item B<--reason> |
73 |
|
74 |
Optionally adds a reason for cancellation (which will trigger a notice to be sent to the patron) |
75 |
|
72 |
=back |
76 |
=back |
73 |
|
77 |
|
74 |
=cut |
78 |
=cut |
Lines 79-84
my @branchcodes;
Link Here
|
79 |
my $use_calendar = 0; |
83 |
my $use_calendar = 0; |
80 |
my $verbose = 0; |
84 |
my $verbose = 0; |
81 |
my $confirm = 0; |
85 |
my $confirm = 0; |
|
|
86 |
my $reason; |
82 |
|
87 |
|
83 |
my $command_line_options = join(" ",@ARGV); |
88 |
my $command_line_options = join(" ",@ARGV); |
84 |
|
89 |
|
Lines 89-94
GetOptions(
Link Here
|
89 |
'holidays' => \$use_calendar, |
94 |
'holidays' => \$use_calendar, |
90 |
'v|verbose' => \$verbose, |
95 |
'v|verbose' => \$verbose, |
91 |
'confirm' => \$confirm, |
96 |
'confirm' => \$confirm, |
|
|
97 |
'reason=s' => \$reason |
92 |
) or pod2usage(1); |
98 |
) or pod2usage(1); |
93 |
pod2usage(1) if $help; |
99 |
pod2usage(1) if $help; |
94 |
|
100 |
|
Lines 111-116
$verbose and warn "Looking for unfilled holds placed $days or more days ago\n";
Link Here
|
111 |
@branchcodes = Koha::Libraries->search->get_column('branchcode') if !@branchcodes; |
117 |
@branchcodes = Koha::Libraries->search->get_column('branchcode') if !@branchcodes; |
112 |
$verbose and warn "Running for branch(es): " . join( "|", @branchcodes ) . "\n"; |
118 |
$verbose and warn "Running for branch(es): " . join( "|", @branchcodes ) . "\n"; |
113 |
|
119 |
|
|
|
120 |
my $cancellation_params = {}; |
121 |
$cancellation_params->{cancellation_reason} = $reason if $reason; |
122 |
|
114 |
foreach my $branch (@branchcodes) { |
123 |
foreach my $branch (@branchcodes) { |
115 |
|
124 |
|
116 |
my $holds = |
125 |
my $holds = |
Lines 135-141
foreach my $branch (@branchcodes) {
Link Here
|
135 |
. $hold->borrowernumber |
144 |
. $hold->borrowernumber |
136 |
. " on biblio: " |
145 |
. " on biblio: " |
137 |
. $hold->biblionumber . "\n"; |
146 |
. $hold->biblionumber . "\n"; |
138 |
$hold->cancel if $confirm; |
147 |
$hold->cancel( $cancellation_params ) if $confirm; |
139 |
} |
148 |
} |
140 |
|
149 |
|
141 |
} |
150 |
} |
142 |
- |
|
|