X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=bin%2Fmozilla%2Fbp.pl;h=10acafdaa079005eb069856c80df4b768f83835f;hb=08c340d2caca21066fd8797e29f07facfde7a07c;hp=93789019ed5fb6c6146ed1dc51889a0f0c55b9e7;hpb=0d9ac875bf41d614388e6cf3864806de4c04c0e9;p=kivitendo-erp.git diff --git a/bin/mozilla/bp.pl b/bin/mozilla/bp.pl index 93789019e..10acafdaa 100644 --- a/bin/mozilla/bp.pl +++ b/bin/mozilla/bp.pl @@ -32,13 +32,56 @@ #====================================================================== 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') @@ -63,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 => @@ -128,7 +171,7 @@ sub search { $account .= qq| + text('button') - . qq|> + . $locale->text('button') . qq|> |; $button2 = qq| - + text('button') - . qq|> + . $locale->text('button') . qq|> |; #write Trigger @@ -178,17 +220,18 @@ sub search { # without JavaScript Calendar $button1 = qq| - |; + |; $button2 = qq| - |; + |; } - + $form->{javascript} .= qq||; $form->header; - + $onload = qq|;setupDateFormat('|. $myconfig{dateformat} .qq|', '|. $locale->text("Falsches Datumsformat!") .qq|')|; + $onload .= qq|;setupPoints('|. $myconfig{numberformat} .qq|', '|. $locale->text("wrongformat") .qq|')|; print qq| - + -
{script}> + {vc}> {type}> @@ -227,10 +270,6 @@ sub search { -{path}> -{login}> -{password}> -
@@ -244,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; - $selected = 0; + assert_bp_access(); - for $i (1 .. $form->{rowcount}) { + my $selected = 0; + + for my $i (1 .. $form->{rowcount}) { if ($form->{"checked_$i"}) { $selected = 1; last; @@ -268,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|; } @@ -281,7 +326,8 @@ sub remove {

$form->{title}

| - . $locale->text('Are you sure you want to remove the marked entries from the queue?') + . $locale->text( + 'Are you sure you want to remove the marked entries from the queue?') . qq|

{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 = 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_$_"} } @@ -317,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} = "| $myconfig{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!')); } @@ -332,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"}) = @@ -344,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); @@ -403,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"; } @@ -416,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} = "" @@ -449,7 +522,7 @@ sub list_spool { print qq| -{script}> + @@ -477,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++; @@ -488,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} = ""; @@ -500,14 +575,14 @@ sub list_spool { } $column_data{invnumber} = - ""; + ""; $column_data{ordnumber} = - ""; + ""; $column_data{quonumber} = - ""; + ""; $column_data{name} = ""; $column_data{spoolfile} = - qq| + qq|{spoolfile}> |; @@ -548,27 +623,31 @@ sub list_spool { - -{path}> -{login}> -{password}> |; - if ($myconfig{printer}) { +# if ($myconfig{printer}) { print qq| +{transdateto}> +{transdatefrom}> +{invnumber}> +{ordnumber}> +{quonumber}> +{customer}> +{vendor}> - + |; - } - if ($form->{menubar}) { - require "$form->{path}/menu.pl"; - &menubar; - } +$form->get_lists(printers=>"ALL_PRINTERS"); +print qq||; + +# } print qq| @@ -577,17 +656,21 @@ sub list_spool { |; - $lxdebug->leave_sub(); + $main::lxdebug->leave_sub(); } 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 { &{ $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}