|
Lines 197-220
sub _assign_item_for_booking {
Link Here
|
| 197 |
my $dtf = Koha::Database->new->schema->storage->datetime_parser; |
197 |
my $dtf = Koha::Database->new->schema->storage->datetime_parser; |
| 198 |
|
198 |
|
| 199 |
my $existing_bookings = $biblio->bookings( |
199 |
my $existing_bookings = $biblio->bookings( |
| 200 |
[ |
200 |
{ |
| 201 |
start_date => { |
201 |
'-and' => [ |
| 202 |
'-between' => [ |
202 |
{ |
| 203 |
$dtf->format_datetime($start_date), |
203 |
'-or' => [ |
| 204 |
$dtf->format_datetime($end_date) |
204 |
start_date => { |
| 205 |
] |
205 |
'-between' => [ |
| 206 |
}, |
206 |
$dtf->format_datetime($start_date), |
| 207 |
end_date => { |
207 |
$dtf->format_datetime($end_date) |
| 208 |
'-between' => [ |
208 |
] |
| 209 |
$dtf->format_datetime($start_date), |
209 |
}, |
| 210 |
$dtf->format_datetime($end_date) |
210 |
end_date => { |
| 211 |
] |
211 |
'-between' => [ |
| 212 |
}, |
212 |
$dtf->format_datetime($start_date), |
| 213 |
{ |
213 |
$dtf->format_datetime($end_date) |
| 214 |
start_date => { '<' => $dtf->format_datetime($start_date) }, |
214 |
] |
| 215 |
end_date => { '>' => $dtf->format_datetime($end_date) } |
215 |
}, |
| 216 |
} |
216 |
{ |
| 217 |
] |
217 |
start_date => { '<' => $dtf->format_datetime($start_date) }, |
|
|
218 |
end_date => { '>' => $dtf->format_datetime($end_date) } |
| 219 |
} |
| 220 |
] |
| 221 |
}, |
| 222 |
{ status => { '-not_in' => [ 'cancelled', 'completed' ] } } |
| 223 |
] |
| 224 |
} |
| 218 |
); |
225 |
); |
| 219 |
|
226 |
|
| 220 |
my $checkouts = |
227 |
my $checkouts = |
|
Lines 227-233
sub _assign_item_for_booking {
Link Here
|
| 227 |
{ '-not_in' => $checkouts->_resultset->get_column('itemnumber')->as_query } |
234 |
{ '-not_in' => $checkouts->_resultset->get_column('itemnumber')->as_query } |
| 228 |
] |
235 |
] |
| 229 |
}, |
236 |
}, |
| 230 |
{ rows => 1 } |
237 |
{ order_by => \'RAND()', rows => 1 } |
| 231 |
); |
238 |
); |
| 232 |
|
239 |
|
| 233 |
my $itemnumber = $bookable_items->single->itemnumber; |
240 |
my $itemnumber = $bookable_items->single->itemnumber; |
| 234 |
- |
|
|