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 |
- |
|
|