From b1916bcaf34f944401155c1b2d2da845fa3241af Mon Sep 17 00:00:00 2001 From: Owen Leonard Date: Fri, 19 Jul 2013 09:07:52 -0400 Subject: [PATCH] Bug 8821 - Receive shipment page should hide inactive funds like new order form This patch adapts the fund-handling code from neworderempty.pl in order to limit the display of funds by default to active ones, with the option to check a box to display all funds. This patch also adds "(inactive)" to the display of funds on this and the neworderempty.tt template because it seemed like that was useful information. To test, make sure you have both active and inactive funds. Start the process of receiving a shipment. The "fund" option in the receive shipment form should show only active funds. Checking the "show all" checkbox should allow you to choose from both active and inactive funds. Signed-off-by: Kyle M Hall Signed-off-by: Jonathan Druart --- acqui/parcels.pl | 24 +++++++++++++++----- .../prog/en/modules/acqui/neworderempty.tt | 2 +- .../intranet-tmpl/prog/en/modules/acqui/parcels.tt | 23 ++++++++++++++++++- 3 files changed, 41 insertions(+), 8 deletions(-) diff --git a/acqui/parcels.pl b/acqui/parcels.pl index fbfa9fa..df02e21 100755 --- a/acqui/parcels.pl +++ b/acqui/parcels.pl @@ -179,13 +179,25 @@ if ($count_parcels) { $template->param( searchresults => $loopres, count => $count_parcels ); } -my $budgets = GetBudgets(); -my @budgets_loop; -foreach my $budget (@$budgets) { - next unless CanUserUseBudget($loggedinuser, $budget, $flags); - push @budgets_loop, $budget; +# build budget list +my $budget_loop = []; +my $budgets = GetBudgetHierarchy; +foreach my $r (@{$budgets}) { + next unless (CanUserUseBudget($loggedinuser, $r, $flags)); + if (!defined $r->{budget_amount} || $r->{budget_amount} == 0) { + next; + } + push @{$budget_loop}, { + b_id => $r->{budget_id}, + b_txt => $r->{budget_name}, + b_active => $r->{budget_period_active}, + }; } +@{$budget_loop} = + sort { uc( $a->{b_txt}) cmp uc( $b->{b_txt}) } @{$budget_loop}; + + $template->param( orderby => $order, filter => $code, @@ -196,7 +208,7 @@ $template->param( shipmentdate_today => C4::Dates->new()->output(), booksellerid => $booksellerid, GST => C4::Context->preference('gist'), - budgets => \@budgets_loop, + budgets => $budget_loop, ); output_html_with_http_headers $input, $cookie, $template->output; 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 da8f88a..c36625c 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/neworderempty.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/neworderempty.tt @@ -421,7 +421,7 @@ $(document).ready(function() [% ELSE %] [% IF ( budget_loo.b_active ) %] - [% ELSE %] + [% ELSE %] [% END %] [% END %] [% END %] 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 26e4af8..5e003f1 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/parcels.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/parcels.tt @@ -16,6 +16,20 @@ var parcelst = $("#parcelst").dataTable($.extend(true, {}, dataTablesDefaults, { "sPaginationType": "four_button" } ) ); + + //keep a copy of all budgets before removing the inactives + var budgetId = $("#shipmentcost_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(); + } + }); }); //]]> @@ -172,9 +186,16 @@ + + + -- 1.7.10.4