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

(-)a/C4/Items.pm (+6 lines)
Lines 1235-1240 $filter->{fromDate} = '01/01/2013'; #Filters only serial issues by the serialite Link Here
1235
                                          #The starting date in C4::Context->preference('dateformat') format
1235
                                          #The starting date in C4::Context->preference('dateformat') format
1236
$filter->{toDate} = '31/12/2014';   #Filters only serial issues by the serialitems.publisheddate
1236
$filter->{toDate} = '31/12/2014';   #Filters only serial issues by the serialitems.publisheddate
1237
                                          #The ending date in C4::Context->preference('dateformat') format
1237
                                          #The ending date in C4::Context->preference('dateformat') format
1238
$filter->{limit} = 15;              #Limits the returning set to this many items
1238
1239
1239
Filters are expected to be validated! If a filter is not defined, that filter is not present in the $filter-HASH
1240
Filters are expected to be validated! If a filter is not defined, that filter is not present in the $filter-HASH
1240
1241
Lines 1359-1364 sub GetItemsInfo { Link Here
1359
    }
1360
    }
1360
1361
1361
    $query .= "ORDER BY home.branchname, items.enumchron, LPAD( items.copynumber, 8, '0' ), items.dateaccessioned DESC" ;
1362
    $query .= "ORDER BY home.branchname, items.enumchron, LPAD( items.copynumber, 8, '0' ), items.dateaccessioned DESC" ;
1363
    if (exists $filter->{limit}) {
1364
        push @$queryParams, $filter->{limit};
1365
        $query .= " LIMIT ?";
1366
    }
1367
1362
    my $sth = $dbh->prepare($query);
1368
    my $sth = $dbh->prepare($query);
1363
    $sth->execute(@$queryParams);
1369
    $sth->execute(@$queryParams);
1364
    my $i = 0;
1370
    my $i = 0;
