From 410c01c3b0682f55bec5b3053588ec13e5ee28c4 Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Mon, 28 Aug 2017 16:01:31 +0000 Subject: [PATCH] Bug 14850 - Use optgroups for active and inactive budgets on invoice.pl To test: 1 - Have some inactive and active budgets 2 - View an invoice in acquisitions 3 - Select the shipping fund dropdown 4 - Note you see all the budgets 5 - Apply patch 6 - View invoice and select shipping fund dropdown 7 - Note you see active budgets followed by inactive budgets --- acqui/invoice.pl | 24 +++++++++++++++------- .../intranet-tmpl/prog/en/modules/acqui/invoice.tt | 15 +++++++++++++- 2 files changed, 31 insertions(+), 8 deletions(-) diff --git a/acqui/invoice.pl b/acqui/invoice.pl index 3ab2d9f..e20633d 100755 --- a/acqui/invoice.pl +++ b/acqui/invoice.pl @@ -37,6 +37,8 @@ use C4::Budgets; use Koha::Acquisition::Booksellers; use Koha::Acquisition::Currencies; +use Koha::Acquisition::Budgets; +use Koha::Acquisition::Budget; use Koha::DateUtils; use Koha::Misc::Files; @@ -146,18 +148,25 @@ foreach my $order (@$orders) { push @foot_loop, map {$_} values %foot; -my $budgets = GetBudgets(); +my $budgets = Koha::Acquisition::Budgets->search(); my @budgets_loop; +my @inactive_budgets_loop; my $shipmentcost_budgetid = $details->{shipmentcost_budgetid}; -foreach my $budget (@$budgets) { - next unless CanUserUseBudget( $loggedinuser, $budget, $flags ); - my %line = %{$budget}; +while ( my $budget = $budgets->next ) { + next unless CanUserUseBudget( $loggedinuser, $budget->budget_id, $flags ); + my $line = $budget->unblessed; if ( $shipmentcost_budgetid - and $budget->{budget_id} == $shipmentcost_budgetid ) + and $budget->budget_id == $shipmentcost_budgetid ) { - $line{selected} = 1; + $line->{selected} = 1; } - push @budgets_loop, \%line; + if ( $budget->active ) { + push @budgets_loop, \%$line; + } + else { + push @inactive_budgets_loop, \%$line; + } + } $template->param( @@ -180,6 +189,7 @@ $template->param( invoiceincgst => $bookseller->invoiceincgst, currency => Koha::Acquisition::Currencies->get_active, budgets_loop => \@budgets_loop, + inactive_budgets_loop => \@inactive_budgets_loop, ); defined( $invoice_files ) && $template->param( files => $invoice_files->GetFilesInfo() ); 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 ba56547..54a1d1c 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/invoice.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/invoice.tt @@ -93,6 +93,7 @@
  • [% IF ( invoiceclosedate ) %] -- 2.1.4