View | Details | Raw Unified | Return to bug 30745
Collapse All | Expand All

(-)a/labels/label-item-search.pl (-13 / +21 lines)
Lines 59-95 my $display_columns = [ {_add => {label => "Add Item", link_fi Link Here
59
if ( $op eq "do_search" ) {
59
if ( $op eq "do_search" ) {
60
    $idx         = $query->param('idx');
60
    $idx         = $query->param('idx');
61
    $ccl_textbox = $query->param('ccl_textbox');
61
    $ccl_textbox = $query->param('ccl_textbox');
62
    if ( $ccl_textbox && $idx ) {
63
        $ccl_query = "$idx:$ccl_textbox";
64
    }
65
62
66
    $datefrom = $query->param('datefrom');
63
    $datefrom = $query->param('datefrom');
67
    $dateto   = $query->param('dateto');
64
    $dateto   = $query->param('dateto');
68
65
66
    my $builder = Koha::SearchEngine::QueryBuilder->new(
67
        { index => $Koha::SearchEngine::BIBLIOS_INDEX } );
68
    my $searcher = Koha::SearchEngine::Search->new(
69
        { index => $Koha::SearchEngine::BIBLIOS_INDEX } );
70
71
    my @limits;
69
    if ($datefrom) {
72
    if ($datefrom) {
70
        $datefrom = eval { dt_from_string ( $datefrom ) };
73
        $datefrom = eval { dt_from_string ( $datefrom ) };
71
        if ($datefrom) {
74
        if ($datefrom) {
72
            $datefrom = output_pref( { dt => $datefrom, dateonly => 1, dateformat => 'iso' } );
75
            $datefrom = output_pref( { dt => $datefrom, dateonly => 1, dateformat => 'iso' } );
73
            $ccl_query .= ' AND ' if $ccl_textbox;
76
            push(@limits, "acqdate,ge,st-date-normalized=$datefrom");
74
            $ccl_query .= "acqdate,ge,st-date-normalized=" . $datefrom;
75
        }
77
        }
76
    }
78
    }
77
79
78
    if ($dateto) {
80
    if ($dateto) {
79
        $dateto = eval { dt_from_string ( $dateto ) };
81
        $dateto = eval { dt_from_string ( $dateto ) };
80
        if ($dateto) {
82
        if ($dateto) {
81
           $dateto = output_pref( { dt => $dateto, dateonly => 1, dateformat => 'iso' } );
83
            $dateto = output_pref( { dt => $dateto, dateonly => 1, dateformat => 'iso' } );
82
            $ccl_query .= ' AND ' if ( $ccl_textbox || $datefrom );
84
            push(@limits, "acqdate,le,st-date-normalized=$dateto");
83
            $ccl_query .= "acqdate,le,st-date-normalized=" . $dateto;
84
        }
85
        }
85
    }
86
    }
86
87
88
    my ( $error, $query, $simple_query, $query_cgi,
89
        $query_desc, $limit, $limit_cgi, $limit_desc,
90
        $query_type )
91
        = $builder->build_query_compat( undef, [$ccl_textbox], [$idx], \@limits);
92
87
    my $offset = $startfrom > 1 ? $startfrom - 1 : 0;
93
    my $offset = $startfrom > 1 ? $startfrom - 1 : 0;
88
    my $searcher = Koha::SearchEngine::Search->new({index => 'biblios'});
89
    ( $error, $marcresults, $total_hits ) = $searcher->simple_search_compat($ccl_query, $offset, $resultsperpage);
90
94
91
    if (!defined $error && @{$marcresults} ) {
95
    my ( $error, $marcresults, $facets ) = $searcher->search_compat(
92
        $show_results = @{$marcresults};
96
        $query, $simple_query, undef, ['biblioserver'], $resultsperpage, $offset,
97
        undef, undef, $query_type, undef
98
   );
99
100
    if (!defined $error && $marcresults->{biblioserver}{RECORDS} ) {
101
        $show_results = $marcresults->{biblioserver}{RECORDS};
93
    }
102
    }
94
    else {
103
    else {
95
        Koha::Logger->get->warn("ERROR label-item-search: no results from simple_search_compat");
104
        Koha::Logger->get->warn("ERROR label-item-search: no results from simple_search_compat");
96
- 

Return to bug 30745