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

(-)a/C4/Items.pm (+6 lines)
Lines 1218-1223 $filter->{fromDate} = '01/01/2013'; #Filters only serial issues by the serialite Link Here
1218
                                          #The starting date in C4::Context->preference('dateformat') format
1218
                                          #The starting date in C4::Context->preference('dateformat') format
1219
$filter->{toDate} = '31/12/2014';   #Filters only serial issues by the serialitems.publisheddate
1219
$filter->{toDate} = '31/12/2014';   #Filters only serial issues by the serialitems.publisheddate
1220
                                          #The ending date in C4::Context->preference('dateformat') format
1220
                                          #The ending date in C4::Context->preference('dateformat') format
1221
$filter->{limit} = 15;              #Limits the returning set to this many items
1221
                                          
1222
                                          
1222
Filters are expected to be validated! If a filter is not defined, that filter is not present in the $filter-HASH
1223
Filters are expected to be validated! If a filter is not defined, that filter is not present in the $filter-HASH
1223
1224
Lines 1342-1347 sub GetItemsInfo { Link Here
1342
    }
1343
    }
1343
    
1344
    
1344
    $query .= "ORDER BY home.branchname, items.enumchron, LPAD( items.copynumber, 8, '0' ), items.dateaccessioned DESC" ;
1345
    $query .= "ORDER BY home.branchname, items.enumchron, LPAD( items.copynumber, 8, '0' ), items.dateaccessioned DESC" ;
1346
    if (exists $filter->{limit}) {
1347
        push @$queryParams, $filter->{limit};
1348
        $query .= " LIMIT ?";
1349
    }
1350
    
1345
    my $sth = $dbh->prepare($query);
1351
    my $sth = $dbh->prepare($query);
1346
    $sth->execute(@$queryParams);
1352
    $sth->execute(@$queryParams);
1347
    my $i = 0;
1353
    my $i = 0;
