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 491-499
sub getRecords {
Link Here
|
491 |
|
501 |
|
492 |
# not an index scan |
502 |
# not an index scan |
493 |
else { |
503 |
else { |
494 |
$record = $results[ $i - 1 ]->record($j)->raw(); |
504 |
$record = $results[ $i - 1 ]->record($j); |
|
|
505 |
last() unless $record; |
506 |
$record = $record->raw(); |
495 |
# warn "RECORD $j:".$record; |
507 |
# warn "RECORD $j:".$record; |
496 |
$results_hash->{'RECORDS'}[$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, $notforloanField, $notforloanSubfield )) ) { |
511 |
$times++; #Skip this record, but make sure we still get the $results_per_page results to display. |
512 |
$results_hash->{'hits'}--; #This wasn't a hit after all :( |
513 |
next(); |
514 |
} |
515 |
|
516 |
push @{$results_hash->{'RECORDS'}}, $record; |
497 |
} |
517 |
} |
498 |
|
518 |
|
499 |
} |
519 |
} |
Lines 1581-1588
sub buildQuery {
Link Here
|
1581 |
## 'available' is defined as (items.onloan is NULL) and (items.itemlost = 0) |
1601 |
## 'available' is defined as (items.onloan is NULL) and (items.itemlost = 0) |
1582 |
## In English: |
1602 |
## In English: |
1583 |
## all records not indexed in the onloan register (zebra) and all records with a value of lost equal to 0 |
1603 |
## all records not indexed in the onloan register (zebra) and all records with a value of lost equal to 0 |
1584 |
$availability_limit .= |
1604 |
# $availability_limit .= |
1585 |
"( ( allrecords,AlwaysMatches='' not onloan,AlwaysMatches='') and (lost,st-numeric=0) )"; #or ( allrecords,AlwaysMatches='' not lost,AlwaysMatches='')) )"; |
1605 |
#"( ( allrecords,AlwaysMatches='' not onloan,AlwaysMatches='') and (lost,st-numeric=0) )"; #or ( allrecords,AlwaysMatches='' not lost,AlwaysMatches='')) )"; |
1586 |
$limit_cgi .= "&limit=available"; |
1606 |
$limit_cgi .= "&limit=available"; |
1587 |
$limit_desc .= ""; |
1607 |
$limit_desc .= ""; |
1588 |
} |
1608 |
} |
Lines 2461-2466
sub new_record_from_zebra {
Link Here
|
2461 |
|
2481 |
|
2462 |
} |
2482 |
} |
2463 |
|
2483 |
|
|
|
2484 |
#Check each item in the MARCXML-String for onloan or notforloan |
2485 |
#Return 1 when the first available item is found. |
2486 |
sub isAvailableFromMARCXML { |
2487 |
my ( $recordXML, $limitHoldingbranch, $holdingbranchField, $holdingbranchSubfield, $onloanField, $onloanSubfield, $notforloanField, $notforloanSubfield ) = @_; |
2488 |
|
2489 |
my @itemsFields = $recordXML =~ /<datafield tag="$holdingbranchField".*?>(.*?)<\/datafield>/sg; |
2490 |
|
2491 |
foreach my $fieldStr (@itemsFields) { |
2492 |
my ($itemHoldingbranch, $itemOnloan, $itemNotforloan); |
2493 |
|
2494 |
if ($fieldStr =~ /<subfield code="$onloanSubfield">(.*?)<\/subfield>/s) { |
2495 |
$itemOnloan = $1; |
2496 |
next() if $itemOnloan; |
2497 |
} |
2498 |
if ($fieldStr =~ /<subfield code="$notforloanSubfield">(.*?)<\/subfield>/s) { |
2499 |
$itemNotforloan = $1; |
2500 |
next() if $itemNotforloan; |
2501 |
} |
2502 |
if ($fieldStr =~ /<subfield code="$holdingbranchSubfield">(.*?)<\/subfield>/s) { |
2503 |
$itemHoldingbranch = $1; |
2504 |
} |
2505 |
if ($itemHoldingbranch && $itemHoldingbranch eq $limitHoldingbranch) { |
2506 |
return 1; #Available ! wooee! |
2507 |
} |
2508 |
} |
2509 |
return 0; |
2510 |
} |
2511 |
|
2464 |
END { } # module clean-up code here (global destructor) |
2512 |
END { } # module clean-up code here (global destructor) |
2465 |
|
2513 |
|
2466 |
1; |
2514 |
1; |