X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=bin%2Fmozilla%2Fcommon.pl;h=f03911c32c153bea5f2358c65a2381b231784181;hb=1c603341fc02e3a5a7b5126cd7df6478d2e34700;hp=9cd54a4563d1e46037aee8107f30acfa5e8fab6c;hpb=ea2e84cc75e2879141eea5e957439936280682bf;p=kivitendo-erp.git diff --git a/bin/mozilla/common.pl b/bin/mozilla/common.pl index 9cd54a456..f03911c32 100644 --- a/bin/mozilla/common.pl +++ b/bin/mozilla/common.pl @@ -69,6 +69,11 @@ sub select_part { $has_charge = 1; map { $_->{has_charge} = 1; } @parts; } + my $has_ean = 0; + if (defined($parts[0]->{ean})) { + $has_ean = 1; + map { $_->{has_ean} = 1; } @parts; + } my $old_form = save_form(); @@ -80,6 +85,7 @@ sub select_part { "nextsub" => "select_part_internal", "callback_sub" => $callback_sub, "has_charge" => $has_charge, + "has_ean" => $has_ean, "remap_parts_id" => $remap_parts_id, "remap_partnumber" => $remap_partnumber }); @@ -270,45 +276,36 @@ sub vendor_selection { sub calculate_qty { $lxdebug->enter_sub(); - my @variable_sort = (); - my %variable_list = (); - my $unit_list = (); $form->{formel} =~ s/\r\n//g; my ($variable_string, $formel) = split /###/,$form->{formel}; - - split m/;/, $variable_string; - foreach $item (@_) { - my($name, $valueunit) = split /=/,$item; - my($value, $unit) = split / /, $valueunit; - - push(@variable_sort, $value); - $variable_list{$value} = $name; - $unit_list{$value} = $unit; + foreach $item (split m/;/, $variable_string) { + next unless $item =~ m/^ \s* (\w+) \s* = \s* (\w+) \s* (\w+) \s* $/x; + push @variable, { + description => $1, + name => $2, + unit => $3, + }; } my @header_sort = qw(variable value unit); - my %header_title = ( "variable" => $locale->text("Variable"), - "value" => $locale->text("Value"), - "unit" => $locale->text("Unit"), - ); - - my @variable = map(+{ "description" => $variable_list{$_}, - "name" => $_, - "unit" => $unit_list{$_} }, @variable_sort); + my %header_title = ( + variable => $locale->text("Variable"), + value => $locale->text("Value"), + unit => $locale->text("Unit"), + ); + my @header = map +{ + column_title => $header_title{$_}, + column => $_, + }, @header_sort; - my @header = - map(+{ "column_title" => $header_title{$_}, - "column" => $_, - }, - @header_sort); $form->{formel} = $formel; - $form->{"title"} = $locale->text("Please enter values"); + $form->{title} = $locale->text("Please enter values"); $form->header(); - print($form->parse_html_template("generic/calculate_qty", { "HEADER" => \@header, + print $form->parse_html_template("generic/calculate_qty", { "HEADER" => \@header, "VARIABLES" => \@variable, - "onload" => $onload })); + "onload" => $onload }); $lxdebug->leave_sub(); } @@ -354,6 +351,14 @@ sub format_dates { $dateformat = $myconfig{"dateformat"} unless ($dateformat); foreach my $idx (@indices) { + if ($form->{TEMPLATE_ARRAYS} && (ref($form->{TEMPLATE_ARRAYS}->{$idx}) eq "ARRAY")) { + for (my $i = 0; $i < scalar(@{$form->{TEMPLATE_ARRAYS}->{$idx}}); $i++) { + $form->{TEMPLATE_ARRAYS}->{$idx}->[$i] = + $locale->reformat_date(\%myconfig, $form->{TEMPLATE_ARRAYS}->{$idx}->[$i], + $dateformat, $longformat); + } + } + next unless (defined($form->{$idx})); if (!ref($form->{$idx})) { @@ -381,6 +386,12 @@ sub reformat_numbers { if (!$numberformat || ($numberformat eq $myconfig{"numberformat"})); foreach my $idx (@indices) { + if ($form->{TEMPLATE_ARRAYS} && (ref($form->{TEMPLATE_ARRAYS}->{$idx}) eq "ARRAY")) { + for (my $i = 0; $i < scalar(@{$form->{TEMPLATE_ARRAYS}->{$idx}}); $i++) { + $form->{TEMPLATE_ARRAYS}->{$idx}->[$i] = $form->parse_amount(\%myconfig, $form->{TEMPLATE_ARRAYS}->{$idx}->[$i]); + } + } + next unless (defined($form->{$idx})); if (!ref($form->{$idx})) { @@ -398,6 +409,12 @@ sub reformat_numbers { $myconfig{"numberformat"} = $numberformat; foreach my $idx (@indices) { + if ($form->{TEMPLATE_ARRAYS} && (ref($form->{TEMPLATE_ARRAYS}->{$idx}) eq "ARRAY")) { + for (my $i = 0; $i < scalar(@{$form->{TEMPLATE_ARRAYS}->{$idx}}); $i++) { + $form->{TEMPLATE_ARRAYS}->{$idx}->[$i] = $form->format_amount(\%myconfig, $form->{TEMPLATE_ARRAYS}->{$idx}->[$i], $places); + } + } + next unless (defined($form->{$idx})); if (!ref($form->{$idx})) { @@ -575,7 +592,7 @@ sub cov_selection_internal { $cov->{address} =~ s{^,}{}x; $cov->{address} =~ s{\ +}{\ }gx; - $cov->{contact} = join " ", map { $cov->{$_} } qw(cp_greeting cp_title cp_givenname cp_name); + $cov->{contact} = join " ", map { $cov->{$_} } qw(cp_gender cp_title cp_givenname cp_name); $cov->{contact} =~ s{\ +}{\ }gx; }