Lines 452-458
sub CanItemBeReserved{
Link Here
|
452 |
my $dbh = C4::Context->dbh; |
452 |
my $dbh = C4::Context->dbh; |
453 |
my $ruleitemtype; # itemtype of the matching issuing rule |
453 |
my $ruleitemtype; # itemtype of the matching issuing rule |
454 |
my $allowedreserves = 0; |
454 |
my $allowedreserves = 0; |
455 |
|
455 |
|
456 |
# we retrieve borrowers and items informations # |
456 |
# we retrieve borrowers and items informations # |
457 |
# item->{itype} will come for biblioitems if necessery |
457 |
# item->{itype} will come for biblioitems if necessery |
458 |
my $item = GetItem($itemnumber); |
458 |
my $item = GetItem($itemnumber); |
Lines 488-495
sub CanItemBeReserved{
Link Here
|
488 |
LEFT JOIN borrowers USING (borrowernumber) |
488 |
LEFT JOIN borrowers USING (borrowernumber) |
489 |
WHERE borrowernumber = ? |
489 |
WHERE borrowernumber = ? |
490 |
"; |
490 |
"; |
491 |
|
491 |
|
492 |
|
492 |
|
493 |
my $branchcode = ""; |
493 |
my $branchcode = ""; |
494 |
my $branchfield = "reserves.branchcode"; |
494 |
my $branchfield = "reserves.branchcode"; |
495 |
|
495 |
|
Lines 500-511
sub CanItemBeReserved{
Link Here
|
500 |
$branchfield = "borrowers.branchcode"; |
500 |
$branchfield = "borrowers.branchcode"; |
501 |
$branchcode = $borrower->{branchcode}; |
501 |
$branchcode = $borrower->{branchcode}; |
502 |
} |
502 |
} |
503 |
|
503 |
|
504 |
# we retrieve rights |
504 |
# we retrieve rights |
505 |
$sth->execute($borrower->{'categorycode'}, $item->{'itype'}, $branchcode); |
505 |
$sth->execute($borrower->{'categorycode'}, $item->{'itype'}, $branchcode); |
506 |
if(my $rights = $sth->fetchrow_hashref()){ |
506 |
if(my $rights = $sth->fetchrow_hashref()){ |
507 |
$ruleitemtype = $rights->{itemtype}; |
507 |
$ruleitemtype = $rights->{itemtype}; |
508 |
$allowedreserves = $rights->{reservesallowed}; |
508 |
$allowedreserves = $rights->{reservesallowed}; |
509 |
}else{ |
509 |
}else{ |
510 |
$ruleitemtype = '*'; |
510 |
$ruleitemtype = '*'; |
511 |
} |
511 |
} |
Lines 513-519
sub CanItemBeReserved{
Link Here
|
513 |
# we retrieve count |
513 |
# we retrieve count |
514 |
|
514 |
|
515 |
$querycount .= "AND $branchfield = ?"; |
515 |
$querycount .= "AND $branchfield = ?"; |
516 |
|
516 |
|
517 |
# If using item-level itypes, fall back to the record |
517 |
# If using item-level itypes, fall back to the record |
518 |
# level itemtype if the hold has no associated item |
518 |
# level itemtype if the hold has no associated item |
519 |
$querycount .= |
519 |
$querycount .= |
Lines 523-529
sub CanItemBeReserved{
Link Here
|
523 |
if ( $ruleitemtype ne "*" ); |
523 |
if ( $ruleitemtype ne "*" ); |
524 |
|
524 |
|
525 |
my $sthcount = $dbh->prepare($querycount); |
525 |
my $sthcount = $dbh->prepare($querycount); |
526 |
|
526 |
|
527 |
if($ruleitemtype eq "*"){ |
527 |
if($ruleitemtype eq "*"){ |
528 |
$sthcount->execute($borrowernumber, $branchcode); |
528 |
$sthcount->execute($borrowernumber, $branchcode); |
529 |
}else{ |
529 |
}else{ |
Lines 737-744
sub GetReservesToBranch {
Link Here
|
737 |
my $dbh = C4::Context->dbh; |
737 |
my $dbh = C4::Context->dbh; |
738 |
my $sth = $dbh->prepare( |
738 |
my $sth = $dbh->prepare( |
739 |
"SELECT reserve_id,borrowernumber,reservedate,itemnumber,timestamp |
739 |
"SELECT reserve_id,borrowernumber,reservedate,itemnumber,timestamp |
740 |
FROM reserves |
740 |
FROM reserves |
741 |
WHERE priority='0' |
741 |
WHERE priority='0' |
742 |
AND branchcode=?" |
742 |
AND branchcode=?" |
743 |
); |
743 |
); |
744 |
$sth->execute( $frombranch ); |
744 |
$sth->execute( $frombranch ); |
Lines 763-769
sub GetReservesForBranch {
Link Here
|
763 |
|
763 |
|
764 |
my $query = " |
764 |
my $query = " |
765 |
SELECT reserve_id,borrowernumber,reservedate,itemnumber,waitingdate |
765 |
SELECT reserve_id,borrowernumber,reservedate,itemnumber,waitingdate |
766 |
FROM reserves |
766 |
FROM reserves |
767 |
WHERE priority='0' |
767 |
WHERE priority='0' |
768 |
AND found='W' |
768 |
AND found='W' |
769 |
"; |
769 |
"; |
Lines 1016-1022
sub CancelExpiredReserves {
Link Here
|
1016 |
} |
1016 |
} |
1017 |
|
1017 |
|
1018 |
if ( $do_cancel ) { |
1018 |
if ( $do_cancel ) { |
1019 |
CancelReserve({ reserve_id => $res->{'reserve_id'}, charge_cancel_fee => 1 }); |
1019 |
CancelReserve( |
|
|
1020 |
{ |
1021 |
reserve_id => $res->{'reserve_id'}, |
1022 |
autofill => C4::Context->preference('ExpireReservesAutoFill'), |
1023 |
charge_cancel_fee => 1, |
1024 |
} |
1025 |
); |
1020 |
} |
1026 |
} |
1021 |
} |
1027 |
} |
1022 |
} |
1028 |
} |
Lines 1041-1047
sub AutoUnsuspendReserves {
Link Here
|
1041 |
|
1047 |
|
1042 |
=head2 CancelReserve |
1048 |
=head2 CancelReserve |
1043 |
|
1049 |
|
1044 |
CancelReserve({ reserve_id => $reserve_id, [ biblionumber => $biblionumber, borrowernumber => $borrrowernumber, itemnumber => $itemnumber, ] [ charge_cancel_fee => 1 ] }); |
1050 |
CancelReserve({ reserve_id => $reserve_id, [ biblionumber => $biblionumber, borrowernumber => $borrrowernumber, itemnumber => $itemnumber, charge_cancel_fee => 1, autofill => $autofill ] }); |
1045 |
|
1051 |
|
1046 |
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. |
1052 |
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. |
1047 |
|
1053 |
|
Lines 1051-1060
sub CancelReserve {
Link Here
|
1051 |
my ( $params ) = @_; |
1057 |
my ( $params ) = @_; |
1052 |
|
1058 |
|
1053 |
my $reserve_id = $params->{'reserve_id'}; |
1059 |
my $reserve_id = $params->{'reserve_id'}; |
|
|
1060 |
my $autofill = $params->{autofill}; |
1061 |
|
1054 |
# Filter out only the desired keys; this will insert undefined values for elements missing in |
1062 |
# Filter out only the desired keys; this will insert undefined values for elements missing in |
1055 |
# \%params, but GetReserveId filters them out anyway. |
1063 |
# \%params, but GetReserveId filters them out anyway. |
1056 |
$reserve_id = GetReserveId( { biblionumber => $params->{'biblionumber'}, borrowernumber => $params->{'borrowernumber'}, itemnumber => $params->{'itemnumber'} } ) unless ( $reserve_id ); |
1064 |
$reserve_id = GetReserveId( { biblionumber => $params->{'biblionumber'}, borrowernumber => $params->{'borrowernumber'}, itemnumber => $params->{'itemnumber'} } ) unless ( $reserve_id ); |
1057 |
|
1065 |
|
|
|
1066 |
|
1058 |
return unless ( $reserve_id ); |
1067 |
return unless ( $reserve_id ); |
1059 |
|
1068 |
|
1060 |
my $dbh = C4::Context->dbh; |
1069 |
my $dbh = C4::Context->dbh; |
Lines 1094-1099
sub CancelReserve {
Link Here
|
1094 |
if ( $charge && $params->{'charge_cancel_fee'} ) { |
1103 |
if ( $charge && $params->{'charge_cancel_fee'} ) { |
1095 |
manualinvoice($reserve->{'borrowernumber'}, $reserve->{'itemnumber'}, 'Hold waiting too long', 'F', $charge); |
1104 |
manualinvoice($reserve->{'borrowernumber'}, $reserve->{'itemnumber'}, 'Hold waiting too long', 'F', $charge); |
1096 |
} |
1105 |
} |
|
|
1106 |
|
1107 |
# only attempt to autofill canceled holds that were found and waiting |
1108 |
if ( $autofill && $reserve->{itemnumber} && $reserve->{found} && $reserve->{found} eq 'W' ) { |
1109 |
my ( undef, $next_hold ) = CheckReserves( $reserve->{'itemnumber'} ); |
1110 |
if ($next_hold) { |
1111 |
my $is_transfer = $reserve->{branchcode} ne $next_hold->{branchcode}; |
1112 |
|
1113 |
ModReserveAffect( |
1114 |
{ |
1115 |
itemnumber => $reserve->{itemnumber}, |
1116 |
borrowernumber => $next_hold->{borrowernumber}, |
1117 |
is_transfer => $is_transfer, |
1118 |
notify_library => 1, |
1119 |
} |
1120 |
); |
1121 |
|
1122 |
ModItemTransfer( $reserve->{itemnumber}, $reserve->{branchcode}, $next_hold->{branchcode} ) |
1123 |
if $is_transfer; |
1124 |
} |
1125 |
} |
1097 |
} |
1126 |
} |
1098 |
|
1127 |
|
1099 |
return $reserve; |
1128 |
return $reserve; |
Lines 1294-1300
take care of the waiting status
Link Here
|
1294 |
=cut |
1323 |
=cut |
1295 |
|
1324 |
|
1296 |
sub ModReserveAffect { |
1325 |
sub ModReserveAffect { |
1297 |
my ( $itemnumber, $borrowernumber,$transferToDo ) = @_; |
1326 |
my ( $params ) = @_; |
|
|
1327 |
|
1328 |
my $itemnumber = $params->{itemnumber}; |
1329 |
my $borrowernumber = $params->{borrowernumber}; |
1330 |
my $transferToDo = $params->{is_transfer}; |
1331 |
my $notify_library = $params->{notify_library}; |
1332 |
|
1298 |
my $dbh = C4::Context->dbh; |
1333 |
my $dbh = C4::Context->dbh; |
1299 |
|
1334 |
|
1300 |
# we want to attach $itemnumber to $borrowernumber, find the biblionumber |
1335 |
# we want to attach $itemnumber to $borrowernumber, find the biblionumber |
Lines 1339-1346
sub ModReserveAffect {
Link Here
|
1339 |
} |
1374 |
} |
1340 |
$sth = $dbh->prepare($query); |
1375 |
$sth = $dbh->prepare($query); |
1341 |
$sth->execute( $itemnumber, $borrowernumber,$biblionumber); |
1376 |
$sth->execute( $itemnumber, $borrowernumber,$biblionumber); |
1342 |
_koha_notify_reserve( $itemnumber, $borrowernumber, $biblionumber ) if ( !$transferToDo && !$already_on_shelf ); |
1377 |
|
|
|
1378 |
_koha_notify_reserve( |
1379 |
{ |
1380 |
itemnumber => $itemnumber, |
1381 |
borrowernumber => $borrowernumber, |
1382 |
biblionumber => $biblionumber, |
1383 |
notify_library => $notify_library, |
1384 |
} |
1385 |
) if ( !$transferToDo && !$already_on_shelf ); |
1386 |
|
1343 |
_FixPriority( { biblionumber => $biblionumber } ); |
1387 |
_FixPriority( { biblionumber => $biblionumber } ); |
|
|
1388 |
|
1344 |
if ( C4::Context->preference("ReturnToShelvingCart") ) { |
1389 |
if ( C4::Context->preference("ReturnToShelvingCart") ) { |
1345 |
CartToShelf( $itemnumber ); |
1390 |
CartToShelf( $itemnumber ); |
1346 |
} |
1391 |
} |
Lines 1385-1391
sub ModReserveMinusPriority {
Link Here
|
1385 |
my $dbh = C4::Context->dbh; |
1430 |
my $dbh = C4::Context->dbh; |
1386 |
my $query = " |
1431 |
my $query = " |
1387 |
UPDATE reserves |
1432 |
UPDATE reserves |
1388 |
SET priority = 0 , itemnumber = ? |
1433 |
SET priority = 0 , itemnumber = ? |
1389 |
WHERE reserve_id = ? |
1434 |
WHERE reserve_id = ? |
1390 |
"; |
1435 |
"; |
1391 |
my $sth_upd = $dbh->prepare($query); |
1436 |
my $sth_upd = $dbh->prepare($query); |
Lines 1600-1606
sub ToggleLowestPriority {
Link Here
|
1600 |
|
1645 |
|
1601 |
my $sth = $dbh->prepare( "UPDATE reserves SET lowestPriority = NOT lowestPriority WHERE reserve_id = ?"); |
1646 |
my $sth = $dbh->prepare( "UPDATE reserves SET lowestPriority = NOT lowestPriority WHERE reserve_id = ?"); |
1602 |
$sth->execute( $reserve_id ); |
1647 |
$sth->execute( $reserve_id ); |
1603 |
|
1648 |
|
1604 |
_FixPriority({ reserve_id => $reserve_id, rank => '999999' }); |
1649 |
_FixPriority({ reserve_id => $reserve_id, rank => '999999' }); |
1605 |
} |
1650 |
} |
1606 |
|
1651 |
|
Lines 1784-1790
sub _FixPriority {
Link Here
|
1784 |
$priority[$j]->{'reserve_id'} |
1829 |
$priority[$j]->{'reserve_id'} |
1785 |
); |
1830 |
); |
1786 |
} |
1831 |
} |
1787 |
|
1832 |
|
1788 |
$sth = $dbh->prepare( "SELECT reserve_id FROM reserves WHERE lowestPriority = 1 ORDER BY priority" ); |
1833 |
$sth = $dbh->prepare( "SELECT reserve_id FROM reserves WHERE lowestPriority = 1 ORDER BY priority" ); |
1789 |
$sth->execute(); |
1834 |
$sth->execute(); |
1790 |
|
1835 |
|
Lines 1919-1925
sub _Findgroupreserve {
Link Here
|
1919 |
|
1964 |
|
1920 |
=head2 _koha_notify_reserve |
1965 |
=head2 _koha_notify_reserve |
1921 |
|
1966 |
|
1922 |
_koha_notify_reserve( $itemnumber, $borrowernumber, $biblionumber ); |
1967 |
_koha_notify_reserve( |
|
|
1968 |
{ |
1969 |
itemnumber => $itemnumber, |
1970 |
borrowernumber => $borrowernumber, |
1971 |
biblionumber => $biblionumber, |
1972 |
notify_library => $notify_library |
1973 |
} |
1974 |
); |
1923 |
|
1975 |
|
1924 |
Sends a notification to the patron that their hold has been filled (through |
1976 |
Sends a notification to the patron that their hold has been filled (through |
1925 |
ModReserveAffect, _not_ ModReserveFill) |
1977 |
ModReserveAffect, _not_ ModReserveFill) |
Lines 1946-1952
The following tables are availalbe witin the notice:
Link Here
|
1946 |
=cut |
1998 |
=cut |
1947 |
|
1999 |
|
1948 |
sub _koha_notify_reserve { |
2000 |
sub _koha_notify_reserve { |
1949 |
my ($itemnumber, $borrowernumber, $biblionumber) = @_; |
2001 |
my ( $params ) = @_; |
|
|
2002 |
|
2003 |
my $itemnumber = $params->{itemnumber}; |
2004 |
my $borrowernumber = $params->{borrowernumber}; |
2005 |
my $biblionumber = $params->{biblionumber}; |
2006 |
my $notify_library = $params->{notify_library}; |
1950 |
|
2007 |
|
1951 |
my $dbh = C4::Context->dbh; |
2008 |
my $dbh = C4::Context->dbh; |
1952 |
my $borrower = C4::Members::GetMember(borrowernumber => $borrowernumber); |
2009 |
my $borrower = C4::Members::GetMember(borrowernumber => $borrowernumber); |
Lines 1997-2008
sub _koha_notify_reserve {
Link Here
|
1997 |
return; |
2054 |
return; |
1998 |
} |
2055 |
} |
1999 |
|
2056 |
|
2000 |
C4::Letters::EnqueueLetter( { |
2057 |
C4::Letters::EnqueueLetter( |
2001 |
letter => $letter, |
2058 |
{ |
2002 |
borrowernumber => $borrowernumber, |
2059 |
letter => $letter, |
2003 |
from_address => $admin_email_address, |
2060 |
borrowernumber => $borrowernumber, |
2004 |
message_transport_type => $mtt, |
2061 |
from_address => $admin_email_address, |
2005 |
} ); |
2062 |
message_transport_type => $mtt, |
|
|
2063 |
} |
2064 |
); |
2006 |
}; |
2065 |
}; |
2007 |
|
2066 |
|
2008 |
while ( my ( $mtt, $letter_code ) = each %{ $messagingprefs->{transports} } ) { |
2067 |
while ( my ( $mtt, $letter_code ) = each %{ $messagingprefs->{transports} } ) { |
Lines 2019-2025
sub _koha_notify_reserve {
Link Here
|
2019 |
if (! $notification_sent) { |
2078 |
if (! $notification_sent) { |
2020 |
&$send_notification('print', 'HOLD'); |
2079 |
&$send_notification('print', 'HOLD'); |
2021 |
} |
2080 |
} |
2022 |
|
2081 |
|
|
|
2082 |
if ($notify_library) { |
2083 |
my $letter = C4::Letters::GetPreparedLetter( |
2084 |
module => 'reserves', |
2085 |
letter_code => 'HOLD_CHANGED', |
2086 |
branchcode => $reserve->{branchcode}, |
2087 |
substitute => { today => C4::Dates->new()->output() }, |
2088 |
tables => { |
2089 |
'branches' => $branch_details, |
2090 |
'borrowers' => $borrower, |
2091 |
'biblio' => $biblionumber, |
2092 |
'reserves' => $reserve, |
2093 |
'items' => $reserve->{'itemnumber'}, |
2094 |
}, |
2095 |
); |
2096 |
|
2097 |
my $email = |
2098 |
C4::Context->preference('ExpireReservesAutoFillEmail') |
2099 |
|| $branch_details->{'branchemail'} |
2100 |
|| C4::Context->preference('KohaAdminEmailAddress'); |
2101 |
|
2102 |
C4::Letters::EnqueueLetter( |
2103 |
{ |
2104 |
letter => $letter, |
2105 |
borrowernumber => $borrowernumber, |
2106 |
message_transport_type => 'email', |
2107 |
from_address => $email, |
2108 |
to_address => $email, |
2109 |
} |
2110 |
); |
2111 |
} |
2023 |
} |
2112 |
} |
2024 |
|
2113 |
|
2025 |
=head2 _ShiftPriorityByDateAndPriority |
2114 |
=head2 _ShiftPriorityByDateAndPriority |