Lines 166-177
Top level function that turns reserves into tmp_holdsqueue and hold_fill_targets
Link Here
|
166 |
=cut |
166 |
=cut |
167 |
|
167 |
|
168 |
sub CreateQueue { |
168 |
sub CreateQueue { |
169 |
my $params = shift; |
169 |
my $params = shift; |
170 |
my $unallocated = $params->{unallocated}; |
170 |
my $unallocated = $params->{unallocated}; |
171 |
my $dbh = C4::Context->dbh; |
171 |
my $dbh = C4::Context->dbh; |
172 |
|
172 |
|
173 |
unless( $unallocated ){ |
173 |
unless ($unallocated) { |
174 |
$dbh->do("DELETE FROM tmp_holdsqueue"); # clear the old table for new info |
174 |
$dbh->do("DELETE FROM tmp_holdsqueue"); # clear the old table for new info |
175 |
$dbh->do("DELETE FROM hold_fill_targets"); |
175 |
$dbh->do("DELETE FROM hold_fill_targets"); |
176 |
} |
176 |
} |
177 |
|
177 |
|
Lines 200-206
sub CreateQueue {
Link Here
|
200 |
$total_bibs++; |
200 |
$total_bibs++; |
201 |
|
201 |
|
202 |
my $result = update_queue_for_biblio( |
202 |
my $result = update_queue_for_biblio( |
203 |
{ biblio_id => $biblionumber, |
203 |
{ |
|
|
204 |
biblio_id => $biblionumber, |
204 |
branches_to_use => $branches_to_use, |
205 |
branches_to_use => $branches_to_use, |
205 |
transport_cost_matrix => $transport_cost_matrix, |
206 |
transport_cost_matrix => $transport_cost_matrix, |
206 |
unallocated => $unallocated |
207 |
unallocated => $unallocated |
Lines 243-249
sub GetBibsWithPendingHoldRequests {
Link Here
|
243 |
|
244 |
|
244 |
=head2 GetPendingHoldRequestsForBib |
245 |
=head2 GetPendingHoldRequestsForBib |
245 |
|
246 |
|
246 |
my $requests = GetPendingHoldRequestsForBib({ biblionumber => $biblionumber, unallocated => $unallocated }); |
247 |
my $requests = GetPendingHoldRequestsForBib( { biblionumber => $biblionumber, unallocated => $unallocated } ); |
247 |
|
248 |
|
248 |
Returns an arrayref of hashrefs to pending, unfilled hold requests |
249 |
Returns an arrayref of hashrefs to pending, unfilled hold requests |
249 |
on the bib identified by $biblionumber. Optionally returns only unallocated holds. The following keys |
250 |
on the bib identified by $biblionumber. Optionally returns only unallocated holds. The following keys |
Lines 263-271
The arrayref is sorted in order of increasing priority.
Link Here
|
263 |
=cut |
264 |
=cut |
264 |
|
265 |
|
265 |
sub GetPendingHoldRequestsForBib { |
266 |
sub GetPendingHoldRequestsForBib { |
266 |
my $params = shift; |
267 |
my $params = shift; |
267 |
my $biblionumber = $params->{biblionumber}; |
268 |
my $biblionumber = $params->{biblionumber}; |
268 |
my $unallocated = $params->{unallocated}; |
269 |
my $unallocated = $params->{unallocated}; |
269 |
|
270 |
|
270 |
my $dbh = C4::Context->dbh; |
271 |
my $dbh = C4::Context->dbh; |
271 |
|
272 |
|
Lines 278-285
sub GetPendingHoldRequestsForBib {
Link Here
|
278 |
AND priority > 0 |
279 |
AND priority > 0 |
279 |
AND reservedate <= CURRENT_DATE() |
280 |
AND reservedate <= CURRENT_DATE() |
280 |
AND suspend = 0 "; |
281 |
AND suspend = 0 "; |
281 |
$request_query .= "AND reserve_id NOT IN (SELECT reserve_id FROM hold_fill_targets) " if $unallocated; |
282 |
$request_query .= "AND reserve_id NOT IN (SELECT reserve_id FROM hold_fill_targets) " if $unallocated; |
282 |
$request_query .= "ORDER BY priority"; |
283 |
$request_query .= "ORDER BY priority"; |
283 |
my $sth = $dbh->prepare($request_query); |
284 |
my $sth = $dbh->prepare($request_query); |
284 |
$sth->execute($biblionumber); |
285 |
$sth->execute($biblionumber); |
285 |
|
286 |
|
Lines 313-329
sub GetItemsAvailableToFillHoldRequestsForBib {
Link Here
|
313 |
my $items_query = "SELECT items.itemnumber, homebranch, holdingbranch, itemtypes.itemtype AS itype |
314 |
my $items_query = "SELECT items.itemnumber, homebranch, holdingbranch, itemtypes.itemtype AS itype |
314 |
FROM items "; |
315 |
FROM items "; |
315 |
|
316 |
|
316 |
if (C4::Context->preference('item-level_itypes')) { |
317 |
if ( C4::Context->preference('item-level_itypes') ) { |
317 |
$items_query .= "LEFT JOIN itemtypes ON (itemtypes.itemtype = items.itype) "; |
318 |
$items_query .= "LEFT JOIN itemtypes ON (itemtypes.itemtype = items.itype) "; |
318 |
} else { |
319 |
} else { |
319 |
$items_query .= "JOIN biblioitems USING (biblioitemnumber) |
320 |
$items_query .= "JOIN biblioitems USING (biblioitemnumber) |
320 |
LEFT JOIN itemtypes USING (itemtype) "; |
321 |
LEFT JOIN itemtypes USING (itemtype) "; |
321 |
} |
322 |
} |
322 |
$items_query .= " LEFT JOIN branchtransfers ON ( |
323 |
$items_query .= " LEFT JOIN branchtransfers ON ( |
323 |
items.itemnumber = branchtransfers.itemnumber |
324 |
items.itemnumber = branchtransfers.itemnumber |
324 |
AND branchtransfers.datearrived IS NULL AND branchtransfers.datecancelled IS NULL |
325 |
AND branchtransfers.datearrived IS NULL AND branchtransfers.datecancelled IS NULL |
325 |
)"; |
326 |
)"; |
326 |
$items_query .= " WHERE items.notforloan = 0 |
327 |
$items_query .= " WHERE items.notforloan = 0 |
327 |
AND holdingbranch IS NOT NULL |
328 |
AND holdingbranch IS NOT NULL |
328 |
AND itemlost = 0 |
329 |
AND itemlost = 0 |
329 |
AND withdrawn = 0"; |
330 |
AND withdrawn = 0"; |