(-)a/installer/data/mysql/sysprefs.sql (+1 lines)
Lines 241-246 INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` Link Here
241
('OpacMaintenance','0','','If ON, enables maintenance warning in OPAC','YesNo'),
241
('OpacMaintenance','0','','If ON, enables maintenance warning in OPAC','YesNo'),
242
('OpacMainUserBlock','Welcome to Koha...\r\n<hr>','70|10','A user-defined block of HTML  in the main content area of the opac main page','Textarea'),
242
('OpacMainUserBlock','Welcome to Koha...\r\n<hr>','70|10','A user-defined block of HTML  in the main content area of the opac main page','Textarea'),
243
('OpacMainUserBlockMobile','',NULL,'Show the following HTML in its own column on the main page of the OPAC (mobile version):','free'),
243
('OpacMainUserBlockMobile','',NULL,'Show the following HTML in its own column on the main page of the OPAC (mobile version):','free'),
244
('OPACmaxItemsOnDetail', '50', NULL, 'On the Bibliographic record details page, show only items from the users branch and prompt the user to filter the items if the record has more then this many items.', 'Integer'),
244
('OPACMobileUserCSS','',NULL,'Include the following CSS for the mobile view on all pages in the OPAC:','free'),
245
('OPACMobileUserCSS','',NULL,'Include the following CSS for the mobile view on all pages in the OPAC:','free'),
245
('OPACMySummaryHTML','','70|10','Enter the HTML that will appear in a column on the \'my summary\' and \'my reading history\' tabs when a user is logged in to the OPAC. Enter {BIBLIONUMBER}, {TITLE}, {AUTHOR}, or {ISBN} in place of their respective variables in the HTML. Leave blank to disable.','Textarea'),
246
('OPACMySummaryHTML','','70|10','Enter the HTML that will appear in a column on the \'my summary\' and \'my reading history\' tabs when a user is logged in to the OPAC. Enter {BIBLIONUMBER}, {TITLE}, {AUTHOR}, or {ISBN} in place of their respective variables in the HTML. Leave blank to disable.','Textarea'),
246
('OpacNav','Important links here.','70|10','Use HTML tags to add navigational links to the left-hand navigational bar in OPAC','Textarea'),
247
('OpacNav','Important links here.','70|10','Use HTML tags to add navigational links to the left-hand navigational bar in OPAC','Textarea'),
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref (+4 lines)
Lines 188-193 OPAC: Link Here
188
              type: textarea
188
              type: textarea
189
              class: code
189
              class: code
190
        -
190
        -
191
            - On the Bibliographic record details page, show only this many items from the users branch and prompt the user to filter the items if the record has more than this many items. If the user has no branch or the branch has no items, displaying items from the past year.
192
            - pref: OPACmaxItemsOnDetail
193
              class: integer
194
        -
191
            - pref: OpacShowLibrariesPulldownMobile
195
            - pref: OpacShowLibrariesPulldownMobile
192
              choices:
196
              choices:
193
                  yes: Show
197
                  yes: Show
(-)a/koha-tmpl/opac-tmpl/prog/en/css/opac-detail.css (+9 lines)
Lines 11-14 Link Here
11
11
12
	padding-right: 20px;
12
	padding-right: 20px;
13
    margin-right: 6px;
13
    margin-right: 6px;
14
}
15
16
#clearFilter {
17
	border: none;
18
	background: none;
19
	color: #006699;
20
}
21
#clearFilter:hover {
22
	color : #990033;
14
}
23
}
(-)a/koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tt (-6 / +14 lines)
Lines 1054-1070 YAHOO.util.Event.onContentReady("furtherm", function () { Link Here
1054
1054
1055
<div id="holdings">
1055
<div id="holdings">
1056
1056
1057
    [% IF ( lotsofholdingsitems ) %]
1057
    [% IF ( showFilter ) %]
1058
        [%# Display the items filtering form used to filter the shown items. See the end of this file! %]
1058
        [%# Display the items filtering form used to filter the shown items. See the end of this file! %]
1059
        [% INCLUDE filter_form tab="holdings" %]
1059
        [% INCLUDE filter_form tab="holdings" %]
1060
    [% END %]
1060
    [% END %]
1061
1061
1062
[% IF ( itemloop.size ) %]
1062
[% IF ( itemloop.size ) %]
1063
1063
    [% IF ( lotsofholdingsitems ) %]
1064
    [% IF ( lotsofholdingsitems ) %]
1064
        <p>This record has many physical items. <a href="/cgi-bin/koha/opac-detail.pl?biblionumber=[% biblionumber %]&amp;viewallitems=1#holdings">Click here to view them all.</a> Or use the filter above to limit your selection</p>
1065
        <p>
1065
    [% ELSE %]
1066
            [% IF noBranchItems %]
1066
        [% INCLUDE items_table items=itemloop tab="holdings" %]
1067
                Limiting items to the most recent received last year.</br>
1068
            [% ELSE %]
1069
                Showing only the most recent items from your branch.</br>
1070
            [% END %]
1071
            This record has many physical items. Use the filter above to limit your selection.
1072
        </p>
1067
    [% END %]
1073
    [% END %]
1074
    [% INCLUDE items_table items=itemloop tab="holdings" %]
1075
1068
    [% IF holds_count.defined || priority %]
1076
    [% IF holds_count.defined || priority %]
1069
    <div id="bib_holds">
1077
    <div id="bib_holds">
1070
        [% IF holds_count.defined %]
1078
        [% IF holds_count.defined %]
Lines 1641-1649 YAHOO.util.Event.onContentReady("furtherm", function () { Link Here
1641
    <div id="filterIssuesParentContainer">
1649
    <div id="filterIssuesParentContainer">
1642
    <a id="filterIssuesButton" >Limit issues</a>
1650
    <a id="filterIssuesButton" >Limit issues</a>
1643
    [% IF filter %]
1651
    [% IF filter %]
1644
        <form id="issuesFilter" method="get" action="/cgi-bin/koha/opac-detail.pl">
1652
        <form id="issuesFilterClearer" method="get" action="/cgi-bin/koha/opac-detail.pl">
1645
            <input type="hidden" name="biblionumber" id="biblionumber" value="[% biblionumber %]"/>
1653
            <input type="hidden" name="biblionumber" id="biblionumber" value="[% biblionumber %]"/>
1646
            <input type="submit" name="clearFilter" value="Clear filter" class="submit"/>
1654
            <input type="submit" id="clearFilter" name="clearFilter" value="Clear filter" class="submit"/>
1647
        </form>
1655
        </form>
1648
    [% END %]
1656
    [% END %]
1649
    <div id="filterIssuesFormContainer">
1657
    <div id="filterIssuesFormContainer">
(-)a/opac/opac-detail.pl (-16 / +59 lines)
Lines 77-90 $biblionumber = int($biblionumber); Link Here
77
##>> Handling the Serial issue filter parameters from the user
77
##>> Handling the Serial issue filter parameters from the user
78
##
78
##
79
# We can filter issues based on these five values.
79
# We can filter issues based on these five values.
80
my $filterBranchLimiter = $query->param('filterBranchLimiter') ? $query->param('filterBranchLimiter') : '_ShowAll';
80
my $filterBranchLimiter = $query->param('filterBranchLimiter') ? $query->param('filterBranchLimiter') : undef;
81
my $filterVolume = $query->param('filterVolume') ? $query->param('filterVolume') : undef;
81
my $filterVolume = $query->param('filterVolume') ? $query->param('filterVolume') : undef;
82
my $filterNumber = $query->param('filterNumber') ? $query->param('filterNumber') : undef;
82
my $filterNumber = $query->param('filterNumber') ? $query->param('filterNumber') : undef;
83
my $filterIssue = $query->param('filterIssue') ? $query->param('filterIssue') : undef;
83
my $filterIssue = $query->param('filterIssue') ? $query->param('filterIssue') : undef;
84
my $filterFromDate = $query->param('filterFrom') ? $query->param('filterFrom') : undef;
84
my $filterFromDate = $query->param('filterFrom') ? $query->param('filterFrom') : undef;
85
my $filterToDate = $query->param('filterTo') ? $query->param('filterTo') : undef;
85
my $filterToDate = $query->param('filterTo') ? $query->param('filterTo') : undef;
86
86
87
my $filter; #a HASH! Collect the filters here, so they can be more conveniently moved around.
87
my $filter = {}; #a HASH! Collect the filters here, so they can be more conveniently moved around.
88
88
89
#We filter by the branch only if a valid branch is given.
89
#We filter by the branch only if a valid branch is given.
90
if (defined $filterBranchLimiter && $filterBranchLimiter ne '_ShowAll') {
90
if (defined $filterBranchLimiter && $filterBranchLimiter ne '_ShowAll') {
Lines 141-146 if (defined $filterToDate && length $filterToDate > 0) { Link Here
141
    }
141
    }
142
}
142
}
143
143
144
$template->param( filter => $filter );
145
146
##
147
##<< Serial issues filter parameters handled! ##
148
##
149
150
# If there are a lot of items, and the user has not decided
151
# to view them all yet, we first warn him
152
my $itemsCount = GetItemsCount($biblionumber);
153
my $lotsofholdingsitems = 0;
154
if ($itemsCount > C4::Context->preference('OPACmaxItemsOnDetail') &&
155
    !($query->param('viewallitems')) ) {
156
157
    $lotsofholdingsitems = 1;
158
    $template->param('lotsofholdingsitems' => $lotsofholdingsitems);
159
}
160
161
my @all_items;
162
if ($lotsofholdingsitems) {
163
    #Spare the poor old DB from this possibly excruciatinly huge read operation.
164
    if (! scalar(%$filter)) { #Is the $filter empty?
165
166
        #Limit the amount of results to the system preference
167
        $filter->{limit} = C4::Context->preference('OPACmaxItemsOnDetail');
168
169
        #Limit display of Items based on the users branch
170
        if (C4::Context->userenv){
171
            $filter->{branch} = C4::Context->userenv->{branch};
172
            $filterBranchLimiter = $filter->{branch}; #Making the branches loop react to this!
173
174
            @all_items = GetItemsInfo($biblionumber, $filter);
175
        }
176
        #Or if branch cannot be defined or has no items, then display Items only from the past year
177
        if( ! (scalar(@all_items)) ) {
178
            delete $filter->{branch}; #Remove the branch filter as it gave no results
179
            undef $filterBranchLimiter;
180
181
            my $now = DateTime->now();
182
            $now->set_year(  ($now->year() - 1)  );
183
            $filter->{fromDate} = Koha::DateUtils::output_pref({ dt => $now, dateformat => 'iso'});
184
            $template->param('noBranchItems' => 1);
185
            @all_items = GetItemsInfo($biblionumber, $filter);
186
        }
187
188
    }
189
}
190
#If we haven't found our items yet, then pull them using whatever we've got.
191
if( ! (scalar(@all_items)) ) {
192
    @all_items = GetItemsInfo($biblionumber, $filter);
193
}
194
144
195
145
##Prepare the custom branches loop containing the _ShowAll entry to show issues from all libraries.
196
##Prepare the custom branches loop containing the _ShowAll entry to show issues from all libraries.
146
my $branchloop;
197
my $branchloop;
Lines 153-171 else { Link Here
153
    unshift @$branchloop, { branchcode => '_ShowAll', branchname => 'Show from any library', selected => '0', value => '_ShowAll'};
204
    unshift @$branchloop, { branchcode => '_ShowAll', branchname => 'Show from any library', selected => '0', value => '_ShowAll'};
154
}
205
}
155
$template->param( branchloop => $branchloop );
206
$template->param( branchloop => $branchloop );
156
$template->param( filter => $filter ) if defined $filter;
157
207
158
##
159
##<< Serial issues filter parameters handled! ##
160
##
161
162
163
my @all_items = GetItemsInfo($biblionumber, $filter);
164
208
165
# Now that the filter is no longer needed, we can reuse it to keep the filter modifications in the UI,
209
# Now that the filter is no longer needed, we can reuse it to keep the filter modifications in the UI,
166
#  by reverting the dates to the same format as in the UI layer.
210
#  by reverting the dates and the branch to the same format as in the UI layer.
167
$filter->{fromDate} = $filterFromDate;
211
$filter->{fromDate} = $filterFromDate if $filterFromDate;
168
$filter->{toDate} = $filterToDate;
212
$filter->{toDate} = $filterToDate if $filterToDate;
213
$filter->{branch} = $filterBranchLimiter if $filterBranchLimiter;
214
$template->param('showFilter' => 1) if (scalar(%$filter));
169
215
170
my @hiddenitems;
216
my @hiddenitems;
171
if (scalar @all_items >= 1) {
217
if (scalar @all_items >= 1) {
Lines 734-744 if (scalar(@itemloop) == 0 || scalar(@otheritemloop) == 0) { Link Here
734
780
735
# If there is a lot of items, and the user has not decided
781
# If there is a lot of items, and the user has not decided
736
# to view them all yet, we first warn him
782
# to view them all yet, we first warn him
737
# TODO: The limit of 50 could be a syspref
783
# TODO: The limit of 50 could be a syspref, it already is !!
738
my $viewallitems = $query->param('viewallitems');
784
my $viewallitems = $query->param('viewallitems');
739
if (scalar(@itemloop) >= 50 && !$viewallitems) {
740
    $template->param('lotsofholdingsitems' => 1);
741
}
742
if (scalar(@otheritemloop) >= 50 && !$viewallitems) {
785
if (scalar(@otheritemloop) >= 50 && !$viewallitems) {
743
    $template->param('lotsofothersholdingsitems' => 1);
786
    $template->param('lotsofothersholdingsitems' => 1);
744
}
787
}
(-)a/t/db_dependent/Items.t (-2 / +5 lines)
Lines 145-151 subtest 'GetHiddenItemnumbers tests' => sub { Link Here
145
145
146
subtest 'Filter items tests' => sub {
146
subtest 'Filter items tests' => sub {
147
147
148
    plan tests => 2;
148
    plan tests => 3;
149
149
150
    # Start transaction
150
    # Start transaction
151
    $dbh->{AutoCommit} = 0;
151
    $dbh->{AutoCommit} = 0;
Lines 173-178 subtest 'Filter items tests' => sub { Link Here
173
    # Testing the dates filter
173
    # Testing the dates filter
174
    my @shouldBeEmpty = C4::Items::GetItemsInfo($biblionumber, {toDate => '01/01/1933'});
174
    my @shouldBeEmpty = C4::Items::GetItemsInfo($biblionumber, {toDate => '01/01/1933'});
175
    is( scalar(@shouldBeEmpty), 0, "Filtering by date");
175
    is( scalar(@shouldBeEmpty), 0, "Filtering by date");
176
177
    # Testing the limit filter
178
    @shouldBeEmpty = C4::Items::GetItemsInfo($biblionumber, {limit => 0});
179
    is( scalar(@shouldBeEmpty), 0, "Filtering by limit");
176
};
180
};
177
181
178
# Helper method to set up a Biblio.
182
# Helper method to set up a Biblio.
179
- 

Return to bug 6385