From f3ee96bd8e55f774fd0e59469331d885166ce9f8 Mon Sep 17 00:00:00 2001 From: Aleisha Amohia Date: Wed, 5 Jun 2024 05:12:59 +0000 Subject: [PATCH] [WIP] Bug 31606: Make acquisitions fund dropdown consistently show budget name --- acqui/neworderempty.pl | 12 ++++--- .../prog/en/includes/budgets_loop.inc | 28 +++++++++++++++++ .../prog/en/modules/acqui/neworderempty.tt | 31 +------------------ .../prog/en/modules/acqui/orderreceive.tt | 30 +----------------- 4 files changed, 38 insertions(+), 63 deletions(-) create mode 100644 koha-tmpl/intranet-tmpl/prog/en/includes/budgets_loop.inc diff --git a/acqui/neworderempty.pl b/acqui/neworderempty.pl index 95c31d9aa85..e19f4c00936 100755 --- a/acqui/neworderempty.pl +++ b/acqui/neworderempty.pl @@ -335,11 +335,16 @@ my $patron = Koha::Patrons->find( $loggedinuser )->unblessed; 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}, { + 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'}, @@ -350,7 +355,6 @@ foreach my $r (@{$budgets}) { }; } - $template->param( sort1 => $data->{'sort1'} ); $template->param( sort2 => $data->{'sort2'} ); @@ -487,7 +491,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/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..fbdff7b7996 --- /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/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
  • -- 2.39.2