Lines 251-256
sub SimpleSearch {
Link Here
|
251 |
$zoom_queries[$i] = new ZOOM::Query::PQF( $query, $zconns[$i]); |
251 |
$zoom_queries[$i] = new ZOOM::Query::PQF( $query, $zconns[$i]); |
252 |
} else { |
252 |
} else { |
253 |
$query =~ s/:/=/g; |
253 |
$query =~ s/:/=/g; |
|
|
254 |
$query =~ s/\?//g; #Remove ? because this error is thrown :> CCL parsing error (10014) Right truncation not supported ZOOM for query: title=MISSÄ ON JATKOT? at /C4/Search.pm line 276. |
254 |
$zoom_queries[$i] = new ZOOM::Query::CCL2RPN( $query, $zconns[$i]); |
255 |
$zoom_queries[$i] = new ZOOM::Query::CCL2RPN( $query, $zconns[$i]); |
255 |
} |
256 |
} |
256 |
$tmpresults[$i] = $zconns[$i]->search( $zoom_queries[$i] ); |
257 |
$tmpresults[$i] = $zconns[$i]->search( $zoom_queries[$i] ); |
Lines 327-333
sub getRecords {
Link Here
|
327 |
my ( |
328 |
my ( |
328 |
$koha_query, $simple_query, $sort_by_ref, $servers_ref, |
329 |
$koha_query, $simple_query, $sort_by_ref, $servers_ref, |
329 |
$results_per_page, $offset, $expanded_facet, $branches, |
330 |
$results_per_page, $offset, $expanded_facet, $branches, |
330 |
$itemtypes, $query_type, $scan, $opac |
331 |
$itemtypes, $query_type, $scan, $opac, $availableLimit |
331 |
) = @_; |
332 |
) = @_; |
332 |
|
333 |
|
333 |
my @servers = @$servers_ref; |
334 |
my @servers = @$servers_ref; |
Lines 347-352
sub getRecords {
Link Here
|
347 |
|
348 |
|
348 |
my @facets_loop; # stores the ref to array of hashes for template facets loop |
349 |
my @facets_loop; # stores the ref to array of hashes for template facets loop |
349 |
|
350 |
|
|
|
351 |
#Get the required marc tags for determining branch-based availability. |
352 |
my ( $holdingbranchField, $holdingbranchSubfield, $onloanField, $onloanSubfield, $notforloanField, $notforloanSubfield ); |
353 |
if ($availableLimit) { |
354 |
( $holdingbranchField, $holdingbranchSubfield ) = GetMarcFromKohaField( "items.holdingbranch" ); |
355 |
( $onloanField, $onloanSubfield ) = GetMarcFromKohaField( "items.onloan" ); |
356 |
( $notforloanField, $notforloanSubfield ) = GetMarcFromKohaField( "items.notforloan" ); |
357 |
} |
358 |
|
359 |
|
350 |
### LOOP THROUGH THE SERVERS |
360 |
### LOOP THROUGH THE SERVERS |
351 |
for ( my $i = 0 ; $i < @servers ; $i++ ) { |
361 |
for ( my $i = 0 ; $i < @servers ; $i++ ) { |
352 |
$zconns[$i] = C4::Context->Zconn( $servers[$i], 1 ); |
362 |
$zconns[$i] = C4::Context->Zconn( $servers[$i], 1 ); |
Lines 450-455
sub getRecords {
Link Here
|
450 |
$times = $size; |
460 |
$times = $size; |
451 |
} |
461 |
} |
452 |
|
462 |
|
|
|
463 |
#If we are using pagination to display other resultset pages. |
464 |
#The results_hash needs to contain Records starting from the given |
465 |
#offset. |
466 |
if ($offset > 0) { |
467 |
$results_hash->{'RECORDS'}->[$offset-1] = undef; |
468 |
} |
469 |
|
453 |
for ( my $j = $offset ; $j < $times ; $j++ ) { |
470 |
for ( my $j = $offset ; $j < $times ; $j++ ) { |
454 |
my $records_hash; |
471 |
my $records_hash; |
455 |
my $record; |
472 |
my $record; |
Lines 491-499
sub getRecords {
Link Here
|
491 |
|
508 |
|
492 |
# not an index scan |
509 |
# not an index scan |
493 |
else { |
510 |
else { |
494 |
$record = $results[ $i - 1 ]->record($j)->raw(); |
511 |
$record = $results[ $i - 1 ]->record($j); |
|
|
512 |
last() unless $record; |
513 |
$record = $record->raw(); |
495 |
# warn "RECORD $j:".$record; |
514 |
# warn "RECORD $j:".$record; |
496 |
$results_hash->{'RECORDS'}[$j] = $record; |
515 |
|
|
|
516 |
if ( $availableLimit && #Availablelimit is 1 if there is no limit=branch:FTL given |
517 |
not(isAvailableFromMARCXML( $record, $availableLimit, $holdingbranchField, $holdingbranchSubfield, $onloanField, $onloanSubfield, $notforloanField, $notforloanSubfield )) ) { |
518 |
$times++; #Skip this record, but make sure we still get the $results_per_page results to display. |
519 |
$results_hash->{'hits'}--; #This wasn't a hit after all :( |
520 |
next(); |
521 |
} |
522 |
|
523 |
push @{$results_hash->{'RECORDS'}}, $record; |
497 |
} |
524 |
} |
498 |
|
525 |
|
499 |
} |
526 |
} |
Lines 1581-1588
sub buildQuery {
Link Here
|
1581 |
## 'available' is defined as (items.onloan is NULL) and (items.itemlost = 0) |
1608 |
## 'available' is defined as (items.onloan is NULL) and (items.itemlost = 0) |
1582 |
## In English: |
1609 |
## In English: |
1583 |
## all records not indexed in the onloan register (zebra) and all records with a value of lost equal to 0 |
1610 |
## all records not indexed in the onloan register (zebra) and all records with a value of lost equal to 0 |
1584 |
$availability_limit .= |
1611 |
# $availability_limit .= |
1585 |
"( ( allrecords,AlwaysMatches='' not onloan,AlwaysMatches='') and (lost,st-numeric=0) )"; #or ( allrecords,AlwaysMatches='' not lost,AlwaysMatches='')) )"; |
1612 |
#"( ( allrecords,AlwaysMatches='' not onloan,AlwaysMatches='') and (lost,st-numeric=0) )"; #or ( allrecords,AlwaysMatches='' not lost,AlwaysMatches='')) )"; |
1586 |
$limit_cgi .= "&limit=available"; |
1613 |
$limit_cgi .= "&limit=available"; |
1587 |
$limit_desc .= ""; |
1614 |
$limit_desc .= ""; |
1588 |
} |
1615 |
} |
Lines 2461-2466
sub new_record_from_zebra {
Link Here
|
2461 |
|
2488 |
|
2462 |
} |
2489 |
} |
2463 |
|
2490 |
|
|
|
2491 |
#Check each item in the MARCXML-String for onloan or notforloan |
2492 |
#Return 1 when the first available item is found. |
2493 |
#PARAM $limitHoldingbranch, counterintuitively is 1, if no holdingbranch based limiting is desired, |
2494 |
# and the holdingbranch code if we want to limit by branch. |
2495 |
|
2496 |
sub isAvailableFromMARCXML { |
2497 |
my ( $recordXML, $limitHoldingbranch, $holdingbranchField, $holdingbranchSubfield, $onloanField, $onloanSubfield, $notforloanField, $notforloanSubfield ) = @_; |
2498 |
|
2499 |
my @itemsFields = $recordXML =~ /<datafield tag="$holdingbranchField".*?>(.*?)<\/datafield>/sg; |
2500 |
|
2501 |
foreach my $fieldStr (@itemsFields) { |
2502 |
my ($itemHoldingbranch, $itemOnloan, $itemNotforloan); |
2503 |
|
2504 |
if ($fieldStr =~ /<subfield code="$onloanSubfield">(.*?)<\/subfield>/s) { |
2505 |
$itemOnloan = $1; |
2506 |
next() if $itemOnloan; |
2507 |
} |
2508 |
if ($fieldStr =~ /<subfield code="$notforloanSubfield">(.*?)<\/subfield>/s) { |
2509 |
$itemNotforloan = $1; |
2510 |
next() if $itemNotforloan; |
2511 |
} |
2512 |
if ($limitHoldingbranch != 1) { #Check for holdingbranch-based availability. |
2513 |
if ($fieldStr =~ /<subfield code="$holdingbranchSubfield">(.*?)<\/subfield>/s) { |
2514 |
$itemHoldingbranch = $1; |
2515 |
} |
2516 |
if ($itemHoldingbranch && $itemHoldingbranch eq $limitHoldingbranch) { |
2517 |
return 1; #Available ! wooee! |
2518 |
} |
2519 |
} |
2520 |
else { |
2521 |
return 1; #We are not checking for holdingbranch-based availability, so any availability is fine! |
2522 |
} |
2523 |
} |
2524 |
return 0; |
2525 |
} |
2526 |
|
2464 |
END { } # module clean-up code here (global destructor) |
2527 |
END { } # module clean-up code here (global destructor) |
2465 |
|
2528 |
|
2466 |
1; |
2529 |
1; |