(-)a/installer/data/mysql/sysprefs.sql (+1 lines)
Lines 239-244 INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` Link Here
239
('OpacMaintenance','0','','If ON, enables maintenance warning in OPAC','YesNo'),
239
('OpacMaintenance','0','','If ON, enables maintenance warning in OPAC','YesNo'),
240
('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'),
240
('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'),
241
('OpacMainUserBlockMobile','',NULL,'Show the following HTML in its own column on the main page of the OPAC (mobile version):','free'),
241
('OpacMainUserBlockMobile','',NULL,'Show the following HTML in its own column on the main page of the OPAC (mobile version):','free'),
242
('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'),
242
('OPACMobileUserCSS','',NULL,'Include the following CSS for the mobile view on all pages in the OPAC:','free'),
243
('OPACMobileUserCSS','',NULL,'Include the following CSS for the mobile view on all pages in the OPAC:','free'),
243
('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'),
244
('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'),
244
('OpacNav','Important links here.','70|10','Use HTML tags to add navigational links to the left-hand navigational bar in OPAC','Textarea'),
245
('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.
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/modules/opac-detail.tt (-5 / +12 lines)
Lines 1054-1060 YAHOO.util.Event.onContentReady("furtherm", function () { Link Here
1054
1054
1055
<div id="holdings">
1055
<div id="holdings">
1056
    
1056
    
1057
    [% IF ( lotsofitems ) %]
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 %]
Lines 1062-1071 YAHOO.util.Event.onContentReady("furtherm", function () { Link Here
1062
[% IF ( itemloop.size ) %]    
1062
[% IF ( itemloop.size ) %]    
1063
    
1063
    
1064
    [% IF ( lotsofitems ) %]
1064
    [% IF ( lotsofitems ) %]
1065
	<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>
1066
    [% ELSE %]
1066
            [% IF userBranchNotDefined %]
1067
        [% 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>
1068
    [% END %]
1073
    [% END %]
1074
    [% INCLUDE items_table items=itemloop tab="holdings" %]
1075
1069
    [% IF holds_count.defined || priority %]
1076
    [% IF holds_count.defined || priority %]
1070
    <div id="bib_holds">
1077
    <div id="bib_holds">
1071
        [% IF holds_count.defined %]
1078
        [% IF holds_count.defined %]
Lines 1638-1644 YAHOO.util.Event.onContentReady("furtherm", function () { Link Here
1638
    <div id="filterIssuesParentContainer">
1645
    <div id="filterIssuesParentContainer">
1639
    <a id="filterIssuesButton" >Limit issues</a>
1646
    <a id="filterIssuesButton" >Limit issues</a>
1640
    [% IF filter %]
1647
    [% IF filter %]
1641
        <form id="issuesFilter" method="get" action="/cgi-bin/koha/opac-detail.pl">
1648
        <form id="issuesFilterClearer" method="get" action="/cgi-bin/koha/opac-detail.pl">
1642
            <input type="hidden" name="biblionumber" id="biblionumber" value="[% biblionumber %]"/>
1649
            <input type="hidden" name="biblionumber" id="biblionumber" value="[% biblionumber %]"/>
1643
            <input type="submit" name="clearFilter" value="Clear filter" class="submit"/>
1650
            <input type="submit" name="clearFilter" value="Clear filter" class="submit"/>
1644
        </form>
1651
        </form>
(-)a/opac/opac-detail.pl (-19 / +44 lines)
Lines 84-90 my $filterIssue = $query->param('filterIssue') ? $query->param('filterIssue') : Link Here
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 $lotsofitems = 0;
154
if ($itemsCount > C4::Context->preference('OPACmaxItemsOnDetail') &&
155
    !($query->param('viewallitems')) ) {
156
    
157
    $lotsofitems = 1;
158
    $template->param('lotsofitems' => $lotsofitems);
159
}
160
161
my @all_items;
162
if ($lotsofitems) {
163
    #Spare the poor old DB from this possibly excruciatinly huge read operation.
164
    if (! scalar(%$filter)) { #Is the $filter empty?
165
        #Limit display of Items based on the users branch
166
        if (C4::Context->userenv){
167
            $filter->{branch} = C4::Context->userenv->{branch};
168
            $filterBranchLimiter = $filter->{branch}; #Making the branches loop react to this!
169
        }
170
        #Or if branch cannot be defined, then display Items only from the past year
171
        else {
172
            my $now = DateTime->now();
173
            $now->set_year(  ($now->year() - 1)  );
174
            $filter->{fromDate} = Koha::DateUtils::output_pref({ dt => $now, dateformat => 'iso'});
175
            $template->param('userBranchNotDefined' => 1);
176
        }
177
        $filter->{limit} = C4::Context->preference('OPACmaxItemsOnDetail');
178
    }
179
}
180
@all_items = GetItemsInfo($biblionumber, $filter);
181
144
182
145
##Prepare the custom branches loop containing the _ShowAll entry to show issues from all libraries.
183
##Prepare the custom branches loop containing the _ShowAll entry to show issues from all libraries.
146
my $branchloop;
184
my $branchloop;
Lines 153-171 else { Link Here
153
    unshift @$branchloop, { branchcode => '_ShowAll', branchname => 'Show from any library', selected => '0', value => '_ShowAll'};
191
    unshift @$branchloop, { branchcode => '_ShowAll', branchname => 'Show from any library', selected => '0', value => '_ShowAll'};
154
}
192
}
155
$template->param( branchloop => $branchloop );
193
$template->param( branchloop => $branchloop );
156
$template->param( filter => $filter ) if defined $filter;
157
158
##
159
##<< Serial issues filter parameters handled! ##
160
##
161
162
194
163
my @all_items = GetItemsInfo($biblionumber, $filter);
164
195
165
# Now that the filter is no longer needed, we can reuse it to keep the filter modifications in the UI,
196
# 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.
197
#  by reverting the dates and the branch to the same format as in the UI layer.
167
$filter->{fromDate} = $filterFromDate;
198
$filter->{fromDate} = $filterFromDate if $filterFromDate;
168
$filter->{toDate} = $filterToDate;
199
$filter->{toDate} = $filterToDate if $filterToDate;
200
$filter->{branch} = $filterBranchLimiter if $filterBranchLimiter;
201
$template->param('showFilter' => 1) if (scalar(%$filter));
169
202
170
my @hiddenitems;
203
my @hiddenitems;
171
if (scalar @all_items >= 1) {
204
if (scalar @all_items >= 1) {
Lines 731-743 if (scalar(@itemloop) == 0 || scalar(@otheritemloop) == 0) { Link Here
731
    }
764
    }
732
}
765
}
733
766
734
# If there is a lot of items, and the user has not decided
735
# to view them all yet, we first warn him
736
# TODO: The limit of 50 could be a syspref
737
my $viewallitems = $query->param('viewallitems');
738
if (scalar(@itemloop) >= 50 && !$viewallitems) {
739
    $template->param('lotsofitems' => 1);
740
}
741
767
742
## get notes and subjects from MARC record
768
## get notes and subjects from MARC record
743
my $dbh              = C4::Context->dbh;
769
my $dbh              = C4::Context->dbh;
744
- 

Return to bug 6385