|
Lines 91-99
my $returnsuggested = $input->param('returnsuggested');
Link Here
|
| 91 |
my $managedby = $input->param('managedby'); |
91 |
my $managedby = $input->param('managedby'); |
| 92 |
my $displayby = $input->param('displayby') || ''; |
92 |
my $displayby = $input->param('displayby') || ''; |
| 93 |
my $tabcode = $input->param('tabcode'); |
93 |
my $tabcode = $input->param('tabcode'); |
|
|
94 |
my $filter_branchcode = $input->param('filter_branchcode'); |
| 94 |
|
95 |
|
| 95 |
# filter informations which are not suggestion related. |
96 |
# filter informations which are not suggestion related. |
| 96 |
my $suggestion_ref = $input->Vars; |
97 |
my $suggestion_ref = $input->Vars; |
|
|
98 |
my $IndependentBranches; |
| 99 |
my $SuperLibrarian; |
| 97 |
|
100 |
|
| 98 |
# get only the columns of Suggestion |
101 |
# get only the columns of Suggestion |
| 99 |
my $schema = Koha::Database->new()->schema; |
102 |
my $schema = Koha::Database->new()->schema; |
|
Lines 117-122
my ( $template, $borrowernumber, $cookie, $userflags ) = get_template_and_user(
Link Here
|
| 117 |
$borrowernumber = $input->param('borrowernumber') if ( $input->param('borrowernumber') ); |
120 |
$borrowernumber = $input->param('borrowernumber') if ( $input->param('borrowernumber') ); |
| 118 |
$template->param('borrowernumber' => $borrowernumber); |
121 |
$template->param('borrowernumber' => $borrowernumber); |
| 119 |
|
122 |
|
|
|
123 |
#Check if IndependentBranches syspref is enabled and if it is then return IndependentBranches variable of 1 so library |
| 124 |
#filtering does not occur in suggestion.tt |
| 125 |
if ( Koha::Config::SysPrefs->find( 'IndependentBranches')->value) { |
| 126 |
$IndependentBranches = 1; |
| 127 |
$template->param( |
| 128 |
IndependentBranches => $IndependentBranches |
| 129 |
); |
| 130 |
} |
| 131 |
|
| 132 |
if (C4::Context->IsSuperLibrarian()) { |
| 133 |
$SuperLibrarian =1; |
| 134 |
$template->param( |
| 135 |
SuperLibrarian => $SuperLibrarian |
| 136 |
); |
| 137 |
} |
| 138 |
|
| 139 |
# |
| 120 |
######################################### |
140 |
######################################### |
| 121 |
## Operations |
141 |
## Operations |
| 122 |
## |
142 |
## |
|
Lines 225-231
elsif ( $op eq 'show' ) {
Link Here
|
| 225 |
} |
245 |
} |
| 226 |
if ($op=~/else/) { |
246 |
if ($op=~/else/) { |
| 227 |
$op='else'; |
247 |
$op='else'; |
| 228 |
|
248 |
|
| 229 |
$displayby||="STATUS"; |
249 |
$displayby||="STATUS"; |
| 230 |
delete $$suggestion_ref{'branchcode'} if($displayby eq "branchcode"); |
250 |
delete $$suggestion_ref{'branchcode'} if($displayby eq "branchcode"); |
| 231 |
# distinct values of display by |
251 |
# distinct values of display by |
|
Lines 245-273
if ($op=~/else/) {
Link Here
|
| 245 |
my $reasonsloop = GetAuthorisedValues("SUGGEST"); |
265 |
my $reasonsloop = GetAuthorisedValues("SUGGEST"); |
| 246 |
foreach my $criteriumvalue ( @criteria_dv ) { |
266 |
foreach my $criteriumvalue ( @criteria_dv ) { |
| 247 |
# By default, display suggestions from current working branch |
267 |
# By default, display suggestions from current working branch |
| 248 |
unless ( exists $$suggestion_ref{'branchcode'} ) { |
268 |
|
| 249 |
$$suggestion_ref{'branchcode'} = C4::Context->userenv->{'branch'}; |
269 |
if ( $IndependentBranches && !$SuperLibrarian) { |
|
|
270 |
unless ( $$suggestion_ref{'branchcode'} ) { |
| 271 |
$$suggestion_ref{'branchcode'} = C4::Context->userenv->{'branch'}; |
| 272 |
} |
| 250 |
} |
273 |
} |
|
|
274 |
|
| 251 |
my $definedvalue = defined $$suggestion_ref{$displayby} && $$suggestion_ref{$displayby} ne ""; |
275 |
my $definedvalue = defined $$suggestion_ref{$displayby} && $$suggestion_ref{$displayby} ne ""; |
| 252 |
|
276 |
|
| 253 |
next if ( $definedvalue && $$suggestion_ref{$displayby} ne $criteriumvalue ); |
277 |
next if ( $definedvalue && $$suggestion_ref{$displayby} ne $criteriumvalue ); |
| 254 |
$$suggestion_ref{$displayby} = $criteriumvalue; |
278 |
$$suggestion_ref{$displayby} = $criteriumvalue; |
| 255 |
|
279 |
|
| 256 |
my $suggestions = &SearchSuggestion($suggestion_ref); |
280 |
my $suggestions = &SearchSuggestion($suggestion_ref); |
|
|
281 |
|
| 282 |
my $filteredsuggestionlist; |
| 257 |
foreach my $suggestion (@$suggestions) { |
283 |
foreach my $suggestion (@$suggestions) { |
| 258 |
if ($suggestion->{budgetid}){ |
284 |
if ($suggestion->{budgetid}){ |
| 259 |
my $bud = GetBudget( $suggestion->{budgetid} ); |
285 |
my $bud = GetBudget( $suggestion->{budgetid} ); |
| 260 |
$suggestion->{budget_name} = $bud->{budget_name} if $bud; |
286 |
$suggestion->{budget_name} = $bud->{budget_name} if $bud; |
| 261 |
} |
287 |
} |
|
|
288 |
if ($filter_branchcode) { |
| 289 |
push @$filteredsuggestionlist, $suggestion if ($suggestion->{'branchcode'} eq $filter_branchcode); |
| 290 |
} |
| 262 |
} |
291 |
} |
| 263 |
push @allsuggestions,{ |
|
|
| 264 |
"suggestiontype"=>$criteriumvalue||"suggest", |
| 265 |
"suggestiontypelabel"=>GetCriteriumDesc($criteriumvalue,$displayby)||"", |
| 266 |
"suggestionscount"=>scalar(@$suggestions), |
| 267 |
'suggestions_loop'=>$suggestions, |
| 268 |
'reasonsloop' => $reasonsloop, |
| 269 |
}; |
| 270 |
|
292 |
|
|
|
293 |
if ( $filter_branchcode && $filteredsuggestionlist) { |
| 294 |
push @allsuggestions,{ |
| 295 |
"suggestiontype"=>$criteriumvalue||"suggest", |
| 296 |
"suggestiontypelabel"=>GetCriteriumDesc($criteriumvalue,$displayby)||"", |
| 297 |
"suggestionscount"=>scalar(@$filteredsuggestionlist), |
| 298 |
'suggestions_loop'=>$filteredsuggestionlist, |
| 299 |
'reasonsloop' => $reasonsloop, |
| 300 |
}; |
| 301 |
} elsif ( $filter_branchcode eq "__ANY__" ) { |
| 302 |
push @allsuggestions,{ |
| 303 |
"suggestiontype"=>$criteriumvalue||"suggest", |
| 304 |
"suggestiontypelabel"=>GetCriteriumDesc($criteriumvalue,$displayby)||"", |
| 305 |
"suggestionscount"=>scalar(@$suggestions), |
| 306 |
'suggestions_loop'=>$suggestions, |
| 307 |
'reasonsloop' => $reasonsloop, |
| 308 |
}; |
| 309 |
} |
| 271 |
delete $$suggestion_ref{$displayby} unless $definedvalue; |
310 |
delete $$suggestion_ref{$displayby} unless $definedvalue; |
| 272 |
} |
311 |
} |
| 273 |
|
312 |
|
| 274 |
- |
|
|