From 0689b5921763c92b70c31d4c922a8a994fffd385 Mon Sep 17 00:00:00 2001 From: Paul Poulain Date: Mon, 1 Aug 2011 17:19:08 +0200 Subject: [PATCH] BZ6069: Multiple level budget list on suggestions Librarians dealing with a suggestion have (and must have) access to all budgets. For a large library/network, it means the list can be huge and impossible to deal with. A possible solution would be to have multiple level lists : one for the top level, then one for the 2nd level, that appears when the 1st level is choosen, then one for the 3rd level (if applicable) when the 2nd level is choosen. --- C4/Budgets.pm | 55 ++++++++++++++++++ .../prog/en/modules/suggestion/suggestion.tt | 59 ++++++++++++++++++++ suggestion/suggestion.pl | 11 ++++ 3 files changed, 125 insertions(+), 0 deletions(-) diff --git a/C4/Budgets.pm b/C4/Budgets.pm index 98e5d63..c4b44c9 100644 --- a/C4/Budgets.pm +++ b/C4/Budgets.pm @@ -46,6 +46,10 @@ BEGIN { &GetBudgetPeriod &GetBudgetPeriods + &GetBudgetFirstChild + &GetBudgetParent + &GetBudgetSecondChild + &ModBudgetPeriod &AddBudgetPeriod &DelBudgetPeriod @@ -464,6 +468,57 @@ sub GetBudgetPeriod { } # ------------------------------------------------------------------- +sub GetBudgetFirstChild { + my $dbh = C4::Context->dbh; + my $query = "SELECT * + FROM `aqbudgets` + WHERE budget_parent_id + IN ( + SELECT budget_id FROM `aqbudgets` + JOIN `aqbudgetperiods` ON aqbudgets.budget_period_id = aqbudgetperiods.budget_period_id + WHERE ((`budget_parent_id` IS NULL)AND (`budget_period_active` LIKE 1))) + ORDER BY `aqbudgets`.`budget_parent_id`, budget_name ASC"; + my $sth= $dbh->prepare($query); + $sth->execute(); + my $data = $sth->fetchall_arrayref({}); + return $data; +} +# ------------------------------------------------------------------- +sub GetBudgetParent { + my $dbh = C4::Context->dbh; + my $query = "SELECT * + FROM `aqbudgets` + JOIN `aqbudgetperiods` ON aqbudgets.budget_period_id = aqbudgetperiods.budget_period_id + WHERE ((`budget_parent_id` IS NULL)AND (`budget_period_active` LIKE 1)) + ORDER BY `aqbudgets`.`budget_id`, budget_name ASC"; + my $sth= $dbh->prepare($query); + $sth->execute(); + my $data = $sth->fetchall_arrayref({}); + return $data; +} +# ------------------------------------------------------------------- +sub GetBudgetSecondChild { + my $dbh = C4::Context->dbh; + my $query = "SELECT * + FROM `aqbudgets` + WHERE budget_parent_id + IN ( + SELECT budget_id + FROM `aqbudgets` + WHERE budget_parent_id + IN ( + SELECT budget_id + FROM `aqbudgets` + JOIN `aqbudgetperiods` ON aqbudgets.budget_period_id = aqbudgetperiods.budget_period_id + WHERE ((`budget_parent_id` IS NULL)AND (`budget_period_active` LIKE 1)))) + ORDER BY `aqbudgets`.`budget_parent_id` , budget_name ASC"; + my $sth= $dbh->prepare($query); + $sth->execute(); + my $data = $sth->fetchall_arrayref({}); + return $data; +} +# ------------------------------------------------------------------- + sub DelBudgetPeriod{ my ($budget_period_id) = @_; my $dbh = C4::Context->dbh; 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 38d784f..13fc225 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/suggestion/suggestion.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/suggestion/suggestion.tt @@ -87,6 +87,57 @@ $(document).ready(function() { calcNewsuggTotal(); }); [% END %] + + + [% INCLUDE 'header.inc' %] @@ -169,6 +220,14 @@ $(document).ready(function() { calcNewsuggTotal(); }); [% FOREACH budgetsloo IN budgetsloop %] [% IF ( budgetsloo.selected ) %][% ELSE %][% END %][% END %] + +
  • diff --git a/suggestion/suggestion.pl b/suggestion/suggestion.pl index d00b632..5508952 100755 --- a/suggestion/suggestion.pl +++ b/suggestion/suggestion.pl @@ -84,6 +84,10 @@ my $tabcode = $input->param('tabcode'); my $suggestion_ref = $input->Vars; delete $$suggestion_ref{$_} foreach qw( suggestedbyme op displayby tabcode edit_field ); + +$suggestion_ref->{'budgetid'} = $suggestion_ref->{'su_sub_budgetid'}||$suggestion_ref->{'sub_budgetid'}||$suggestion_ref->{'budgetid'}; +delete $$suggestion_ref{$_} foreach qw( suggestedbyme op displayby tabcode edit_field sub_budgetid su_sub_budgetid); + foreach (keys %$suggestion_ref){ delete $$suggestion_ref{$_} if (!$$suggestion_ref{$_} && ($op eq 'else' || $op eq 'change')); } @@ -300,8 +304,15 @@ foreach my $budget ( @{$budgets} ) { ## Please see file perltidy.ERR $budget->{'selected'}=1 if ($$suggestion_ref{'budgetid'} && $budget->{'budget_id'} eq $$suggestion_ref{'budgetid'}) }; +my $bud = GetBudgetParent(); +my $subbud = GetBudgetFirstChild(); +my $susubbud = GetBudgetSecondChild(); $template->param( budgetsloop => $budgets); +$template->param( budgetsloop => $bud ); +$template->param( sub_budgetsloop => $subbud ); +$template->param( su_sub_budgetsloop => $susubbud ); + $template->param( "statusselected_$$suggestion_ref{'STATUS'}" =>1); # get currencies and rates -- 1.7.4.1