Lines 105-111
BEGIN {
Link Here
|
105 |
|
105 |
|
106 |
&GetReserve |
106 |
&GetReserve |
107 |
&GetReservesFromItemnumber |
107 |
&GetReservesFromItemnumber |
108 |
&GetReservesFromBiblionumber |
|
|
109 |
&GetReservesFromBorrowernumber |
108 |
&GetReservesFromBorrowernumber |
110 |
&GetReservesForBranch |
109 |
&GetReservesForBranch |
111 |
&GetReservesToBranch |
110 |
&GetReservesToBranch |
Lines 276-347
sub GetReserve {
Link Here
|
276 |
return $sth->fetchrow_hashref(); |
275 |
return $sth->fetchrow_hashref(); |
277 |
} |
276 |
} |
278 |
|
277 |
|
279 |
=head2 GetReservesFromBiblionumber |
|
|
280 |
|
281 |
my $reserves = GetReservesFromBiblionumber({ |
282 |
biblionumber => $biblionumber, |
283 |
[ itemnumber => $itemnumber, ] |
284 |
[ all_dates => 1|0 ] |
285 |
}); |
286 |
|
287 |
This function gets the list of reservations for one C<$biblionumber>, |
288 |
returning an arrayref pointing to the reserves for C<$biblionumber>. |
289 |
|
290 |
By default, only reserves whose start date falls before the current |
291 |
time are returned. To return all reserves, including future ones, |
292 |
the C<all_dates> parameter can be included and set to a true value. |
293 |
|
294 |
If the C<itemnumber> parameter is supplied, reserves must be targeted |
295 |
to that item or not targeted to any item at all; otherwise, they |
296 |
are excluded from the list. |
297 |
|
298 |
=cut |
299 |
|
300 |
sub GetReservesFromBiblionumber { |
301 |
my ( $params ) = @_; |
302 |
my $biblionumber = $params->{biblionumber} or return []; |
303 |
my $itemnumber = $params->{itemnumber}; |
304 |
my $all_dates = $params->{all_dates} // 0; |
305 |
my $dbh = C4::Context->dbh; |
306 |
|
307 |
# Find the desired items in the reserves |
308 |
my @params; |
309 |
my $query = " |
310 |
SELECT reserve_id, |
311 |
branchcode, |
312 |
timestamp AS rtimestamp, |
313 |
priority, |
314 |
biblionumber, |
315 |
borrowernumber, |
316 |
reservedate, |
317 |
found, |
318 |
itemnumber, |
319 |
reservenotes, |
320 |
expirationdate, |
321 |
lowestPriority, |
322 |
suspend, |
323 |
suspend_until, |
324 |
itemtype |
325 |
FROM reserves |
326 |
WHERE biblionumber = ? "; |
327 |
push( @params, $biblionumber ); |
328 |
unless ( $all_dates ) { |
329 |
$query .= " AND reservedate <= CAST(NOW() AS DATE) "; |
330 |
} |
331 |
if ( $itemnumber ) { |
332 |
$query .= " AND ( itemnumber IS NULL OR itemnumber = ? )"; |
333 |
push( @params, $itemnumber ); |
334 |
} |
335 |
$query .= "ORDER BY priority"; |
336 |
my $sth = $dbh->prepare($query); |
337 |
$sth->execute( @params ); |
338 |
my @results; |
339 |
while ( my $data = $sth->fetchrow_hashref ) { |
340 |
push @results, $data; |
341 |
} |
342 |
return \@results; |
343 |
} |
344 |
|
345 |
=head2 GetReservesFromItemnumber |
278 |
=head2 GetReservesFromItemnumber |
346 |
|
279 |
|
347 |
( $reservedate, $borrowernumber, $branchcode, $reserve_id, $waitingdate ) = GetReservesFromItemnumber($itemnumber); |
280 |
( $reservedate, $borrowernumber, $branchcode, $reserve_id, $waitingdate ) = GetReservesFromItemnumber($itemnumber); |
348 |
- |
|
|