From 18cd5bd41fd3658c74ac3caa5538c4cdc57c023c Mon Sep 17 00:00:00 2001 From: charles Date: Wed, 6 Aug 2014 16:44:19 -0400 Subject: [PATCH] Bug 7498 - Cloning a budget, enable change of description Patch sponsored by the CCSR ( http://www.ccsr.qc.ca ) This new patch builds on the work of Bug 12164 by allowing the user to enter a new name (budget_period_description) for the cloned budget. A test was added to t/db_dependent/Budgets.t. Signed-off-by: Paola Rossi --- C4/Budgets.pm | 14 ++++++++------ admin/aqbudgetperiods.pl | 4 ++++ .../prog/en/modules/admin/aqbudgetperiods.tt | 10 +++++++++- t/db_dependent/Budgets.t | 6 +++++- 4 files changed, 26 insertions(+), 8 deletions(-) diff --git a/C4/Budgets.pm b/C4/Budgets.pm index e0e8f72..1a7f7e4 100644 --- a/C4/Budgets.pm +++ b/C4/Budgets.pm @@ -1029,18 +1029,20 @@ amounts will be reset. =cut sub CloneBudgetPeriod { - my ($params) = @_; - my $budget_period_id = $params->{budget_period_id}; - my $budget_period_startdate = $params->{budget_period_startdate}; - my $budget_period_enddate = $params->{budget_period_enddate}; + my ($params) = @_; + my $budget_period_id = $params->{budget_period_id}; + my $budget_period_startdate = $params->{budget_period_startdate}; + my $budget_period_enddate = $params->{budget_period_enddate}; + my $budget_period_description = $params->{budget_period_description}; my $mark_original_budget_as_inactive = $params->{mark_original_budget_as_inactive} || 0; my $reset_all_budgets = $params->{reset_all_budgets} || 0; my $budget_period = GetBudgetPeriod($budget_period_id); - $budget_period->{budget_period_startdate} = $budget_period_startdate; - $budget_period->{budget_period_enddate} = $budget_period_enddate; + $budget_period->{budget_period_startdate} = $budget_period_startdate; + $budget_period->{budget_period_enddate} = $budget_period_enddate; + $budget_period->{budget_period_description} = $budget_period_description; # The new budget (budget_period) should be active by default $budget_period->{budget_period_active} = 1; my $original_budget_period_id = $budget_period->{budget_period_id}; diff --git a/admin/aqbudgetperiods.pl b/admin/aqbudgetperiods.pl index 808f9cb..d92ce37 100755 --- a/admin/aqbudgetperiods.pl +++ b/admin/aqbudgetperiods.pl @@ -177,9 +177,11 @@ elsif ( $op eq 'delete_confirmed' ) { # display the form for duplicating elsif ( $op eq 'duplicate_form'){ + my $budgetperiod = GetBudgetPeriod($budget_period_id, $input); $template->param( 'duplicate_form' => '1', 'budget_period_id' => $budget_period_id, + 'budgetperiod' => $budgetperiod, ); } @@ -189,6 +191,7 @@ elsif ( $op eq 'duplicate_budget' ){ my $budget_period_startdate = dt_from_string $input->param('budget_period_startdate'); my $budget_period_enddate = dt_from_string $input->param('budget_period_enddate'); + my $budget_period_description = $input->param('budget_period_description'); my $mark_original_budget_as_inactive = $input->param('mark_original_budget_as_inactive'); my $reset_all_budgets = $input->param('reset_all_budgets'); @@ -197,6 +200,7 @@ elsif ( $op eq 'duplicate_budget' ){ budget_period_id => $budget_period_id, budget_period_startdate => $budget_period_startdate, budget_period_enddate => $budget_period_enddate, + budget_period_description => $budget_period_description, mark_original_budget_as_inactive => $mark_original_budget_as_inactive, reset_all_budgets => $reset_all_budgets, } diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/aqbudgetperiods.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/aqbudgetperiods.tt index 31139ab..0b0648a 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/aqbudgetperiods.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/aqbudgetperiods.tt @@ -27,7 +27,10 @@ if( f.budget_period_startdate > f.budget_period_enddate ) { _alertString += "\n- " + _("Start date must be before end date"); } - + if (!(isNotNull(f.budget_period_description,1))){ + _alertString += "\n- " + _("Budget description missing"); + } + if(_alertString.length==0){ f.submit(); } else { @@ -262,6 +265,11 @@
[% INCLUDE 'date-format.inc' %]
+ +
  • + + +
  • diff --git a/t/db_dependent/Budgets.t b/t/db_dependent/Budgets.t index a565c8d..1584436 100755 --- a/t/db_dependent/Budgets.t +++ b/t/db_dependent/Budgets.t @@ -1,5 +1,5 @@ use Modern::Perl; -use Test::More tests => 107; +use Test::More tests => 108; BEGIN { use_ok('C4::Budgets') @@ -367,9 +367,13 @@ my $budget_period_id_cloned = C4::Budgets::CloneBudgetPeriod( budget_period_id => $budget_period_id, budget_period_startdate => '2014-01-01', budget_period_enddate => '2014-12-31', + budget_period_description => 'Budget Period Cloned', } ); +my $budget_period_cloned = C4::Budgets::GetBudgetPeriod($budget_period_id_cloned); +is($budget_period_cloned->{budget_period_description}, 'Budget Period Cloned', 'Cloned budget\'s description is updated.'); + my $budget_hierarchy = GetBudgetHierarchy($budget_period_id); my $budget_hierarchy_cloned = GetBudgetHierarchy($budget_period_id_cloned); -- 1.7.10.4