X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;ds=sidebyside;f=SL%2FForm.pm;h=4bea5f094d4dc51386abb29df1940b52289e6e98;hb=ddc3bbb167d3010b0058efa8f90936d15be76c2e;hp=5abc672c040dba3b87482ad706cc2e2bb3910683;hpb=9f055edb25f912aa2cb3dfd8e8a4cf20703f75a2;p=kivitendo-erp.git diff --git a/SL/Form.pm b/SL/Form.pm index 5abc672c0..4bea5f094 100644 --- a/SL/Form.pm +++ b/SL/Form.pm @@ -146,7 +146,7 @@ sub new { $self->{action} = lc $self->{action}; $self->{action} =~ s/( |-|,|\#)/_/g; - $self->{version} = "2.4-RC2"; + $self->{version} = "2.4.0"; $main::lxdebug->leave_sub(); @@ -349,7 +349,7 @@ sub isblank { sub header { $main::lxdebug->enter_sub(); - my ($self) = @_; + my ($self, $extra_code) = @_; if ($self->{header}) { $main::lxdebug->leave_sub(); @@ -366,6 +366,8 @@ sub header { |; } + $self->{favicon} = "favicon.ico" unless $self->{favicon}; + if ($self->{favicon} && (-f "$self->{favicon}")) { $favicon = qq| @@ -437,6 +439,7 @@ function fokus(){document.$self->{fokus}.focus();} + $extra_code |; @@ -773,7 +776,10 @@ sub parse_template { $self->{"notes"} = $self->{ $self->{"formname"} . "notes" }; map({ $self->{"employee_${_}"} = $myconfig->{$_}; } - qw(email tel fax name signature company address businessnumber)); + qw(email tel fax name signature company address businessnumber + co_ustid taxnumber duns)); + map({ $self->{"employee_${_}"} =~ s/\\n/\n/g; } + qw(company address signature)); $self->{copies} = 1 if (($self->{copies} *= 1) <= 0); @@ -799,9 +805,6 @@ sub parse_template { } close(OUT); - - use Data::Dumper; - #print(STDERR Dumper($self)); if ($template->uses_temp_file() || $self->{media} eq 'email') { @@ -836,7 +839,7 @@ sub parse_template { } else { - @{ $mail->{attachments} } = ($self->{tmpfile}) unless ($form->{do_not_attach}); + @{ $mail->{attachments} } = ($self->{tmpfile}) unless ($self->{do_not_attach}); $mail->{message} =~ s/\r\n/\n/g; $myconfig->{signature} =~ s/\\n/\n/g; @@ -1146,6 +1149,13 @@ sub set_payment_options { $self->{payment_terms} =~ s/<%netto_date%>/$self->{netto_date}/g; $self->{payment_terms} =~ s/<%skonto_date%>/$self->{skonto_date}/g; $self->{payment_terms} =~ s/<%skonto_amount%>/$self->{skonto_amount}/g; + $self->{payment_terms} =~ s/<%total%>/$self->{total}/g; + $self->{payment_terms} =~ s/<%invtotal%>/$self->{invtotal}/g; + $self->{payment_terms} =~ s/<%currency%>/$self->{currency}/g; + $self->{payment_terms} =~ s/<%terms_netto%>/$self->{terms_netto}/g; + $self->{payment_terms} =~ s/<%account_number%>/$self->{account_number}/g; + $self->{payment_terms} =~ s/<%bank%>/$self->{bank}/g; + $self->{payment_terms} =~ s/<%bank_code%>/$self->{bank_code}/g; $dbh->disconnect; } @@ -1252,7 +1262,7 @@ sub get_shipto { my $sth = $dbh->prepare($query); $sth->execute || $self->dberror($query); $ref = $sth->fetchrow_hashref(NAME_lc); - map { $form->{$_} = $ref->{$_} } keys %$ref; + map { $self->{$_} = $ref->{$_} } keys %$ref; $sth->finish; $dbh->disconnect; } @@ -1326,6 +1336,24 @@ sub get_employee { $main::lxdebug->leave_sub(); } +sub get_duedate { + $main::lxdebug->enter_sub(); + + my ($self, $myconfig) = @_; + + my $dbh = $self->dbconnect($myconfig); + my $query = qq|SELECT current_date+terms_netto FROM payment_terms + WHERE id = '$self->{payment_id}'|; + my $sth = $dbh->prepare($query); + $sth->execute || $self->dberror($query); + + ($self->{duedate}) = $sth->fetchrow_array; + + $sth->finish; + + $main::lxdebug->leave_sub(); +} + # get other contact for transaction and form - html/tex sub get_contact { $main::lxdebug->enter_sub(); @@ -1507,7 +1535,7 @@ sub all_vc { FROM language ORDER BY 1|; $sth = $dbh->prepare($query); - $sth->execute || $form->dberror($query); + $sth->execute || $self->dberror($query); while ($ref = $sth->fetchrow_hashref(NAME_lc)) { push @{ $self->{languages} }, $ref; @@ -1519,7 +1547,7 @@ sub all_vc { FROM printers ORDER BY 1|; $sth = $dbh->prepare($query); - $sth->execute || $form->dberror($query); + $sth->execute || $self->dberror($query); while ($ref = $sth->fetchrow_hashref(NAME_lc)) { push @{ $self->{printers} }, $ref; @@ -1532,7 +1560,7 @@ sub all_vc { FROM payment_terms ORDER BY 1|; $sth = $dbh->prepare($query); - $sth->execute || $form->dberror($query); + $sth->execute || $self->dberror($query); while ($ref = $sth->fetchrow_hashref(NAME_lc)) { push @{ $self->{payment_terms} }, $ref; @@ -1558,7 +1586,7 @@ sub language_payment { FROM language ORDER BY 1|; my $sth = $dbh->prepare($query); - $sth->execute || $form->dberror($query); + $sth->execute || $self->dberror($query); while ($ref = $sth->fetchrow_hashref(NAME_lc)) { push @{ $self->{languages} }, $ref; @@ -1570,7 +1598,7 @@ sub language_payment { FROM printers ORDER BY 1|; $sth = $dbh->prepare($query); - $sth->execute || $form->dberror($query); + $sth->execute || $self->dberror($query); while ($ref = $sth->fetchrow_hashref(NAME_lc)) { push @{ $self->{printers} }, $ref; @@ -1582,7 +1610,7 @@ sub language_payment { FROM payment_terms ORDER BY 1|; $sth = $dbh->prepare($query); - $sth->execute || $form->dberror($query); + $sth->execute || $self->dberror($query); while ($ref = $sth->fetchrow_hashref(NAME_lc)) { push @{ $self->{payment_terms} }, $ref; @@ -1593,7 +1621,7 @@ sub language_payment { $query = qq|SELECT id, description FROM buchungsgruppen|; $sth = $dbh->prepare($query); - $sth->execute || $form->dberror($query); + $sth->execute || $self->dberror($query); $self->{BUCHUNGSGRUPPEN} = []; while (my $ref = $sth->fetchrow_hashref(NAME_lc)) { @@ -1706,7 +1734,7 @@ sub create_links { $query = qq|SELECT id, description FROM tax_zones|; $sth = $dbh->prepare($query); - $sth->execute || $form->dberror($query); + $sth->execute || $self->dberror($query); while (my $ref = $sth->fetchrow_hashref(NAME_lc)) { @@ -2546,4 +2574,33 @@ sub parse_date { return ($yy, $mm, $dd); } +sub reformat_date { + $main::lxdebug->enter_sub(); + + my ($self, $myconfig, $date, $output_format, $longformat) = @_; + + $main::lxdebug->leave_sub() and return "" unless ($date); + + my ($yy, $mm, $dd) = $self->parse_date($myconfig, $date); + + $output_format =~ /d+/; + substr($output_format, $-[0], $+[0] - $-[0]) = + sprintf("%0" . (length($&)) . "d", $dd); + + $output_format =~ /m+/; + substr($output_format, $-[0], $+[0] - $-[0]) = + sprintf("%0" . (length($&)) . "d", $mm); + + $output_format =~ /y+/; + if (length($&) == 2) { + $yy -= $yy >= 2000 ? 2000 : 1900; + } + substr($output_format, $-[0], $+[0] - $-[0]) = + sprintf("%0" . (length($&)) . "d", $yy); + + $main::lxdebug->leave_sub(); + + return $output_format; +} + 1;