X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FForm.pm;h=d4c1fdf97aec175e8765308355e39a2ab025a020;hb=611a3dd324e413b4653c850546e50a0a7336a8bc;hp=59e01de07e2c8c0149498486e9047c5f13d9b53d;hpb=56ed64675501781efea751581d146d5bc49fad6a;p=kivitendo-erp.git diff --git a/SL/Form.pm b/SL/Form.pm index 59e01de07..d4c1fdf97 100644 --- a/SL/Form.pm +++ b/SL/Form.pm @@ -41,6 +41,7 @@ use Data::Dumper; use CGI; use CGI::Ajax; use Cwd; +use IO::File; use SL::Auth; use SL::Auth::DB; use SL::Auth::LDAP; @@ -470,7 +471,7 @@ sub isblank { my ($self, $name, $msg) = @_; my $curr = $self; - foreach my $part (split /\./, $name) { + foreach my $part (split m/\./, $name) { if (!$curr->{$part} || ($curr->{$part} =~ /^\s*$/)) { $self->error($msg); } @@ -598,11 +599,11 @@ sub header { 'charset' => $db_charset,); print qq|${doctype} + $self->{titlebar} $stylesheet $pagelayout $favicon - $jsscript $ajax @@ -638,6 +639,20 @@ sub header { $main::lxdebug->leave_sub(); } +sub ajax_response_header { + $main::lxdebug->enter_sub(); + + my ($self) = @_; + + my $db_charset = $main::dbcharset ? $main::dbcharset : Common::DEFAULT_CHARSET; + my $cgi = $main::cgi || CGI->new(''); + my $output = $cgi->header('-charset' => $db_charset); + + $main::lxdebug->leave_sub(); + + return $output; +} + sub _prepare_html_template { $main::lxdebug->enter_sub(); @@ -690,6 +705,7 @@ sub _prepare_html_template { $additional_params->{"myconfig_jsc_dateformat"} = $jsc_dateformat; } + $additional_params->{"conf_dbcharset"} = $main::dbcharset; $additional_params->{"conf_webdav"} = $main::webdav; $additional_params->{"conf_lizenzen"} = $main::lizenzen; $additional_params->{"conf_latex_templates"} = $main::latex; @@ -729,13 +745,26 @@ sub parse_html_template { map { $additional_params->{$_} ||= $self->{$_} } keys %{ $self }; + my $in = IO::File->new($file, 'r'); + + if (!$in) { + print STDERR "Error opening template file: $!"; + $main::lxdebug->leave_sub(); + return ''; + } + + my $input = join('', <$in>); + $in->close(); + + if ($main::locale) { + $input = $main::locale->{iconv}->convert($input); + } + my $output; - if (!$template->process($file, $additional_params, \$output)) { + if (!$template->process(\$input, $additional_params, \$output)) { print STDERR $template->error(); } - $output = $main::locale->{iconv}->convert($output) if ($main::locale); - $main::lxdebug->leave_sub(); return $output; @@ -919,16 +948,19 @@ sub format_amount_units { my $self = shift; my %params = @_; - Common::check_params(\%params, qw(amount part_unit)); - my $myconfig = \%main::myconfig; - my $amount = $params{amount}; + my $amount = $params{amount} * 1; my $places = $params{places}; my $part_unit_name = $params{part_unit}; my $amount_unit_name = $params{amount_unit}; my $conv_units = $params{conv_units}; my $max_places = $params{max_places}; + if (!$part_unit_name) { + $main::lxdebug->leave_sub(); + return ''; + } + AM->retrieve_all_units(); my $all_units = $main::all_units; @@ -1858,21 +1890,15 @@ sub get_salesman { $main::lxdebug->leave_sub() and return unless $salesman_id; - my $dbh = $self->get_standard_dbh($myconfig); - - my ($login) = - selectrow_query($self, $dbh, qq|SELECT login FROM employee WHERE id = ?|, - $salesman_id); + my $dbh = $self->get_standard_dbh($myconfig); + my ($login) = selectrow_query($self, $dbh, qq|SELECT login FROM employee WHERE id = ?|, $salesman_id); if ($login) { - my $user = new User($main::memberfile, $login); - map({ $self->{"salesman_$_"} = $user->{$_}; } - qw(address businessnumber co_ustid company duns email fax name - taxnumber tel)); - $self->{salesman_login} = $login; - - $self->{salesman_name} = $login - if ($self->{salesman_name} eq ""); + my $user = User->new($login); + map { $self->{"salesman_$_"} = $user->{$_}; } qw(address businessnumber co_ustid company duns email fax name signature taxnumber tel); + + $self->{salesman_login} = $login; + $self->{salesman_name} ||= $login; } $main::lxdebug->leave_sub();