Lines 117-126
BEGIN {
Link Here
|
117 |
&CancelReserve |
117 |
&CancelReserve |
118 |
&CancelExpiredReserves |
118 |
&CancelExpiredReserves |
119 |
|
119 |
|
|
|
120 |
&AutoUnsuspendReserves |
121 |
|
120 |
&IsAvailableForItemLevelRequest |
122 |
&IsAvailableForItemLevelRequest |
121 |
|
123 |
|
122 |
&AlterPriority |
124 |
&AlterPriority |
123 |
&ToggleLowestPriority |
125 |
&ToggleLowestPriority |
|
|
126 |
&ToggleSuspend |
127 |
&SuspendAll |
124 |
); |
128 |
); |
125 |
@EXPORT_OK = qw( MergeHolds ); |
129 |
@EXPORT_OK = qw( MergeHolds ); |
126 |
} |
130 |
} |
Lines 263-269
sub GetReservesFromBiblionumber {
Link Here
|
263 |
itemnumber, |
267 |
itemnumber, |
264 |
reservenotes, |
268 |
reservenotes, |
265 |
expirationdate, |
269 |
expirationdate, |
266 |
lowestPriority |
270 |
lowestPriority, |
|
|
271 |
suspend, |
272 |
suspend_until |
267 |
FROM reserves |
273 |
FROM reserves |
268 |
WHERE biblionumber = ? "; |
274 |
WHERE biblionumber = ? "; |
269 |
unless ( $all_dates ) { |
275 |
unless ( $all_dates ) { |
Lines 873-878
sub CancelExpiredReserves {
Link Here
|
873 |
|
879 |
|
874 |
} |
880 |
} |
875 |
|
881 |
|
|
|
882 |
=head2 AutoUnsuspendReserves |
883 |
|
884 |
AutoUnsuspendReserves(); |
885 |
|
886 |
Unsuspends all suspended reserves with a suspend_until date from before today. |
887 |
|
888 |
=cut |
889 |
|
890 |
sub AutoUnsuspendReserves { |
891 |
|
892 |
my $dbh = C4::Context->dbh; |
893 |
|
894 |
my $query = "UPDATE reserves SET suspend = 0, suspend_until = NULL WHERE DATE( suspend_until ) < DATE( CURDATE() )"; |
895 |
my $sth = $dbh->prepare( $query ); |
896 |
$sth->execute(); |
897 |
|
898 |
} |
899 |
|
876 |
=head2 CancelReserve |
900 |
=head2 CancelReserve |
877 |
|
901 |
|
878 |
&CancelReserve($biblionumber, $itemnumber, $borrowernumber); |
902 |
&CancelReserve($biblionumber, $itemnumber, $borrowernumber); |
Lines 1008-1014
itemnumber and supplying itemnumber.
Link Here
|
1008 |
|
1032 |
|
1009 |
sub ModReserve { |
1033 |
sub ModReserve { |
1010 |
#subroutine to update a reserve |
1034 |
#subroutine to update a reserve |
1011 |
my ( $rank, $biblio, $borrower, $branch , $itemnumber) = @_; |
1035 |
my ( $rank, $biblio, $borrower, $branch , $itemnumber, $suspend_until) = @_; |
1012 |
return if $rank eq "W"; |
1036 |
return if $rank eq "W"; |
1013 |
return if $rank eq "n"; |
1037 |
return if $rank eq "n"; |
1014 |
my $dbh = C4::Context->dbh; |
1038 |
my $dbh = C4::Context->dbh; |
Lines 1041-1054
sub ModReserve {
Link Here
|
1041 |
|
1065 |
|
1042 |
} |
1066 |
} |
1043 |
elsif ($rank =~ /^\d+/ and $rank > 0) { |
1067 |
elsif ($rank =~ /^\d+/ and $rank > 0) { |
1044 |
my $query = qq/ |
1068 |
my $query = " |
1045 |
UPDATE reserves SET priority = ? ,branchcode = ?, itemnumber = ?, found = NULL, waitingdate = NULL |
1069 |
UPDATE reserves SET priority = ? ,branchcode = ?, itemnumber = ?, found = NULL, waitingdate = NULL |
1046 |
WHERE biblionumber = ? |
1070 |
WHERE biblionumber = ? |
1047 |
AND borrowernumber = ? |
1071 |
AND borrowernumber = ? |
1048 |
/; |
1072 |
"; |
1049 |
my $sth = $dbh->prepare($query); |
1073 |
my $sth = $dbh->prepare($query); |
1050 |
$sth->execute( $rank, $branch,$itemnumber, $biblio, $borrower); |
1074 |
$sth->execute( $rank, $branch,$itemnumber, $biblio, $borrower); |
1051 |
$sth->finish; |
1075 |
$sth->finish; |
|
|
1076 |
|
1077 |
if ( defined( $suspend_until ) ) { |
1078 |
if ( $suspend_until ) { |
1079 |
$suspend_until = C4::Dates->new( $suspend_until )->output("iso"); |
1080 |
warn "SUSPEND UNTIL: $suspend_until"; |
1081 |
$dbh->do("UPDATE reserves SET suspend = 1, suspend_until = ? WHERE biblionumber = ? AND borrowernumber = ?", undef, ( $suspend_until, $biblio, $borrower ) ); |
1082 |
} else { |
1083 |
$dbh->do("UPDATE reserves SET suspend_until = NULL WHERE biblionumber = ? AND borrowernumber = ?", undef, ( $biblio, $borrower ) ); |
1084 |
} |
1085 |
} |
1086 |
|
1052 |
_FixPriority( $biblio, $borrower, $rank); |
1087 |
_FixPriority( $biblio, $borrower, $rank); |
1053 |
} |
1088 |
} |
1054 |
} |
1089 |
} |
Lines 1455-1460
sub ToggleLowestPriority {
Link Here
|
1455 |
_FixPriority( $biblionumber, $borrowernumber, '999999' ); |
1490 |
_FixPriority( $biblionumber, $borrowernumber, '999999' ); |
1456 |
} |
1491 |
} |
1457 |
|
1492 |
|
|
|
1493 |
=head2 ToggleSuspend |
1494 |
|
1495 |
ToggleSuspend( $borrowernumber, $biblionumber ); |
1496 |
|
1497 |
This function sets the suspend field to true if is false, and false if it is true. |
1498 |
If the reserve is currently suspended with a suspend_until date, that date will |
1499 |
be cleared when it is unsuspended. |
1500 |
|
1501 |
=cut |
1502 |
|
1503 |
sub ToggleSuspend { |
1504 |
my ( $borrowernumber, $biblionumber ) = @_; |
1505 |
|
1506 |
my $dbh = C4::Context->dbh; |
1507 |
|
1508 |
my $sth = $dbh->prepare( |
1509 |
"UPDATE reserves SET suspend = NOT suspend, |
1510 |
suspend_until = CASE WHEN suspend = 0 THEN NULL ELSE suspend_until END |
1511 |
WHERE biblionumber = ? |
1512 |
AND borrowernumber = ? |
1513 |
"); |
1514 |
$sth->execute( |
1515 |
$biblionumber, |
1516 |
$borrowernumber, |
1517 |
); |
1518 |
$sth->finish; |
1519 |
} |
1520 |
|
1521 |
=head2 SuspendAll |
1522 |
|
1523 |
SuspendAll( |
1524 |
borrowernumber => $borrowernumber, |
1525 |
[ biblionumber => $biblionumber, ] |
1526 |
[ suspend_until => $suspend_until, ] |
1527 |
[ suspend => $suspend ] |
1528 |
); |
1529 |
|
1530 |
This function accepts a set of hash keys as its parameters. |
1531 |
It requires either borrowernumber or biblionumber, or both. |
1532 |
|
1533 |
suspend_until is wholly optional. |
1534 |
|
1535 |
=cut |
1536 |
|
1537 |
sub SuspendAll { |
1538 |
my %params = @_; |
1539 |
|
1540 |
my $borrowernumber = $params{'borrowernumber'} || undef; |
1541 |
my $biblionumber = $params{'biblionumber'} || undef; |
1542 |
my $suspend_until = $params{'suspend_until'} || undef; |
1543 |
my $suspend = defined( $params{'suspend'} ) ? $params{'suspend'} : 1; |
1544 |
|
1545 |
warn "C4::Reserves::SuspendAll( borrowernumber => $borrowernumber, biblionumber => $biblionumber, suspend_until => $suspend_until, suspend => $suspend )"; |
1546 |
|
1547 |
$suspend_until = C4::Dates->new( $suspend_until )->output("iso") if ( defined( $suspend_until ) ); |
1548 |
|
1549 |
return unless ( $borrowernumber || $biblionumber ); |
1550 |
|
1551 |
my ( $query, $sth, $dbh, @query_params ); |
1552 |
|
1553 |
$query = "UPDATE reserves SET suspend = ? "; |
1554 |
push( @query_params, $suspend ); |
1555 |
if ( !$suspend ) { |
1556 |
$query .= ", suspend_until = NULL "; |
1557 |
} elsif ( $suspend_until ) { |
1558 |
$query .= ", suspend_until = ? "; |
1559 |
push( @query_params, $suspend_until ); |
1560 |
} |
1561 |
$query .= " WHERE "; |
1562 |
if ( $borrowernumber ) { |
1563 |
$query .= " borrowernumber = ? "; |
1564 |
push( @query_params, $borrowernumber ); |
1565 |
} |
1566 |
$query .= " AND " if ( $borrowernumber && $biblionumber ); |
1567 |
if ( $biblionumber ) { |
1568 |
$query .= " biblionumber = ? "; |
1569 |
push( @query_params, $biblionumber ); |
1570 |
} |
1571 |
$query .= " AND found IS NULL "; |
1572 |
|
1573 |
$dbh = C4::Context->dbh; |
1574 |
$sth = $dbh->prepare( $query ); |
1575 |
$sth->execute( @query_params ); |
1576 |
$sth->finish; |
1577 |
} |
1578 |
|
1579 |
|
1458 |
=head2 _FixPriority |
1580 |
=head2 _FixPriority |
1459 |
|
1581 |
|
1460 |
&_FixPriority($biblio,$borrowernumber,$rank,$ignoreSetLowestRank); |
1582 |
&_FixPriority($biblio,$borrowernumber,$rank,$ignoreSetLowestRank); |
Lines 1599-1604
sub _Findgroupreserve {
Link Here
|
1599 |
AND item_level_request = 1 |
1721 |
AND item_level_request = 1 |
1600 |
AND itemnumber = ? |
1722 |
AND itemnumber = ? |
1601 |
AND reservedate <= CURRENT_DATE() |
1723 |
AND reservedate <= CURRENT_DATE() |
|
|
1724 |
AND suspend = 0 |
1602 |
/; |
1725 |
/; |
1603 |
my $sth = $dbh->prepare($item_level_target_query); |
1726 |
my $sth = $dbh->prepare($item_level_target_query); |
1604 |
$sth->execute($itemnumber); |
1727 |
$sth->execute($itemnumber); |
Lines 1629-1634
sub _Findgroupreserve {
Link Here
|
1629 |
AND item_level_request = 0 |
1752 |
AND item_level_request = 0 |
1630 |
AND hold_fill_targets.itemnumber = ? |
1753 |
AND hold_fill_targets.itemnumber = ? |
1631 |
AND reservedate <= CURRENT_DATE() |
1754 |
AND reservedate <= CURRENT_DATE() |
|
|
1755 |
AND suspend = 0 |
1632 |
/; |
1756 |
/; |
1633 |
$sth = $dbh->prepare($title_level_target_query); |
1757 |
$sth = $dbh->prepare($title_level_target_query); |
1634 |
$sth->execute($itemnumber); |
1758 |
$sth->execute($itemnumber); |
Lines 1660-1665
sub _Findgroupreserve {
Link Here
|
1660 |
OR reserves.constrainttype='a' ) |
1784 |
OR reserves.constrainttype='a' ) |
1661 |
AND (reserves.itemnumber IS NULL OR reserves.itemnumber = ?) |
1785 |
AND (reserves.itemnumber IS NULL OR reserves.itemnumber = ?) |
1662 |
AND reserves.reservedate <= CURRENT_DATE() |
1786 |
AND reserves.reservedate <= CURRENT_DATE() |
|
|
1787 |
AND suspend = 0 |
1663 |
/; |
1788 |
/; |
1664 |
$sth = $dbh->prepare($query); |
1789 |
$sth = $dbh->prepare($query); |
1665 |
$sth->execute( $biblio, $bibitem, $itemnumber ); |
1790 |
$sth->execute( $biblio, $bibitem, $itemnumber ); |