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

(-)a/C4/Search.pm (-2 / +2 lines)
Lines 446-452 sub getRecords { Link Here
446
                # loop through the results
446
                # loop through the results
447
                $results_hash->{'hits'} = $size;
447
                $results_hash->{'hits'} = $size;
448
                my $times;
448
                my $times;
449
                if ( $offset + $results_per_page <= $size ) {
449
                if ( $results_per_page != 'all' && ($offset + $results_per_page <= $size) ) {
450
                    $times = $offset + $results_per_page;
450
                    $times = $offset + $results_per_page;
451
                }
451
                }
452
                else {
452
                else {
Lines 1898-1904 sub searchResults { Link Here
1898
1898
1899
    # handle which records to actually retrieve
1899
    # handle which records to actually retrieve
1900
    my $times;
1900
    my $times;
1901
    if ( $hits && $offset + $results_per_page <= $hits ) {
1901
    if ( $hits && $results_per_page != 'all' && ($offset + $results_per_page <= $hits) ) {
1902
        $times = $offset + $results_per_page;
1902
        $times = $offset + $results_per_page;
1903
    }
1903
    }
1904
    else {
1904
    else {
(-)a/catalogue/search.pl (-6 / +14 lines)
Lines 148-154 use C4::Koha; Link Here
148
use URI::Escape;
148
use URI::Escape;
149
use POSIX qw(ceil floor);
149
use POSIX qw(ceil floor);
150
use C4::Search::History;
150
use C4::Search::History;
151
151
use String::Random;
152
use Koha::ItemTypes;
152
use Koha::ItemTypes;
153
use Koha::Library::Groups;
153
use Koha::Library::Groups;
154
use Koha::Patrons;
154
use Koha::Patrons;
Lines 454-464 for (my $ii = 0; $ii < @operands; ++$ii) Link Here
454
# Params that can only have one value
454
# Params that can only have one value
455
my $scan = $params->{'scan'};
455
my $scan = $params->{'scan'};
456
my $count = C4::Context->preference('numSearchResults') || 20;
456
my $count = C4::Context->preference('numSearchResults') || 20;
457
my $results_per_page = $params->{'count'} || $count;
457
my @results_per_page_options = grep /^\d+$/,
458
                               map {s/\s+//g;$_;}
459
                               split /,/, C4::Context->preference('numSearchResultsPerPage');
460
push(@results_per_page_options, $count);
461
@results_per_page_options = do { my %seen; grep { !$seen{$_}++ } @results_per_page_options };
462
@results_per_page_options = sort {$a <=> $b} @results_per_page_options;
463
464
my $results_per_page = $params->{'results_per_page'} || $cgi->cookie("results_per_page") || $count;
465
my $page = $cgi->param('page') || 1;
458
my $offset = $params->{'offset'} || 0;
466
my $offset = $params->{'offset'} || 0;
459
$offset = 0 if $offset < 0;
467
$offset = 0 if $offset < 0;
460
my $page = $cgi->param('page') || 1;
468
my $hits;
461
#my $offset = ($page-1)*$results_per_page;
462
my $expanded_facet = $params->{'expand'};
469
my $expanded_facet = $params->{'expand'};
463
470
464
# Define some global variables
471
# Define some global variables
Lines 553-559 my @sup_results_array; Link Here
553
for (my $i=0;$i<@servers;$i++) {
560
for (my $i=0;$i<@servers;$i++) {
554
    my $server = $servers[$i];
561
    my $server = $servers[$i];
555
    if ($server =~/biblioserver/) { # this is the local bibliographic server
562
    if ($server =~/biblioserver/) { # this is the local bibliographic server
556
        my $hits = $results_hashref->{$server}->{"hits"} // 0;
563
        $hits = $results_hashref->{$server}->{"hits"} // 0;
564
        $results_per_page = $hits if $results_per_page == 'all';
557
        my $page = $cgi->param('page') || 0;
565
        my $page = $cgi->param('page') || 0;
558
        my @newresults = searchResults({ 'interface' => 'intranet' }, $query_desc, $hits, $results_per_page, $offset, $scan,
566
        my @newresults = searchResults({ 'interface' => 'intranet' }, $query_desc, $hits, $results_per_page, $offset, $scan,
559
                                       $results_hashref->{$server}->{"RECORDS"});
567
                                       $results_hashref->{$server}->{"RECORDS"});
Lines 619-625 for (my $i=0;$i<@servers;$i++) { Link Here
619
            if ($query_desc || $limit_desc) {
627
            if ($query_desc || $limit_desc) {
620
                $template->param(searchdesc => 1);
628
                $template->param(searchdesc => 1);
621
            }
629
            }
622
            $template->param(results_per_page =>  $results_per_page);
630
            $template->param(results_per_page =>  $results_per_page == $hits ? 'all' : $results_per_page);
623
            # must define a value for size if not present in DB
631
            # must define a value for size if not present in DB
624
            # in order to avoid problems generated by the default size value in TT
632
            # in order to avoid problems generated by the default size value in TT
625
            foreach my $line (@newresults) {
633
            foreach my $line (@newresults) {
(-)a/installer/data/mysql/atomicupdate/bug_14715-searchresults_syspref.sql (+2 lines)
Line 0 Link Here
1
INSERT IGNORE INTO systempreferences (`variable`, `value`, `options`, `explanation`,`type`) VALUES ('OPACnumSearchResultsPerPage', '10,20,40,60,80,100', NULL, 'Option list of number of results per page to show in OPAC search results','YesNo');
2
INSERT IGNORE INTO systempreferences (`variable`, `value`, `options`, `explanation`,`type`) VALUES ('numSearchResultsPerPage', '10,20,40,60,80,100', NULL, 'Option list of number of results per page to show in staff client search results','YesNo');
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tt (-1 / +40 lines)
Lines 20-25 Link Here
20
[% INCLUDE 'doc-head-open.inc' %]
20
[% INCLUDE 'doc-head-open.inc' %]
21
<title>Koha &rsaquo; Catalog &rsaquo; [% IF ( searchdesc ) %]Results of search [% IF ( query_desc ) %]for '[% query_desc | html %]'[% END %][% IF ( limit_desc ) %]&nbsp;with limit(s):&nbsp;'[% limit_desc | html %]'[% END %][% ELSE %]You did not specify any search criteria[% END %]</title>
21
<title>Koha &rsaquo; Catalog &rsaquo; [% IF ( searchdesc ) %]Results of search [% IF ( query_desc ) %]for '[% query_desc | html %]'[% END %][% IF ( limit_desc ) %]&nbsp;with limit(s):&nbsp;'[% limit_desc | html %]'[% END %][% ELSE %]You did not specify any search criteria[% END %]</title>
22
[% INCLUDE 'doc-head-close.inc' %]
22
[% INCLUDE 'doc-head-close.inc' %]
23
});
23
</head>
24
</head>
24
25
25
<body id="catalog_results" class="catalog">
26
<body id="catalog_results" class="catalog">
Lines 61-68 Link Here
61
        </h3>
62
        </h3>
62
63
63
        <div id="searchheader">
64
        <div id="searchheader">
64
65
            <div id="selection_ops">
65
            <div id="selection_ops">
66
            <form action="/cgi-bin/koha/catalogue/search.pl" method="get" id="resultoptionsform">
67
                [% IF ( searchdesc ) %]
68
                    [% FOREACH QUERY_INPUT IN QUERY_INPUTS %]
69
                    <input type="hidden" name="[% QUERY_INPUT.input_name |html %]" value="[% QUERY_INPUT.input_value |html %]"/>
70
                    [% END %]
71
                    [% FOREACH LIMIT_INPUT IN LIMIT_INPUTS %]
72
                    <input type="hidden" name="[% LIMIT_INPUT.input_name |html %]" value="[% LIMIT_INPUT.input_value |html %]"/>
73
                    [% END %]
74
                [% END %]
75
                <!-- RE-SORT START -->
76
                    <label for="sort_by">Sort By: </label>
77
                    <select id="sort_by" name="sort_by">
78
                    [% INCLUDE 'resort_form.inc' %]
79
                    </select>
80
                <!-- RESORT END -->
81
                <!-- RESULTS_PER_PAGE START -->
82
                    <label for="results_per_page">Results per page: </label>
83
                    <select id="results_per_page" name="results_per_page">
84
                        <option value="20" [% 'SELECTED' IF results_per_page == '20' %]>20</option>
85
                        <option value="40" [% 'SELECTED' IF results_per_page == '40' %]>40</option>
86
                        <option value="60" [% 'SELECTED' IF results_per_page == '60' %]>60</option>
87
                        <option value="80" [% 'SELECTED' IF results_per_page == '80' %]>80</option>
88
                        <option value="100" [% 'SELECTED' IF results_per_page == '100' %]>100</option>
89
                        <option value="all" [% 'SELECTED' IF results_per_page == 'all' %]>all</option>
90
                    </select>
91
                <!-- RESULTS_PER_PAGE END -->
92
                    <input type="submit" value="Go" />
93
            </form>
94
            <h3>
95
                [% total %] result(s) found [% IF ( query_desc ) %]for <span style="font-weight: bold;">'[% query_desc |html %]'</span>[% END %][% IF limit_desc  %]&nbsp;with limit(s): <span style="font-weight: bold;">'[% limit_desc | html %]'</span>[% END %][% IF ( LibraryName ) %] in [% LibraryName %] Catalog[% END %].<br />&nbsp;
96
            </h3>
66
                <a href="#" id="select_all"><i class="fa fa-check"></i> Select all</a>
97
                <a href="#" id="select_all"><i class="fa fa-check"></i> Select all</a>
67
                |
98
                |
68
                <a href="#" id="clear_all"><i class="fa fa-remove"></i> Clear all</a>
99
                <a href="#" id="clear_all"><i class="fa fa-remove"></i> Clear all</a>
Lines 629-634 Link Here
629
                stickTo: "main",
660
                stickTo: "main",
630
                stickyClass: "floating"
661
                stickyClass: "floating"
631
            });
662
            });
663
            $('#resultoptionsform').find("input:submit").hide();
664
            $('#sort_by').change(function() {
665
                $('#resultoptionsform').submit();
666
            });
667
            $('#results_per_page').change(function() {
668
                $.cookie('results_per_page', $(this).val());
669
                $('#resultoptionsform').submit();
670
            });
632
671
633
            $("#cartsubmit").click(function(e){
672
            $("#cartsubmit").click(function(e){
634
                e.preventDefault();
673
                e.preventDefault();
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-results.tt (+14 lines)
Lines 164-169 Link Here
164
                                    [% UNLESS tag %]
164
                                    [% UNLESS tag %]
165
                                        <div class="sort_by pull-right">
165
                                        <div class="sort_by pull-right">
166
                                            <select id="sort_by" class="resort" name="sort_by"> [% INCLUDE 'resort_form.inc' %] </select>
166
                                            <select id="sort_by" class="resort" name="sort_by"> [% INCLUDE 'resort_form.inc' %] </select>
167
168
                                            <label for="results_per_page">Results per page: </label>
169
                                            <select id="results_per_page" name="results_per_page">
170
                                                <option value="20" [% 'SELECTED' IF results_per_page == '20' %]>20</option>
171
                                                <option value="40" [% 'SELECTED' IF results_per_page == '40' %]>40</option>
172
                                                <option value="60" [% 'SELECTED' IF results_per_page == '60' %]>60</option>
173
                                                <option value="80" [% 'SELECTED' IF results_per_page == '80' %]>80</option>
174
                                                <option value="100" [% 'SELECTED' IF results_per_page == '100' %]>100</option>
175
                                            </select>
176
167
                                            <input type="submit" class="btn btn-small clearfix" id="sortsubmit" value="Go" />
177
                                            <input type="submit" class="btn btn-small clearfix" id="sortsubmit" value="Go" />
168
                                        </div>
178
                                        </div>
169
                                    [% END %]
179
                                    [% END %]
Lines 828-833 $(document).ready(function(){ Link Here
828
    $('.resort').change(function() {
838
    $('.resort').change(function() {
829
        $('#bookbag_form').submit();
839
        $('#bookbag_form').submit();
830
    });
840
    });
841
    $('#results_per_page').change(function() {
842
        $.cookie('results_per_page', $(this).val());
843
        $('#bookbag_form').submit();
844
    });
831
    $("span.clearall").html("<a id=\"CheckNone\" href=\"#\">"+_("Clear all")+"<\/a>");
845
    $("span.clearall").html("<a id=\"CheckNone\" href=\"#\">"+_("Clear all")+"<\/a>");
832
    $("span.checkall").html("<a id=\"CheckAll\" href=\"#\">"+_("Select all")+"<\/a>");
846
    $("span.checkall").html("<a id=\"CheckAll\" href=\"#\">"+_("Select all")+"<\/a>");
833
847
(-)a/opac/opac-search.pl (-6 / +4 lines)
Lines 523-533 if ($params->{'limit-yr'}) { Link Here
523
my $scan = $params->{'scan'};
523
my $scan = $params->{'scan'};
524
my $count = C4::Context->preference('OPACnumSearchResults') || 20;
524
my $count = C4::Context->preference('OPACnumSearchResults') || 20;
525
my $countRSS         = C4::Context->preference('numSearchRSSResults') || 50;
525
my $countRSS         = C4::Context->preference('numSearchRSSResults') || 50;
526
my $results_per_page = $params->{'count'} || $count;
526
my $results_per_page = $params->{'results_per_page'} || $cgi->cookie("results_per_page") || $count;
527
my $page = $cgi->param('page') || 1;
527
my $offset = $params->{'offset'} || 0;
528
my $offset = $params->{'offset'} || 0;
528
$offset = 0 if $offset < 0;
529
$offset = 0 if $offset < 0;
529
my $page = $cgi->param('page') || 1;
530
$offset = ($page-1)*$results_per_page if $page>1;
531
my $hits;
530
my $hits;
532
my $expanded_facet = $params->{'expand'};
531
my $expanded_facet = $params->{'expand'};
533
532
Lines 604-610 if ($tag) { Link Here
604
    # FIXME: No facets for tags search.
603
    # FIXME: No facets for tags search.
605
} elsif ($build_grouped_results) {
604
} elsif ($build_grouped_results) {
606
    eval {
605
    eval {
607
        ($error, $results_hashref, $facets) = C4::Search::pazGetRecords($query,$simple_query,\@sort_by,\@servers,$results_per_page,$offset,$expanded_facet,undef,$query_type,$scan);
606
        ($error, $results_hashref, $facets) = C4::Search::pazGetRecords($query,$simple_query,\@sort_by,\@servers,$results_per_page,$offset,$expanded_facet,$query_type,$scan);
608
    };
607
    };
609
} else {
608
} else {
610
    $pasarParams .= '&amp;query=' . uri_escape_utf8($query);
609
    $pasarParams .= '&amp;query=' . uri_escape_utf8($query);
Lines 801-807 for (my $i=0;$i<@servers;$i++) { Link Here
801
            if ($query_desc || $limit_desc) {
800
            if ($query_desc || $limit_desc) {
802
                $template->param(searchdesc => 1);
801
                $template->param(searchdesc => 1);
803
            }
802
            }
804
            $template->param(results_per_page =>  $results_per_page);
803
            $template->param(results_per_page => $results_per_page);
805
            my $hide = C4::Context->preference('OpacHiddenItems');
804
            my $hide = C4::Context->preference('OpacHiddenItems');
806
            $hide = ($hide =~ m/\S/) if $hide; # Just in case it has some spaces/new lines
805
            $hide = ($hide =~ m/\S/) if $hide; # Just in case it has some spaces/new lines
807
            my $branch = '';
806
            my $branch = '';
808
- 

Return to bug 14715