|
Lines 1706-1718
sub FixPriority {
Link Here
|
| 1706 |
} |
1706 |
} |
| 1707 |
my @priority; |
1707 |
my @priority; |
| 1708 |
|
1708 |
|
| 1709 |
# get what's left |
1709 |
# get what's left, sorting lowestPriority holds to the bottom |
| 1710 |
my $query = " |
1710 |
my $query = " |
| 1711 |
SELECT reserve_id, borrowernumber, reservedate |
1711 |
SELECT reserve_id, borrowernumber, reservedate |
| 1712 |
FROM reserves |
1712 |
FROM reserves |
| 1713 |
WHERE biblionumber = ? |
1713 |
WHERE biblionumber = ? |
| 1714 |
AND ((found <> 'W' AND found <> 'T' AND found <> 'P') OR found IS NULL) |
1714 |
AND ((found <> 'W' AND found <> 'T' AND found <> 'P') OR found IS NULL) |
| 1715 |
ORDER BY priority ASC |
1715 |
ORDER BY lowestPriority ASC, priority ASC |
| 1716 |
"; |
1716 |
"; |
| 1717 |
my $sth = $dbh->prepare($query); |
1717 |
my $sth = $dbh->prepare($query); |
| 1718 |
$sth->execute($biblionumber); |
1718 |
$sth->execute($biblionumber); |
|
Lines 1731-1736
sub FixPriority {
Link Here
|
| 1731 |
} |
1731 |
} |
| 1732 |
} |
1732 |
} |
| 1733 |
|
1733 |
|
|
|
1734 |
# if this hold is marked lowest priority, we can only move it so far |
| 1735 |
if ( $hold && $hold->lowestPriority && $rank ne 'del' ) { |
| 1736 |
my $query = " |
| 1737 |
SELECT max(priority) |
| 1738 |
FROM reserves |
| 1739 |
WHERE biblionumber = ? |
| 1740 |
AND ((found <> 'W' AND found <> 'T' AND found <> 'P') OR found IS NULL) |
| 1741 |
AND lowestPriority = 0; |
| 1742 |
"; |
| 1743 |
my $sth = $dbh->prepare($query); |
| 1744 |
$sth->execute($biblionumber); |
| 1745 |
my ($highest_non_lowest_priority) = $sth->fetchrow_array(); |
| 1746 |
$rank = $highest_non_lowest_priority + 1 |
| 1747 |
if ( $highest_non_lowest_priority && $rank <= $highest_non_lowest_priority ); |
| 1748 |
} |
| 1749 |
|
| 1734 |
# if index exists in array then move it to new position |
1750 |
# if index exists in array then move it to new position |
| 1735 |
if ( $key > -1 && $rank ne 'del' && $rank > 0 ) { |
1751 |
if ( $key > -1 && $rank ne 'del' && $rank > 0 ) { |
| 1736 |
my $new_rank = $rank - 1; # $new_rank is what you want the new index to be in the array |
1752 |
my $new_rank = $rank - 1; # $new_rank is what you want the new index to be in the array |
|
Lines 1740-1772
sub FixPriority {
Link Here
|
| 1740 |
} |
1756 |
} |
| 1741 |
|
1757 |
|
| 1742 |
# now fix the priority on those that are left.... |
1758 |
# now fix the priority on those that are left.... |
|
|
1759 |
# only updating if changed |
| 1743 |
$query = " |
1760 |
$query = " |
| 1744 |
UPDATE reserves |
1761 |
UPDATE reserves |
| 1745 |
SET priority = ? |
1762 |
SET priority = ? |
| 1746 |
WHERE reserve_id = ? |
1763 |
WHERE reserve_id = ? AND priority != ? |
| 1747 |
"; |
1764 |
"; |
| 1748 |
$sth = $dbh->prepare($query); |
1765 |
$sth = $dbh->prepare($query); |
| 1749 |
for ( my $j = 0 ; $j < @priority ; $j++ ) { |
1766 |
for ( my $j = 0 ; $j < @priority ; $j++ ) { |
| 1750 |
$sth->execute( |
1767 |
$sth->execute( |
| 1751 |
$j + 1, |
1768 |
$j + 1, |
| 1752 |
$priority[$j]->{'reserve_id'} |
1769 |
$priority[$j]->{'reserve_id'}, $j + 1 |
| 1753 |
); |
1770 |
); |
| 1754 |
} |
1771 |
} |
| 1755 |
|
1772 |
|
| 1756 |
unless ($ignoreSetLowestRank) { |
|
|
| 1757 |
$sth = $dbh->prepare( |
| 1758 |
"SELECT reserve_id FROM reserves WHERE lowestPriority = 1 AND biblionumber = ? ORDER BY priority"); |
| 1759 |
$sth->execute($biblionumber); |
| 1760 |
while ( my $res = $sth->fetchrow_hashref() ) { |
| 1761 |
FixPriority( |
| 1762 |
{ |
| 1763 |
reserve_id => $res->{'reserve_id'}, |
| 1764 |
rank => '999999', |
| 1765 |
ignoreSetLowestRank => 1 |
| 1766 |
} |
| 1767 |
); |
| 1768 |
} |
| 1769 |
} |
| 1770 |
} |
1773 |
} |
| 1771 |
|
1774 |
|
| 1772 |
=head2 _Findgroupreserve |
1775 |
=head2 _Findgroupreserve |
| 1773 |
- |
|
|