X-Git-Url: http://koha-dev.rot13.org:8081/gitweb/?a=blobdiff_plain;f=admin%2Faqplan.pl;h=ffb11456060a81e6e73ab51826cf9890e08c5a1c;hb=d4233cf1dd1bd7353f38fbd1d79de79c47296486;hp=51983b9b11cd9b99a33be6e284b4ee0afde2af5d;hpb=2c6765610856bd298cec045077a55296ae10abda;p=koha_gimpoz diff --git a/admin/aqplan.pl b/admin/aqplan.pl index 51983b9b11..ffb1145606 100755 --- a/admin/aqplan.pl +++ b/admin/aqplan.pl @@ -21,6 +21,7 @@ # This software is placed under the gnu General Public License, v2 (http://www.gnu.org/licenses/gpl.html) use strict; +#use warnings; FIXME - Bug 2505 use CGI; use List::Util qw/min/; use Date::Calc qw/Delta_YMD Easter_Sunday Today Decode_Date_EU/; @@ -49,7 +50,7 @@ my ( $template, $borrowernumber, $cookie, $staff_flags ) = get_template_and_user type => "intranet", authnotrequired => 0, flagsrequired => { acquisition => 'planning_manage' }, - debug => 1, + debug => 0, } ); @@ -59,7 +60,9 @@ my $budget_period_id = $input->param('budget_period_id'); my $period = GetBudgetPeriod($budget_period_id); my $count = GetPeriodsCount(); my $cur = GetCurrency; - +$template->param( symbol => $cur->{symbol}, + currency => $cur->{currency} + ); $template->param( period_button_only => 1 ) if $count == 0; @@ -71,21 +74,19 @@ my $budget_period_startdate = $period->{'budget_period_startdate'}; my $budget_period_enddate = $period->{'budget_period_enddate'}; my $budget_period_locked = $period->{'budget_period_locked'}; my $budget_period_description = $period->{'budget_period_description'}; -my $budget_period_dropbox = GetBudgetPeriodsDropbox($budget_period_id ); $template->param( budget_period_id => $budget_period_id, budget_period_locked => $budget_period_locked, budget_period_description => $budget_period_description, - budget_period_dropbox => $budget_period_dropbox, auth_cats_loop => $auth_cats_loop, ); # ------- get periods stuff ------------------ -my $borrower_id = $template->{param_map}->{'USER_INFO'}[0]->{'borrowernumber'}; -my $borrower_branchcode = $template->{param_map}->{'USER_INFO'}[0]->{'branchcode'}; +my $borrower_id = $template->{VARS}->{'USER_INFO'}[0]->{'borrowernumber'}; +my $borrower_branchcode = $template->{VARS}->{'USER_INFO'}[0]->{'branchcode'}; my $periods; my $authcat = $input->param('authcat'); @@ -94,7 +95,6 @@ my $show_actual = $input->param('show_actual'); my $show_percent = $input->param('show_percent'); my $output = $input->param("output"); my $basename = $input->param("basename"); -my $mime = $input->param("MIME"); my $del = $input->param("sep"); my $show_mine = $input->param('show_mine') ; @@ -132,7 +132,7 @@ my $op = $input->param("op"); my $budget_branchcode; -my $budgets_ref = GetBudgetHierarchy( $budget_period_id, $show_mine?$template->{param_map}->{'USER_INFO'}[0]->{'branchcode'}:'', $show_mine?$template->{param_map}->{'USER_INFO'}[0]->{'borrowernumber'}:'' ); +my $budgets_ref = GetBudgetHierarchy( $budget_period_id, $show_mine?$template->{VARS}->{'USER_INFO'}[0]->{'branchcode'}:'', $show_mine?$template->{VARS}->{'USER_INFO'}[0]->{'borrowernumber'}:'' ); # build categories list my $sth = $dbh->prepare("select distinct category from authorised_values where category like 'A%' "); @@ -152,6 +152,7 @@ while ( my ($category) = $sth->fetchrow_array ) { push( @category_list, 'MONTHS' ); push( @category_list, 'ITEMTYPES' ); push( @category_list, 'BRANCHES' ); +push( @category_list, $$_{'authcat'} ) foreach @$auth_cats_loop; #reorder the list @category_list = sort { $a cmp $b } @category_list; @@ -172,9 +173,7 @@ my $CGISort; my @authvals; my %labels; - - my @names = $input->param(); - +my @names = $input->param(); # ------------------------------------------------------------ if ( $op eq 'save' ) { #get budgets @@ -291,6 +290,18 @@ elsif ( $authcat eq 'ITEMTYPES' ) { } } $sth->finish; +} elsif ($authcat) { + my $query = qq{ SELECT * FROM authorised_values WHERE category=? order by lib }; + my $sth = $dbh->prepare($query); + $sth->execute($authcat); + if ( $sth->rows > 0 ) { + for ( my $i = 0 ; $i < $sth->rows ; $i++ ) { + my $results = $sth->fetchrow_hashref; + push @authvals, $results->{authorised_value}; + $labels{ $results->{authorised_value} } = $results->{lib}; + } + } + $sth->finish; } my @authvals_row; @@ -320,11 +331,10 @@ foreach my $n (@names) { # ------------------------------------------------------------ # DEFAULT DISPLAY BEGINS -my @mime = ( C4::Context->preference("MIME") ); my $CGIextChoice = CGI::scrolling_list( -name => 'MIME', -id => 'MIME', - -values => \@mime, + -values => ['CSV'], # FIXME translation -size => 1, -multiple => 0 ); @@ -440,7 +450,6 @@ $template->param( show_actual => $show_actual, show_percent => $show_percent, show_mine => $show_mine, - cur => $cur->{symbol}, cur_format => $cur_format, CGIextChoice => $CGIextChoice, CGIsepChoice => $CGIsepChoice, @@ -454,6 +463,8 @@ output_html_with_http_headers $input, $cookie, $template->output; sub _print_to_csv { my ( $header, $results ) = @_; + binmode STDOUT, ':encoding(UTF-8)'; + my $csv = Text::CSV_XS->new( { sep_char => $del, always_quote => 'TRUE', @@ -476,7 +487,8 @@ sub _print_to_csv { print "$str\n"; foreach my $row (@$results) { - my @col = ( $row->{'budget_name'}, $row->{'budget_amount'} ); + $row->{'budget_name_indent'} =~ s/ / /g; + my @col = ( $row->{'budget_name_indent'}, $row->{'budget_amount'} ); my $l = $row->{'lines'}; foreach my $line (@$l) { push @col, $line->{'estimated_amount'};