X-Git-Url: http://koha-dev.rot13.org:8081/gitweb/?a=blobdiff_plain;f=admin%2Faqplan.pl;h=cbded1ca64b11f7749b13da40a1d62eca5f47d0c;hb=2685f7992dcfea91be83154bef6ea04fba49e314;hp=fd3f2e62580040869b62e6707d083cef54f4df84;hpb=216b0cff0de168ce95f11b648c2e794083a00874;p=koha-ffzg.git diff --git a/admin/aqplan.pl b/admin/aqplan.pl index fd3f2e6258..cbded1ca64 100755 --- a/admin/aqplan.pl +++ b/admin/aqplan.pl @@ -22,21 +22,27 @@ use Modern::Perl; 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 Date::Calc qw( Delta_YMD ); +use Date::Manip qw( DateCalc UnixDate ); use Text::CSV_XS; -use C4::Acquisition; -use C4::Budgets; +use C4::Budgets qw( + CanUserUseBudget + GetBudgetAuthCats + GetBudgetHierarchy + GetBudgetPeriod + GetBudgetsPlanCell + GetCols + GetPeriodsCount + HideCols + ModBudgetPlan +); use C4::Context; -use C4::Output; -use C4::Koha; -use C4::Auth; -use C4::Debug; +use C4::Output qw( output_html_with_http_headers ); +use C4::Auth qw( get_template_and_user ); use Koha::Acquisition::Currencies; -our $input = new CGI; +our $input = CGI->new; #### $input my $dbh = C4::Context->dbh; @@ -45,9 +51,7 @@ my ( $template, $borrowernumber, $cookie, $staff_flags ) = get_template_and_user { template_name => "admin/aqplan.tt", query => $input, type => "intranet", - authnotrequired => 0, flagsrequired => { acquisition => 'planning_manage' }, - debug => 0, } ); @@ -84,16 +88,16 @@ $template->param( # ------- get periods stuff ------------------ -my $borrower_id = $template->{VARS}->{'USER_INFO'}->{'borrowernumber'}; -my $borrower_branchcode = $template->{VARS}->{'USER_INFO'}->{'branchcode'}; + +my $borrower_branchcode = my $branch_code = C4::Context->userenv->{'branch'}; my $authcat = $input->param('authcat'); -my $show_active = $input->param('show_active'); +my $show_active = $input->param('show_active') // 0; my $show_actual = $input->param('show_actual'); my $show_percent = $input->param('show_percent'); -my $output = $input->param("output"); +my $output = $input->param("output") // q{}; our $basename = $input->param("basename"); -our $del = $input->param("sep"); +our $del = C4::Context->csv_delimiter(scalar $input->param("sep")); my $show_mine = $input->param('show_mine') ; @@ -106,9 +110,13 @@ if ( $budget_period_locked == 1 && not defined $show_actual ) { $authcat = 'Asort1' if not defined $authcat; # defaults to Asort if no authcat given my $budget_id = $input->param('budget_id'); -my $op = $input->param("op"); +my $op = $input->param("op") // q{}; -my $budgets_ref = GetBudgetHierarchy( $budget_period_id, $show_mine?$template->{VARS}->{'USER_INFO'}->{'branchcode'}:'', $show_mine?$template->{VARS}->{'USER_INFO'}->{'borrowernumber'}:'' ); +my $budgets_ref = GetBudgetHierarchy( + $budget_period_id, + $show_mine ? $borrower_branchcode : '', + $show_mine ? $borrowernumber : '' +); # build categories list my $sth = $dbh->prepare("select distinct category from authorised_values where category like 'A%' "); @@ -299,7 +307,7 @@ foreach my $n (@names) { # DEFAULT DISPLAY BEGINS my $CGIextChoice = ( 'CSV' ); # FIXME translation -my $CGIsepChoice = ( C4::Context->preference("delimiter") ); +my $CGIsepChoice = ( C4::Context->csv_delimiter ); my ( @budget_lines, %cell_hash ); @@ -315,7 +323,7 @@ foreach my $budget (@budgets) { if ( $period->{budget_period_locked} == 1 ) { $budget_lock = 1; } elsif ( $budget->{budget_permission} == 1 ) { - $budget_lock = 1 if $borrower_id != $budget->{'budget_owner_id'}; + $budget_lock = 1 if $borrowernumber != $budget->{'budget_owner_id'}; } elsif ( $budget->{budget_permission} == 2 ) { $budget_lock = 1 if $borrower_branchcode ne $budget->{budget_branchcode}; } @@ -350,8 +358,8 @@ foreach my $budget (@budgets) { ); my ( $actual, $estimated, $display ) = GetBudgetsPlanCell( \%cell, $period, $budget ); - $cell{actual_amount} = sprintf( "%.2f", $actual ); - $cell{estimated_amount} = sprintf( "%.2f", $estimated ); + $cell{actual_amount} = sprintf( "%.2f", $actual // 0 ); + $cell{estimated_amount} = sprintf( "%.2f", $estimated // 0 ); $cell{display} = $authvals_row[$i]{display}; $cell{colnum} = $i;