Bugzilla – Attachment 110659 Details for
Bug 11176
Purchase suggestions should respect the 'active' switch on budgets
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 11176: Add active switch on budgets select in suggestions
Bug-11176-Add-active-switch-on-budgets-select-in-s.patch (text/plain), 5.71 KB, created by
David Nind
on 2020-09-24 13:58:04 UTC
(
hide
)
Description:
Bug 11176: Add active switch on budgets select in suggestions
Filename:
MIME Type:
Creator:
David Nind
Created:
2020-09-24 13:58:04 UTC
Size:
5.71 KB
patch
obsolete
>From 0558ef045922eaf514c0dca7cffd825d177855f1 Mon Sep 17 00:00:00 2001 >From: Fridolin Somers <fridolin.somers@biblibre.com> >Date: Thu, 24 Sep 2020 14:21:43 +0200 >Subject: [PATCH] Bug 11176: Add active switch on budgets select in suggestions > >When creating a new purchase suggestion, all funds display and are available for selection. >The behaviour of this drop-down menu should mirror that of those drop-down menus elsewhere in acquisitions, >where only funds that are linked to active budgets display to the user. > >This patch add the active switch based on what exists in acqui/invoice.tt and acqui/invoice.pl. > >Looks like actually in suggestion.pl budgets list was fetches with GetBudgets(). >But this is for the filter in 'Acquisition information'. >Budgets selection on suggestion creation/edition must use GetBudgetHierarchy(), like in acqui/invoice.pl, >in order to have the actif status. > >Test plan : >1) Create a budget periods active B1 with a fund F1 >2) Create a budget periods inactive B2 with a fund F2 >3) Go to suggestions module >4) Create a new suggestion >5) Check you see only active fund F1 >6) Click on 'Show inactive' >7) Check you see also 'F2 (inactive)' >8) Choose fund F1 and save >9) Select the suggestion and edit >10) Check fund F1 is selected >11) Come back to suggestion table >12) Check filter 'Book fund' under 'Acquisition information' contains all funds > >Signed-off-by: David Nind <david@davidnind.com> >--- > .../prog/en/modules/suggestion/suggestion.tt | 31 +++++++++++++++++++--- > suggestion/suggestion.pl | 21 +++++++++++++-- > 2 files changed, 47 insertions(+), 5 deletions(-) > >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 4e801db741..8930674422 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/suggestion/suggestion.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/suggestion/suggestion.tt >@@ -447,10 +447,21 @@ > </li> > <li><label for="budgetid">Fund:</label> > <select name="budgetid" id="budgetid"> >- <option value="">Any</option>[% FOREACH budgetsloo IN budgetsloop %] >- [% IF ( budgetsloo.selected ) %]<option value="[% budgetsloo.budget_id | html %]" selected="selected">[% budgetsloo.budget_name | html %]</option>[% ELSE %]<option value="[% budgetsloo.budget_id | html %]">[% budgetsloo.budget_name | html %]</option>[% END %][% END %] >+ <option value="">Any</option> >+ [% FOREACH budget IN sugg_budgets %] >+ [% IF ( budget.selected ) %] >+ <option value="[% budget.b_id | html %]" selected="selected">[% budget.b_txt | html %] [% IF ( !budget.b_active ) %](inactive)[% END %]</option> >+ [% ELSIF ( budget.b_active ) %] >+ <option value="[% budget.b_id | html %]">[% budget.b_txt | html %]</option> >+ [% ELSE %] >+ <option value="[% budget.b_id | html %]" class="b_inactive">[% budget.b_txt | html %] (inactive)</option> >+ [% END %] >+ [% END %] > </select> >- </li><li><label for="quantity">Copies:</label> >+ <label for="showallfunds" style="float:none;width:auto;"> Show inactive:</label> >+ <input type="checkbox" id="showallfunds" /> >+ </li> >+ <li><label for="quantity">Copies:</label> > <input type="text" size="10" id="quantity" name="quantity" value="[% quantity | html %]" /> > </li> > <li> >@@ -1186,6 +1197,20 @@ > $('#notify').prop('checked', false).prop('disabled', true); > }); > >+ //keep a copy of all budgets before removing the inactives >+ var budgetId = $("form#add_edit #budgetid"); >+ var disabledBudgetsCopy = budgetId.html(); >+ $('.b_inactive').remove(); >+ >+ $('#showallfunds').click(function() { >+ if ($(this).is(":checked")) { >+ budgetId.html(disabledBudgetsCopy); //Puts back all the funds >+ } >+ else { >+ $('.b_inactive').remove(); >+ } >+ }); >+ > }); > </script> > [% END %] >diff --git a/suggestion/suggestion.pl b/suggestion/suggestion.pl >index bd4c1a0696..ce8a9dee90 100755 >--- a/suggestion/suggestion.pl >+++ b/suggestion/suggestion.pl >@@ -407,7 +407,7 @@ $template->param( returnsuggestedby => $returnsuggestedby ); > my $patron_reason_loop = GetAuthorisedValues("OPAC_SUG"); > $template->param(patron_reason_loop=>$patron_reason_loop); > >-#Budgets management >+# Budgets for filtering > my $budgets = GetBudgets; > my @budgets_loop; > foreach my $budget ( @{$budgets} ) { >@@ -420,8 +420,25 @@ foreach my $budget ( @{$budgets} ) { > > push @budgets_loop, $budget; > } >- > $template->param( budgetsloop => \@budgets_loop); >+ >+# Budgets for suggestion add or edition >+my $sugg_budget_loop = []; >+my $sugg_budgets = GetBudgetHierarchy(); >+foreach my $r ( @{$sugg_budgets} ) { >+ next unless ( CanUserUseBudget( $borrowernumber, $r, $userflags ) ); >+ my $selected = ( $$suggestion_ref{budgetid} && $r->{budget_id} eq $$suggestion_ref{budgetid} ) ? 1 : 0; >+ push @{$sugg_budget_loop}, >+ { >+ b_id => $r->{budget_id}, >+ b_txt => $r->{budget_name}, >+ b_active => $r->{budget_period_active}, >+ selected => $selected, >+ }; >+} >+@{$sugg_budget_loop} = sort { uc( $a->{b_txt} ) cmp uc( $b->{b_txt} ) } @{$sugg_budget_loop}; >+$template->param( sugg_budgets => $sugg_budget_loop); >+ > if( $suggestion_ref->{STATUS} ) { > $template->param( > "statusselected_".$suggestion_ref->{STATUS} => 1, >-- >2.11.0
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 11176
:
110646
|
110659
|
110699