Lines 252-258
sub AddReserve {
Link Here
|
252 |
foreach (@$bibitems) { |
252 |
foreach (@$bibitems) { |
253 |
$sth->execute($borrowernumber, $biblionumber, $resdate, $_); |
253 |
$sth->execute($borrowernumber, $biblionumber, $resdate, $_); |
254 |
} |
254 |
} |
255 |
|
255 |
|
256 |
return $reserve_id; |
256 |
return $reserve_id; |
257 |
} |
257 |
} |
258 |
|
258 |
|
Lines 498-504
sub CanItemBeReserved{
Link Here
|
498 |
my $dbh = C4::Context->dbh; |
498 |
my $dbh = C4::Context->dbh; |
499 |
my $ruleitemtype; # itemtype of the matching issuing rule |
499 |
my $ruleitemtype; # itemtype of the matching issuing rule |
500 |
my $allowedreserves = 0; |
500 |
my $allowedreserves = 0; |
501 |
|
501 |
|
502 |
# we retrieve borrowers and items informations # |
502 |
# we retrieve borrowers and items informations # |
503 |
# item->{itype} will come for biblioitems if necessery |
503 |
# item->{itype} will come for biblioitems if necessery |
504 |
my $item = GetItem($itemnumber); |
504 |
my $item = GetItem($itemnumber); |
Lines 535-542
sub CanItemBeReserved{
Link Here
|
535 |
LEFT JOIN borrowers USING (borrowernumber) |
535 |
LEFT JOIN borrowers USING (borrowernumber) |
536 |
WHERE borrowernumber = ? |
536 |
WHERE borrowernumber = ? |
537 |
"; |
537 |
"; |
538 |
|
538 |
|
539 |
|
539 |
|
540 |
my $branchcode = ""; |
540 |
my $branchcode = ""; |
541 |
my $branchfield = "reserves.branchcode"; |
541 |
my $branchfield = "reserves.branchcode"; |
542 |
|
542 |
|
Lines 547-558
sub CanItemBeReserved{
Link Here
|
547 |
$branchfield = "borrowers.branchcode"; |
547 |
$branchfield = "borrowers.branchcode"; |
548 |
$branchcode = $borrower->{branchcode}; |
548 |
$branchcode = $borrower->{branchcode}; |
549 |
} |
549 |
} |
550 |
|
550 |
|
551 |
# we retrieve rights |
551 |
# we retrieve rights |
552 |
$sth->execute($borrower->{'categorycode'}, $item->{'itype'}, $branchcode); |
552 |
$sth->execute($borrower->{'categorycode'}, $item->{'itype'}, $branchcode); |
553 |
if(my $rights = $sth->fetchrow_hashref()){ |
553 |
if(my $rights = $sth->fetchrow_hashref()){ |
554 |
$ruleitemtype = $rights->{itemtype}; |
554 |
$ruleitemtype = $rights->{itemtype}; |
555 |
$allowedreserves = $rights->{reservesallowed}; |
555 |
$allowedreserves = $rights->{reservesallowed}; |
556 |
}else{ |
556 |
}else{ |
557 |
$ruleitemtype = '*'; |
557 |
$ruleitemtype = '*'; |
558 |
} |
558 |
} |
Lines 560-569
sub CanItemBeReserved{
Link Here
|
560 |
# we retrieve count |
560 |
# we retrieve count |
561 |
|
561 |
|
562 |
$querycount .= "AND $branchfield = ?"; |
562 |
$querycount .= "AND $branchfield = ?"; |
563 |
|
563 |
|
564 |
$querycount .= " AND $itemtypefield = ?" if ($ruleitemtype ne "*"); |
564 |
$querycount .= " AND $itemtypefield = ?" if ($ruleitemtype ne "*"); |
565 |
my $sthcount = $dbh->prepare($querycount); |
565 |
my $sthcount = $dbh->prepare($querycount); |
566 |
|
566 |
|
567 |
if($ruleitemtype eq "*"){ |
567 |
if($ruleitemtype eq "*"){ |
568 |
$sthcount->execute($borrowernumber, $branchcode); |
568 |
$sthcount->execute($borrowernumber, $branchcode); |
569 |
}else{ |
569 |
}else{ |
Lines 818-825
sub GetReservesToBranch {
Link Here
|
818 |
my $dbh = C4::Context->dbh; |
818 |
my $dbh = C4::Context->dbh; |
819 |
my $sth = $dbh->prepare( |
819 |
my $sth = $dbh->prepare( |
820 |
"SELECT reserve_id,borrowernumber,reservedate,itemnumber,timestamp |
820 |
"SELECT reserve_id,borrowernumber,reservedate,itemnumber,timestamp |
821 |
FROM reserves |
821 |
FROM reserves |
822 |
WHERE priority='0' |
822 |
WHERE priority='0' |
823 |
AND branchcode=?" |
823 |
AND branchcode=?" |
824 |
); |
824 |
); |
825 |
$sth->execute( $frombranch ); |
825 |
$sth->execute( $frombranch ); |
Lines 844-850
sub GetReservesForBranch {
Link Here
|
844 |
|
844 |
|
845 |
my $query = " |
845 |
my $query = " |
846 |
SELECT reserve_id,borrowernumber,reservedate,itemnumber,waitingdate |
846 |
SELECT reserve_id,borrowernumber,reservedate,itemnumber,waitingdate |
847 |
FROM reserves |
847 |
FROM reserves |
848 |
WHERE priority='0' |
848 |
WHERE priority='0' |
849 |
AND found='W' |
849 |
AND found='W' |
850 |
"; |
850 |
"; |
Lines 1102-1108
sub CancelExpiredReserves {
Link Here
|
1102 |
manualinvoice($res->{'borrowernumber'}, $res->{'itemnumber'}, 'Hold waiting too long', 'F', $charge); |
1102 |
manualinvoice($res->{'borrowernumber'}, $res->{'itemnumber'}, 'Hold waiting too long', 'F', $charge); |
1103 |
} |
1103 |
} |
1104 |
|
1104 |
|
1105 |
CancelReserve({ reserve_id => $res->{'reserve_id'} }); |
1105 |
CancelReserve( |
|
|
1106 |
{ |
1107 |
reserve_id => $res->{'reserve_id'}, |
1108 |
autofill => C4::Context->preference('ExpireReservesAutoFill'), |
1109 |
} |
1110 |
); |
1106 |
} |
1111 |
} |
1107 |
} |
1112 |
} |
1108 |
} |
1113 |
} |
Lines 1129-1135
sub AutoUnsuspendReserves {
Link Here
|
1129 |
|
1134 |
|
1130 |
=head2 CancelReserve |
1135 |
=head2 CancelReserve |
1131 |
|
1136 |
|
1132 |
CancelReserve({ reserve_id => $reserve_id, [ biblionumber => $biblionumber, borrowernumber => $borrrowernumber, itemnumber => $itemnumber ] }); |
1137 |
CancelReserve({ reserve_id => $reserve_id, [ biblionumber => $biblionumber, borrowernumber => $borrrowernumber, itemnumber => $itemnumber, autofill => $autofill ] }); |
1133 |
|
1138 |
|
1134 |
Cancels a reserve. |
1139 |
Cancels a reserve. |
1135 |
|
1140 |
|
Lines 1139-1144
sub CancelReserve {
Link Here
|
1139 |
my ( $params ) = @_; |
1144 |
my ( $params ) = @_; |
1140 |
|
1145 |
|
1141 |
my $reserve_id = $params->{'reserve_id'}; |
1146 |
my $reserve_id = $params->{'reserve_id'}; |
|
|
1147 |
my $autofill = $params->{autofill}; |
1148 |
|
1142 |
$reserve_id = GetReserveId( $params ) unless ( $reserve_id ); |
1149 |
$reserve_id = GetReserveId( $params ) unless ( $reserve_id ); |
1143 |
|
1150 |
|
1144 |
return unless ( $reserve_id ); |
1151 |
return unless ( $reserve_id ); |
Lines 1174-1179
sub CancelReserve {
Link Here
|
1174 |
|
1181 |
|
1175 |
# now fix the priority on the others.... |
1182 |
# now fix the priority on the others.... |
1176 |
_FixPriority({ biblionumber => $reserve->{biblionumber} }); |
1183 |
_FixPriority({ biblionumber => $reserve->{biblionumber} }); |
|
|
1184 |
|
1185 |
# only attempt to autofill canceled holds that were found and waiting |
1186 |
if ( $autofill && $reserve->{itemnumber} && $reserve->{found} && $reserve->{found} eq 'W' ) { |
1187 |
my ( undef, $next_hold ) = CheckReserves( $reserve->{'itemnumber'} ); |
1188 |
if ($next_hold) { |
1189 |
my $is_transfer = $reserve->{branchcode} ne $next_hold->{branchcode}; |
1190 |
|
1191 |
ModReserveAffect( |
1192 |
{ |
1193 |
itemnumber => $reserve->{itemnumber}, |
1194 |
borrowernumber => $next_hold->{borrowernumber}, |
1195 |
is_transfer => $is_transfer, |
1196 |
notify_library => 1, |
1197 |
} |
1198 |
); |
1199 |
|
1200 |
ModItemTransfer( $reserve->{itemnumber}, $reserve->{branchcode}, $next_hold->{branchcode} ) |
1201 |
if $is_transfer; |
1202 |
} |
1203 |
} |
1177 |
} |
1204 |
} |
1178 |
|
1205 |
|
1179 |
return $reserve; |
1206 |
return $reserve; |
Lines 1367-1373
take care of the waiting status
Link Here
|
1367 |
=cut |
1394 |
=cut |
1368 |
|
1395 |
|
1369 |
sub ModReserveAffect { |
1396 |
sub ModReserveAffect { |
1370 |
my ( $itemnumber, $borrowernumber,$transferToDo ) = @_; |
1397 |
my ( $params ) = @_; |
|
|
1398 |
|
1399 |
my $itemnumber = $params->{itemnumber}; |
1400 |
my $borrowernumber = $params->{borrowernumber}; |
1401 |
my $transferToDo = $params->{is_transfer}; |
1402 |
my $notify_library = $params->{notify_library}; |
1403 |
|
1371 |
my $dbh = C4::Context->dbh; |
1404 |
my $dbh = C4::Context->dbh; |
1372 |
|
1405 |
|
1373 |
# we want to attach $itemnumber to $borrowernumber, find the biblionumber |
1406 |
# we want to attach $itemnumber to $borrowernumber, find the biblionumber |
Lines 1412-1419
sub ModReserveAffect {
Link Here
|
1412 |
} |
1445 |
} |
1413 |
$sth = $dbh->prepare($query); |
1446 |
$sth = $dbh->prepare($query); |
1414 |
$sth->execute( $itemnumber, $borrowernumber,$biblionumber); |
1447 |
$sth->execute( $itemnumber, $borrowernumber,$biblionumber); |
1415 |
_koha_notify_reserve( $itemnumber, $borrowernumber, $biblionumber ) if ( !$transferToDo && !$already_on_shelf ); |
1448 |
|
|
|
1449 |
_koha_notify_reserve( |
1450 |
{ |
1451 |
itemnumber => $itemnumber, |
1452 |
borrowernumber => $borrowernumber, |
1453 |
biblionumber => $biblionumber, |
1454 |
notify_library => $notify_library, |
1455 |
} |
1456 |
) if ( !$transferToDo && !$already_on_shelf ); |
1457 |
|
1416 |
_FixPriority( { biblionumber => $biblionumber } ); |
1458 |
_FixPriority( { biblionumber => $biblionumber } ); |
|
|
1459 |
|
1417 |
if ( C4::Context->preference("ReturnToShelvingCart") ) { |
1460 |
if ( C4::Context->preference("ReturnToShelvingCart") ) { |
1418 |
CartToShelf( $itemnumber ); |
1461 |
CartToShelf( $itemnumber ); |
1419 |
} |
1462 |
} |
Lines 1458-1464
sub ModReserveMinusPriority {
Link Here
|
1458 |
my $dbh = C4::Context->dbh; |
1501 |
my $dbh = C4::Context->dbh; |
1459 |
my $query = " |
1502 |
my $query = " |
1460 |
UPDATE reserves |
1503 |
UPDATE reserves |
1461 |
SET priority = 0 , itemnumber = ? |
1504 |
SET priority = 0 , itemnumber = ? |
1462 |
WHERE reserve_id = ? |
1505 |
WHERE reserve_id = ? |
1463 |
"; |
1506 |
"; |
1464 |
my $sth_upd = $dbh->prepare($query); |
1507 |
my $sth_upd = $dbh->prepare($query); |
Lines 1673-1679
sub ToggleLowestPriority {
Link Here
|
1673 |
|
1716 |
|
1674 |
my $sth = $dbh->prepare( "UPDATE reserves SET lowestPriority = NOT lowestPriority WHERE reserve_id = ?"); |
1717 |
my $sth = $dbh->prepare( "UPDATE reserves SET lowestPriority = NOT lowestPriority WHERE reserve_id = ?"); |
1675 |
$sth->execute( $reserve_id ); |
1718 |
$sth->execute( $reserve_id ); |
1676 |
|
1719 |
|
1677 |
_FixPriority({ reserve_id => $reserve_id, rank => '999999' }); |
1720 |
_FixPriority({ reserve_id => $reserve_id, rank => '999999' }); |
1678 |
} |
1721 |
} |
1679 |
|
1722 |
|
Lines 1882-1888
sub _FixPriority {
Link Here
|
1882 |
$priority[$j]->{'reserve_id'} |
1925 |
$priority[$j]->{'reserve_id'} |
1883 |
); |
1926 |
); |
1884 |
} |
1927 |
} |
1885 |
|
1928 |
|
1886 |
$sth = $dbh->prepare( "SELECT reserve_id FROM reserves WHERE lowestPriority = 1 ORDER BY priority" ); |
1929 |
$sth = $dbh->prepare( "SELECT reserve_id FROM reserves WHERE lowestPriority = 1 ORDER BY priority" ); |
1887 |
$sth->execute(); |
1930 |
$sth->execute(); |
1888 |
|
1931 |
|
Lines 2026-2032
sub _Findgroupreserve {
Link Here
|
2026 |
|
2069 |
|
2027 |
=head2 _koha_notify_reserve |
2070 |
=head2 _koha_notify_reserve |
2028 |
|
2071 |
|
2029 |
_koha_notify_reserve( $itemnumber, $borrowernumber, $biblionumber ); |
2072 |
_koha_notify_reserve( |
|
|
2073 |
{ |
2074 |
itemnumber => $itemnumber, |
2075 |
borrowernumber => $borrowernumber, |
2076 |
biblionumber => $biblionumber, |
2077 |
notify_library => $notify_library |
2078 |
} |
2079 |
); |
2030 |
|
2080 |
|
2031 |
Sends a notification to the patron that their hold has been filled (through |
2081 |
Sends a notification to the patron that their hold has been filled (through |
2032 |
ModReserveAffect, _not_ ModReserveFill) |
2082 |
ModReserveAffect, _not_ ModReserveFill) |
Lines 2034-2040
ModReserveAffect, _not_ ModReserveFill)
Link Here
|
2034 |
=cut |
2084 |
=cut |
2035 |
|
2085 |
|
2036 |
sub _koha_notify_reserve { |
2086 |
sub _koha_notify_reserve { |
2037 |
my ($itemnumber, $borrowernumber, $biblionumber) = @_; |
2087 |
my ( $params ) = @_; |
|
|
2088 |
|
2089 |
my $itemnumber = $params->{itemnumber}; |
2090 |
my $borrowernumber = $params->{borrowernumber}; |
2091 |
my $biblionumber = $params->{biblionumber}; |
2092 |
my $notify_library = $params->{notify_library}; |
2038 |
|
2093 |
|
2039 |
my $dbh = C4::Context->dbh; |
2094 |
my $dbh = C4::Context->dbh; |
2040 |
my $borrower = C4::Members::GetMember(borrowernumber => $borrowernumber); |
2095 |
my $borrower = C4::Members::GetMember(borrowernumber => $borrowernumber); |
Lines 2084-2095
sub _koha_notify_reserve {
Link Here
|
2084 |
return; |
2139 |
return; |
2085 |
} |
2140 |
} |
2086 |
|
2141 |
|
2087 |
C4::Letters::EnqueueLetter( { |
2142 |
C4::Letters::EnqueueLetter( |
2088 |
letter => $letter, |
2143 |
{ |
2089 |
borrowernumber => $borrowernumber, |
2144 |
letter => $letter, |
2090 |
from_address => $admin_email_address, |
2145 |
borrowernumber => $borrowernumber, |
2091 |
message_transport_type => $mtt, |
2146 |
from_address => $admin_email_address, |
2092 |
} ); |
2147 |
message_transport_type => $mtt, |
|
|
2148 |
} |
2149 |
); |
2093 |
}; |
2150 |
}; |
2094 |
|
2151 |
|
2095 |
while ( my ( $mtt, $letter_code ) = each %{ $messagingprefs->{transports} } ) { |
2152 |
while ( my ( $mtt, $letter_code ) = each %{ $messagingprefs->{transports} } ) { |
Lines 2106-2112
sub _koha_notify_reserve {
Link Here
|
2106 |
if (! $notification_sent) { |
2163 |
if (! $notification_sent) { |
2107 |
&$send_notification('print', 'HOLD'); |
2164 |
&$send_notification('print', 'HOLD'); |
2108 |
} |
2165 |
} |
2109 |
|
2166 |
|
|
|
2167 |
if ($notify_library) { |
2168 |
my $letter = C4::Letters::GetPreparedLetter( |
2169 |
module => 'reserves', |
2170 |
letter_code => 'HOLD_CHANGED', |
2171 |
branchcode => $reserve->{branchcode}, |
2172 |
substitute => { today => C4::Dates->new()->output() }, |
2173 |
tables => { |
2174 |
'branches' => $branch_details, |
2175 |
'borrowers' => $borrower, |
2176 |
'biblio' => $biblionumber, |
2177 |
'reserves' => $reserve, |
2178 |
'items' => $reserve->{'itemnumber'}, |
2179 |
}, |
2180 |
); |
2181 |
|
2182 |
my $email = |
2183 |
C4::Context->preference('ExpireReservesAutoFillEmail') |
2184 |
|| $branch_details->{'branchemail'} |
2185 |
|| C4::Context->preference('KohaAdminEmailAddress'); |
2186 |
|
2187 |
C4::Letters::EnqueueLetter( |
2188 |
{ |
2189 |
letter => $letter, |
2190 |
borrowernumber => $borrowernumber, |
2191 |
message_transport_type => 'email', |
2192 |
from_address => $email, |
2193 |
to_address => $email, |
2194 |
} |
2195 |
); |
2196 |
} |
2110 |
} |
2197 |
} |
2111 |
|
2198 |
|
2112 |
=head2 _ShiftPriorityByDateAndPriority |
2199 |
=head2 _ShiftPriorityByDateAndPriority |