X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FForm.pm;h=cbfc81f32dc1a8ed3af0d8dbbccb897408ea7f2e;hb=d94a4ac363f77bac26b2b905ff8697118a83b9dc;hp=1faec58a14b2763b406ad9ef4391ed60775a2dd3;hpb=54e4131e091831e00a861fe2c4f53e344b87ddca;p=kivitendo-erp.git diff --git a/SL/Form.pm b/SL/Form.pm index 1faec58a1..cbfc81f32 100644 --- a/SL/Form.pm +++ b/SL/Form.pm @@ -143,12 +143,10 @@ sub new { my %parameters = _request_to_hash($_); map({ $self->{$_} = $parameters{$_}; } keys(%parameters)); - $self->{menubar} = 1 if $self->{path} =~ /lynx/i; - $self->{action} = lc $self->{action}; $self->{action} =~ s/( |-|,|\#)/_/g; - $self->{version} = "2.4.0"; + $self->{version} = "2.3.9"; $main::lxdebug->leave_sub(); @@ -221,6 +219,25 @@ sub unquote { } +sub quote_html { + $main::lxdebug->enter_sub(2); + + my ($self, $str) = @_; + + my %replace = + ('order' => ['"', '<', '>'], + '<' => '<', + '>' => '>', + '"' => '"', + ); + + map({ $str =~ s/$_/$replace{$_}/g; } @{ $replace{"order"} }); + + $main::lxdebug->leave_sub(2); + + return $str; +} + sub hide_form { my $self = shift; @@ -492,22 +509,14 @@ sub parse_html_template { $additional_params->{"conf_latex_templates"} = $main::latex; $additional_params->{"conf_opendocument_templates"} = $main::opendocument_templates; - my $menu; - if (-f $self->{"login"} . "_menu.ini") { - $menu = Menu->new($self->{"login"} . "_menu.ini"); - } else { - $menu = Menu->new("menu.ini"); - } - $menu->generate_acl("", $additional_params); - my @additional_param_names = keys(%{$additional_params}); foreach my $key ($template->param()) { - if (grep(/^${key}$/, @additional_param_names)) { - $template->param($key => $additional_params->{$key}); - } else { - $template->param($key => $self->{$key}); - } + my $param = $self->{$key}; + $param = $additional_params->{$key} if (grep(/^${key}$/, @additional_param_names)); + $param = [] if (($template->query("name" => $key) eq "LOOP") && (ref($param) ne "ARRAY")); + $template->param($key => $param); } + my $output = $template->output(); $main::lxdebug->leave_sub(); @@ -516,12 +525,23 @@ sub parse_html_template { } sub show_generic_error { - my ($self, $error, $title) = @_; + my ($self, $error, $title, $action) = @_; my $add_params = {}; $add_params->{"title"} = $title if ($title); $self->{"label_error"} = $error; + my @vars; + if ($action) { + map({ delete($self->{$_}); } qw(action)); + map({ push(@vars, { "name" => $_, "value" => $self->{$_} }) + if (!ref($self->{$_})); } + keys(%{$self})); + $add_params->{"SHOW_BUTTON"} = 1; + $add_params->{"BUTTON_LABEL"} = $action; + } + $add_params->{"VARIABLES"} = \@vars; + $self->header(); print($self->parse_html_template("generic/error", $add_params)); @@ -629,78 +649,38 @@ sub sort_columns { return @columns; } - +# sub format_amount { $main::lxdebug->enter_sub(2); my ($self, $myconfig, $amount, $places, $dash) = @_; - - #Workaround for $format_amount calls without $places - if (!defined $places) { - (my $dec) = ($amount =~ /\.(\d+)/); - $places = length $dec; + + if ($amount eq "") { + $amount = 0; } + my $neg = ($amount =~ s/-//); - if ($places =~ /\d/) { - $amount = $self->round_amount($amount, $places); - } + $amount = $self->round_amount($amount, $places) if ($places =~ /\d/); - # is the amount negative - my $negative = ($amount < 0); - my $fillup = ""; + my @d = map { s/\d//g; reverse split // } my $tmp = $myconfig->{numberformat}; # get delim chars + my @p = split /\./, $amount ; # split amount at decimal point - if ($amount != 0) { - if ($myconfig->{numberformat} && ($myconfig->{numberformat} ne '1000.00')) - { - my ($whole, $dec) = split /\./, "$amount"; - $whole =~ s/-//; - $amount = join '', reverse split //, $whole; - $fillup = "0" x ($places - length($dec)); + $p[0] =~ s/\B(?=(...)*$)/$d[1]/g if $d[1]; # add 1,000 delimiters - if ($myconfig->{numberformat} eq '1,000.00') { - $amount =~ s/\d{3,}?/$&,/g; - $amount =~ s/,$//; - $amount = join '', reverse split //, $amount; - $amount .= "\.$dec" . $fillup if ($places ne '' && $places * 1 != 0); - } + $amount = $p[0]; + $amount .= $d[0].$p[1].(0 x ($places - length $p[1])) if ($places || $p[1] ne ''); - if ($myconfig->{numberformat} eq '1.000,00') { - $amount =~ s/\d{3,}?/$&./g; - $amount =~ s/\.$//; - $amount = join '', reverse split //, $amount; - $amount .= ",$dec" . $fillup if ($places ne '' && $places * 1 != 0); - } - - if ($myconfig->{numberformat} eq '1000,00') { - $amount = "$whole"; - $amount .= ",$dec" . $fillup if ($places ne '' && $places * 1 != 0); - } - - if ($dash =~ /-/) { - $amount = ($negative) ? "($amount)" : "$amount"; - } elsif ($dash =~ /DRCR/) { - $amount = ($negative) ? "$amount DR" : "$amount CR"; - } else { - $amount = ($negative) ? "-$amount" : "$amount"; - } - } - } else { - if ($dash eq "0" && $places) { - if ($myconfig->{numberformat} eq '1.000,00') { - $amount = "0" . "," . "0" x $places; - } else { - $amount = "0" . "." . "0" x $places; - } - } else { - $amount = ($dash ne "") ? "$dash" : "0"; - } - } + $amount = do { + ($dash =~ /-/) ? ($neg ? "($amount)" : "$amount" ) : + ($dash =~ /DRCR/) ? ($neg ? "$amount DR" : "$amount CR" ) : + ($neg ? "-$amount" : "$amount" ) ; + }; + $main::lxdebug->leave_sub(2); - return $amount; } - +# sub parse_amount { $main::lxdebug->enter_sub(2); @@ -822,6 +802,7 @@ sub parse_template { $mail->{to} = qq|$self->{email}|; $mail->{from} = qq|"$myconfig->{name}" <$myconfig->{email}>|; $mail->{fileid} = "$fileid."; + $myconfig->{signature} =~ s/\\r\\n/\\n/g; # if we send html or plain text inline if (($self->{format} eq 'html') && ($self->{sendmode} eq 'inline')) { @@ -829,7 +810,7 @@ sub parse_template { $mail->{message} =~ s/\r\n/
\n/g; $myconfig->{signature} =~ s/\\n/
\n/g; - $mail->{message} .= "
\n--
\n$myconfig->{signature}\n
"; + $mail->{message} .= "
\n--
\n$myconfig->{signature}\n
"; open(IN, $self->{tmpfile}) or $self->error($self->cleanup . "$self->{tmpfile} : $!"); @@ -843,8 +824,9 @@ sub parse_template { @{ $mail->{attachments} } = ($self->{tmpfile}) unless ($form->{do_not_attach}); - $myconfig->{signature} =~ s/\\n/\r\n/g; - $mail->{message} .= "\r\n--\r\n$myconfig->{signature}"; + $mail->{message} =~ s/\r\n/\n/g; + $myconfig->{signature} =~ s/\\n/\n/g; + $mail->{message} .= "\n-- \n$myconfig->{signature}"; } @@ -1252,7 +1234,7 @@ sub get_shipto { my $query = qq|SELECT s.* FROM shipto s - WHERE s.id = $self->{shipto_id}|; + WHERE s.shipto_id = $self->{shipto_id}|; my $sth = $dbh->prepare($query); $sth->execute || $self->dberror($query); $ref = $sth->fetchrow_hashref(NAME_lc); @@ -1279,7 +1261,6 @@ sub add_shipto { } $self->{"shipto$item"} =~ s/\'/\'\'/g; } - if ($shipto) { if ($self->{shipto_id}) { my $query = qq| UPDATE shipto set @@ -1294,7 +1275,7 @@ sub add_shipto { shiptophone = '$self->{shiptophone}', shiptofax = '$self->{shiptofax}', shiptoemail = '$self->{shiptoemail}' - WHERE id = $self->{shipto_id}|; + WHERE shipto_id = $self->{shipto_id}|; $dbh->do($query) || $self->dberror($query); } else { my $query = @@ -1606,18 +1587,6 @@ sub language_payment { } $sth->finish; - # get adr - $query = qq|SELECT id, adr_description, adr_code - FROM adr|; - $sth = $dbh->prepare($query); - $sth->execute || $form->dberror($query); - - - $self->{ADR} = []; - while (my $ref = $sth->fetchrow_hashref(NAME_lc)) { - push @{ $self->{ADR} }, $ref; - } - $sth->finish; $dbh->disconnect; $main::lxdebug->leave_sub(); } @@ -2355,10 +2324,14 @@ sub new { my ($type, $country, $NLS_file) = @_; my $self = {}; - %self = (); if ($country && -d "locale/$country") { + local *IN; $self->{countrycode} = $country; - eval { require "locale/$country/$NLS_file"; }; + if (open(IN, "locale/$country/$NLS_file")) { + my $code = join("", ); + eval($code); + close(IN); + } } $self->{NLS_file} = $NLS_file; @@ -2378,7 +2351,7 @@ sub new { sub text { my ($self, $text) = @_; - return (exists $self{texts}{$text}) ? $self{texts}{$text} : $text; + return (exists $self->{texts}{$text}) ? $self->{texts}{$text} : $text; } sub findsub { @@ -2386,8 +2359,8 @@ sub findsub { my ($self, $text) = @_; - if (exists $self{subs}{$text}) { - $text = $self{subs}{$text}; + if (exists $self->{subs}{$text}) { + $text = $self->{subs}{$text}; } else { if ($self->{countrycode} && $self->{NLS_file}) { Form->error(