From 3314d7c2247d46033fcd7cd1e1663a705db02fea Mon Sep 17 00:00:00 2001 From: =?utf8?q?Sven=20Sch=C3=B6ling?= Date: Tue, 20 Oct 2009 16:40:59 +0200 Subject: [PATCH] bp strict --- bin/mozilla/bp.pl | 112 ++++++++++++++++++++++++++++++---------------- 1 file changed, 73 insertions(+), 39 deletions(-) diff --git a/bin/mozilla/bp.pl b/bin/mozilla/bp.pl index 654a26776..10acafdaa 100644 --- a/bin/mozilla/bp.pl +++ b/bin/mozilla/bp.pl @@ -39,9 +39,13 @@ use List::Util qw(first); require "bin/mozilla/common.pl"; +use strict; + # end of main sub assert_bp_access { + my $form = $main::form; + my %access_map = ( 'invoice' => 'invoice_edit', 'sales_order' => 'sales_order_edit', @@ -53,23 +57,29 @@ sub assert_bp_access { ); if ($form->{type} && $access_map{$form->{type}}) { - $auth->assert($access_map{$form->{type}}); + $main::auth->assert($access_map{$form->{type}}); } elsif ($form->{type} eq 'packing_list') { - $lxdebug->message(0, "1"); - if (!$auth->assert('sales_order_edit', 1)) { - $lxdebug->message(0, "2"); - $auth->assert('invoice_edit') ; + $main::lxdebug->message(0, "1"); + if (!$main::auth->assert('sales_order_edit', 1)) { + $main::lxdebug->message(0, "2"); + $main::auth->assert('invoice_edit') ; } - $lxdebug->message(0, "3"); + $main::lxdebug->message(0, "3"); } else { - $auth->assert('DOES_NOT_EXIST'); + $main::auth->assert('DOES_NOT_EXIST'); } } sub search { - $lxdebug->enter_sub(); + $main::lxdebug->enter_sub(); + + my $form = $main::form; + my %myconfig = %main::myconfig; + my $locale = $main::locale; + + my ($name, $account, $onload); assert_bp_access(); @@ -96,7 +106,7 @@ sub search { # $locale->text('Customer') # $locale->text('Vendor') - %label = ( + my %label = ( invoice => { title => 'Sales Invoices', name => 'Customer', l_invnumber => 'Y' }, packing_list => @@ -161,7 +171,7 @@ sub search { $account .= qq| \n|; } @@ -324,11 +338,15 @@ sub remove { |; - $lxdebug->leave_sub(); + $main::lxdebug->leave_sub(); } sub yes { - $lxdebug->enter_sub(); + $main::lxdebug->enter_sub(); + + my $form = $main::form; + my %myconfig = %main::myconfig; + my $locale = $main::locale; assert_bp_access(); @@ -336,14 +354,18 @@ sub yes { $form->{callback} .= "&header=1" if $form->{callback}; $form->redirect($locale->text('Removed spoolfiles!')) - if (BP->delete_spool(\%myconfig, \%$form, $spool)); + if (BP->delete_spool(\%myconfig, \%$form, $main::spool)); $form->error($locale->text('Cannot remove files!')); - $lxdebug->leave_sub(); + $main::lxdebug->leave_sub(); } sub print { - $lxdebug->enter_sub(); + $main::lxdebug->enter_sub(); + + my $form = $main::form; + my %myconfig = %main::myconfig; + my $locale = $main::locale; assert_bp_access(); @@ -360,11 +382,11 @@ sub print { $form->{callback} .= "&header=1"; } - for $i (1 .. $form->{rowcount}) { + for my $i (1 .. $form->{rowcount}) { if ($form->{"checked_$i"}) { $form->info($locale->text('Printing ... ')); - if (BP->print_spool(\%myconfig, \%$form, $spool, "| $selected_printer")) { + if (BP->print_spool(\%myconfig, \%$form, $main::spool, "| $selected_printer")) { print $locale->text('done'); $form->redirect($locale->text('Marked entries printed!')); } @@ -374,11 +396,15 @@ sub print { $form->error('Nothing selected!'); - $lxdebug->leave_sub(); + $main::lxdebug->leave_sub(); } sub list_spool { - $lxdebug->enter_sub(); + $main::lxdebug->enter_sub(); + + my $form = $main::form; + my %myconfig = %main::myconfig; + my $locale = $main::locale; assert_bp_access(); @@ -388,12 +414,13 @@ sub list_spool { BP->get_spoolfiles(\%myconfig, \%$form); - $title = $form->escape($form->{title}); - $href = "bp.pl?action=list_spool&vc=$form->{vc}&type=$form->{type}&title=$title"; + my $title = $form->escape($form->{title}); + my $href = "bp.pl?action=list_spool&vc=$form->{vc}&type=$form->{type}&title=$title"; $title = $form->escape($form->{title}, 1); - $callback = + my $callback = "bp.pl?action=list_spool&vc=$form->{vc}&type=$form->{type}&title=$title"; + my $option; if ($form->{ $form->{vc} }) { $callback .= "&$form->{vc}=" . $form->escape($form->{ $form->{vc} }, 1); @@ -446,9 +473,9 @@ sub list_spool { . $locale->date(\%myconfig, $form->{transdateto}, 1); } - $name = ucfirst $form->{vc}; + my $name = ucfirst $form->{vc}; - @columns = (transdate); + my @columns = qw(transdate); if ($form->{type} =~ /(invoice|packing_list|check|receipt)/) { push @columns, "invnumber"; } @@ -459,10 +486,13 @@ sub list_spool { push @columns, "quonumber"; } - push @columns, (name, spoolfile); - @column_index = $form->sort_columns(@columns); + push @columns, qw(name spoolfile); + my @column_index = $form->sort_columns(@columns); unshift @column_index, "checked"; + my %column_header; + my %column_data; + $column_header{checked} = " "; $column_header{transdate} = "" @@ -520,9 +550,11 @@ sub list_spool { # escape callback for href $callback = $form->escape($callback); - $i = 0; + my $i = 0; + my $j = 0; + my $spoolfile; - foreach $ref (@{ $form->{SPOOL} }) { + foreach my $ref (@{ $form->{SPOOL} }) { $i++; @@ -531,7 +563,7 @@ sub list_spool { if ($ref->{invoice}) { $ref->{module} = ($ref->{module} eq 'ar') ? "is" : "ir"; } - $module = "$ref->{module}.pl"; + my $module = "$ref->{module}.pl"; $column_data{transdate} = "$ref->{transdate} "; @@ -550,7 +582,7 @@ sub list_spool { "{id}&type=$form->{type}&callback=$callback>$ref->{quonumber}"; $column_data{name} = "$ref->{name}"; $column_data{spoolfile} = - qq|{spoolfile}>$ref->{spoolfile} + qq|{spoolfile}>$ref->{spoolfile} {spoolfile}> |; @@ -628,15 +660,17 @@ print qq||; } sub select_all { - $lxdebug->enter_sub(); + $main::lxdebug->enter_sub(); + + my $form = $main::form; assert_bp_access(); map { $form->{"checked_$_"} = 1 } (1 .. $form->{rowcount}); &list_spool; - $lxdebug->leave_sub(); + $main::lxdebug->leave_sub(); } -sub continue { call_sub($form->{"nextsub"}); } +sub continue { call_sub($main::form->{"nextsub"}); } -- 2.20.1