|
Lines 1576-1596
sub AlterPriority {
Link Here
|
| 1576 |
|
1576 |
|
| 1577 |
=head2 ToggleLowestPriority |
1577 |
=head2 ToggleLowestPriority |
| 1578 |
|
1578 |
|
| 1579 |
ToggleLowestPriority( $borrowernumber, $biblionumber ); |
1579 |
ToggleLowestPriority( $reserve_id, $is_lowestPriority ); |
| 1580 |
|
1580 |
|
| 1581 |
This function sets the lowestPriority field to true if is false, and false if it is true. |
1581 |
This function sets the lowestPriority field to true if is false, and false if it is true |
|
|
1582 |
and then reorders the holds on the record. |
| 1583 |
|
| 1584 |
A hold toggled to lowest priority will go the bottom. |
| 1585 |
A hold toggled to NOT lowest priority will go to the bottom of other non-lowest priority holds. |
| 1582 |
|
1586 |
|
| 1583 |
=cut |
1587 |
=cut |
| 1584 |
|
1588 |
|
| 1585 |
sub ToggleLowestPriority { |
1589 |
sub ToggleLowestPriority { |
| 1586 |
my ($reserve_id) = @_; |
1590 |
my ( $reserve_id, $is_lowestPriority ) = @_; |
| 1587 |
|
1591 |
|
| 1588 |
my $dbh = C4::Context->dbh; |
1592 |
my $dbh = C4::Context->dbh; |
| 1589 |
|
1593 |
|
|
|
1594 |
my $rank = $is_lowestPriority ? undef : '999999'; |
| 1595 |
|
| 1590 |
my $sth = $dbh->prepare("UPDATE reserves SET lowestPriority = NOT lowestPriority WHERE reserve_id = ?"); |
1596 |
my $sth = $dbh->prepare("UPDATE reserves SET lowestPriority = NOT lowestPriority WHERE reserve_id = ?"); |
| 1591 |
$sth->execute($reserve_id); |
1597 |
$sth->execute($reserve_id); |
| 1592 |
|
1598 |
|
| 1593 |
FixPriority( { reserve_id => $reserve_id, rank => '999999' } ); |
1599 |
FixPriority( { reserve_id => $reserve_id, rank => $rank } ); |
| 1594 |
} |
1600 |
} |
| 1595 |
|
1601 |
|
| 1596 |
=head2 SuspendAll |
1602 |
=head2 SuspendAll |
|
Lines 1744-1750
sub FixPriority {
Link Here
|
| 1744 |
} |
1750 |
} |
| 1745 |
|
1751 |
|
| 1746 |
# if index exists in array then move it to new position |
1752 |
# if index exists in array then move it to new position |
| 1747 |
if ( $key > -1 && $rank ne 'del' && $rank > 0 ) { |
1753 |
if ( $key > -1 && $rank ne 'del' && $rank && $rank > 0 ) { |
| 1748 |
my $new_rank = $rank - 1; # $new_rank is what you want the new index to be in the array |
1754 |
my $new_rank = $rank - 1; # $new_rank is what you want the new index to be in the array |
| 1749 |
my $moving_item = splice( @priority, $key, 1 ); |
1755 |
my $moving_item = splice( @priority, $key, 1 ); |
| 1750 |
$new_rank = scalar @priority if $new_rank > scalar @priority; |
1756 |
$new_rank = scalar @priority if $new_rank > scalar @priority; |