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

(-)a/C4/Reserves.pm (-10 / +13 lines)
Lines 879-899 sub CancelExpiredReserves { Link Here
879
879
880
    my $today = dt_from_string();
880
    my $today = dt_from_string();
881
    my $cancel_on_holidays = C4::Context->preference('ExpireReservesOnHolidays');
881
    my $cancel_on_holidays = C4::Context->preference('ExpireReservesOnHolidays');
882
    my $expireWaiting = C4::Context->preference('ExpireReservesMaxPickUpDelay');
882
883
883
    my $dbh = C4::Context->dbh;
884
    my $dbh = C4::Context->dbh;
884
    my $sth = $dbh->prepare( "
885
        SELECT * FROM reserves WHERE DATE(expirationdate) < DATE( CURDATE() )
886
        AND expirationdate IS NOT NULL
887
    " );
888
    $sth->execute();
889
885
890
    while ( my $res = $sth->fetchrow_hashref() ) {
886
    my $dtf = Koha::Database->new->schema->storage->datetime_parser;
891
        my $calendar = Koha::Calendar->new( branchcode => $res->{'branchcode'} );
887
892
        my $cancel_params = { reserve_id => $res->{'reserve_id'} };
888
    my $params = { expirationdate => { '<', $dtf->format_date($today) } };
889
890
    $params->{found} = undef unless $expireWaiting;
891
892
    # FIXME To move to Koha::Holds->search_expired (?)
893
    my $holds = Koha::Holds->search( $params );
893
894
895
    while ( my $hold = $holds->next ) {
896
        my $calendar = Koha::Calendar->new( branchcode => $hold->branchcode );
894
        next if !$cancel_on_holidays && $calendar->is_holiday( $today );
897
        next if !$cancel_on_holidays && $calendar->is_holiday( $today );
895
898
896
        if ( $res->{found} eq 'W' ) {
899
        my $cancel_params = { reserve_id => $hold->reserve_id };
900
        if ( $hold->found eq 'W' ) {
897
            $cancel_params->{charge_cancel_fee} = 1;
901
            $cancel_params->{charge_cancel_fee} = 1;
898
        }
902
        }
899
903
900
- 

Return to bug 19260