Bei Einkaufs-/Verkaufsmasken sowie bei Debitoren- und Kreditorenbuchungen wird ein...
[kivitendo-erp.git] / SL / Form.pm
index d59adee..a11122c 100644 (file)
@@ -258,6 +258,8 @@ sub hide_form {
 sub error {
   $main::lxdebug->enter_sub();
 
+  $main::lxdebug->show_backtrace();
+
   my ($self, $msg) = @_;
   if ($ENV{HTTP_USER_AGENT}) {
     $msg =~ s/\n/<br>/g;
@@ -506,7 +508,6 @@ sub parse_html_template {
     $additional_params->{"myconfig_jsc_dateformat"} = $jsc_dateformat;
   }
 
-  $additional_params->{"conf_jscalendar"} = $main::jscalendar;
   $additional_params->{"conf_lizenzen"} = $main::lizenzen;
   $additional_params->{"conf_latex_templates"} = $main::latex;
   $additional_params->{"conf_opendocument_templates"} = $main::opendocument_templates;
@@ -729,7 +730,9 @@ sub parse_template {
   $main::lxdebug->enter_sub();
 
   my ($self, $myconfig, $userspath) = @_;
-  my $template;
+  my ($template, $out);
+
+  local (*IN, *OUT);
 
   $self->{"cwd"} = getcwd();
   $self->{"tmpdir"} = $self->{cwd} . "/${userspath}";
@@ -772,7 +775,19 @@ sub parse_template {
   # OUT is used for the media, screen, printer, email
   # for postscript we store a copy in a temporary file
   my $fileid = time;
-  $self->{tmpfile} ||= "$userspath/${fileid}.$self->{IN}";
+  my $prepend_userspath;
+
+  if (!$self->{tmpfile}) {
+    $self->{tmpfile}   = "${fileid}.$self->{IN}";
+    $prepend_userspath = 1;
+  }
+
+  $prepend_userspath = 1 if substr($self->{tmpfile}, 0, length $userspath) eq $userspath;
+
+  $self->{tmpfile} =~ s|.*/||;
+  $self->{tmpfile} =~ s/[^a-zA-Z0-9\._\ \-]//g;
+  $self->{tmpfile} = "$userspath/$self->{tmpfile}" if $prepend_userspath;
+
   if ($template->uses_temp_file() || $self->{media} eq 'email') {
     $out = $self->{OUT};
     $self->{OUT} = ">$self->{tmpfile}";
@@ -839,7 +854,7 @@ sub parse_template {
 
       }
 
-      my $err = $mail->send($out);
+      my $err = $mail->send();
       $self->error($self->cleanup . "$err") if ($err);
 
     } else {
@@ -860,7 +875,9 @@ sub parse_template {
           open(OUT, $self->{OUT})
             or $self->error($self->cleanup . "$self->{OUT} : $!");
         } else {
-          $self->{attachment_filename} = $self->generate_attachment_filename();
+          $self->{attachment_filename} = ($self->{attachment_filename}) 
+                                       ? $self->{attachment_filename}
+                                       : $self->generate_attachment_filename();
 
           # launch application
           print qq|Content-Type: | . $template->get_mime_type() . qq|
@@ -1644,6 +1661,20 @@ $main::lxdebug->enter_sub();
   $main::lxdebug->leave_sub();
 }
 
+sub _get_payments {
+$main::lxdebug->enter_sub();
+
+  my ($self, $dbh, $key) = @_;
+
+  $key = "all_payments" unless ($key);
+
+  my $query = qq|SELECT * FROM payment_terms ORDER BY id|;
+  $self->{$key} = selectall_hashref_query($self, $dbh, $query);
+
+  $main::lxdebug->leave_sub();
+}
+
 sub _get_customers {
   $main::lxdebug->enter_sub();
 
@@ -1651,7 +1682,7 @@ sub _get_customers {
 
   $key = "all_customers" unless ($key);
 
-  my $query = qq|SELECT * FROM customer LIMIT $main::myconfig{vclimit}|;
+  my $query = qq|SELECT * FROM customer|;
 
   $self->{$key} = selectall_hashref_query($self, $dbh, $query);
 
@@ -1665,7 +1696,7 @@ sub _get_vendors {
 
   $key = "all_vendors" unless ($key);
 
-  my $query = qq|SELECT * FROM vendor|; # LIMIT $main::myconfig{vclimit}|;
+  my $query = qq|SELECT * FROM vendor|;
 
   $self->{$key} = selectall_hashref_query($self, $dbh, $query);
 
@@ -1741,6 +1772,10 @@ sub get_lists {
   if($params{"vendors"}) {
     $self->_get_vendors($dbh, $params{"vendors"});
   }
+  
+  if($params{"payments"}) {
+    $self->_get_payments($dbh, $params{"payments"});
+  }
 
   $dbh->disconnect();