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