From 12a9e98d2d90d72a6aafda901838673c76578a1a Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Wed, 3 Jul 2024 14:07:15 +0000 Subject: [PATCH] Bug 37246: Use the same dropdown for filtering and editing/adding budgets This patch removes a second fetch of budgets form the db, and clones the dropdown in the template as we will only ever be displaying one of them at a time. The JS is moved to fire for both operations. To test: 1 - Create an active and inactive budget in acquisitions 2 - Add funs to both 3 - Visit - Acquisitions -> Suggestions 4 - Click 'Acquisition information' under filters on the left 5 - Note all funds are showing 6 - Apply patch 7 - Reload 8 - Note you only see active budgets 9 - Check the box to show inactive, verify they show 10 - Filter by an inactive budget 11 - Confirm selection remains 12 - Add a suggestion and verify budget dropdown works 13 - Edit the suggestion and verify budget dropdown works Signed-off-by: Sam Lau Signed-off-by: Pedro Amorim Signed-off-by: Katrin Fischer --- .../prog/en/modules/suggestion/suggestion.tt | 44 ++++++++++--------- suggestion/suggestion.pl | 15 ------- 2 files changed, 24 insertions(+), 35 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 5d9e0bf8f4..481d9ae046 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/suggestion/suggestion.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/suggestion/suggestion.tt @@ -605,7 +605,7 @@ [% END %] - +
  • @@ -1219,22 +1219,25 @@
    1. - + + +
    @@ -1325,6 +1328,20 @@ }); return 0; } + + //keep a copy of all budgets before removing the inactives + var budgetId = $("#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(); + } + }); [% IF ( op == 'show' || op == 'else' ) %] @@ -1483,19 +1500,6 @@ $('#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(); - } - }); }); diff --git a/suggestion/suggestion.pl b/suggestion/suggestion.pl index 4ee69957f0..3c68cf1384 100755 --- a/suggestion/suggestion.pl +++ b/suggestion/suggestion.pl @@ -470,21 +470,6 @@ $template->param( returnsuggestedby => $returnsuggestedby ); my $patron_reason_loop = GetAuthorisedValues("OPAC_SUG"); $template->param(patron_reason_loop=>$patron_reason_loop); -# Budgets for filtering -my $budgets = GetBudgets; -my @budgets_loop; -foreach my $budget ( @{$budgets} ) { - next unless (CanUserUseBudget($borrowernumber, $budget, $userflags)); - - ## Please see file perltidy.ERR - $budget->{'selected'} = 1 - if ($$suggestion_ref{'budgetid'} - && $budget->{'budget_id'} eq $$suggestion_ref{'budgetid'}); - - push @budgets_loop, $budget; -} -$template->param( budgetsloop => \@budgets_loop); - # Budgets for suggestion add or edition my $sugg_budget_loop = []; my $sugg_budgets = GetBudgetHierarchy(); -- 2.39.5