Lines 775-784
sub GetReserveStatus {
Link Here
|
775 |
|
775 |
|
776 |
($status, $reserve, $all_reserves) = &CheckReserves($itemnumber); |
776 |
($status, $reserve, $all_reserves) = &CheckReserves($itemnumber); |
777 |
($status, $reserve, $all_reserves) = &CheckReserves(undef, $barcode); |
777 |
($status, $reserve, $all_reserves) = &CheckReserves(undef, $barcode); |
|
|
778 |
($status, $reserve, $all_reserves) = &CheckReserves($itemnumber,undef,$lookahead); |
778 |
|
779 |
|
779 |
Find a book in the reserves. |
780 |
Find a book in the reserves. |
780 |
|
781 |
|
781 |
C<$itemnumber> is the book's item number. |
782 |
C<$itemnumber> is the book's item number. |
|
|
783 |
C<$lookahead> is the number of days to look in advance for future reserves. |
782 |
|
784 |
|
783 |
As I understand it, C<&CheckReserves> looks for the given item in the |
785 |
As I understand it, C<&CheckReserves> looks for the given item in the |
784 |
reserves. If it is found, that's a match, and C<$status> is set to |
786 |
reserves. If it is found, that's a match, and C<$status> is set to |
Lines 799-805
table in the Koha database.
Link Here
|
799 |
=cut |
801 |
=cut |
800 |
|
802 |
|
801 |
sub CheckReserves { |
803 |
sub CheckReserves { |
802 |
my ( $item, $barcode ) = @_; |
804 |
my ( $item, $barcode, $lookahead_days) = @_; |
803 |
my $dbh = C4::Context->dbh; |
805 |
my $dbh = C4::Context->dbh; |
804 |
my $sth; |
806 |
my $sth; |
805 |
my $select; |
807 |
my $select; |
Lines 846-852
sub CheckReserves {
Link Here
|
846 |
return ( '' ) if ( $notforloan_per_item > 0 ) or $notforloan_per_itemtype; |
848 |
return ( '' ) if ( $notforloan_per_item > 0 ) or $notforloan_per_itemtype; |
847 |
|
849 |
|
848 |
# Find this item in the reserves |
850 |
# Find this item in the reserves |
849 |
my @reserves = _Findgroupreserve( $bibitem, $biblio, $itemnumber ); |
851 |
my @reserves = _Findgroupreserve( $bibitem, $biblio, $itemnumber, $lookahead_days); |
850 |
|
852 |
|
851 |
# $priority and $highest are used to find the most important item |
853 |
# $priority and $highest are used to find the most important item |
852 |
# in the list returned by &_Findgroupreserve. (The lower $priority, |
854 |
# in the list returned by &_Findgroupreserve. (The lower $priority, |
Lines 1728-1738
sub _FixPriority {
Link Here
|
1728 |
|
1730 |
|
1729 |
=head2 _Findgroupreserve |
1731 |
=head2 _Findgroupreserve |
1730 |
|
1732 |
|
1731 |
@results = &_Findgroupreserve($biblioitemnumber, $biblionumber, $itemnumber); |
1733 |
@results = &_Findgroupreserve($biblioitemnumber, $biblionumber, $itemnumber, $lookahead); |
1732 |
|
1734 |
|
1733 |
Looks for an item-specific match first, then for a title-level match, returning the |
1735 |
Looks for an item-specific match first, then for a title-level match, returning the |
1734 |
first match found. If neither, then we look for a 3rd kind of match based on |
1736 |
first match found. If neither, then we look for a 3rd kind of match based on |
1735 |
reserve constraints. |
1737 |
reserve constraints. |
|
|
1738 |
Lookahead is the number of days to look in advance. |
1736 |
|
1739 |
|
1737 |
TODO: add more explanation about reserve constraints |
1740 |
TODO: add more explanation about reserve constraints |
1738 |
|
1741 |
|
Lines 1744-1750
C<biblioitemnumber>.
Link Here
|
1744 |
=cut |
1747 |
=cut |
1745 |
|
1748 |
|
1746 |
sub _Findgroupreserve { |
1749 |
sub _Findgroupreserve { |
1747 |
my ( $bibitem, $biblio, $itemnumber ) = @_; |
1750 |
my ( $bibitem, $biblio, $itemnumber, $lookahead) = @_; |
1748 |
my $dbh = C4::Context->dbh; |
1751 |
my $dbh = C4::Context->dbh; |
1749 |
|
1752 |
|
1750 |
# TODO: consolidate at least the SELECT portion of the first 2 queries to a common $select var. |
1753 |
# TODO: consolidate at least the SELECT portion of the first 2 queries to a common $select var. |
Lines 1768-1778
sub _Findgroupreserve {
Link Here
|
1768 |
AND priority > 0 |
1771 |
AND priority > 0 |
1769 |
AND item_level_request = 1 |
1772 |
AND item_level_request = 1 |
1770 |
AND itemnumber = ? |
1773 |
AND itemnumber = ? |
1771 |
AND reservedate <= CURRENT_DATE() |
1774 |
AND reservedate <= DATE_ADD(NOW(),INTERVAL ? DAY) |
1772 |
AND suspend = 0 |
1775 |
AND suspend = 0 |
1773 |
/; |
1776 |
/; |
1774 |
my $sth = $dbh->prepare($item_level_target_query); |
1777 |
my $sth = $dbh->prepare($item_level_target_query); |
1775 |
$sth->execute($itemnumber); |
1778 |
$sth->execute($itemnumber, $lookahead||0); |
1776 |
my @results; |
1779 |
my @results; |
1777 |
if ( my $data = $sth->fetchrow_hashref ) { |
1780 |
if ( my $data = $sth->fetchrow_hashref ) { |
1778 |
push( @results, $data ); |
1781 |
push( @results, $data ); |
Lines 1799-1809
sub _Findgroupreserve {
Link Here
|
1799 |
AND priority > 0 |
1802 |
AND priority > 0 |
1800 |
AND item_level_request = 0 |
1803 |
AND item_level_request = 0 |
1801 |
AND hold_fill_targets.itemnumber = ? |
1804 |
AND hold_fill_targets.itemnumber = ? |
1802 |
AND reservedate <= CURRENT_DATE() |
1805 |
AND reservedate <= DATE_ADD(NOW(),INTERVAL ? DAY) |
1803 |
AND suspend = 0 |
1806 |
AND suspend = 0 |
1804 |
/; |
1807 |
/; |
1805 |
$sth = $dbh->prepare($title_level_target_query); |
1808 |
$sth = $dbh->prepare($title_level_target_query); |
1806 |
$sth->execute($itemnumber); |
1809 |
$sth->execute($itemnumber, $lookahead||0); |
1807 |
@results = (); |
1810 |
@results = (); |
1808 |
if ( my $data = $sth->fetchrow_hashref ) { |
1811 |
if ( my $data = $sth->fetchrow_hashref ) { |
1809 |
push( @results, $data ); |
1812 |
push( @results, $data ); |
Lines 1831-1841
sub _Findgroupreserve {
Link Here
|
1831 |
AND reserves.reservedate = reserveconstraints.reservedate ) |
1834 |
AND reserves.reservedate = reserveconstraints.reservedate ) |
1832 |
OR reserves.constrainttype='a' ) |
1835 |
OR reserves.constrainttype='a' ) |
1833 |
AND (reserves.itemnumber IS NULL OR reserves.itemnumber = ?) |
1836 |
AND (reserves.itemnumber IS NULL OR reserves.itemnumber = ?) |
1834 |
AND reserves.reservedate <= CURRENT_DATE() |
1837 |
AND reserves.reservedate <= DATE_ADD(NOW(),INTERVAL ? DAY) |
1835 |
AND suspend = 0 |
1838 |
AND suspend = 0 |
1836 |
/; |
1839 |
/; |
1837 |
$sth = $dbh->prepare($query); |
1840 |
$sth = $dbh->prepare($query); |
1838 |
$sth->execute( $biblio, $bibitem, $itemnumber ); |
1841 |
$sth->execute( $biblio, $bibitem, $itemnumber, $lookahead||0); |
1839 |
@results = (); |
1842 |
@results = (); |
1840 |
while ( my $data = $sth->fetchrow_hashref ) { |
1843 |
while ( my $data = $sth->fetchrow_hashref ) { |
1841 |
push( @results, $data ); |
1844 |
push( @results, $data ); |