From 1cbe5ff1ae3012d3edd2f73ff4efd8049d974477 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 Signed-off-by: Rhonda Kuiper --- acqui/addorderiso2709.pl | 29 +++++++------- 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 | 12 +----- suggestion/suggestion.pl | 31 +++++++++------ 15 files changed, 140 insertions(+), 202 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 4b4d899031..e777e64c17 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 %budget_loops; 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}, + 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 05b6b28628..a3666e8815 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 2c88908086..41fdc000c8 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 95c31d9aa8..082ccea63f 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 550e41e810..1a660404f1 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 0cbc6d7671..c9d458fb4c 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 0000000000..d23e0c40b3 --- /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 09066e6795..12abc2f71b 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 7657df8bff..95ecfe6bb3 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 e4e2dd561c..1bd360f494 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 a8aa424cfe..86b8b8878b 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 ba3e00dfb4..f156d90895 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 703227a53d..99556f73ff 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 4b5b7eb03f..9571fc6f67 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/suggestion/suggestion.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/suggestion/suggestion.tt @@ -1280,19 +1280,11 @@ [% END %] [% END %] - [% FOREACH budget IN sugg_budgets %] - [% IF ( budget.selected ) %] - - [% ELSIF ( budget.b_active ) %] - - [% ELSE %] - - [% END %] - [% END %] + [% INCLUDE 'budgets_loop.inc' inactive_class = "b_inactive" %] - + [% END %] [% MACRO jsinclude BLOCK %] diff --git a/suggestion/suggestion.pl b/suggestion/suggestion.pl index 2f6b53970f..a4fb5c634e 100755 --- a/suggestion/suggestion.pl +++ b/suggestion/suggestion.pl @@ -509,21 +509,28 @@ my $patron_reason_loop = GetAuthorisedValues("OPAC_SUG"); $template->param(patron_reason_loop=>$patron_reason_loop); # Budgets for suggestion add or edition -my $sugg_budget_loop = []; -my $sugg_budgets = GetBudgetHierarchy(); +my %budget_loops; +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, - }; + 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