Form->header: $extra_code als deprecated kommentiert.
[kivitendo-erp.git] / SL / Form.pm
index b85d374..1668252 100644 (file)
@@ -37,8 +37,6 @@
 
 package Form;
 
-#use strict;
-
 use Data::Dumper;
 
 use CGI;
@@ -59,6 +57,8 @@ use Template;
 use List::Util qw(first max min sum);
 use List::MoreUtils qw(any);
 
+use strict;
+
 my $standard_dbh;
 
 END {
@@ -306,13 +306,15 @@ sub new {
   my $db_charset   = $main::dbcharset;
   $db_charset    ||= Common::DEFAULT_CHARSET;
 
-  if ($self->{INPUT_ENCODING} && (lc $self->{INPUT_ENCODING} ne $db_charset)) {
-    require Text::Iconv;
-    my $iconv = Text::Iconv->new($self->{INPUT_ENCODING}, $db_charset);
+  if ($self->{INPUT_ENCODING}) {
+    if (lc $self->{INPUT_ENCODING} ne lc $db_charset) {
+      require Text::Iconv;
+      my $iconv = Text::Iconv->new($self->{INPUT_ENCODING}, $db_charset);
 
-    _recode_recursively($iconv, $self);
+      _recode_recursively($iconv, $self);
+    }
 
-    delete $self{INPUT_ENCODING};
+    delete $self->{INPUT_ENCODING};
   }
 
   $self->{action}  =  lc $self->{action};
@@ -607,9 +609,10 @@ sub create_http_response {
     my $session_cookie_value   = $main::auth->get_session_id();
     $session_cookie_value    ||= 'NO_SESSION';
 
-    $session_cookie = $cgi->cookie('-name'  => $main::auth->get_session_cookie_name(),
-                                   '-value' => $session_cookie_value,
-                                   '-path'  => $base_path);
+    $session_cookie = $cgi->cookie('-name'   => $main::auth->get_session_cookie_name(),
+                                   '-value'  => $session_cookie_value,
+                                   '-path'   => $base_path,
+                                   '-secure' => $ENV{HTTPS});
   }
 
   my %cgi_params = ('-type' => $params{content_type});
@@ -627,6 +630,8 @@ sub create_http_response {
 sub header {
   $main::lxdebug->enter_sub();
 
+  # extra code ist currently only used by menuv3 and menuv4 to set their css.
+  # it is strongly deprecated, and will be changed in a future version.
   my ($self, $extra_code) = @_;
 
   if ($self->{header}) {
@@ -671,13 +676,22 @@ sub header {
                         </style>|;
     }
 
-    my $fokus = qq|  document.$self->{fokus}.focus();| if ($self->{"fokus"});
+    my $fokus = qq|
+    <script type="text/javascript">
+    <!--
+      function fokus() {
+        document.$self->{fokus}.focus();
+      }
+    //-->
+    </script>
+    | if $self->{"fokus"};
 
     #Set Calendar
     my $jsscript = "";
     if ($self->{jsscript} == 1) {
 
       $jsscript = qq|
+        <script type="text/javascript" src="js/jquery.js"></script>
         <script type="text/javascript" src="js/common.js"></script>
         <style type="text/css">\@import url(js/jscalendar/calendar-win2k-1.css);</style>
         <script type="text/javascript" src="js/jscalendar/calendar.js"></script>
@@ -708,13 +722,7 @@ sub header {
   $jsscript
   $ajax
 
-  <script type="text/javascript">
-  <!--
-    function focus() {
-      $fokus
-    }
-  //-->
-  </script>
+  $fokus
 
   <meta name="robots" content="noindex,nofollow" />
   <script type="text/javascript" src="js/highlight_input.js"></script>
@@ -1355,9 +1363,6 @@ Content-Length: $numbytes
 
         while (<IN>) {
           print OUT $_;
-        open(DUMP_OUT, "> /tmp/lx2.dump" );
-        print(DUMP_OUT Dumper($self));
-        close(DUMP_OUT);
 
         }
 
@@ -1398,6 +1403,7 @@ sub get_formname_translation {
     storno_packing_list     => $main::locale->text('Storno Packing List'),
     sales_delivery_order    => $main::locale->text('Delivery Order'),
     purchase_delivery_order => $main::locale->text('Delivery Order'),
+    dunning                 => $main::locale->text('Dunning'),
   );
 
   $main::lxdebug->leave_sub();
@@ -1584,7 +1590,7 @@ sub get_standard_dbh {
   my ($self, $myconfig) = @_;
 
   if ($standard_dbh && !$standard_dbh->{Active}) {
-    $main::lxdebug->message(LXDebug::INFO, "get_standard_dbh: \$standard_dbh is defined but not Active anymore");
+    $main::lxdebug->message(LXDebug->INFO(), "get_standard_dbh: \$standard_dbh is defined but not Active anymore");
     undef $standard_dbh;
   }
 
@@ -2020,6 +2026,8 @@ sub get_employee {
 
   my ($self, $dbh) = @_;
 
+  $dbh ||= $self->get_standard_dbh(\%main::myconfig);
+
   my $query = qq|SELECT id, name FROM employee WHERE login = ?|;
   ($self->{"employee_id"}, $self->{"employee"}) = selectrow_query($self, $dbh, $query, $self->{login});
   $self->{"employee_id"} *= 1;
@@ -2062,11 +2070,11 @@ sub get_duedate {
 
   my ($self, $myconfig, $reference_date) = @_;
 
-  my $reference_date = $reference_date ? conv_dateq($reference_date) . '::DATE' : 'current_date';
+  $reference_date = $reference_date ? conv_dateq($reference_date) . '::DATE' : 'current_date';
 
-  my $dbh            = $self->get_standard_dbh($myconfig);
-  my $query          = qq|SELECT ${reference_date} + terms_netto FROM payment_terms WHERE id = ?|;
-  my ($duedate)      = selectrow_query($self, $dbh, $query, $self->{payment_id});
+  my $dbh         = $self->get_standard_dbh($myconfig);
+  my $query       = qq|SELECT ${reference_date} + terms_netto FROM payment_terms WHERE id = ?|;
+  my ($duedate)   = selectrow_query($self, $dbh, $query, $self->{payment_id});
 
   $main::lxdebug->leave_sub();
 
@@ -2193,7 +2201,7 @@ sub _get_charts {
   my $transdate = quote_db_date($params->{transdate});
 
   my $query =
-    qq|SELECT c.id, c.accno, c.description, c.link, tk.taxkey_id, tk.tax_id | .
+    qq|SELECT c.id, c.accno, c.description, c.link, c.charttype, tk.taxkey_id, tk.tax_id | .
     qq|FROM chart c | .
     qq|LEFT JOIN taxkeys tk ON | .
     qq|(tk.id = (SELECT id FROM taxkeys | .