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;
{ template_name => "admin/aqplan.tt",
query => $input,
type => "intranet",
- authnotrequired => 0,
flagsrequired => { acquisition => 'planning_manage' },
- debug => 0,
}
);
# ------- 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') // 0;
my $show_percent = $input->param('show_percent');
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') ;
my $budget_id = $input->param('budget_id');
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%' ");
# 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 );
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};
}