@@ -, +, @@ --- C4/Budgets.pm | 30 +++ .../prog/en/includes/reports-menu.inc | 1 + .../prog/en/includes/reports/fields.inc | 25 ++ .../prog/en/modules/reports/reports-home.tt | 1 + .../prog/en/modules/reports/suggestions_stats.tt | 186 ++++++++++++++ .../modules/reports/suggestions_stats_results.tt | 83 +++++++ reports/suggestions_stats.pl | 268 +++++++++++++++++++++ t/db_dependent/Budgets.t | 13 +- 8 files changed, 606 insertions(+), 1 deletion(-) create mode 100644 koha-tmpl/intranet-tmpl/prog/en/includes/reports/fields.inc create mode 100644 koha-tmpl/intranet-tmpl/prog/en/modules/reports/suggestions_stats.tt create mode 100644 koha-tmpl/intranet-tmpl/prog/en/modules/reports/suggestions_stats_results.tt create mode 100755 reports/suggestions_stats.pl --- a/C4/Budgets.pm +++ a/C4/Budgets.pm @@ -195,6 +195,36 @@ sub GetBudgetChildren { |, { Slice => {} }, $budget_id ); } +sub GetBudgetDescendantsIds { + my ($budget_id) = @_; + + return () unless $budget_id; + + my @descendants_ids; + + my $query = q| + SELECT budget_id FROM aqbudgets WHERE budget_parent_id = ? + |; + my $dbh = C4::Context->dbh; + my @children_ids = map { + $_->{budget_id} + } @{ $dbh->selectall_arrayref($query, {Slice => {}}, $budget_id) }; + + while (@children_ids) { + push @descendants_ids, @children_ids; + $query = ' + SELECT budget_id + FROM aqbudgets + WHERE budget_parent_id IN (' . join(',', ('?') x @children_ids) . ')'; + @children_ids = map { + $_->{budget_id} + } @{ $dbh->selectall_arrayref($query, {Slice => {}}, @children_ids) }; + } + + return @descendants_ids; +} + + sub SetOwnerToFundHierarchy { my ( $budget_id, $borrowernumber ) = @_; --- a/koha-tmpl/intranet-tmpl/prog/en/includes/reports-menu.inc +++ a/koha-tmpl/intranet-tmpl/prog/en/includes/reports-menu.inc @@ -6,6 +6,7 @@
Statistics wizards