+=item AlterPriority
+AlterPriority( $where, $borrowernumber, $biblionumber, $reservedate );
+
+This function changes a reserve's priority up, down, to the top, or to the bottom.
+Input: $where is 'up', 'down', 'top' or 'bottom'. Biblionumber, Date reserve was placed
+
+=cut
+sub AlterPriority {
+ my ( $where, $borrowernumber, $biblionumber ) = @_;
+
+ my $dbh = C4::Context->dbh;
+
+ ## Find this reserve
+ my $sth = $dbh->prepare('SELECT * FROM reserves WHERE biblionumber = ? AND borrowernumber = ? AND cancellationdate IS NULL');
+ $sth->execute( $biblionumber, $borrowernumber );
+ my $reserve = $sth->fetchrow_hashref();
+ $sth->finish();
+
+ if ( $where eq 'up' || $where eq 'down' ) {
+
+ my $priority = $reserve->{'priority'};
+ $priority = $where eq 'up' ? $priority - 1 : $priority + 1;
+ _FixPriority( $biblionumber, $borrowernumber, $priority )
+
+ } elsif ( $where eq 'top' ) {
+
+ _FixPriority( $biblionumber, $borrowernumber, '1' )
+
+ } elsif ( $where eq 'bottom' ) {
+
+ _FixPriority( $biblionumber, $borrowernumber, '999999' )
+
+ }
+}
+
+=item ToggleLowestPriority
+ToggleLowestPriority( $borrowernumber, $biblionumber );
+
+This function sets the lowestPriority field to true if is false, and false if it is true.
+=cut
+
+sub ToggleLowestPriority {
+ my ( $borrowernumber, $biblionumber ) = @_;
+
+ my $dbh = C4::Context->dbh;
+
+ my $sth = $dbh->prepare(
+ "UPDATE reserves SET lowestPriority = NOT lowestPriority
+ WHERE biblionumber = ?
+ AND borrowernumber = ?"
+ );
+ $sth->execute(
+ $biblionumber,
+ $borrowernumber,
+ );
+ $sth->finish;
+
+ _FixPriority( $biblionumber, $borrowernumber, '999999' );
+}
+