- @marclist = $query->param('marclist');
- @and_or = $query->param('and_or');
- @excluding = $query->param('excluding');
- @operator = $query->param('operator');
- @value = $query->param('value');
- $orderby = $query->param('orderby');
- if (scalar @marclist) {
- #catalogsearch( $dbh, \@tags, \@and_or, \@excluding, \@operator, \@value,
- # $startfrom * $resultsperpage,
- # $resultsperpage, $orderby );
- ( $error, $marcresults ) = SimpleSearch( $marclist[0], $startfrom, $resultsperpage );
- if ($marcresults) {
- $show_results = scalar @$marcresults;
- } else {
- warn "ERROR label-item-search: no results from SimpleSearch";
- # leave $show_results undef
- }
- }
+ my $QParser;
+ $QParser = C4::Context->queryparser if (C4::Context->preference('UseQueryParser'));
+ $idx = $query->param('idx');
+ $ccl_textbox = $query->param('ccl_textbox');
+ if ( $ccl_textbox && $idx ) {
+ $ccl_query = "$idx:$ccl_textbox";
+ }
+
+ $datefrom = $query->param('datefrom');
+ $dateto = $query->param('dateto');
+
+ if ($datefrom) {
+ $datefrom = eval { dt_from_string ( $datefrom ) };
+ if ($datefrom) {
+ $datefrom = output_pref( { dt => $datefrom, dateonly => 1, dateformat => 'iso' } );
+ if ($QParser) {
+ $ccl_query .= ' && ' if $ccl_textbox;
+ $ccl_query .=
+ "acqdate(" . $datefrom . '-)';
+ } else {
+ $ccl_query .= ' and ' if $ccl_textbox;
+ $ccl_query .= "acqdate,st-date-normalized,ge=" . $datefrom;
+ }
+ }
+ }
+
+ if ($dateto) {
+ $dateto = eval { dt_from_string ( $dateto ) };
+ if ($dateto) {
+ $dateto = output_pref( { dt => $dateto, dateonly => 1, dateformat => 'iso' } );
+ if ($QParser) {
+ $ccl_query .= ' && ' if ( $ccl_textbox || $datefrom );
+ $ccl_query .= "acqdate(-" . $dateto . ')';
+ } else {
+ $ccl_query .= ' and ' if ( $ccl_textbox || $datefrom );
+ $ccl_query .= "acqdate,st-date-normalized,le=" . $dateto;
+ }
+ }
+ }
+
+ my $offset = $startfrom > 1 ? $startfrom - 1 : 0;
+ my $searcher = Koha::SearchEngine::Search->new({index => 'biblios'});
+ ( $error, $marcresults, $total_hits ) = $searcher->simple_search_compat($ccl_query, $offset, $resultsperpage);
+
+ if (!defined $error && @{$marcresults} ) {
+ $show_results = @{$marcresults};
+ }
+ else {
+ $debug and warn "ERROR label-item-search: no results from simple_search_compat";
+
+ # leave $show_results undef
+ }