Fehler bei Lieferadressen die Anfuehrungszeichen im Namen enthalten
[kivitendo-erp.git] / SL / Form.pm
index 0616e1e..4bea5f0 100644 (file)
@@ -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|<LINK REL="shortcut icon" HREF="$self->{favicon}" TYPE="image/x-icon">
@@ -437,6 +439,7 @@ function fokus(){document.$self->{fokus}.focus();}
   
   </script>
 
+  $extra_code
 </head>
 
 |;
@@ -773,7 +776,8 @@ 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));
 
@@ -835,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;
@@ -1145,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;
   }
@@ -1251,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;
   }
@@ -1325,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();
@@ -1506,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;
@@ -1518,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;
@@ -1531,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;
@@ -1557,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;
@@ -1569,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;
@@ -1581,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;
@@ -1592,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)) {
@@ -1705,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)) {