Lines 203-222
sub move_hold_item {
Link Here
|
203 |
|
203 |
|
204 |
if ( $canReserve->{status} eq 'OK' ) { |
204 |
if ( $canReserve->{status} eq 'OK' ) { |
205 |
|
205 |
|
206 |
# Find the highest priority among holds on the new item |
206 |
# Find the lowest priority among holds on the new item |
207 |
my $highest_new_priority = Koha::Holds->search( |
207 |
my $highest_new_priority = Koha::Holds->search( |
208 |
{ biblionumber => $new_biblionumber }, |
208 |
{ biblionumber => $new_biblionumber }, |
209 |
{ order_by => { -desc => 'priority' }, rows => 1 } |
209 |
{ order_by => { -desc => 'priority' }, rows => 1 } |
210 |
)->next; |
210 |
)->next; |
211 |
|
211 |
my $next_available_priority = |
212 |
my $max_new_priority = $highest_new_priority ? $highest_new_priority->priority : 0; |
212 |
$highest_new_priority ? $highest_new_priority->priority + 1 : 1; # Always start at 1 if empty |
213 |
my $new_priority = $max_new_priority + 1; |
|
|
214 |
|
213 |
|
215 |
$self->update( |
214 |
$self->update( |
216 |
{ |
215 |
{ |
217 |
itemnumber => $new_item->itemnumber, |
216 |
itemnumber => $new_item->itemnumber, |
218 |
biblionumber => $new_item->biblionumber, |
217 |
biblionumber => $new_item->biblionumber, |
219 |
priority => $new_priority, |
218 |
priority => $next_available_priority, |
220 |
} |
219 |
} |
221 |
); |
220 |
); |
222 |
|
221 |
|
223 |
- |
|
|