Merge branch 'master' of lx-office.linet-services.de:lx-office-erp
authorMoritz Bunkus <m.bunkus@linet-services.de>
Thu, 13 Jan 2011 14:17:16 +0000 (15:17 +0100)
committerMoritz Bunkus <m.bunkus@linet-services.de>
Thu, 13 Jan 2011 14:17:16 +0000 (15:17 +0100)
SL/CVar.pm
SL/Dispatcher.pm
SL/Helper/DateTime.pm [new file with mode: 0644]
SL/IC.pm
SL/Locale.pm
scripts/console
templates/webpages/ic/assembly_row.html

index 8c4f6a8..0de9a4b 100644 (file)
@@ -30,6 +30,7 @@ sub get_configs {
     FROM custom_variable_configs $where ORDER BY sortkey
 SQL
 
+  $::form->{CVAR_CONFIGS} = {} unless 'HASH' eq ref $::form->{CVAR_CONFIGS};
   if (!$::form->{CVAR_CONFIGS}->{$params{module}}) {
     my $configs  = selectall_hashref_query($form, $dbh, $query, @values);
 
index 4a3f131..da7ffef 100644 (file)
@@ -9,11 +9,13 @@ BEGIN {
 }
 
 use CGI qw( -no_xhtml);
+use DateTime;
 use English qw(-no_match_vars);
 use SL::Auth;
 use SL::LXDebug;
 use SL::Locale;
 use SL::Common;
+use SL::Helper::DateTime;
 use Form;
 use List::Util qw(first);
 use File::Basename;
diff --git a/SL/Helper/DateTime.pm b/SL/Helper/DateTime.pm
new file mode 100644 (file)
index 0000000..fa035eb
--- /dev/null
@@ -0,0 +1,57 @@
+package DateTime;
+
+sub now_local {
+  return shift->now(time_zone => $::locale->get_local_time_zone);
+}
+
+sub today_local {
+  return shift->now(time_zone => $::locale->get_local_time_zone)->truncate(to => 'day');
+}
+
+sub to_lxoffice {
+  return $::locale->format_date(\%::myconfig, $_[0]);
+}
+
+sub from_lxoffice {
+  return $::locale->parse_date_to_object(\%::myconfig, $_[1]);
+}
+
+1;
+
+__END__
+
+=encoding utf8
+
+=head1 NAME
+
+SL::Helpers::DateTime - helper functions for L<DateTime>
+
+=head1 FUNCTIONS
+
+=over 4
+
+=item C<now_local>
+
+Returns the current time with the time zone set to the local time zone.
+
+=item C<today_local>
+
+Returns the current date with the time zone set to the local time zone.
+
+=item C<to_lxoffice>
+
+Formats the date according to the current Lx-Office user's date
+format.
+
+=item C<from_lxoffice>
+
+Parses a date string formatted in the current Lx-Office user's date
+format and returns an instance of L<DateTime>.
+
+=back
+
+=head1 AUTHOR
+
+Moritz Bunkus E<lt>m.bunkus@linet-services.deE<gt>
+
+=cut
index f3f887d..ac3d6f2 100644 (file)
--- a/SL/IC.pm
+++ b/SL/IC.pm
@@ -1535,7 +1535,7 @@ sub retrieve_accounts {
   }
 
   if ($transdate eq "") {
-    $transdate = "current_date";
+    $transdate = DateTime->today_local->to_lxoffice;
   } else {
     $transdate = $dbh->quote($transdate);
   }
index e996739..c45a1a1 100644 (file)
@@ -497,4 +497,10 @@ sub restore_numberformat {
   $myconfig->{numberformat} = $self->{saved_numberformat} if $self->{saved_numberformat};
 }
 
+sub get_local_time_zone {
+  my $self = shift;
+  $self->{local_time_zone} ||= DateTime::TimeZone->new(name => 'local');
+  return $self->{local_time_zone};
+}
+
 1;
index e3129a0..42c193a 100755 (executable)
@@ -39,8 +39,10 @@ package Devel::REPL;
 
 use utf8;
 use CGI qw( -no_xhtml);
+use DateTime;
 use SL::Auth;
 use SL::Form;
+use SL::Helper::DateTime;
 use SL::Locale;
 use SL::LXDebug;
 use Data::Dumper;
index c7f8d83..02a7804 100644 (file)
@@ -1,5 +1,6 @@
 [%- USE T8 %]
 [%- USE LxERP %]
+[%- USE HTML %]
   <tr class=listheading>
    <th class=listheading>[% 'Individual Items' | $T8 %]</th>
   </tr>
@@ -19,7 +20,7 @@
       <td[% ' align=' _ rcol.align IF rcol.align %]>[%- rcol.data %]</td>
  [%- END %]
  [%- FOREACH hidden = row.hiddens %]
-      <input type=hidden name="[% hidden.name %]" value="[% hidden.value %]">
+      <input type=hidden name="[% HTML.escape(hidden.name) %]" value="[% HTML.escape(hidden.value) %]">
  [%- END %]
      </tr>
 [%- END %]