Bugzilla – Attachment 72637 Details for
Bug 18743
Filter suggestion lists correctly for IndependentBranches
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 18743 - Removed library filter in Acquisition suggestions when IndependentBranches enabled
Bug-18743---Removed-library-filter-in-Acquisition-.patch (text/plain), 12.14 KB, created by
Nicolas Legrand
on 2018-03-12 10:32:14 UTC
(
hide
)
Description:
Bug 18743 - Removed library filter in Acquisition suggestions when IndependentBranches enabled
Filename:
MIME Type:
Creator:
Nicolas Legrand
Created:
2018-03-12 10:32:14 UTC
Size:
12.14 KB
patch
obsolete
>From 7d7cb9de1d68de3dc379208ac670cb46dbfcb4fc Mon Sep 17 00:00:00 2001 >From: Alex Buckley <alexbuckley@catalyst.net.nz> >Date: Fri, 30 Jun 2017 15:30:12 +0000 >Subject: [PATCH] Bug 18743 - Removed library filter in Acquisition suggestions > when IndependentBranches enabled > >Also ensured that when a superlibrarian is logged in then suggestions from >all branches are displayed with IndependentBranches being either on or off, as this >syspref does not affect what suggestions superlibrarians can see. > >But when non-superlibrarian user with access to the acquisitions module >visits it when IndependentBranches is enabled then only suggestions of >the branch they are logged in with are displayed. > >If non-superlibrarian users log in when IndependentBranches is not >enabled then suggestions from all branches are displayed. > >Note: The library filter in the 'Organize by' area (which is displayed when multiple branches suggestions are displayed according to the aforementioned logic) successfully splits the suggestions into different tabs with the correct number of suggestions for each branch >displayed in each tab. > >Test plan: >1. Relicate the bug described in description comment > >2. Apply patch > >3. Create 2 suggestions a library branch (which I will refer to in this >test plan as branch A) > >4. Create 1 suggestion for a different branch (which I will refer to as >branch B) > >5. Log into staff client as superlibrarian with either branch and ensure the >IndependentBranches syspref is set to 'yes' > >6. Go to Acquisitions->Suggestions Management > >7. Notice that suggestions from branch A and B are displayed > >8. In the Organize by are click to filter by library and click go > >9. Notice that one tab says <name of branch A> (2) whilst the other tab >says <name of branch B> (1) with each tab containing the relevant >suggestions to that branch > >10. In the Acquisition information filter select branch A and then click >'Go' and notice that it successfully filters the results and shows 2 >suggestions of branch A only > >11. Now change the IndependentBranches syspref to 'no' > >12. Repeat steps 6, 7, 8, 9, 10 noticing the same outcome in step 9 and >10 > >13. Log out and log back into staff client in branch A as a non-superlibrarian user >who has access to the Acquisitions module > >14. Currently IndependentBranches is set to 'no' so go to >Acquisitions->Suggestions Management > >15. Repeat steps 6, 7, 8, 9, 10 and notice the same outcome as step 9 >and 10 > >16. Change IndependentBranches to 'yes' > >17. Go to Acquisitions->Suggestions Management > >18. Notice that only suggestions from branch A (the branch you are >logged in with) are displayed. This is because when IndependentBranches >is enabled non-superlibrarians do not need to see suggestions from other >branches > >19. Also notice that there is no 'library' option in the 'Organized by' >area and there is no library filter in the acquisition information area. This is because only suggestions from the current branch are displayed and so organizing/filtering by library is redundant. > >Sponsored-by: Catalyst IT >--- > C4/Suggestions.pm | 15 ++++-- > .../prog/en/modules/suggestion/suggestion.tt | 30 ++++++----- > suggestion/suggestion.pl | 59 ++++++++++++++++++---- > 3 files changed, 76 insertions(+), 28 deletions(-) > >diff --git a/C4/Suggestions.pm b/C4/Suggestions.pm >index 70b7b0d..96ba1c3 100644 >--- a/C4/Suggestions.pm >+++ b/C4/Suggestions.pm >@@ -131,25 +131,30 @@ sub SearchSuggestion { > } > } > >+ my $userenv = C4::Context->userenv; > # filter on user branch > if ( C4::Context->preference('IndependentBranches') ) { >- my $userenv = C4::Context->userenv; >- if ($userenv) { >- if ( !C4::Context->IsSuperLibrarian() && !$suggestion->{branchcode} ) >+ if ( !C4::Context->IsSuperLibrarian() && $userenv ) > { > push @sql_params, $$userenv{branch}; > push @query, q{ > AND (suggestions.branchcode=? OR suggestions.branchcode='') > }; >+ }else{ >+ if ( defined $suggestion->{branchcode} && $suggestion->{branchcode} ) { >+ unless ( $suggestion->{branchcode} eq '__ANY__' ) { >+ push @sql_params, $suggestion->{branchcode}; >+ push @query, qq{ AND suggestions.branchcode=? }; >+ } >+ } > } >- } > } else { > if ( defined $suggestion->{branchcode} && $suggestion->{branchcode} ) { > unless ( $suggestion->{branchcode} eq '__ANY__' ) { > push @sql_params, $suggestion->{branchcode}; > push @query, qq{ AND suggestions.branchcode=? }; > } >- } >+ } > } > > # filter on nillable fields >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/suggestion/suggestion.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/suggestion/suggestion.tt >index c793e2d..bf1e59d 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/suggestion/suggestion.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/suggestion/suggestion.tt >@@ -605,10 +605,12 @@ > [% ELSE %] > <option value="STATUS">Status</option> > [% END %] >- [% IF ( displayby == "branchcode" ) %] >- <option value="branchcode" selected="selected">Library</option> >- [% ELSE %] >- <option value="branchcode">Library</option> >+ [% IF ( IndependentBranches == 0 ) || (SuperLibrarian) %] >+ [% IF ( displayby == "branchcode" ) %] >+ <option value="branchcode" selected="selected">Library</option> >+ [% ELSE %] >+ <option value="branchcode">Library</option> >+ [% END %] > [% END %] > [% IF ( displayby == "itemtype" ) %] > <option value="itemtype" selected="selected">Item type</option> >@@ -727,15 +729,17 @@ > [% IF ( budgetid_loo.selected ) %] <option value="[% budgetid_loo.code %]" selected="selected">[% budgetid_loo.desc %]</option>[% ELSE %]<option value="[% budgetid_loo.code %]">[% budgetid_loo.desc %]</option>[% END %] > [% END %] > </select></li> >- <li><label for="branchcode">Library:</label> >- <select name="branchcode" id="branchcode"> >- <option value="__ANY__">Any</option> >- [% IF branchfilter %] >- [% PROCESS options_for_libraries libraries => Branches.all( selected => branchfilter ) %] >- [% ELSE %] >- [% PROCESS options_for_libraries libraries => Branches.all( selected => branchcode ) %] >- [% END %] >- </select></li><li><input type="submit" value="Go" /></li></ol> >+ [% IF (IndependentBranches == 0 ) %] >+ <li><label for="branchcode">Library:</label> >+ <select name="filter_branchcode" id="filter_branchcode"> >+ <option value="__ANY__">Any</option> >+ [% IF branchfilter %] >+ [% PROCESS options_for_libraries libraries => Branches.all( selected => branchfilter ) %] >+ [% ELSE %] >+ [% PROCESS options_for_libraries libraries => Branches.all( selected => branchcode ) %] >+ [% END %] >+ </select></li><li><input type="submit" value="Go" /></li></ol> >+ [% END %] > </fieldset> > </div> > </form> >diff --git a/suggestion/suggestion.pl b/suggestion/suggestion.pl >index 98fcca4..21aeb7d 100755 >--- a/suggestion/suggestion.pl >+++ b/suggestion/suggestion.pl >@@ -92,9 +92,12 @@ my $managedby = $input->param('managedby'); > my $displayby = $input->param('displayby') || ''; > my $tabcode = $input->param('tabcode'); > my $reasonsloop = GetAuthorisedValues("SUGGEST"); >+my $filter_branchcode = $input->param('filter_branchcode'); > > # filter informations which are not suggestion related. > my $suggestion_ref = $input->Vars; >+my $IndependentBranches; >+my $SuperLibrarian; > > # get only the columns of Suggestion > my $schema = Koha::Database->new()->schema; >@@ -118,6 +121,23 @@ my ( $template, $borrowernumber, $cookie, $userflags ) = get_template_and_user( > $borrowernumber = $input->param('borrowernumber') if ( $input->param('borrowernumber') ); > $template->param('borrowernumber' => $borrowernumber); > >+#Check if IndependentBranches syspref is enabled and if it is then return IndependentBranches variable of 1 so library >+#filtering does not occur in suggestion.tt >+if ( Koha::Config::SysPrefs->find( 'IndependentBranches')->value) { >+ $IndependentBranches = 1; >+ $template->param( >+ IndependentBranches => $IndependentBranches >+ ); >+} >+ >+if (C4::Context->IsSuperLibrarian()) { >+ $SuperLibrarian =1; >+ $template->param( >+ SuperLibrarian => $SuperLibrarian >+ ); >+} >+ >+# > ######################################### > ## Operations > ## >@@ -241,7 +261,7 @@ elsif ( $op eq 'show' ) { > } > if ($op=~/else/) { > $op='else'; >- >+ > $displayby||="STATUS"; > delete $$suggestion_ref{'branchcode'} if($displayby eq "branchcode"); > # distinct values of display by >@@ -260,29 +280,48 @@ if ($op=~/else/) { > my @allsuggestions; > foreach my $criteriumvalue ( @criteria_dv ) { > # By default, display suggestions from current working branch >- unless ( exists $$suggestion_ref{'branchcode'} ) { >- $$suggestion_ref{'branchcode'} = C4::Context->userenv->{'branch'}; >+ >+ if ( $IndependentBranches && !$SuperLibrarian) { >+ unless ( $$suggestion_ref{'branchcode'} ) { >+ $$suggestion_ref{'branchcode'} = C4::Context->userenv->{'branch'}; >+ } > } >+ > my $definedvalue = defined $$suggestion_ref{$displayby} && $$suggestion_ref{$displayby} ne ""; > > next if ( $definedvalue && $$suggestion_ref{$displayby} ne $criteriumvalue ); > $$suggestion_ref{$displayby} = $criteriumvalue; > > my $suggestions = &SearchSuggestion($suggestion_ref); >+ >+ my $filteredsuggestionlist; > foreach my $suggestion (@$suggestions) { > if ($suggestion->{budgetid}){ > my $bud = GetBudget( $suggestion->{budgetid} ); > $suggestion->{budget_name} = $bud->{budget_name} if $bud; > } >+ if ($filter_branchcode) { >+ push @$filteredsuggestionlist, $suggestion if ($suggestion->{'branchcode'} eq $filter_branchcode); >+ } > } >- push @allsuggestions,{ >- "suggestiontype"=>$criteriumvalue||"suggest", >- "suggestiontypelabel"=>GetCriteriumDesc($criteriumvalue,$displayby)||"", >- "suggestionscount"=>scalar(@$suggestions), >- 'suggestions_loop'=>$suggestions, >- 'reasonsloop' => $reasonsloop, >- }; > >+ if ( $filter_branchcode && $filteredsuggestionlist) { >+ push @allsuggestions,{ >+ "suggestiontype"=>$criteriumvalue||"suggest", >+ "suggestiontypelabel"=>GetCriteriumDesc($criteriumvalue,$displayby)||"", >+ "suggestionscount"=>scalar(@$filteredsuggestionlist), >+ 'suggestions_loop'=>$filteredsuggestionlist, >+ 'reasonsloop' => $reasonsloop, >+ }; >+ } elsif ( $filter_branchcode eq "__ANY__" ) { >+ push @allsuggestions,{ >+ "suggestiontype"=>$criteriumvalue||"suggest", >+ "suggestiontypelabel"=>GetCriteriumDesc($criteriumvalue,$displayby)||"", >+ "suggestionscount"=>scalar(@$suggestions), >+ 'suggestions_loop'=>$suggestions, >+ 'reasonsloop' => $reasonsloop, >+ }; >+ } > delete $$suggestion_ref{$displayby} unless $definedvalue; > } > >-- >2.1.4
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 18743
:
64742
|
64763
|
64768
|
68298
|
71030
|
72637
|
72679
|
94300
|
94417
|
94418
|
94515
|
94516
|
94737
|
94738
|
94739
|
94740
|
94741
|
94742