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 132-137
BEGIN {
Link Here
|
132 |
&ToggleSuspend |
135 |
&ToggleSuspend |
133 |
&SuspendAll |
136 |
&SuspendAll |
134 |
|
137 |
|
|
|
138 |
&_reserve_last_pickup_date |
139 |
|
135 |
&GetReservesControlBranch |
140 |
&GetReservesControlBranch |
136 |
); |
141 |
); |
137 |
@EXPORT_OK = qw( MergeHolds ); |
142 |
@EXPORT_OK = qw( MergeHolds ); |
Lines 719-725
sub GetReservesForBranch {
Link Here
|
719 |
my $dbh = C4::Context->dbh; |
724 |
my $dbh = C4::Context->dbh; |
720 |
|
725 |
|
721 |
my $query = " |
726 |
my $query = " |
722 |
SELECT reserve_id,borrowernumber,reservedate,itemnumber,waitingdate |
727 |
SELECT reserve_id,borrowernumber,reservedate,itemnumber,waitingdate,branchcode |
723 |
FROM reserves |
728 |
FROM reserves |
724 |
WHERE priority='0' |
729 |
WHERE priority='0' |
725 |
AND found='W' |
730 |
AND found='W' |
Lines 935-946
sub CancelExpiredReserves {
Link Here
|
935 |
$sth = $dbh->prepare( $query ); |
940 |
$sth = $dbh->prepare( $query ); |
936 |
$sth->execute( $max_pickup_delay ); |
941 |
$sth->execute( $max_pickup_delay ); |
937 |
|
942 |
|
|
|
943 |
my $today = DateTime->now( time_zone => C4::Context->tz() ); |
944 |
|
938 |
while (my $res = $sth->fetchrow_hashref ) { |
945 |
while (my $res = $sth->fetchrow_hashref ) { |
939 |
if ( $charge ) { |
946 |
my $expiration = _reserve_last_pickup_date( $res ); |
940 |
manualinvoice($res->{'borrowernumber'}, $res->{'itemnumber'}, 'Hold waiting too long', 'F', $charge); |
947 |
if ( $today > $expiration ) { |
|
|
948 |
if ( $charge ) { |
949 |
manualinvoice($res->{'borrowernumber'}, $res->{'itemnumber'}, 'Hold waiting too long', 'F', $charge); |
950 |
} |
951 |
CancelReserve({ reserve_id => $res->{'reserve_id'} }); |
941 |
} |
952 |
} |
942 |
|
|
|
943 |
CancelReserve({ reserve_id => $res->{'reserve_id'} }); |
944 |
} |
953 |
} |
945 |
} |
954 |
} |
946 |
|
955 |
|
Lines 1815-1820
sub _Findgroupreserve {
Link Here
|
1815 |
return @results; |
1824 |
return @results; |
1816 |
} |
1825 |
} |
1817 |
|
1826 |
|
|
|
1827 |
=head2 _reserve_last_pickup_date |
1828 |
|
1829 |
my $last_dt = _reserve_last_pickup_date($reserve); |
1830 |
|
1831 |
Returns the DateTime for the last pickup date for reserve. |
1832 |
|
1833 |
=cut |
1834 |
|
1835 |
sub _reserve_last_pickup_date { |
1836 |
my ($reserve) = @_; |
1837 |
|
1838 |
my $startdate = $reserve->{waitingdate} ? dt_from_string($reserve->{waitingdate}) : DateTime->now( time_zone => C4::Context->tz() ); |
1839 |
my $calendar = Koha::Calendar->new( branchcode => $reserve->{branchcode} ); |
1840 |
my $expiration = $calendar->days_forward( $startdate, C4::Context->preference('ReservesMaxPickUpDelay') ); |
1841 |
|
1842 |
return $expiration; |
1843 |
} |
1844 |
|
1818 |
=head2 _koha_notify_reserve |
1845 |
=head2 _koha_notify_reserve |
1819 |
|
1846 |
|
1820 |
_koha_notify_reserve( $itemnumber, $borrowernumber, $biblionumber, $reserve_id ); |
1847 |
_koha_notify_reserve( $itemnumber, $borrowernumber, $biblionumber, $reserve_id ); |
Lines 1851-1856
sub _koha_notify_reserve {
Link Here
|
1851 |
|
1878 |
|
1852 |
my $admin_email_address = $branch_details->{'branchemail'} || C4::Context->preference('KohaAdminEmailAddress'); |
1879 |
my $admin_email_address = $branch_details->{'branchemail'} || C4::Context->preference('KohaAdminEmailAddress'); |
1853 |
|
1880 |
|
|
|
1881 |
my $expiration = _reserve_last_pickup_date($reserve); |
1882 |
|
1854 |
my %letter_params = ( |
1883 |
my %letter_params = ( |
1855 |
module => 'reserves', |
1884 |
module => 'reserves', |
1856 |
branchcode => $reserve->{branchcode}, |
1885 |
branchcode => $reserve->{branchcode}, |
Lines 1861-1867
sub _koha_notify_reserve {
Link Here
|
1861 |
'reserves' => $reserve, |
1890 |
'reserves' => $reserve, |
1862 |
'items', $reserve->{'itemnumber'}, |
1891 |
'items', $reserve->{'itemnumber'}, |
1863 |
}, |
1892 |
}, |
1864 |
substitute => { today => C4::Dates->new()->output() }, |
1893 |
substitute => { |
|
|
1894 |
'lastpickupdate' => C4::Dates->new($expiration->ymd(), 'iso')->output() |
1895 |
}, |
1896 |
|
1865 |
); |
1897 |
); |
1866 |
|
1898 |
|
1867 |
my $notification_sent = 0; #Keeping track if a Hold_filled message is sent. If no message can be sent, then default to a print message. |
1899 |
my $notification_sent = 0; #Keeping track if a Hold_filled message is sent. If no message can be sent, then default to a print message. |
Lines 2195-2200
sub ReserveSlip {
Link Here
|
2195 |
}) or return; |
2227 |
}) or return; |
2196 |
my $reserve = GetReserveInfo($reserve_id) or return; |
2228 |
my $reserve = GetReserveInfo($reserve_id) or return; |
2197 |
|
2229 |
|
|
|
2230 |
my $expiration = _reserve_last_pickup_date($reserve); |
2231 |
|
2198 |
return C4::Letters::GetPreparedLetter ( |
2232 |
return C4::Letters::GetPreparedLetter ( |
2199 |
module => 'circulation', |
2233 |
module => 'circulation', |
2200 |
letter_code => $transfer ? 'TRANSFERSLIP' : 'RESERVESLIP', |
2234 |
letter_code => $transfer ? 'TRANSFERSLIP' : 'RESERVESLIP', |
Lines 2206-2211
sub ReserveSlip {
Link Here
|
2206 |
'biblio' => $reserve->{biblionumber}, |
2240 |
'biblio' => $reserve->{biblionumber}, |
2207 |
'items' => $reserve->{itemnumber}, |
2241 |
'items' => $reserve->{itemnumber}, |
2208 |
}, |
2242 |
}, |
|
|
2243 |
substitute => { |
2244 |
'lastpickupdate' => C4::Dates->new($expiration->ymd(), 'iso')->output() |
2245 |
}, |
2209 |
); |
2246 |
); |
2210 |
} |
2247 |
} |
2211 |
|
2248 |
|