Lines 109-114
BEGIN {
Link Here
|
109 |
&ModReserveStatus |
109 |
&ModReserveStatus |
110 |
&ModReserveCancelAll |
110 |
&ModReserveCancelAll |
111 |
&ModReserveMinusPriority |
111 |
&ModReserveMinusPriority |
|
|
112 |
&MoveReserve |
112 |
|
113 |
|
113 |
&CheckReserves |
114 |
&CheckReserves |
114 |
&CanBookBeReserved |
115 |
&CanBookBeReserved |
Lines 731-738
sub GetReserveStatus {
Link Here
|
731 |
|
732 |
|
732 |
=head2 CheckReserves |
733 |
=head2 CheckReserves |
733 |
|
734 |
|
734 |
($status, $reserve) = &CheckReserves($itemnumber); |
735 |
($status, $reserve, $all_reserves) = &CheckReserves($itemnumber); |
735 |
($status, $reserve) = &CheckReserves(undef, $barcode); |
736 |
($status, $reserve, $all_reserves) = &CheckReserves(undef, $barcode); |
736 |
|
737 |
|
737 |
Find a book in the reserves. |
738 |
Find a book in the reserves. |
738 |
|
739 |
|
Lines 800-806
sub CheckReserves {
Link Here
|
800 |
my $priority = 10000000; |
801 |
my $priority = 10000000; |
801 |
foreach my $res (@reserves) { |
802 |
foreach my $res (@reserves) { |
802 |
if ( $res->{'itemnumber'} == $itemnumber && $res->{'priority'} == 0) { |
803 |
if ( $res->{'itemnumber'} == $itemnumber && $res->{'priority'} == 0) { |
803 |
return ( "Waiting", $res ); # Found it |
804 |
return ( "Waiting", $res, \@reserves ); # Found it |
804 |
} else { |
805 |
} else { |
805 |
# See if this item is more important than what we've got so far |
806 |
# See if this item is more important than what we've got so far |
806 |
if ( $res->{'priority'} && $res->{'priority'} < $priority ) { |
807 |
if ( $res->{'priority'} && $res->{'priority'} < $priority ) { |
Lines 821-827
sub CheckReserves {
Link Here
|
821 |
# We return the most important (i.e. next) reservation. |
822 |
# We return the most important (i.e. next) reservation. |
822 |
if ($highest) { |
823 |
if ($highest) { |
823 |
$highest->{'itemnumber'} = $item; |
824 |
$highest->{'itemnumber'} = $item; |
824 |
return ( "Reserved", $highest ); |
825 |
return ( "Reserved", $highest, \@reserves ); |
825 |
} |
826 |
} |
826 |
else { |
827 |
else { |
827 |
return ( 0, 0 ); |
828 |
return ( 0, 0 ); |
Lines 1794-1799
sub _ShiftPriorityByDateAndPriority {
Link Here
|
1794 |
return $new_priority; # so the caller knows what priority they wind up receiving |
1795 |
return $new_priority; # so the caller knows what priority they wind up receiving |
1795 |
} |
1796 |
} |
1796 |
|
1797 |
|
|
|
1798 |
|
1799 |
=head2 MoveReserve |
1800 |
|
1801 |
MoveReserve( $itemnumber, $borrowernumber, $cancelreserve ) |
1802 |
|
1803 |
Use when checking out an item to handle reserves |
1804 |
If $cancelreserve boolean is set to true, it will remove existing reserve |
1805 |
|
1806 |
=cut |
1807 |
|
1808 |
sub MoveReserve { |
1809 |
my ( $itemnumber, $borrowernumber, $cancelreserve ) = @_; |
1810 |
|
1811 |
my ( $restype, $res, $all_reserves ) = CheckReserves( $itemnumber ); |
1812 |
return unless $res; |
1813 |
|
1814 |
my $biblionumber = $res->{biblionumber}; |
1815 |
my $biblioitemnumber = $res->{biblioitemnumber}; |
1816 |
|
1817 |
if ($res->{borrowernumber} == $borrowernumber) { |
1818 |
ModReserveFill($res); |
1819 |
} |
1820 |
else { |
1821 |
# warn "Reserved"; |
1822 |
# The item is reserved by someone else. |
1823 |
# Find this item in the reserves |
1824 |
|
1825 |
my $borr_res; |
1826 |
foreach (@$all_reserves) { |
1827 |
$_->{'borrowernumber'} == $borrowernumber or next; |
1828 |
$_->{'biblionumber'} == $biblionumber or next; |
1829 |
|
1830 |
$borr_res = $_; |
1831 |
last; |
1832 |
} |
1833 |
|
1834 |
if ( $borr_res ) { |
1835 |
# The item is reserved by the current patron |
1836 |
ModReserveFill($borr_res); |
1837 |
} |
1838 |
|
1839 |
if ($cancelreserve) { # cancel reserves on this item |
1840 |
CancelReserve(0, $res->{'itemnumber'}, $res->{'borrowernumber'}); |
1841 |
CancelReserve($res->{'biblionumber'}, 0, $res->{'borrowernumber'}); |
1842 |
} |
1843 |
} |
1844 |
} |
1845 |
|
1846 |
|
1797 |
=head1 AUTHOR |
1847 |
=head1 AUTHOR |
1798 |
|
1848 |
|
1799 |
Koha Development Team <http://koha-community.org/> |
1849 |
Koha Development Team <http://koha-community.org/> |