|
Lines 1788-1800
sub FixPriority {
Link Here
|
| 1788 |
} |
1788 |
} |
| 1789 |
my @priority; |
1789 |
my @priority; |
| 1790 |
|
1790 |
|
| 1791 |
# get what's left |
1791 |
# get what's left, sorting lowestPriority holds to the bottom |
| 1792 |
my $query = " |
1792 |
my $query = " |
| 1793 |
SELECT reserve_id, borrowernumber, reservedate |
1793 |
SELECT reserve_id, borrowernumber, reservedate |
| 1794 |
FROM reserves |
1794 |
FROM reserves |
| 1795 |
WHERE biblionumber = ? |
1795 |
WHERE biblionumber = ? |
| 1796 |
AND ((found <> 'W' AND found <> 'T' AND found <> 'P') OR found IS NULL) |
1796 |
AND ((found <> 'W' AND found <> 'T' AND found <> 'P') OR found IS NULL) |
| 1797 |
ORDER BY priority ASC |
1797 |
ORDER BY lowestPriority ASC, priority ASC |
| 1798 |
"; |
1798 |
"; |
| 1799 |
my $sth = $dbh->prepare($query); |
1799 |
my $sth = $dbh->prepare($query); |
| 1800 |
$sth->execute($biblionumber); |
1800 |
$sth->execute($biblionumber); |
|
Lines 1813-1818
sub FixPriority {
Link Here
|
| 1813 |
} |
1813 |
} |
| 1814 |
} |
1814 |
} |
| 1815 |
|
1815 |
|
|
|
1816 |
# if this hold is marked lowest priority, we can only move it so far |
| 1817 |
if ( $hold && $hold->lowestPriority && $rank ne 'del' ) { |
| 1818 |
my $query = " |
| 1819 |
SELECT max(priority) |
| 1820 |
FROM reserves |
| 1821 |
WHERE biblionumber = ? |
| 1822 |
AND ((found <> 'W' AND found <> 'T' AND found <> 'P') OR found IS NULL) |
| 1823 |
AND lowestPriority = 0; |
| 1824 |
"; |
| 1825 |
my $sth = $dbh->prepare($query); |
| 1826 |
$sth->execute($biblionumber); |
| 1827 |
my ($highest_non_lowest_priority) = $sth->fetchrow_array(); |
| 1828 |
$rank = $highest_non_lowest_priority + 1 |
| 1829 |
if ( $highest_non_lowest_priority && $rank <= $highest_non_lowest_priority ); |
| 1830 |
} |
| 1831 |
|
| 1816 |
# if index exists in array then move it to new position |
1832 |
# if index exists in array then move it to new position |
| 1817 |
if ( $key > -1 && $rank ne 'del' && $rank > 0 ) { |
1833 |
if ( $key > -1 && $rank ne 'del' && $rank > 0 ) { |
| 1818 |
my $new_rank = $rank - 1; # $new_rank is what you want the new index to be in the array |
1834 |
my $new_rank = $rank - 1; # $new_rank is what you want the new index to be in the array |
|
Lines 1822-1854
sub FixPriority {
Link Here
|
| 1822 |
} |
1838 |
} |
| 1823 |
|
1839 |
|
| 1824 |
# now fix the priority on those that are left.... |
1840 |
# now fix the priority on those that are left.... |
|
|
1841 |
# only updating if changed |
| 1825 |
$query = " |
1842 |
$query = " |
| 1826 |
UPDATE reserves |
1843 |
UPDATE reserves |
| 1827 |
SET priority = ? |
1844 |
SET priority = ? |
| 1828 |
WHERE reserve_id = ? |
1845 |
WHERE reserve_id = ? AND priority != ? |
| 1829 |
"; |
1846 |
"; |
| 1830 |
$sth = $dbh->prepare($query); |
1847 |
$sth = $dbh->prepare($query); |
| 1831 |
for ( my $j = 0 ; $j < @priority ; $j++ ) { |
1848 |
for ( my $j = 0 ; $j < @priority ; $j++ ) { |
| 1832 |
$sth->execute( |
1849 |
$sth->execute( |
| 1833 |
$j + 1, |
1850 |
$j + 1, |
| 1834 |
$priority[$j]->{'reserve_id'} |
1851 |
$priority[$j]->{'reserve_id'}, $j + 1 |
| 1835 |
); |
1852 |
); |
| 1836 |
} |
1853 |
} |
| 1837 |
|
1854 |
|
| 1838 |
unless ($ignoreSetLowestRank) { |
|
|
| 1839 |
$sth = $dbh->prepare( |
| 1840 |
"SELECT reserve_id FROM reserves WHERE lowestPriority = 1 AND biblionumber = ? ORDER BY priority"); |
| 1841 |
$sth->execute($biblionumber); |
| 1842 |
while ( my $res = $sth->fetchrow_hashref() ) { |
| 1843 |
FixPriority( |
| 1844 |
{ |
| 1845 |
reserve_id => $res->{'reserve_id'}, |
| 1846 |
rank => '999999', |
| 1847 |
ignoreSetLowestRank => 1 |
| 1848 |
} |
| 1849 |
); |
| 1850 |
} |
| 1851 |
} |
| 1852 |
} |
1855 |
} |
| 1853 |
|
1856 |
|
| 1854 |
=head2 _Findgroupreserve |
1857 |
=head2 _Findgroupreserve |
| 1855 |
- |
|
|