X-Git-Url: http://koha-dev.rot13.org:8081/gitweb/?a=blobdiff_plain;f=acqui%2Facqui-home.pl;h=cd5683185a98569e4105b73479f5be658cc1322f;hb=b91efb3b6668bdb50ea475571eae7858aa2b1f52;hp=45a04bf25e6a2247969321f807b1680581a7f69f;hpb=70af4593722ce2f3debd4f6d2c251ad29008b923;p=koha_fer diff --git a/acqui/acqui-home.pl b/acqui/acqui-home.pl index 45a04bf25e..cd5683185a 100755 --- a/acqui/acqui-home.pl +++ b/acqui/acqui-home.pl @@ -38,9 +38,10 @@ use C4::Budgets; use C4::Members; use C4::Branch; use C4::Debug; +use C4::Suggestions; my $query = CGI->new; -my ( $template, $loggedinuser, $cookie ) = get_template_and_user( +my ( $template, $loggedinuser, $cookie, $userflags ) = get_template_and_user( { template_name => 'acqui/acqui-home.tmpl', query => $query, type => 'intranet', @@ -74,9 +75,10 @@ if ( $cur_format eq 'FR' ) { ); } -my $budget_arr = - GetBudgetHierarchy( '', $user->{branchcode}, - $template->{param_map}->{'USER_INFO'}[0]->{'borrowernumber'} ); +my $status = $query->param('status') || "ASKED"; +my $suggestions_count = CountSuggestion($status); + +my $budget_arr = GetBudgetHierarchy; my $total = 0; my $totspent = 0; @@ -84,7 +86,14 @@ my $totordered = 0; my $totcomtd = 0; my $totavail = 0; +my $total_active = 0; +my $totspent_active = 0; +my $totordered_active = 0; +my $totavail_active = 0; + +my @budget_loop; foreach my $budget ( @{$budget_arr} ) { + next unless (CanUserUseBudget($loggedinuser, $budget, $userflags)); $budget->{budget_code_indent} =~ s/\ /\ \;/g; @@ -93,8 +102,9 @@ foreach my $budget ( @{$budget_arr} ) { my $member = GetMember( borrowernumber => $budget->{budget_owner_id} ); if ($member) { - $budget->{budget_owner} = - $member->{'firstname'} . ' ' . $member->{'surname'}; + $budget->{budget_owner_firstname} = $member->{'firstname'}; + $budget->{budget_owner_surname} = $member->{'surname'}; + $budget->{budget_owner_borrowernumber} = $member->{'borrowernumber'}; } if ( !defined $budget->{budget_amount} ) { @@ -117,21 +127,34 @@ foreach my $budget ( @{$budget_arr} ) { $totordered += $budget->{'budget_ordered'}; $totavail += $budget->{'budget_avail'}; + if ($budget->{budget_period_active}){ + $total_active += $budget->{'budget_amount'}; + $totspent_active += $budget->{'budget_spent'}; + $totordered_active += $budget->{'budget_ordered'}; + $totavail_active += $budget->{'budget_avail'}; + } + for my $field (qw( budget_amount budget_spent budget_ordered budget_avail ) ) { - $budget->{$field} = $num_formatter->format_price( $budget->{$field} ); + $budget->{"formatted_$field"} = $num_formatter->format_price( $budget->{$field} ); } + + push @budget_loop, $budget; } $template->param( - type => 'intranet', - loop_budget => $budget_arr, + loop_budget => \@budget_loop, branchname => $branchname, total => $num_formatter->format_price($total), totspent => $num_formatter->format_price($totspent), totordered => $num_formatter->format_price($totordered), totcomtd => $num_formatter->format_price($totcomtd), totavail => $num_formatter->format_price($totavail), + total_active => $num_formatter->format_price($total_active), + totspent_active => $num_formatter->format_price($totspent_active), + totordered_active => $num_formatter->format_price($totordered_active), + totavail_active => $num_formatter->format_price($totavail_active), + suggestions_count => $suggestions_count, ); output_html_with_http_headers $query, $cookie, $template->output;