|
Lines 329-335
sub getRecords {
Link Here
|
| 329 |
my ( |
329 |
my ( |
| 330 |
$koha_query, $simple_query, $sort_by_ref, $servers_ref, |
330 |
$koha_query, $simple_query, $sort_by_ref, $servers_ref, |
| 331 |
$results_per_page, $offset, $expanded_facet, $branches, |
331 |
$results_per_page, $offset, $expanded_facet, $branches, |
| 332 |
$itemtypes, $query_type, $scan, $opac |
332 |
$itemtypes, $query_type, $scan, $opac, $availableLimit |
| 333 |
) = @_; |
333 |
) = @_; |
| 334 |
|
334 |
|
| 335 |
my @servers = @$servers_ref; |
335 |
my @servers = @$servers_ref; |
|
Lines 348-353
sub getRecords {
Link Here
|
| 348 |
my $facets_maxrecs = C4::Context->preference('maxRecordsForFacets')||20; |
348 |
my $facets_maxrecs = C4::Context->preference('maxRecordsForFacets')||20; |
| 349 |
|
349 |
|
| 350 |
my @facets_loop; # stores the ref to array of hashes for template facets loop |
350 |
my @facets_loop; # stores the ref to array of hashes for template facets loop |
|
|
351 |
|
| 352 |
#Get the required marc tags for determining branch-based availability. |
| 353 |
my ( $holdingbranchField, $holdingbranchSubfield, $onloanField, $onloanSubfield ); |
| 354 |
if ($availableLimit) { |
| 355 |
( $holdingbranchField, $holdingbranchSubfield ) = GetMarcFromKohaField( "items.holdingbranch" ); |
| 356 |
( $onloanField, $onloanSubfield ) = GetMarcFromKohaField( "items.onloan" ); |
| 357 |
} |
| 358 |
|
| 351 |
|
359 |
|
| 352 |
### LOOP THROUGH THE SERVERS |
360 |
### LOOP THROUGH THE SERVERS |
| 353 |
for ( my $i = 0 ; $i < @servers ; $i++ ) { |
361 |
for ( my $i = 0 ; $i < @servers ; $i++ ) { |
|
Lines 493-500
sub getRecords {
Link Here
|
| 493 |
|
501 |
|
| 494 |
# not an index scan |
502 |
# not an index scan |
| 495 |
else { |
503 |
else { |
| 496 |
$record = $results[ $i - 1 ]->record($j)->raw(); |
504 |
$record = $results[ $i - 1 ]->record($j); |
|
|
505 |
last() unless $record; |
| 506 |
$record = $record->raw(); |
| 497 |
# warn "RECORD $j:".$record; |
507 |
# warn "RECORD $j:".$record; |
|
|
508 |
|
| 509 |
if ( $availableLimit && $availableLimit != 1 && #Availablelimit is 1 if there is no limit=branch:FTL given |
| 510 |
not(isAvailableFromMARCXML( $record, $availableLimit, $holdingbranchField, $holdingbranchSubfield, $onloanField, $onloanSubfield )) ) { |
| 511 |
$times++; #Skip this record, but make sure we still get the $results_per_page results to display. |
| 512 |
next(); |
| 513 |
} |
| 514 |
|
| 498 |
$results_hash->{'RECORDS'}[$j] = $record; |
515 |
$results_hash->{'RECORDS'}[$j] = $record; |
| 499 |
} |
516 |
} |
| 500 |
|
517 |
|
|
Lines 1535-1542
sub buildQuery {
Link Here
|
| 1535 |
## 'available' is defined as (items.onloan is NULL) and (items.itemlost = 0) |
1552 |
## 'available' is defined as (items.onloan is NULL) and (items.itemlost = 0) |
| 1536 |
## In English: |
1553 |
## In English: |
| 1537 |
## all records not indexed in the onloan register (zebra) and all records with a value of lost equal to 0 |
1554 |
## all records not indexed in the onloan register (zebra) and all records with a value of lost equal to 0 |
| 1538 |
$availability_limit .= |
1555 |
# $availability_limit .= |
| 1539 |
"( ( allrecords,AlwaysMatches='' not onloan,AlwaysMatches='') and (lost,st-numeric=0) )"; #or ( allrecords,AlwaysMatches='' not lost,AlwaysMatches='')) )"; |
1556 |
#"( ( allrecords,AlwaysMatches='' not onloan,AlwaysMatches='') and (lost,st-numeric=0) )"; #or ( allrecords,AlwaysMatches='' not lost,AlwaysMatches='')) )"; |
| 1540 |
$limit_cgi .= "&limit=available"; |
1557 |
$limit_cgi .= "&limit=available"; |
| 1541 |
$limit_desc .= ""; |
1558 |
$limit_desc .= ""; |
| 1542 |
} |
1559 |
} |
|
Lines 2434-2439
sub new_record_from_zebra {
Link Here
|
| 2434 |
|
2451 |
|
| 2435 |
} |
2452 |
} |
| 2436 |
|
2453 |
|
|
|
2454 |
sub isAvailableFromMARCXML { |
| 2455 |
my ( $recordXML, $limitHoldingbranch, $holdingbranchField, $holdingbranchSubfield, $onloanField, $onloanSubfield ) = @_; |
| 2456 |
|
| 2457 |
my @itemsFields = $recordXML =~ /<datafield tag="$holdingbranchField".*?>(.*?)<\/datafield>/sg; |
| 2458 |
|
| 2459 |
my ($itemHoldingbranch, $itemOnloan); |
| 2460 |
foreach my $fieldStr (@itemsFields) { |
| 2461 |
if ($fieldStr =~ /<subfield code="$holdingbranchSubfield">(.*?)<\/subfield>/s) { |
| 2462 |
$itemHoldingbranch = $1; |
| 2463 |
} |
| 2464 |
if ($fieldStr =~ /<subfield code="$onloanSubfield">(.*?)<\/subfield>/s) { |
| 2465 |
$itemOnloan = $1; |
| 2466 |
} |
| 2467 |
if ($itemHoldingbranch && not($itemOnloan) && $itemHoldingbranch eq $limitHoldingbranch) { |
| 2468 |
return 1; #Available ! wooee! |
| 2469 |
} |
| 2470 |
} |
| 2471 |
return 0; |
| 2472 |
} |
| 2473 |
|
| 2437 |
END { } # module clean-up code here (global destructor) |
2474 |
END { } # module clean-up code here (global destructor) |
| 2438 |
|
2475 |
|
| 2439 |
1; |
2476 |
1; |