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

(-)a/C4/Reserves.pm (-1 / +48 lines)
Lines 1191-1202 sub ModReserveAffect { Link Here
1191
        $hold->set_processing();
1191
        $hold->set_processing();
1192
    } else {
1192
    } else {
1193
        $hold->set_waiting($desk_id);
1193
        $hold->set_waiting($desk_id);
1194
        _koha_notify_reserve( $hold->reserve_id, $notify_library ) unless $already_on_shelf;
1194
        _koha_notify_reserve( $hold->reserve_id ) unless $already_on_shelf;
1195
        # Complete transfer if one exists
1195
        # Complete transfer if one exists
1196
        my $transfer = $hold->item->get_transfer;
1196
        my $transfer = $hold->item->get_transfer;
1197
        $transfer->receive if $transfer;
1197
        $transfer->receive if $transfer;
1198
    }
1198
    }
1199
1199
1200
    _koha_notify_hold_changed( $hold ) if $notify_library;
1201
1200
    _FixPriority( { biblionumber => $biblionumber } );
1202
    _FixPriority( { biblionumber => $biblionumber } );
1201
    my $item = Koha::Items->find($itemnumber);
1203
    my $item = Koha::Items->find($itemnumber);
1202
    if ( $item->location && $item->location eq 'CART'
1204
    if ( $item->location && $item->location eq 'CART'
Lines 1918-1923 sub _koha_notify_reserve { Link Here
1918
    }
1920
    }
1919
}
1921
}
1920
1922
1923
=head2 _koha_notify_hold_changed
1924
1925
  _koha_notify_hold_changed( $hold_object );
1926
1927
=cut
1928
1929
sub _koha_notify_hold_changed {
1930
    my $hold = shift;
1931
1932
    my $patron = $hold->patron;
1933
    my $library = $hold->branch;
1934
1935
    my $letter = C4::Letters::GetPreparedLetter(
1936
        module      => 'reserves',
1937
        letter_code => 'HOLD_CHANGED',
1938
        branchcode  => $hold->branchcode,
1939
        substitute  => { today => output_pref( dt_from_string ) },
1940
        tables      => {
1941
            'branches'    => $library->unblessed,
1942
            'borrowers'   => $patron->unblessed,
1943
            'biblio'      => $hold->biblionumber,
1944
            'biblioitems' => $hold->biblionumber,
1945
            'reserves'    => $hold->unblessed,
1946
            'items'       => $hold->itemnumber,
1947
        },
1948
    );
1949
1950
    return unless $letter;
1951
1952
    my $email =
1953
         C4::Context->preference('ExpireReservesAutoFillEmail')
1954
      || $library->branchemail
1955
      || C4::Context->preference('KohaAdminEmailAddress');
1956
1957
    C4::Letters::EnqueueLetter(
1958
        {
1959
            letter                 => $letter,
1960
            borrowernumber         => $patron->id,
1961
            message_transport_type => 'email',
1962
            from_address           => $email,
1963
            to_address             => $email,
1964
        }
1965
    );
1966
}
1967
1921
=head2 _ShiftPriorityByDateAndPriority
1968
=head2 _ShiftPriorityByDateAndPriority
1922
1969
1923
  $new_priority = _ShiftPriorityByDateAndPriority( $biblionumber, $reservedate, $priority );
1970
  $new_priority = _ShiftPriorityByDateAndPriority( $biblionumber, $reservedate, $priority );
(-)a/t/db_dependent/Holds/ExpireReservesAutoFill.t (-9 / +8 lines)
Lines 100-110 subtest 'Test automatically canceled expired waiting holds to fill the next hold Link Here
100
100
101
    CancelExpiredReserves();
101
    CancelExpiredReserves();
102
102
103
    my @holds = Koha::Holds->search( {}, { order_by => 'priority' } );
103
    my $holds = Koha::Holds->search( {}, { order_by => 'priority' } );
104
    $hold_2 = $holds[0];
104
    $hold_2 = $holds->next;
105
    $hold_3 = $holds[1];
105
    $hold_3 = $holds->next;
106
106
107
    is( @holds,            2,   'Found 2 holds' );
107
    is( $holds->count,     2,   'Found 2 holds' );
108
    is( $hold_2->priority, 0,   'Next hold in line now has priority of 0' );
108
    is( $hold_2->priority, 0,   'Next hold in line now has priority of 0' );
109
    is( $hold_2->found,    'W', 'Next hold in line is now set to waiting' );
109
    is( $hold_2->found,    'W', 'Next hold in line is now set to waiting' );
110
110
Lines 117-126 subtest 'Test automatically canceled expired waiting holds to fill the next hold Link Here
117
117
118
    CancelExpiredReserves();
118
    CancelExpiredReserves();
119
119
120
    @holds = Koha::Holds->search( {}, { order_by => 'priority' } );
120
    $holds = Koha::Holds->search( {}, { order_by => 'priority' } );
121
    $hold_3 = $holds[0];
121
    $hold_3 = $holds->next;
122
122
123
    is( @holds,            1,   'Found 1 hold' );
123
    is( $holds->count,     1,   'Found 1 hold' );
124
    is( $hold_3->priority, 0,   'Next hold in line now has priority of 0' );
124
    is( $hold_3->priority, 0,   'Next hold in line now has priority of 0' );
125
    is( $hold_3->found,    'W', 'Next hold in line is now set to waiting' );
125
    is( $hold_3->found,    'W', 'Next hold in line is now set to waiting' );
126
126
Lines 186-190 subtest 'Test automatically canceled expired waiting holds to fill the next hold Link Here
186
186
187
    my @messages = $schema->resultset('MessageQueue')
187
    my @messages = $schema->resultset('MessageQueue')
188
      ->search( { letter_code => 'HOLD_CHANGED' } );
188
      ->search( { letter_code => 'HOLD_CHANGED' } );
189
    is( @messages, 0, 'No messages in the message queue when generating transfer' );
189
    is( @messages, 1, 'Nessage is generated in the message queue when generating transfer' );
190
};
190
};
191
- 

Return to bug 14364