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 $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 |
|
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 731-743
if (scalar(@itemloop) == 0 || scalar(@otheritemloop) == 0) {
Link Here
|
731 |
} |
777 |
} |
732 |
} |
778 |
} |
733 |
|
779 |
|
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 |
|
780 |
|
742 |
## get notes and subjects from MARC record |
781 |
## get notes and subjects from MARC record |
743 |
my $dbh = C4::Context->dbh; |
782 |
my $dbh = C4::Context->dbh; |