Lines 38-43
use C4::Branch qw( GetBranchDetail );
Link Here
|
38 |
use C4::Dates qw( format_date_in_iso ); |
38 |
use C4::Dates qw( format_date_in_iso ); |
39 |
|
39 |
|
40 |
use Koha::DateUtils; |
40 |
use Koha::DateUtils; |
|
|
41 |
use Koha::Calendar; |
42 |
|
43 |
use DateTime; |
41 |
|
44 |
|
42 |
use List::MoreUtils qw( firstidx ); |
45 |
use List::MoreUtils qw( firstidx ); |
43 |
|
46 |
|
Lines 981-995
sub CancelExpiredReserves {
Link Here
|
981 |
my $charge = C4::Context->preference("ExpireReservesMaxPickUpDelayCharge"); |
984 |
my $charge = C4::Context->preference("ExpireReservesMaxPickUpDelayCharge"); |
982 |
|
985 |
|
983 |
my $query = "SELECT * FROM reserves WHERE TO_DAYS( NOW() ) - TO_DAYS( waitingdate ) > ? AND found = 'W' AND priority = 0"; |
986 |
my $query = "SELECT * FROM reserves WHERE TO_DAYS( NOW() ) - TO_DAYS( waitingdate ) > ? AND found = 'W' AND priority = 0"; |
|
|
987 |
|
988 |
my $today = DateTime->now( time_zone => C4::Context->tz() ); |
989 |
|
984 |
$sth = $dbh->prepare( $query ); |
990 |
$sth = $dbh->prepare( $query ); |
985 |
$sth->execute( $max_pickup_delay ); |
991 |
$sth->execute( $max_pickup_delay ); |
986 |
|
992 |
|
987 |
while (my $res = $sth->fetchrow_hashref ) { |
993 |
while (my $res = $sth->fetchrow_hashref ) { |
988 |
if ( $charge ) { |
|
|
989 |
manualinvoice($res->{'borrowernumber'}, $res->{'itemnumber'}, 'Hold waiting too long', 'F', $charge); |
990 |
} |
991 |
|
994 |
|
992 |
CancelReserve({ reserve_id => $res->{'reserve_id'} }); |
995 |
my $calendar = Koha::Calendar->new( branchcode => $res->{branchcode} ); |
|
|
996 |
my $expiration = $calendar->days_forward( $res->{waitingdate}, $max_pickup_delay ); |
997 |
|
998 |
if ( $today > $expiration ) { |
999 |
if ( $charge ) { |
1000 |
manualinvoice($res->{'borrowernumber'}, $res->{'itemnumber'}, 'Hold waiting too long', 'F', $charge); |
1001 |
} |
1002 |
CancelReserve({ reserve_id => $res->{'reserve_id'} }); |
1003 |
} |
993 |
} |
1004 |
} |
994 |
} |
1005 |
} |
995 |
|
1006 |
|
Lines 1871-1876
sub _Findgroupreserve {
Link Here
|
1871 |
return @results; |
1882 |
return @results; |
1872 |
} |
1883 |
} |
1873 |
|
1884 |
|
|
|
1885 |
=head2 _reserve_last_pickup_date |
1886 |
|
1887 |
my $last_dt = _reserve_last_pickup_date($reserve); |
1888 |
|
1889 |
Returns the DateTime for the last pickup date for reserve. |
1890 |
|
1891 |
=cut |
1892 |
|
1893 |
sub _reserve_last_pickup_date { |
1894 |
my ($reserve) = @_; |
1895 |
|
1896 |
my $startdate = $reserve->{waitingdate} ? dt_from_string($reserve->{waitingdate}) : DateTime->now( time_zone => C4::Context->tz() ); |
1897 |
my $calendar = Koha::Calendar->new( branchcode => $reserve->{branchcode} ); |
1898 |
my $expiration = $calendar->days_forward( $startdate, C4::Context->preference('ReservesMaxPickUpDelay') ); |
1899 |
|
1900 |
return $expiration; |
1901 |
} |
1902 |
|
1903 |
|
1874 |
=head2 _koha_notify_reserve |
1904 |
=head2 _koha_notify_reserve |
1875 |
|
1905 |
|
1876 |
_koha_notify_reserve( $itemnumber, $borrowernumber, $biblionumber ); |
1906 |
_koha_notify_reserve( $itemnumber, $borrowernumber, $biblionumber ); |
Lines 1910-1915
sub _koha_notify_reserve {
Link Here
|
1910 |
|
1940 |
|
1911 |
my $admin_email_address = $branch_details->{'branchemail'} || C4::Context->preference('KohaAdminEmailAddress'); |
1941 |
my $admin_email_address = $branch_details->{'branchemail'} || C4::Context->preference('KohaAdminEmailAddress'); |
1912 |
|
1942 |
|
|
|
1943 |
my $expiration = _reserve_last_pickup_date($reserve); |
1944 |
|
1913 |
my %letter_params = ( |
1945 |
my %letter_params = ( |
1914 |
module => 'reserves', |
1946 |
module => 'reserves', |
1915 |
branchcode => $reserve->{branchcode}, |
1947 |
branchcode => $reserve->{branchcode}, |
Lines 1920-1926
sub _koha_notify_reserve {
Link Here
|
1920 |
'reserves' => $reserve, |
1952 |
'reserves' => $reserve, |
1921 |
'items', $reserve->{'itemnumber'}, |
1953 |
'items', $reserve->{'itemnumber'}, |
1922 |
}, |
1954 |
}, |
1923 |
substitute => { today => C4::Dates->new()->output() }, |
1955 |
substitute => { |
|
|
1956 |
'lastpickupdate' => C4::Dates->new($expiration->ymd(), 'iso')->output() |
1957 |
}, |
1924 |
); |
1958 |
); |
1925 |
|
1959 |
|
1926 |
|
1960 |
|
Lines 2223-2228
sub ReserveSlip {
Link Here
|
2223 |
}) or return; |
2257 |
}) or return; |
2224 |
my $reserve = GetReserveInfo($reserve_id) or return; |
2258 |
my $reserve = GetReserveInfo($reserve_id) or return; |
2225 |
|
2259 |
|
|
|
2260 |
my $expiration = _reserve_last_pickup_date($reserve); |
2261 |
|
2226 |
return C4::Letters::GetPreparedLetter ( |
2262 |
return C4::Letters::GetPreparedLetter ( |
2227 |
module => 'circulation', |
2263 |
module => 'circulation', |
2228 |
letter_code => 'RESERVESLIP', |
2264 |
letter_code => 'RESERVESLIP', |
Lines 2234-2239
sub ReserveSlip {
Link Here
|
2234 |
'biblio' => $reserve->{biblionumber}, |
2270 |
'biblio' => $reserve->{biblionumber}, |
2235 |
'items' => $reserve->{itemnumber}, |
2271 |
'items' => $reserve->{itemnumber}, |
2236 |
}, |
2272 |
}, |
|
|
2273 |
substitute => { |
2274 |
'lastpickupdate' => C4::Dates->new($expiration->ymd(), 'iso')->output() |
2275 |
}, |
2237 |
); |
2276 |
); |
2238 |
} |
2277 |
} |
2239 |
|
2278 |
|