Locales Quoting war fehlerhaft.
[kivitendo-erp.git] / SL / Form.pm
index d4c1fdf..a6b21e2 100644 (file)
@@ -57,7 +57,7 @@ use List::Util qw(first max min sum);
 
 my $standard_dbh;
 
-sub DESTROY {
+END {
   if ($standard_dbh) {
     $standard_dbh->disconnect();
     undef $standard_dbh;
@@ -222,7 +222,7 @@ sub new {
   $self->{action}  =  lc $self->{action};
   $self->{action}  =~ s/( |-|,|\#)/_/g;
 
-  $self->{version} =  "2.4.3";
+  $self->{version} =  "2.6.0 beta 1";
 
   $main::lxdebug->leave_sub();
 
@@ -617,15 +617,15 @@ sub header {
 
   <meta name="robots" content="noindex,nofollow" />
   <script type="text/javascript" src="js/highlight_input.js"></script>
-  <link rel="stylesheet" type="text/css" href="css/tabcontent.css" />
 
+  <link rel="stylesheet" type="text/css" href="css/tabcontent.css" />
   <script type="text/javascript" src="js/tabcontent.js">
 
   /***********************************************
-  * Tab Content script- Dynamic Drive DHTML code library (www.dynamicdrive.com)
-  * This notice MUST stay intact for legal use
-  * Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
-  ***********************************************/
+   * Tab Content script v2.2- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
+   * This notice MUST stay intact for legal use
+   * Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
+   ***********************************************/
 
   </script>
 
@@ -771,6 +771,8 @@ sub parse_html_template {
 }
 
 sub show_generic_error {
+  $main::lxdebug->enter_sub();
+
   my ($self, $error, %params) = @_;
 
   my $add_params = {
@@ -797,10 +799,14 @@ sub show_generic_error {
   $self->header();
   print $self->parse_html_template("generic/error", $add_params);
 
+  $main::lxdebug->leave_sub();
+
   die("Error: $error\n");
 }
 
 sub show_generic_information {
+  $main::lxdebug->enter_sub();
+
   my ($self, $text, $title) = @_;
 
   my $add_params = {
@@ -813,6 +819,8 @@ sub show_generic_information {
   $self->header();
   print $self->parse_html_template("generic/information", $add_params);
 
+  $main::lxdebug->leave_sub();
+
   die("Information: $error\n");
 }
 
@@ -1107,13 +1115,11 @@ sub parse_template {
   # Copy the notes from the invoice/sales order etc. back to the variable "notes" because that is where most templates expect it to be.
   $self->{"notes"} = $self->{ $self->{"formname"} . "notes" };
 
-  map({ $self->{"employee_${_}"} = $myconfig->{$_}; }
-      qw(email tel fax name signature company address businessnumber
-         co_ustid taxnumber duns));
+  if (!$self->{employee_id}) {
+    map { $self->{"employee_${_}"} = $myconfig->{$_}; } qw(email tel fax name signature company address businessnumber co_ustid taxnumber duns);
+  }
 
-  map({ $self->{"${_}"} = $myconfig->{$_}; }
-      qw(co_ustid));
-              
+  map { $self->{"${_}"} = $myconfig->{$_}; } qw(co_ustid);
 
   $self->{copies} = 1 if (($self->{copies} *= 1) <= 0);
 
@@ -1308,14 +1314,19 @@ sub generate_attachment_filename {
   my $attachment_filename = $main::locale->unquote_special_chars('HTML', $self->get_formname_translation());
   my $prefix              = $self->get_number_prefix_for_type();
 
-  if ($attachment_filename && $self->{"${prefix}number"}) {
+  if ($self->{preview} && (first { $self->{type} eq $_ } qw(invoice credit_note))) {
+    $attachment_filename .= ' (' . $main::locale->text('Preview') . ')' . $self->get_extension_for_format();
+
+  } elsif ($attachment_filename && $self->{"${prefix}number"}) {
     $attachment_filename .=  "_" . $self->{"${prefix}number"} . $self->get_extension_for_format();
-    $attachment_filename  =  $main::locale->quote_special_chars('filenames', $attachment_filename);
-    $attachment_filename  =~ s|[\s/\\]+|_|g;
+
   } else {
     $attachment_filename = "";
   }
 
+  $attachment_filename =  $main::locale->quote_special_chars('filenames', $attachment_filename);
+  $attachment_filename =~ s|[\s/\\]+|_|g;
+
   return $attachment_filename;
 }
 
@@ -1883,22 +1894,31 @@ sub get_employee {
   $main::lxdebug->leave_sub();
 }
 
-sub get_salesman {
+sub get_employee_data {
   $main::lxdebug->enter_sub();
 
-  my ($self, $myconfig, $salesman_id) = @_;
+  my $self     = shift;
+  my %params   = @_;
+
+  Common::check_params(\%params, qw(prefix));
+  Common::check_params_x(\%params, qw(id));
+
+  if (!$params{id}) {
+    $main::lxdebug->leave_sub();
+    return;
+  }
 
-  $main::lxdebug->leave_sub() and return unless $salesman_id;
+  my $myconfig = \%main::myconfig;
+  my $dbh      = $params{dbh} || $self->get_standard_dbh($myconfig);
 
-  my $dbh     = $self->get_standard_dbh($myconfig);
-  my ($login) = selectrow_query($self, $dbh, qq|SELECT login FROM employee WHERE id = ?|, $salesman_id);
+  my ($login)  = selectrow_query($self, $dbh, qq|SELECT login FROM employee WHERE id = ?|, conv_i($params{id}));
 
   if ($login) {
     my $user = User->new($login);
-    map { $self->{"salesman_$_"} = $user->{$_}; } qw(address businessnumber co_ustid company duns email fax name signature taxnumber tel);
+    map { $self->{$params{prefix} . "_${_}"} = $user->{$_}; } qw(address businessnumber co_ustid company duns email fax name signature taxnumber tel);
 
-    $self->{salesman_login}   = $login;
-    $self->{salesman_name}  ||= $login;
+    $self->{$params{prefix} . '_login'}   = $login;
+    $self->{$params{prefix} . '_name'}  ||= $login;
   }
 
   $main::lxdebug->leave_sub();