Backtrace anzeigen, wenn ein Fehler in User.pm ausgelöst wird.
[kivitendo-erp.git] / SL / Form.pm
index 77d8307..a10880d 100644 (file)
@@ -258,7 +258,7 @@ sub hide_form {
 sub error {
   $main::lxdebug->enter_sub();
 
-  $main::lxdebug->full_error_call_trace();
+  $main::lxdebug->show_backtrace();
 
   my ($self, $msg) = @_;
   if ($ENV{HTTP_USER_AGENT}) {
@@ -508,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;
@@ -731,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}";
@@ -774,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}";
@@ -841,7 +854,7 @@ sub parse_template {
 
       }
 
-      my $err = $mail->send($out);
+      my $err = $mail->send();
       $self->error($self->cleanup . "$err") if ($err);
 
     } else {
@@ -862,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|
@@ -1504,10 +1519,7 @@ sub _get_shipto {
   $key = "all_shipto" unless ($key);
 
   # get shipping addresses
-  my $query =
-    qq|SELECT shipto_id, shiptoname, shiptodepartment_1 | .
-    qq|FROM shipto | .
-    qq|WHERE trans_id = ?|;
+  my $query = qq|SELECT * FROM shipto WHERE trans_id = ?|;
 
   $self->{$key} = selectall_hashref_query($self, $dbh, $query, $vc_id);
 
@@ -1667,7 +1679,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);
 
@@ -1681,7 +1693,21 @@ 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);
+
+  $main::lxdebug->leave_sub();
+}
+
+sub _get_departments {
+  $main::lxdebug->enter_sub();
+
+  my ($self, $dbh, $key) = @_;
+
+  $key = "all_departments" unless ($key);
+
+  my $query = qq|SELECT * FROM department|;
 
   $self->{$key} = selectall_hashref_query($self, $dbh, $query);
 
@@ -1762,6 +1788,10 @@ sub get_lists {
     $self->_get_payments($dbh, $params{"payments"});
   }
 
+  if($params{"departments"}) {
+    $self->_get_departments($dbh, $params{"departments"});
+  }
+
   $dbh->disconnect();
 
   $main::lxdebug->leave_sub();
@@ -2447,10 +2477,9 @@ sub save_history {
 sub get_history {
   $main::lxdebug->enter_sub();
 
-  my $self = shift();
-  my $dbh = shift();
-  my $trans_id = shift();
-  my $restriction = shift();
+  my ($self, $dbh, $trans_id, $restriction, $order) = @_;
+  my ($orderBy, $desc) = split(/\-\-/, $order);
+  $order = " ORDER BY " . ($order eq "" ? " h.itime " : ($desc == 1 ? $orderBy . " DESC " : $orderBy . " "));
   my @tempArray;
   my $i = 0;
   if ($trans_id ne "") {
@@ -2458,7 +2487,7 @@ sub get_history {
       qq|SELECT h.employee_id, h.itime::timestamp(0) AS itime, h.addition, h.what_done, emp.name, h.snumbers, h.trans_id AS id | .
       qq|FROM history_erp h | .
       qq|LEFT JOIN employee emp ON (emp.id = h.employee_id) | .
-      qq|WHERE trans_id = ? |
+      qq|WHERE trans_id = ? |. $order
       . $restriction;
 
     my $sth = $dbh->prepare($query) || $self->dberror($query);