my $priority = 10000000;
foreach my $res (@reserves) {
if ( $res->{'itemnumber'} == $itemnumber && $res->{'priority'} == 0) {
- return ( "Waiting", $res, \@reserves ); # Found it
+ if ($res->{'found'} eq 'W') {
+ return ( "Waiting", $res, \@reserves ); # Found it, it is waiting
+ } else {
+ return ( "Reserved", $res, \@reserves ); # Found determinated hold, e. g. the tranferred one
+ }
} else {
my $patron;
my $iteminfo;
=cut
sub CancelExpiredReserves {
-
my $today = dt_from_string();
my $cancel_on_holidays = C4::Context->preference('ExpireReservesOnHolidays');
-
- my $dbh = C4::Context->dbh;
+ my $expireWaiting = C4::Context->preference('ExpireReservesMaxPickUpDelay');
my $dtf = Koha::Database->new->schema->storage->datetime_parser;
- my $today = dt_from_string;
+ my $params = { expirationdate => { '<', $dtf->format_date($today) } };
+ $params->{found} = undef unless $expireWaiting;
+
# FIXME To move to Koha::Holds->search_expired (?)
- my $holds = Koha::Holds->search(
- {
- expirationdate => { '<', $dtf->format_date($today) }
- }
- );
+ my $holds = Koha::Holds->search( $params );
while ( my $hold = $holds->next ) {
my $calendar = Koha::Calendar->new( branchcode => $hold->branchcode );
next if !$cancel_on_holidays && $calendar->is_holiday( $today );
my $cancel_params = {};
- if ( $holds->found eq 'W' ) {
+ if ( $hold->found eq 'W' ) {
$cancel_params->{charge_cancel_fee} = 1;
}
$hold->cancel( $cancel_params );
-
}
}