X-Git-Url: http://git.rot13.org/?a=blobdiff_plain;f=admin%2Faqplan.pl;h=a27fb0a4cabe5c8ed70282d88946a7bf722b10c6;hb=8dad1582c100017f8ad3e331c9a9b9cc9ed4e4d6;hp=9cc8c5990d2d089db001c218911702dae30b16be;hpb=8648c21ddf975d9c8b589c8457e73e511077a05b;p=koha.git diff --git a/admin/aqplan.pl b/admin/aqplan.pl index 9cc8c5990d..a27fb0a4ca 100755 --- a/admin/aqplan.pl +++ b/admin/aqplan.pl @@ -3,18 +3,18 @@ # Copyright 2008-2009 BibLibre SARL # This file is part of Koha. # -# Koha is free software; you can redistribute it and/or modify it under the -# terms of the GNU General Public License as published by the Free Software -# Foundation; either version 2 of the License, or (at your option) any later -# version. +# Koha is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. # -# Koha is distributed in the hope that it will be useful, but WITHOUT ANY -# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR -# A PARTICULAR PURPOSE. See the GNU General Public License for more details. +# Koha is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. # -# You should have received a copy of the GNU General Public License along -# with Koha; if not, write to the Free Software Foundation, Inc., -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +# You should have received a copy of the GNU General Public License +# along with Koha; if not, see . #script to administer the aqbudgets0 table #written 20/02/2002 by paul.poulain@free.fr @@ -22,12 +22,10 @@ use strict; #use warnings; FIXME - Bug 2505 -use CGI; +use CGI qw ( -utf8 ); use List::Util qw/min/; use Date::Calc qw/Delta_YMD Easter_Sunday Today Decode_Date_EU/; use Date::Manip qw/ ParseDate UnixDate DateCalc/; -use C4::Dates qw/format_date format_date_in_iso/; -use Number::Format qw(format_price); use Text::CSV_XS; use C4::Acquisition; @@ -36,8 +34,8 @@ use C4::Context; use C4::Output; use C4::Koha; use C4::Auth; -use C4::Input; use C4::Debug; +use Koha::Acquisition::Currencies; my $input = new CGI; #### $input @@ -45,7 +43,7 @@ my $input = new CGI; my $dbh = C4::Context->dbh; my ( $template, $borrowernumber, $cookie, $staff_flags ) = get_template_and_user( - { template_name => "admin/aqplan.tmpl", + { template_name => "admin/aqplan.tt", query => $input, type => "intranet", authnotrequired => 0, @@ -59,9 +57,9 @@ my $budget_period_id = $input->param('budget_period_id'); # IF PERIOD_ID IS DEFINED, GET THE PERIOD - ELSE GET THE ACTIVE PERIOD BY DEFAULT my $period = GetBudgetPeriod($budget_period_id); my $count = GetPeriodsCount(); -my $cur = GetCurrency; -$template->param( symbol => $cur->{symbol}, - currency => $cur->{currency} +my $active_currency = Koha::Acquisition::Currencies->get_active; +$template->param( symbol => $active_currency->symbol, + currency => $active_currency->currency, ); $template->param( period_button_only => 1 ) if $count == 0; @@ -85,10 +83,9 @@ $template->param( # ------- get periods stuff ------------------ -my $borrower_id = $template->{VARS}->{'USER_INFO'}[0]->{'borrowernumber'}; -my $borrower_branchcode = $template->{VARS}->{'USER_INFO'}[0]->{'branchcode'}; +my $borrower_id = $template->{VARS}->{'USER_INFO'}->{'borrowernumber'}; +my $borrower_branchcode = $template->{VARS}->{'USER_INFO'}->{'branchcode'}; -my $periods; my $authcat = $input->param('authcat'); my $show_active = $input->param('show_active'); my $show_actual = $input->param('show_actual'); @@ -99,27 +96,7 @@ my $del = $input->param("sep"); my $show_mine = $input->param('show_mine') ; -my @hide_cols = $input->param('hide_cols'); - -my $cur_format = C4::Context->preference("CurrencyFormat"); -my $num; - -if ( $cur_format eq 'FR' ) { - $num = new Number::Format( - 'decimal_fill' => '2', - 'decimal_point' => ',', - 'int_curr_symbol' => '', - 'mon_thousands_sep' => ' ', - 'thousands_sep' => ' ', - 'mon_decimal_point' => ',' - ); -} else { # US by default.. - $num = new Number::Format( - 'int_curr_symbol' => '', - 'mon_thousands_sep' => ',', - 'mon_decimal_point' => '.' - ); -} +my @hide_cols = $input->multi_param('hide_cols'); if ( $budget_period_locked == 1 && not defined $show_actual ) { $show_actual = 1; @@ -130,9 +107,7 @@ $authcat = 'Asort1' if not defined $authcat; # defaults to Asort if no authcat my $budget_id = $input->param('budget_id'); my $op = $input->param("op"); -my $budget_branchcode; - -my $budgets_ref = GetBudgetHierarchy( $budget_period_id, $show_mine?$template->{VARS}->{'USER_INFO'}[0]->{'branchcode'}:'', $show_mine?$template->{VARS}->{'USER_INFO'}[0]->{'borrowernumber'}:'' ); +my $budgets_ref = GetBudgetHierarchy( $budget_period_id, $show_mine?$template->{VARS}->{'USER_INFO'}->{'branchcode'}:'', $show_mine?$template->{VARS}->{'USER_INFO'}->{'borrowernumber'}:'' ); # build categories list my $sth = $dbh->prepare("select distinct category from authorised_values where category like 'A%' "); @@ -152,28 +127,21 @@ 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; +push( @category_list, $_ ) foreach @$auth_cats_loop; #reorder the list @category_list = sort { $a cmp $b } @category_list; -my $tab_list = CGI::scrolling_list( - -name => 'authcat', - -id => 'authcat', - -values => \@category_list, - -default => $authcat, - -size => 1, - -tabindex => '', - -multiple => 0, -); -$template->param( authcat_dropbox => $tab_list ); +$template->param( authcat_dropbox => { + values => \@category_list, + default => $authcat, + }); my @budgets = @$budgets_ref; -my $CGISort; my @authvals; my %labels; -my @names = $input->param(); +my @names = $input->multi_param(); # ------------------------------------------------------------ if ( $op eq 'save' ) { #get budgets @@ -189,7 +157,6 @@ if ( $op eq 'save' ) { my %seen; @buds = grep { !$seen{$_}++ } @buds; @auth_values = grep { !$seen{$_}++ } @auth_values; - my @budget_ids; my @budget_lines; foreach my $budget (@buds) { @@ -225,7 +192,6 @@ HideCols($authcat, @hide_cols); } # ------------------------------------------------------------ if ( $authcat =~ m/^Asort/ ) { - # ----------- copied from C4::Input::buildCGIsort() my $query = qq{ SELECT * FROM authorised_values WHERE category=? order by lib }; my $sth = $dbh->prepare($query); $sth->execute($authcat ); @@ -239,7 +205,7 @@ if ( $authcat =~ m/^Asort/ ) { $sth->finish; @authvals = sort { $a <=> $b } @authvals; } -elsif ( $authcat eq 'MONTHS' ) { +elsif ( $authcat eq 'MONTHS' && $budget_period_startdate && $budget_period_enddate ) { # build months my @start_date = UnixDate( $budget_period_startdate, ( '%Y', '%m', '%d' ) ); @@ -331,22 +297,8 @@ foreach my $n (@names) { # ------------------------------------------------------------ # DEFAULT DISPLAY BEGINS -my $CGIextChoice = CGI::scrolling_list( - -name => 'MIME', - -id => 'MIME', - -values => ['CSV'], # FIXME translation - -size => 1, - -multiple => 0 -); - -my @dels = ( C4::Context->preference("delimiter") ); -my $CGIsepChoice = CGI::scrolling_list( - -name => 'sep', - -id => 'sep', - -values => \@dels, - -size => 1, - -multiple => 0 -); +my $CGIextChoice = ( 'CSV' ); # FIXME translation +my $CGIsepChoice = ( C4::Context->preference("delimiter") ); my ( @budget_lines, %cell_hash ); @@ -372,7 +324,7 @@ foreach my $budget (@budgets) { or $authcat eq 'BRANCHES' or $authcat eq 'MONTHS' ) { - # but skip budgets that dont match the current auth-category + # but skip budgets that don't match the current auth-category next if ( $budget->{'sort1_authcat'} ne $authcat && $budget->{'sort2_authcat'} ne $authcat ); } @@ -415,8 +367,7 @@ foreach my $budget (@budgets) { %budget_line = ( lines => \@cells_line, - budget_name_indent => $budget->{budget_name_indent}, - budget_amount_formatted => $num->format_price( $budget->{budget_amount} ), + budget_name => $budget->{budget_name}, budget_amount => $budget->{budget_amount}, budget_alloc => $budget->{budget_alloc}, budget_act_remain => sprintf( "%.2f", $budget_act_remain ), @@ -454,12 +405,11 @@ $template->param( show_actual => $show_actual, show_percent => $show_percent, show_mine => $show_mine, - cur_format => $cur_format, CGIextChoice => $CGIextChoice, CGIsepChoice => $CGIsepChoice, authvals => \@authvals_row, - hide_cols_loop => \@hide_cols + hide_cols_loop => \@hide_cols, ); output_html_with_http_headers $input, $cookie, $template->output; @@ -491,8 +441,7 @@ sub _print_to_csv { print "$str\n"; foreach my $row (@$results) { - $row->{'budget_name_indent'} =~ s/ / /g; - my @col = ( $row->{'budget_name_indent'}, $row->{'budget_amount'} ); + my @col = ( $row->{'budget_name'}, $row->{'budget_amount'} ); my $l = $row->{'lines'}; foreach my $line (@$l) { push @col, $line->{'estimated_amount'};