X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;ds=sidebyside;f=SL%2FForm.pm;h=ff7d0efa045962c838ab8167cebfafb429e3e225;hb=b2448c147778ca345decb911aee36f13eca610ae;hp=050614d5622879178350d3aae21cc04eecc4c2bf;hpb=eda8d185d9230b47f2795978c68bdc55a8bea438;p=kivitendo-erp.git
diff --git a/SL/Form.pm b/SL/Form.pm
index 050614d56..ff7d0efa0 100644
--- a/SL/Form.pm
+++ b/SL/Form.pm
@@ -501,12 +501,13 @@ sub header {
push @header, "";
}
- push @header, map { qq|| } $self->use_stylesheet;
+ push @header, map { qq|| } $self->use_stylesheet;
push @header, "" if $self->{landscape};
push @header, "" if -f $self->{favicon};
push @header, map { qq|| }
qw(jquery common jscalendar/calendar jscalendar/lang/calendar-de jscalendar/calendar-setup part_selection jquery-ui jqModal switchmenuframe);
+ push @header, $self->{javascript} if $self->{javascript};
push @header, map { qq|| }
qw(main menu tabcontent list_accounts jquery.autocomplete jquery.multiselect2side frame_header/header ui-lightness/jquery-ui-1.8.12.custom);
push @header, map { qq|| }
@@ -594,7 +595,7 @@ sub set_standard_title {
$::lxdebug->enter_sub;
my $self = shift;
- $self->{titlebar} = "Lx-Office " . $::locale->text('Version') . " $self->{version}";
+ $self->{titlebar} = "kivitendo " . $::locale->text('Version') . " $self->{version}";
$self->{titlebar} .= "- $::myconfig{name}" if $::myconfig{name};
$self->{titlebar} .= "- $::myconfig{dbname}" if $::myconfig{name};
@@ -694,6 +695,8 @@ sub init_template {
return $self->template if $self->template;
+ # Force scripts/locales.pl to pick up the exception handling template.
+ # parse_html_template('generic/exception')
return $self->template(Template->new({
'INTERPOLATE' => 0,
'EVAL_PERL' => 0,
@@ -703,6 +706,7 @@ sub init_template {
'INCLUDE_PATH' => '.:templates/webpages',
'COMPILE_EXT' => '.tcc',
'COMPILE_DIR' => $::lx_office_conf{paths}->{userspath} . '/templates-cache',
+ 'ERROR' => 'templates/webpages/generic/exception.html',
})) || die;
}
@@ -787,10 +791,8 @@ sub write_trigger {
# default
my %dateformats = (
"dd.mm.yy" => "%d.%m.%Y",
- "dd-mm-yy" => "%d-%m-%Y",
"dd/mm/yy" => "%d/%m/%Y",
"mm/dd/yy" => "%m/%d/%Y",
- "mm-dd-yy" => "%m-%d-%Y",
"yyyy-mm-dd" => "%Y-%m-%d",
);
@@ -864,39 +866,30 @@ sub format_amount {
$main::lxdebug->enter_sub(2);
my ($self, $myconfig, $amount, $places, $dash) = @_;
- $dash ||= '';
+ $amount ||= 0;
+ $dash ||= '';
+ my $neg = $amount < 0;
+ my $force_places = defined $places && $places >= 0;
- if ($amount eq "") {
- $amount = 0;
- }
-
- # Hey watch out! The amount can be an exponential term like 1.13686837721616e-13
+ $amount = $self->round_amount($amount, abs $places) if $force_places;
+ $amount = sprintf "%.*f", ($force_places ? $places : 10), abs $amount; # 6 is default for %fa
- my $neg = ($amount =~ s/^-//);
- my $exp = ($amount =~ m/[e]/) ? 1 : 0;
+ # before the sprintf amount was a number, afterwards it's a string. because of the dynamic nature of perl
+ # this is easy to confuse, so keep in mind: before this comment no s///, m//, concat or other strong ops on
+ # $amount. after this comment no +,-,*,/,abs. it will only introduce subtle bugs.
- if (defined($places) && ($places ne '')) {
- if (not $exp) {
- if ($places < 0) {
- $amount *= 1;
- $places *= -1;
-
- if ($amount =~ /\.(\d+)/) {
- my $actual_places = length $1;
- $places = $actual_places if $actual_places > $places;
- }
- }
- }
- $amount = $self->round_amount($amount, $places);
- }
+ $amount =~ s/0*$//; # cull trailing 0s
my @d = map { s/\d//g; reverse split // } my $tmp = $myconfig->{numberformat}; # get delim chars
- my @p = split(/\./, $amount); # split amount at decimal point
-
- $p[0] =~ s/\B(?=(...)*$)/$d[1]/g if $d[1]; # add 1,000 delimiters
+ my @p = split(/\./, $amount); # split amount at decimal point
+ $p[0] =~ s/\B(?=(...)*$)/$d[1]/g if $d[1]; # add 1,000 delimiters
$amount = $p[0];
- $amount .= $d[0].($p[1]||'').(0 x ($places - length ($p[1]||''))) if ($places || $p[1] ne '');
+ if ($places || $p[1]) {
+ $amount .= $d[0]
+ . ( $p[1] || '' )
+ . (0 x (abs($places || 0) - length ($p[1]||''))); # pad the fraction
+ }
$amount = do {
($dash =~ /-/) ? ($neg ? "($amount)" : "$amount" ) :
@@ -904,7 +897,6 @@ sub format_amount {
($neg ? "-$amount" : "$amount" ) ;
};
-
$main::lxdebug->leave_sub(2);
return $amount;
}
@@ -1113,10 +1105,10 @@ sub parse_template {
$suffix = $self->{IN};
$suffix =~ s/.*\.//;
($temp_fh, $self->{tmpfile}) = File::Temp::tempfile(
- 'lx-office-printXXXXXX',
+ 'kivitendo-printXXXXXX',
SUFFIX => '.' . ($suffix || 'tex'),
DIR => $userspath,
- UNLINK => 1,
+ UNLINK => ($::lx_office_conf{debug} && $::lx_office_conf{debug}->{keep_temp_files})? 0 : 1,
);
close $temp_fh;
@@ -1994,8 +1986,17 @@ sub get_duedate {
$reference_date = $reference_date ? conv_dateq($reference_date) . '::DATE' : 'current_date';
my $dbh = $self->get_standard_dbh($myconfig);
+ my $payment_id;
+
+ if($self->{payment_id}) {
+ $payment_id = $self->{payment_id};
+ } elsif($self->{vendor_id}) {
+ my $query = 'SELECT payment_id FROM vendor WHERE id = ?';
+ ($payment_id) = selectrow_query($self, $dbh, $query, $self->{vendor_id});
+ }
+
my $query = qq|SELECT ${reference_date} + terms_netto FROM payment_terms WHERE id = ?|;
- my ($duedate) = selectrow_query($self, $dbh, $query, $self->{payment_id});
+ my ($duedate) = selectrow_query($self, $dbh, $query, $payment_id);
$main::lxdebug->leave_sub();
@@ -2566,7 +2567,8 @@ sub all_vc {
# setup sales contacts
$query = qq|SELECT e.id, e.name
FROM employee e
- WHERE (e.sales = '1') AND (NOT e.id = ?)|;
+ WHERE (e.sales = '1') AND (NOT e.id = ?)
+ ORDER BY name|;
$self->{all_employees} = selectall_hashref_query($self, $dbh, $query, $self->{employee_id});
# this is for self
@@ -2574,11 +2576,6 @@ sub all_vc {
{ id => $self->{employee_id},
name => $self->{employee} });
- # sort the whole thing
- @{ $self->{all_employees} } =
- sort { $a->{name} cmp $b->{name} } @{ $self->{all_employees} };
-
-
# prepare query for departments
$query = qq|SELECT id, description
FROM department