From a16f256645d604f0918309dabc900b30b7553591 Mon Sep 17 00:00:00 2001 From: Aleisha Amohia Date: Wed, 5 Jun 2024 05:12:59 +0000 Subject: [PATCH] Bug 31606: Make acquisitions fund dropdown consistently show budget name This patch moves the budget/fund dropdown into a reusable block. So far it has only been applied to dropdowns encountered along the basic order & receive process. To test: 1) Apply patch and restart services 2) Create two budgets. Under each budget, create funds with the same codes (this is so we can depend on the budget names to differentiate between funds). Make one or more funds inactive. 3) Find or create a vendor and an open basket 4) Click Add to basket 5) Search for an existing record 6) Click Add order for your chosen record 7) Fill out required item information 8) Scroll down to Accounting details and open the Fund dropdown. Confirm funds show as expected with their budgets 9) Toggle the 'Show inactive' checkbox and confirm it shows and hides inactive funds as expected 10) Cancel or Save your order 11) In another tab, go to Suggestions 12) Click New purchase suggestion 13) Fill out required bibliographic information 14) Scroll down to Acquisition information and open the Fund dropdown. Confirm funds show as expected with their budgets 15) Toggle the 'Show inactive' checkbox and confirm it shows and hides inactive funds as expected 16) Submit your suggestion 17) Check the checkbox for your suggestion and mark it as Accepted 18) In your other tab with your basket, click Add to basket 19) Choose From a suggestion 20) Click Order for your suggestion 21) Fill out required item information 22) Scroll down to Accounting details and open the Fund dropdown. Confirm funds show as expected with their budgets 23) Toggle the 'Show inactive' checkbox and confirm it shows and hides inactive funds as expected 24) Cancel or Save your order 25) In another tab, go to Serials 26) Click New subscription 27) Fill out required record and serials planning information and Save 28) In your other tab with your basket, click Add to basket 29) Choose From a subscription 30) Search for your subscription and choose Order 31) Scroll down to Accounting details and open the Fund dropdown. Confirm funds show as expected with their budgets 32) Toggle the 'Show inactive' checkbox and confirm it shows and hides inactive funds as expected 33) Cancel or Save your order 34) Click Add to basket 35) Choose From existing orders (copy) 36) Open the Fund dropdown. Confirm funds show as expected with their budgets 37) Do a search and check the checkbox for an order, then click Next 38) Open the Fund dropdown. Confirm funds show as expected with their budgets 39) Toggle the 'Show inactive' checkbox and confirm it shows and hides inactive funds as expected 40) Cancel or Duplicate orders 41) Click Add to basket 42) Choose From a new file 43) Upload a MARC file and stage a record for import, then choose Add staged files to basket 44) Select a checkbox for a record to expand it 45) Open the Fund dropdown. Confirm funds show as expected with their budgets 46) Go to the Default accounting details tab 47) Open the Fund dropdown. Confirm funds show as expected with their budgets 48) Toggle the 'Show inactive' checkbox and confirm it shows and hides inactive funds as expected 49) Save your order 50) Close the basket 51) Click Receive shipments 52) Open the Shipping fund dropdown. Confirm funds show as expected with their budgets 53) Toggle the 'Show inactive' checkbox and confirm it shows and hides inactive funds as expected 54) Fill out required invoice information and Save 55) Click Receive for one of your orders 56) Open the Fund dropdown. Confirm funds show as expected with their budgets 57) Toggle the 'Show inactive' checkbox and confirm it shows and hides inactive funds as expected Sponsored-by: Friends of Round Rock Library --- acqui/addorderiso2709.pl | 33 ++++++++-------- acqui/duplicate_orders.pl | 26 +++++++------ acqui/invoice.pl | 32 ++++++++-------- acqui/neworderempty.pl | 29 ++++++++------ acqui/orderreceive.pl | 2 +- acqui/parcels.pl | 30 +++++++++------ .../prog/en/includes/budgets_loop.inc | 28 ++++++++++++++ .../prog/en/modules/acqui/addorderiso2709.tt | 38 ++----------------- .../prog/en/modules/acqui/duplicate_orders.tt | 6 +-- .../prog/en/modules/acqui/invoice.tt | 10 +---- .../prog/en/modules/acqui/neworderempty.tt | 31 +-------------- .../prog/en/modules/acqui/orderreceive.tt | 30 +-------------- .../prog/en/modules/acqui/parcels.tt | 8 +--- .../prog/en/modules/suggestion/suggestion.tt | 10 +---- suggestion/suggestion.pl | 33 +++++++++------- 15 files changed, 142 insertions(+), 204 deletions(-) create mode 100644 koha-tmpl/intranet-tmpl/prog/en/includes/budgets_loop.inc diff --git a/acqui/addorderiso2709.pl b/acqui/addorderiso2709.pl index 4b4d899031a..ef3a40151ab 100755 --- a/acqui/addorderiso2709.pl +++ b/acqui/addorderiso2709.pl @@ -400,25 +400,28 @@ my $patron = Koha::Patrons->find( $loggedinuser )->unblessed; my $budget = GetBudget($budget_id); # build budget list -my $budget_loop = []; -my $budgets_hierarchy = GetBudgetHierarchy; -foreach my $r ( @{$budgets_hierarchy} ) { - next unless (CanUserUseBudget($patron, $r, $userflags)); - push @{$budget_loop}, - { b_id => $r->{budget_id}, - b_txt => $r->{budget_name}, - b_code => $r->{budget_code}, +my %budget_loops; +my $budgets = GetBudgetHierarchy; +foreach my $r ( @{$budgets} ) { + next unless ( CanUserUseBudget( $patron, $r, $userflags ) ); + unless ( defined $budget_loops{ $r->{budget_period_id} } ) { + $budget_loops{ $r->{budget_period_id} }->{description} = $r->{budget_period_description}; + $budget_loops{ $r->{budget_period_id} }->{active} = $r->{budget_period_active}; + $budget_loops{ $r->{budget_period_id} }->{funds} = []; + } + push @{ $budget_loops{ $r->{budget_period_id} }->{funds} }, { + b_id => $r->{budget_id}, + b_txt => $r->{budget_name}, + b_code => $r->{budget_code}, b_sort1_authcat => $r->{'sort1_authcat'}, b_sort2_authcat => $r->{'sort2_authcat'}, - b_active => $r->{budget_period_active}, - b_sel => ( $r->{budget_id} == $budget_id ) ? 1 : 0, - }; + b_active => $r->{budget_period_active}, + b_sel => ( $r->{budget_id} == $budget_id ) ? 1 : 0, + b_level => $r->{budget_level}, + }; } -@{$budget_loop} = - sort { uc( $a->{b_txt}) cmp uc( $b->{b_txt}) } @{$budget_loop}; - -$template->param( budget_loop => $budget_loop,); +$template->param( budget_loop => \%budget_loops ); output_html_with_http_headers $input, $cookie, $template->output; diff --git a/acqui/duplicate_orders.pl b/acqui/duplicate_orders.pl index 05b6b28628c..a3666e88150 100755 --- a/acqui/duplicate_orders.pl +++ b/acqui/duplicate_orders.pl @@ -102,28 +102,30 @@ elsif ( $op eq 'cud-batch_edit' ) { @ordernumbers = $input->multi_param('ordernumber'); # build budget list - my $budget_loop = []; - my $budgets_hierarchy = GetBudgetHierarchy; - foreach my $r ( @{$budgets_hierarchy} ) { - next - unless ( C4::Budgets::CanUserUseBudget( $patron, $r, $userflags ) ); - - push @{$budget_loop}, - { + my %budget_loops; + my $budgets = GetBudgetHierarchy; + foreach my $r ( @{$budgets} ) { + next unless ( CanUserUseBudget( $patron, $r, $userflags ) ); + unless ( defined $budget_loops{ $r->{budget_period_id} } ) { + $budget_loops{ $r->{budget_period_id} }->{description} = $r->{budget_period_description}; + $budget_loops{ $r->{budget_period_id} }->{active} = $r->{budget_period_active}; + $budget_loops{ $r->{budget_period_id} }->{funds} = []; + } + push @{ $budget_loops{ $r->{budget_period_id} }->{funds} }, { b_id => $r->{budget_id}, b_txt => $r->{budget_name}, b_code => $r->{budget_code}, b_sort1_authcat => $r->{'sort1_authcat'}, b_sort2_authcat => $r->{'sort2_authcat'}, b_active => $r->{budget_period_active}, - }; + b_sel => ( $r->{budget_id} == scalar $input->param('budget') ) ? 1 : 0, + b_level => $r->{budget_level}, + }; } - @{$budget_loop} = - sort { uc( $a->{b_txt} ) cmp uc( $b->{b_txt} ) } @{$budget_loop}; $template->param( currencies => Koha::Acquisition::Currencies->search, - budget_loop => $budget_loop, + budget_loop => \%budget_loops, ); } elsif ( $op eq 'cud-do_duplicate' ) { diff --git a/acqui/invoice.pl b/acqui/invoice.pl index 2c889080869..41fdc000c8b 100755 --- a/acqui/invoice.pl +++ b/acqui/invoice.pl @@ -293,27 +293,27 @@ push @foot_loop, map {$_} values %foot; my $shipmentcost_budgetid = $details->{shipmentcost_budgetid}; # build budget list -my $budget_loop = []; -my $budgets = GetBudgetHierarchy(); +my %budget_loops; +my $budgets = GetBudgetHierarchy; foreach my $r ( @{$budgets} ) { next unless ( CanUserUseBudget( $loggedinuser, $r, $flags ) ); - - my $selected = $shipmentcost_budgetid ? $r->{budget_id} eq $shipmentcost_budgetid : 0; - - push @{$budget_loop}, - { - b_id => $r->{budget_id}, - b_txt => $r->{budget_name}, - b_active => $r->{budget_period_active}, - selected => $selected, + unless ( defined $budget_loops{ $r->{budget_period_id} } ) { + $budget_loops{ $r->{budget_period_id} }->{description} = $r->{budget_period_description}; + $budget_loops{ $r->{budget_period_id} }->{active} = $r->{budget_period_active}; + $budget_loops{ $r->{budget_period_id} }->{funds} = []; + } + push @{ $budget_loops{ $r->{budget_period_id} }->{funds} }, { + b_id => $r->{budget_id}, + b_txt => $r->{budget_name}, + b_code => $r->{budget_code}, b_sort1_authcat => $r->{'sort1_authcat'}, b_sort2_authcat => $r->{'sort2_authcat'}, - }; + b_active => $r->{budget_period_active}, + b_sel => $shipmentcost_budgetid ? $r->{budget_id} eq $shipmentcost_budgetid : 0, + b_level => $r->{budget_level}, + }; } -@{$budget_loop} = - sort { uc( $a->{b_txt} ) cmp uc( $b->{b_txt} ) } @{$budget_loop}; - my $adjustments = Koha::Acquisition::Invoice::Adjustments->search({ invoiceid => $details->{'invoiceid'} }); if ( $adjustments ) { $template->param( adjustments => $adjustments ); } @@ -345,7 +345,7 @@ $template->param( total_tax_included_shipment => $total_tax_included + $shipmentcost, invoiceincgst => $bookseller->invoiceincgst, currency => $active_currency, - budgets => $budget_loop, + budget_loop => \%budget_loops, budget => GetBudget( $shipmentcost_budgetid ), has_invoice_unitprice => $has_invoice_unitprice, ); diff --git a/acqui/neworderempty.pl b/acqui/neworderempty.pl index 95c31d9aa85..082ccea63fe 100755 --- a/acqui/neworderempty.pl +++ b/acqui/neworderempty.pl @@ -333,24 +333,29 @@ my $active_currency = Koha::Acquisition::Currencies->get_active; # build bookfund list my $patron = Koha::Patrons->find( $loggedinuser )->unblessed; -my $budget = GetBudget($budget_id); +my $budget = GetBudget($budget_id); + # build budget list -my $budget_loop = []; +my %budget_loops; my $budgets = GetBudgetHierarchy; -foreach my $r (@{$budgets}) { - next unless (CanUserUseBudget($patron, $r, $userflags)); - push @{$budget_loop}, { - b_id => $r->{budget_id}, - b_txt => $r->{budget_name}, +foreach my $r ( @{$budgets} ) { + next unless ( CanUserUseBudget( $patron, $r, $userflags ) ); + unless ( defined $budget_loops{ $r->{budget_period_id} } ) { + $budget_loops{ $r->{budget_period_id} }->{description} = $r->{budget_period_description}; + $budget_loops{ $r->{budget_period_id} }->{active} = $r->{budget_period_active}; + $budget_loops{ $r->{budget_period_id} }->{funds} = []; + } + push @{ $budget_loops{ $r->{budget_period_id} }->{funds} }, { + b_id => $r->{budget_id}, + b_txt => $r->{budget_name}, b_sort1_authcat => $r->{'sort1_authcat'}, b_sort2_authcat => $r->{'sort2_authcat'}, - b_active => $r->{budget_period_active}, - b_sel => ( $r->{budget_id} == $budget_id ) ? 1 : 0, - b_level => $r->{budget_level}, + b_active => $r->{budget_period_active}, + b_sel => ( $r->{budget_id} == $budget_id ) ? 1 : 0, + b_level => $r->{budget_level}, }; } - $template->param( sort1 => $data->{'sort1'} ); $template->param( sort2 => $data->{'sort2'} ); @@ -487,7 +492,7 @@ $template->param( author => $data->{'author'}, publicationyear => $data->{'publicationyear'} ? $data->{'publicationyear'} : $data->{'copyrightdate'}, editionstatement => $data->{'editionstatement'}, - budget_loop => $budget_loop, + budget_loop => \%budget_loops, isbn => $data->{'isbn'}, ean => $data->{'ean'}, seriestitle => $data->{'seriestitle'}, diff --git a/acqui/orderreceive.pl b/acqui/orderreceive.pl index 550e41e8103..1a660404f16 100755 --- a/acqui/orderreceive.pl +++ b/acqui/orderreceive.pl @@ -199,7 +199,7 @@ foreach my $budget (@{$budgets}) { b_level => $budget->{budget_level}, }; } -$template->{'VARS'}->{'budget_loops'} = \%budget_loops; +$template->{'VARS'}->{'budget_loop'} = \%budget_loops; my $op = $input->param('op'); if ($op and $op eq 'cud-edit'){ diff --git a/acqui/parcels.pl b/acqui/parcels.pl index 0cbc6d76719..c9d458fb4ce 100755 --- a/acqui/parcels.pl +++ b/acqui/parcels.pl @@ -198,21 +198,27 @@ if ($count_parcels) { } # build budget list -my $budget_loop = []; +my %budget_loops; my $budgets = GetBudgetHierarchy; -foreach my $r (@{$budgets}) { - next unless (CanUserUseBudget($loggedinuser, $r, $flags)); - push @{$budget_loop}, { - b_id => $r->{budget_id}, - b_txt => $r->{budget_name}, - b_active => $r->{budget_period_active}, +foreach my $r ( @{$budgets} ) { + next unless ( CanUserUseBudget( $loggedinuser, $r, $flags ) ); + unless ( defined $budget_loops{ $r->{budget_period_id} } ) { + $budget_loops{ $r->{budget_period_id} }->{description} = $r->{budget_period_description}; + $budget_loops{ $r->{budget_period_id} }->{active} = $r->{budget_period_active}; + $budget_loops{ $r->{budget_period_id} }->{funds} = []; + } + push @{ $budget_loops{ $r->{budget_period_id} }->{funds} }, { + b_id => $r->{budget_id}, + b_txt => $r->{budget_name}, + b_code => $r->{budget_code}, + b_sort1_authcat => $r->{'sort1_authcat'}, + b_sort2_authcat => $r->{'sort2_authcat'}, + b_active => $r->{budget_period_active}, + b_sel => ( $r->{budget_id} == $shipmentcost_budgetid ) ? 1 : 0, + b_level => $r->{budget_level}, }; } -@{$budget_loop} = - sort { uc( $a->{b_txt}) cmp uc( $b->{b_txt}) } @{$budget_loop}; - - $template->param( orderby => $order, filter => $code, @@ -223,7 +229,7 @@ $template->param( shipmentdate_today => dt_from_string, booksellerid => $booksellerid, GST => C4::Context->preference('TaxRates'), - budgets => $budget_loop, + budget_loop => \%budget_loops, ); output_html_with_http_headers $input, $cookie, $template->output; diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/budgets_loop.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/budgets_loop.inc new file mode 100644 index 00000000000..d23e0c40b39 --- /dev/null +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/budgets_loop.inc @@ -0,0 +1,28 @@ +[% FOREACH budget_period_id IN budget_loop.keys %] + [% SET budget_period = budget_loop.$budget_period_id %] + [% IF budget_period.active %] + + [% ELSE %] + + [% END %] + [% FOREACH budget_loo IN budget_period.funds %] + [% level_indent_cnt = 0 %] + [% level_indent = "" %] + [% WHILE level_indent_cnt < budget_loo.b_level %] + [% level_indent = level_indent _ " -- " %] + [% level_indent_cnt = level_indent_cnt +1 %] + [% END %] + [% IF ( budget_loo.b_sel ) %] + [% active_count = 0 #select no other fund %] + + [% END %] + +[% END %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/addorderiso2709.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/addorderiso2709.tt index 09066e6795b..12abc2f71b9 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/addorderiso2709.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/addorderiso2709.tt @@ -213,19 +213,7 @@ [% END %] @@ -345,21 +333,7 @@ Required @@ -506,13 +480,7 @@ diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/duplicate_orders.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/duplicate_orders.tt index 7657df8bff4..95ecfe6bb3b 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/duplicate_orders.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/duplicate_orders.tt @@ -211,11 +211,7 @@ diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/invoice.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/invoice.tt index be89ba07c36..8435e9e389a 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/invoice.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/invoice.tt @@ -10,7 +10,7 @@ - + [% END %] [% INCLUDE 'doc-head-open.inc' %] @@ -528,13 +528,7 @@ [% MACRO jsinclude BLOCK %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/neworderempty.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/neworderempty.tt index a8aa424cfe2..86b8b8878bb 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/neworderempty.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/neworderempty.tt @@ -592,37 +592,8 @@
  • - [% active_count = 0 %] - [% IF !ordernumber %] - [% FOREACH budget_loo IN budget_loop %] - [% active_count= active_count + budget_loo.b_active %] - [% END %] - [% END %] Required diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/orderreceive.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/orderreceive.tt index 9e6f5f71925..0bd87f3762a 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/orderreceive.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/orderreceive.tt @@ -291,35 +291,7 @@ - [% FOREACH budget_period_id IN budget_loops.keys %] - [% SET budget_period = budget_loops.$budget_period_id %] - [% IF budget_period.active %] - - [% ELSE %] - - [% END %] - [% FOREACH budget_loo IN budget_period.funds %] - [% level_indent_cnt = 0 %] - [% level_indent = "" %] - [% WHILE level_indent_cnt < budget_loo.b_level %] - [% level_indent = level_indent _ " -- " %] - [% level_indent_cnt = level_indent_cnt +1 %] - [% END %] - - [% IF ( budget_loo.b_sel ) %] - [% active_count = 0 #select no other fund %] - - [% END %] - - [% END %] + [% INCLUDE 'budgets_loop.inc' inactive_class = "inactive_budget" %] Required
  • diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/parcels.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/parcels.tt index 703227a53dc..99556f73ffd 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/parcels.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/parcels.tt @@ -179,13 +179,7 @@ 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 5d9e0bf8f45..a9968f0c499 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/suggestion/suggestion.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/suggestion/suggestion.tt @@ -594,15 +594,7 @@ diff --git a/suggestion/suggestion.pl b/suggestion/suggestion.pl index 4ee69957f03..a8635c0aaf5 100755 --- a/suggestion/suggestion.pl +++ b/suggestion/suggestion.pl @@ -486,21 +486,28 @@ foreach my $budget ( @{$budgets} ) { $template->param( budgetsloop => \@budgets_loop); # Budgets for suggestion add or edition -my $sugg_budget_loop = []; -my $sugg_budgets = GetBudgetHierarchy(); -foreach my $r ( @{$sugg_budgets} ) { +my %budget_loops; +my $budgets = GetBudgetHierarchy; +foreach my $r ( @{$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, - }; + unless ( defined $budget_loops{ $r->{budget_period_id} } ) { + $budget_loops{ $r->{budget_period_id} }->{description} = $r->{budget_period_description}; + $budget_loops{ $r->{budget_period_id} }->{active} = $r->{budget_period_active}; + $budget_loops{ $r->{budget_period_id} }->{funds} = []; + } + push @{ $budget_loops{ $r->{budget_period_id} }->{funds} }, { + b_id => $r->{budget_id}, + b_txt => $r->{budget_name}, + b_code => $r->{budget_code}, + b_sort1_authcat => $r->{'sort1_authcat'}, + b_sort2_authcat => $r->{'sort2_authcat'}, + b_active => $r->{budget_period_active}, + b_sel => ( $$suggestion_ref{budgetid} && $r->{budget_id} eq $$suggestion_ref{budgetid} ) ? 1 : 0, + b_level => $r->{budget_level}, + }; } -@{$sugg_budget_loop} = sort { uc( $a->{b_txt} ) cmp uc( $b->{b_txt} ) } @{$sugg_budget_loop}; -$template->param( sugg_budgets => $sugg_budget_loop); + +$template->param( budget_loop => \%budget_loops ); if( $suggestion_ref->{STATUS} ) { $template->param( -- 2.39.2