Lines 442-448
sub CanItemBeReserved{
Link Here
|
442 |
my $dbh = C4::Context->dbh; |
442 |
my $dbh = C4::Context->dbh; |
443 |
my $ruleitemtype; # itemtype of the matching issuing rule |
443 |
my $ruleitemtype; # itemtype of the matching issuing rule |
444 |
my $allowedreserves = 0; |
444 |
my $allowedreserves = 0; |
445 |
|
445 |
|
446 |
# we retrieve borrowers and items informations # |
446 |
# we retrieve borrowers and items informations # |
447 |
# item->{itype} will come for biblioitems if necessery |
447 |
# item->{itype} will come for biblioitems if necessery |
448 |
my $item = GetItem($itemnumber); |
448 |
my $item = GetItem($itemnumber); |
Lines 478-485
sub CanItemBeReserved{
Link Here
|
478 |
LEFT JOIN borrowers USING (borrowernumber) |
478 |
LEFT JOIN borrowers USING (borrowernumber) |
479 |
WHERE borrowernumber = ? |
479 |
WHERE borrowernumber = ? |
480 |
"; |
480 |
"; |
481 |
|
481 |
|
482 |
|
482 |
|
483 |
my $branchcode = ""; |
483 |
my $branchcode = ""; |
484 |
my $branchfield = "reserves.branchcode"; |
484 |
my $branchfield = "reserves.branchcode"; |
485 |
|
485 |
|
Lines 490-501
sub CanItemBeReserved{
Link Here
|
490 |
$branchfield = "borrowers.branchcode"; |
490 |
$branchfield = "borrowers.branchcode"; |
491 |
$branchcode = $borrower->{branchcode}; |
491 |
$branchcode = $borrower->{branchcode}; |
492 |
} |
492 |
} |
493 |
|
493 |
|
494 |
# we retrieve rights |
494 |
# we retrieve rights |
495 |
$sth->execute($borrower->{'categorycode'}, $item->{'itype'}, $branchcode); |
495 |
$sth->execute($borrower->{'categorycode'}, $item->{'itype'}, $branchcode); |
496 |
if(my $rights = $sth->fetchrow_hashref()){ |
496 |
if(my $rights = $sth->fetchrow_hashref()){ |
497 |
$ruleitemtype = $rights->{itemtype}; |
497 |
$ruleitemtype = $rights->{itemtype}; |
498 |
$allowedreserves = $rights->{reservesallowed}; |
498 |
$allowedreserves = $rights->{reservesallowed}; |
499 |
}else{ |
499 |
}else{ |
500 |
$ruleitemtype = '*'; |
500 |
$ruleitemtype = '*'; |
501 |
} |
501 |
} |
Lines 503-509
sub CanItemBeReserved{
Link Here
|
503 |
# we retrieve count |
503 |
# we retrieve count |
504 |
|
504 |
|
505 |
$querycount .= "AND $branchfield = ?"; |
505 |
$querycount .= "AND $branchfield = ?"; |
506 |
|
506 |
|
507 |
# If using item-level itypes, fall back to the record |
507 |
# If using item-level itypes, fall back to the record |
508 |
# level itemtype if the hold has no associated item |
508 |
# level itemtype if the hold has no associated item |
509 |
$querycount .= |
509 |
$querycount .= |
Lines 513-519
sub CanItemBeReserved{
Link Here
|
513 |
if ( $ruleitemtype ne "*" ); |
513 |
if ( $ruleitemtype ne "*" ); |
514 |
|
514 |
|
515 |
my $sthcount = $dbh->prepare($querycount); |
515 |
my $sthcount = $dbh->prepare($querycount); |
516 |
|
516 |
|
517 |
if($ruleitemtype eq "*"){ |
517 |
if($ruleitemtype eq "*"){ |
518 |
$sthcount->execute($borrowernumber, $branchcode); |
518 |
$sthcount->execute($borrowernumber, $branchcode); |
519 |
}else{ |
519 |
}else{ |
Lines 726-733
sub GetReservesToBranch {
Link Here
|
726 |
my $dbh = C4::Context->dbh; |
726 |
my $dbh = C4::Context->dbh; |
727 |
my $sth = $dbh->prepare( |
727 |
my $sth = $dbh->prepare( |
728 |
"SELECT reserve_id,borrowernumber,reservedate,itemnumber,timestamp |
728 |
"SELECT reserve_id,borrowernumber,reservedate,itemnumber,timestamp |
729 |
FROM reserves |
729 |
FROM reserves |
730 |
WHERE priority='0' |
730 |
WHERE priority='0' |
731 |
AND branchcode=?" |
731 |
AND branchcode=?" |
732 |
); |
732 |
); |
733 |
$sth->execute( $frombranch ); |
733 |
$sth->execute( $frombranch ); |
Lines 752-758
sub GetReservesForBranch {
Link Here
|
752 |
|
752 |
|
753 |
my $query = " |
753 |
my $query = " |
754 |
SELECT reserve_id,borrowernumber,reservedate,itemnumber,waitingdate |
754 |
SELECT reserve_id,borrowernumber,reservedate,itemnumber,waitingdate |
755 |
FROM reserves |
755 |
FROM reserves |
756 |
WHERE priority='0' |
756 |
WHERE priority='0' |
757 |
AND found='W' |
757 |
AND found='W' |
758 |
"; |
758 |
"; |
Lines 1005-1011
sub CancelExpiredReserves {
Link Here
|
1005 |
} |
1005 |
} |
1006 |
|
1006 |
|
1007 |
if ( $do_cancel ) { |
1007 |
if ( $do_cancel ) { |
1008 |
CancelReserve({ reserve_id => $res->{'reserve_id'}, charge_cancel_fee => 1 }); |
1008 |
CancelReserve( |
|
|
1009 |
{ |
1010 |
reserve_id => $res->{'reserve_id'}, |
1011 |
autofill => C4::Context->preference('ExpireReservesAutoFill'), |
1012 |
charge_cancel_fee => 1, |
1013 |
} |
1014 |
); |
1009 |
} |
1015 |
} |
1010 |
} |
1016 |
} |
1011 |
} |
1017 |
} |
Lines 1032-1038
sub AutoUnsuspendReserves {
Link Here
|
1032 |
|
1038 |
|
1033 |
=head2 CancelReserve |
1039 |
=head2 CancelReserve |
1034 |
|
1040 |
|
1035 |
CancelReserve({ reserve_id => $reserve_id, [ biblionumber => $biblionumber, borrowernumber => $borrrowernumber, itemnumber => $itemnumber, ] [ charge_cancel_fee => 1 ] }); |
1041 |
CancelReserve({ reserve_id => $reserve_id, [ biblionumber => $biblionumber, borrowernumber => $borrrowernumber, itemnumber => $itemnumber, charge_cancel_fee => 1, autofill => $autofill ] }); |
1036 |
|
1042 |
|
1037 |
Cancels a reserve. If C<charge_cancel_fee> is passed and the C<ExpireReservesMaxPickUpDelayCharge> syspref is set, charge that fee to the patron's account. |
1043 |
Cancels a reserve. If C<charge_cancel_fee> is passed and the C<ExpireReservesMaxPickUpDelayCharge> syspref is set, charge that fee to the patron's account. |
1038 |
|
1044 |
|
Lines 1042-1051
sub CancelReserve {
Link Here
|
1042 |
my ( $params ) = @_; |
1048 |
my ( $params ) = @_; |
1043 |
|
1049 |
|
1044 |
my $reserve_id = $params->{'reserve_id'}; |
1050 |
my $reserve_id = $params->{'reserve_id'}; |
|
|
1051 |
my $autofill = $params->{autofill}; |
1052 |
|
1045 |
# Filter out only the desired keys; this will insert undefined values for elements missing in |
1053 |
# Filter out only the desired keys; this will insert undefined values for elements missing in |
1046 |
# \%params, but GetReserveId filters them out anyway. |
1054 |
# \%params, but GetReserveId filters them out anyway. |
1047 |
$reserve_id = GetReserveId( { biblionumber => $params->{'biblionumber'}, borrowernumber => $params->{'borrowernumber'}, itemnumber => $params->{'itemnumber'} } ) unless ( $reserve_id ); |
1055 |
$reserve_id = GetReserveId( { biblionumber => $params->{'biblionumber'}, borrowernumber => $params->{'borrowernumber'}, itemnumber => $params->{'itemnumber'} } ) unless ( $reserve_id ); |
1048 |
|
1056 |
|
|
|
1057 |
|
1049 |
return unless ( $reserve_id ); |
1058 |
return unless ( $reserve_id ); |
1050 |
|
1059 |
|
1051 |
my $dbh = C4::Context->dbh; |
1060 |
my $dbh = C4::Context->dbh; |
Lines 1085-1090
sub CancelReserve {
Link Here
|
1085 |
if ( $charge && $params->{'charge_cancel_fee'} ) { |
1094 |
if ( $charge && $params->{'charge_cancel_fee'} ) { |
1086 |
manualinvoice($reserve->{'borrowernumber'}, $reserve->{'itemnumber'}, 'Hold waiting too long', 'F', $charge); |
1095 |
manualinvoice($reserve->{'borrowernumber'}, $reserve->{'itemnumber'}, 'Hold waiting too long', 'F', $charge); |
1087 |
} |
1096 |
} |
|
|
1097 |
|
1098 |
# only attempt to autofill canceled holds that were found and waiting |
1099 |
if ( $autofill && $reserve->{itemnumber} && $reserve->{found} && $reserve->{found} eq 'W' ) { |
1100 |
my ( undef, $next_hold ) = CheckReserves( $reserve->{'itemnumber'} ); |
1101 |
if ($next_hold) { |
1102 |
my $is_transfer = $reserve->{branchcode} ne $next_hold->{branchcode}; |
1103 |
|
1104 |
ModReserveAffect( |
1105 |
{ |
1106 |
itemnumber => $reserve->{itemnumber}, |
1107 |
borrowernumber => $next_hold->{borrowernumber}, |
1108 |
is_transfer => $is_transfer, |
1109 |
notify_library => 1, |
1110 |
} |
1111 |
); |
1112 |
|
1113 |
ModItemTransfer( $reserve->{itemnumber}, $reserve->{branchcode}, $next_hold->{branchcode} ) |
1114 |
if $is_transfer; |
1115 |
} |
1116 |
} |
1088 |
} |
1117 |
} |
1089 |
|
1118 |
|
1090 |
return $reserve; |
1119 |
return $reserve; |
Lines 1278-1284
take care of the waiting status
Link Here
|
1278 |
=cut |
1307 |
=cut |
1279 |
|
1308 |
|
1280 |
sub ModReserveAffect { |
1309 |
sub ModReserveAffect { |
1281 |
my ( $itemnumber, $borrowernumber,$transferToDo ) = @_; |
1310 |
my ( $params ) = @_; |
|
|
1311 |
|
1312 |
my $itemnumber = $params->{itemnumber}; |
1313 |
my $borrowernumber = $params->{borrowernumber}; |
1314 |
my $transferToDo = $params->{is_transfer}; |
1315 |
my $notify_library = $params->{notify_library}; |
1316 |
|
1282 |
my $dbh = C4::Context->dbh; |
1317 |
my $dbh = C4::Context->dbh; |
1283 |
|
1318 |
|
1284 |
# we want to attach $itemnumber to $borrowernumber, find the biblionumber |
1319 |
# we want to attach $itemnumber to $borrowernumber, find the biblionumber |
Lines 1323-1330
sub ModReserveAffect {
Link Here
|
1323 |
} |
1358 |
} |
1324 |
$sth = $dbh->prepare($query); |
1359 |
$sth = $dbh->prepare($query); |
1325 |
$sth->execute( $itemnumber, $borrowernumber,$biblionumber); |
1360 |
$sth->execute( $itemnumber, $borrowernumber,$biblionumber); |
1326 |
_koha_notify_reserve( $itemnumber, $borrowernumber, $biblionumber ) if ( !$transferToDo && !$already_on_shelf ); |
1361 |
|
|
|
1362 |
_koha_notify_reserve( |
1363 |
{ |
1364 |
itemnumber => $itemnumber, |
1365 |
borrowernumber => $borrowernumber, |
1366 |
biblionumber => $biblionumber, |
1367 |
notify_library => $notify_library, |
1368 |
} |
1369 |
) if ( !$transferToDo && !$already_on_shelf ); |
1370 |
|
1327 |
_FixPriority( { biblionumber => $biblionumber } ); |
1371 |
_FixPriority( { biblionumber => $biblionumber } ); |
|
|
1372 |
|
1328 |
if ( C4::Context->preference("ReturnToShelvingCart") ) { |
1373 |
if ( C4::Context->preference("ReturnToShelvingCart") ) { |
1329 |
CartToShelf( $itemnumber ); |
1374 |
CartToShelf( $itemnumber ); |
1330 |
} |
1375 |
} |
Lines 1369-1375
sub ModReserveMinusPriority {
Link Here
|
1369 |
my $dbh = C4::Context->dbh; |
1414 |
my $dbh = C4::Context->dbh; |
1370 |
my $query = " |
1415 |
my $query = " |
1371 |
UPDATE reserves |
1416 |
UPDATE reserves |
1372 |
SET priority = 0 , itemnumber = ? |
1417 |
SET priority = 0 , itemnumber = ? |
1373 |
WHERE reserve_id = ? |
1418 |
WHERE reserve_id = ? |
1374 |
"; |
1419 |
"; |
1375 |
my $sth_upd = $dbh->prepare($query); |
1420 |
my $sth_upd = $dbh->prepare($query); |
Lines 1584-1590
sub ToggleLowestPriority {
Link Here
|
1584 |
|
1629 |
|
1585 |
my $sth = $dbh->prepare( "UPDATE reserves SET lowestPriority = NOT lowestPriority WHERE reserve_id = ?"); |
1630 |
my $sth = $dbh->prepare( "UPDATE reserves SET lowestPriority = NOT lowestPriority WHERE reserve_id = ?"); |
1586 |
$sth->execute( $reserve_id ); |
1631 |
$sth->execute( $reserve_id ); |
1587 |
|
1632 |
|
1588 |
_FixPriority({ reserve_id => $reserve_id, rank => '999999' }); |
1633 |
_FixPriority({ reserve_id => $reserve_id, rank => '999999' }); |
1589 |
} |
1634 |
} |
1590 |
|
1635 |
|
Lines 1794-1800
sub _FixPriority {
Link Here
|
1794 |
$priority[$j]->{'reserve_id'} |
1839 |
$priority[$j]->{'reserve_id'} |
1795 |
); |
1840 |
); |
1796 |
} |
1841 |
} |
1797 |
|
1842 |
|
1798 |
$sth = $dbh->prepare( "SELECT reserve_id FROM reserves WHERE lowestPriority = 1 ORDER BY priority" ); |
1843 |
$sth = $dbh->prepare( "SELECT reserve_id FROM reserves WHERE lowestPriority = 1 ORDER BY priority" ); |
1799 |
$sth->execute(); |
1844 |
$sth->execute(); |
1800 |
|
1845 |
|
Lines 1929-1935
sub _Findgroupreserve {
Link Here
|
1929 |
|
1974 |
|
1930 |
=head2 _koha_notify_reserve |
1975 |
=head2 _koha_notify_reserve |
1931 |
|
1976 |
|
1932 |
_koha_notify_reserve( $itemnumber, $borrowernumber, $biblionumber ); |
1977 |
_koha_notify_reserve( |
|
|
1978 |
{ |
1979 |
itemnumber => $itemnumber, |
1980 |
borrowernumber => $borrowernumber, |
1981 |
biblionumber => $biblionumber, |
1982 |
notify_library => $notify_library |
1983 |
} |
1984 |
); |
1933 |
|
1985 |
|
1934 |
Sends a notification to the patron that their hold has been filled (through |
1986 |
Sends a notification to the patron that their hold has been filled (through |
1935 |
ModReserveAffect, _not_ ModReserveFill) |
1987 |
ModReserveAffect, _not_ ModReserveFill) |
Lines 1937-1943
ModReserveAffect, _not_ ModReserveFill)
Link Here
|
1937 |
=cut |
1989 |
=cut |
1938 |
|
1990 |
|
1939 |
sub _koha_notify_reserve { |
1991 |
sub _koha_notify_reserve { |
1940 |
my ($itemnumber, $borrowernumber, $biblionumber) = @_; |
1992 |
my ( $params ) = @_; |
|
|
1993 |
|
1994 |
my $itemnumber = $params->{itemnumber}; |
1995 |
my $borrowernumber = $params->{borrowernumber}; |
1996 |
my $biblionumber = $params->{biblionumber}; |
1997 |
my $notify_library = $params->{notify_library}; |
1941 |
|
1998 |
|
1942 |
my $dbh = C4::Context->dbh; |
1999 |
my $dbh = C4::Context->dbh; |
1943 |
my $borrower = C4::Members::GetMember(borrowernumber => $borrowernumber); |
2000 |
my $borrower = C4::Members::GetMember(borrowernumber => $borrowernumber); |
Lines 1987-1998
sub _koha_notify_reserve {
Link Here
|
1987 |
return; |
2044 |
return; |
1988 |
} |
2045 |
} |
1989 |
|
2046 |
|
1990 |
C4::Letters::EnqueueLetter( { |
2047 |
C4::Letters::EnqueueLetter( |
1991 |
letter => $letter, |
2048 |
{ |
1992 |
borrowernumber => $borrowernumber, |
2049 |
letter => $letter, |
1993 |
from_address => $admin_email_address, |
2050 |
borrowernumber => $borrowernumber, |
1994 |
message_transport_type => $mtt, |
2051 |
from_address => $admin_email_address, |
1995 |
} ); |
2052 |
message_transport_type => $mtt, |
|
|
2053 |
} |
2054 |
); |
1996 |
}; |
2055 |
}; |
1997 |
|
2056 |
|
1998 |
while ( my ( $mtt, $letter_code ) = each %{ $messagingprefs->{transports} } ) { |
2057 |
while ( my ( $mtt, $letter_code ) = each %{ $messagingprefs->{transports} } ) { |
Lines 2009-2015
sub _koha_notify_reserve {
Link Here
|
2009 |
if (! $notification_sent) { |
2068 |
if (! $notification_sent) { |
2010 |
&$send_notification('print', 'HOLD'); |
2069 |
&$send_notification('print', 'HOLD'); |
2011 |
} |
2070 |
} |
2012 |
|
2071 |
|
|
|
2072 |
if ($notify_library) { |
2073 |
my $letter = C4::Letters::GetPreparedLetter( |
2074 |
module => 'reserves', |
2075 |
letter_code => 'HOLD_CHANGED', |
2076 |
branchcode => $reserve->{branchcode}, |
2077 |
substitute => { today => C4::Dates->new()->output() }, |
2078 |
tables => { |
2079 |
'branches' => $branch_details, |
2080 |
'borrowers' => $borrower, |
2081 |
'biblio' => $biblionumber, |
2082 |
'reserves' => $reserve, |
2083 |
'items' => $reserve->{'itemnumber'}, |
2084 |
}, |
2085 |
); |
2086 |
|
2087 |
my $email = |
2088 |
C4::Context->preference('ExpireReservesAutoFillEmail') |
2089 |
|| $branch_details->{'branchemail'} |
2090 |
|| C4::Context->preference('KohaAdminEmailAddress'); |
2091 |
|
2092 |
C4::Letters::EnqueueLetter( |
2093 |
{ |
2094 |
letter => $letter, |
2095 |
borrowernumber => $borrowernumber, |
2096 |
message_transport_type => 'email', |
2097 |
from_address => $email, |
2098 |
to_address => $email, |
2099 |
} |
2100 |
); |
2101 |
} |
2013 |
} |
2102 |
} |
2014 |
|
2103 |
|
2015 |
=head2 _ShiftPriorityByDateAndPriority |
2104 |
=head2 _ShiftPriorityByDateAndPriority |