X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/mfinanz.git/blobdiff_plain/be4e11d36f40d90622fdf35eb07ab207422b5455..fce441db:/bin/mozilla/bp.pl?ds=sidebyside diff --git a/bin/mozilla/bp.pl b/bin/mozilla/bp.pl index 6e7d9277a..10acafdaa 100644 --- a/bin/mozilla/bp.pl +++ b/bin/mozilla/bp.pl @@ -33,15 +33,55 @@ use SL::BP; use Data::Dumper; +use List::Util qw(first); 1; 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', + 'sales_quotation' => 'sales_quotation_edit', + 'purchase_order' => 'purchase_order_edit', + 'request_quotation' => 'request_quotation_edit', + 'check' => 'cash', + 'receipt' => 'cash', + ); + + if ($form->{type} && $access_map{$form->{type}}) { + $main::auth->assert($access_map{$form->{type}}); + + } elsif ($form->{type} eq 'packing_list') { + $main::lxdebug->message(0, "1"); + if (!$main::auth->assert('sales_order_edit', 1)) { + $main::lxdebug->message(0, "2"); + $main::auth->assert('invoice_edit') ; + } + $main::lxdebug->message(0, "3"); + + } else { + $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(); # $locale->text('Sales Invoices') # $locale->text('Packing Lists') @@ -66,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 => @@ -131,7 +171,7 @@ sub search { $account .= qq| {vc}> {type}> @@ -229,10 +270,6 @@ sub search { -{path}> -{login}> -{password}> -
@@ -246,15 +283,20 @@ $jsscript |; - $lxdebug->leave_sub(); + $main::lxdebug->leave_sub(); } sub remove { - $lxdebug->enter_sub(); + $main::lxdebug->enter_sub(); + + my $form = $main::form; + my $locale = $main::locale; + + assert_bp_access(); - $selected = 0; + my $selected = 0; - for $i (1 .. $form->{rowcount}) { + for my $i (1 .. $form->{rowcount}) { if ($form->{"checked_$i"}) { $selected = 1; last; @@ -270,12 +312,13 @@ sub remove { print qq| -
{script}> + |; map { delete $form->{$_} } qw(action header); - foreach $key (keys %$form) { + foreach my $key (keys %$form) { + next if (($key eq 'login') || ($key eq 'password') || ('' ne ref $form->{$key})); print qq|\n|; } @@ -295,28 +338,43 @@ 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(); $form->info($locale->text('Removing marked entries from queue ...')); $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(); $form->get_lists(printers => 'ALL_PRINTERS'); # use the command stored in the databse or fall back to $myconfig{printer} - my $selected_printer = (grep { $_->{id} eq $form->{printer} } @{ $form->{ALL_PRINTERS} })[0]->{'printer_command'} || $myconfig{printer}; + my $selected_printer = first { $_ } map ({ $_ ->{printer_command} } + grep { $_->{id} eq $form->{printer} } + @{ $form->{ALL_PRINTERS} }), + $myconfig{printer}; if ($form->{callback}) { map { $form->{callback} .= "&checked_$_=1" if $form->{"checked_$_"} } @@ -324,12 +382,11 @@ sub print { $form->{callback} .= "&header=1"; } - for $i (1 .. $form->{rowcount}) { + for my $i (1 .. $form->{rowcount}) { if ($form->{"checked_$i"}) { - $form->{OUT} = "| $selected_printer"; $form->info($locale->text('Printing ... ')); - if (BP->print_spool(\%myconfig, \%$form, $spool)) { + if (BP->print_spool(\%myconfig, \%$form, $main::spool, "| $selected_printer")) { print $locale->text('done'); $form->redirect($locale->text('Marked entries printed!')); } @@ -339,11 +396,17 @@ 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(); $form->{ $form->{vc} } = $form->unescape($form->{ $form->{vc} }); ($form->{ $form->{vc} }, $form->{"$form->{vc}_id"}) = @@ -351,13 +414,13 @@ sub list_spool { BP->get_spoolfiles(\%myconfig, \%$form); - $title = $form->escape($form->{title}); - $href = - "$form->{script}?action=list_spool&path=$form->{path}&login=$form->{login}&password=$form->{password}&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 = - "$form->{script}?action=list_spool&path=$form->{path}&login=$form->{login}&password=$form->{password}&vc=$form->{vc}&type=$form->{type}&title=$title"; + 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); @@ -410,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"; } @@ -423,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} = "" @@ -456,7 +522,7 @@ sub list_spool { print qq| -{script}> + @@ -484,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++; @@ -495,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} = ""; @@ -507,14 +575,14 @@ sub list_spool { } $column_data{invnumber} = - ""; + ""; $column_data{ordnumber} = - ""; + ""; $column_data{quonumber} = - ""; + ""; $column_data{name} = ""; $column_data{spoolfile} = - qq| + qq|{spoolfile}> |; @@ -555,10 +623,6 @@ sub list_spool { - -{path}> -{login}> -{password}> |; # if ($myconfig{printer}) { @@ -580,7 +644,7 @@ sub list_spool { $form->get_lists(printers=>"ALL_PRINTERS"); print qq||; # } @@ -596,13 +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"}); }
$ref->{transdate} {id}&path=$form->{path}&login=$form->{login}&password=$form->{password}&type=$form->{type}&callback=$callback>$ref->{invnumber}{id}&type=$form->{type}&callback=$callback>$ref->{invnumber}{id}&path=$form->{path}&login=$form->{login}&password=$form->{password}&type=$form->{type}&callback=$callback>$ref->{ordnumber}{id}&type=$form->{type}&callback=$callback>$ref->{ordnumber}{id}&path=$form->{path}&login=$form->{login}&password=$form->{password}&type=$form->{type}&callback=$callback>$ref->{quonumber}{id}&type=$form->{type}&callback=$callback>$ref->{quonumber}$ref->{name}{spoolfile}>$ref->{spoolfile}{spoolfile}>$ref->{spoolfile}