Merge branch 'master' of git@vc.linet-services.de:public/lx-office-erp
authorG. Richardson <information@lx-office-hosting.de>
Fri, 4 Nov 2011 12:40:51 +0000 (13:40 +0100)
committerG. Richardson <information@lx-office-hosting.de>
Fri, 4 Nov 2011 12:40:51 +0000 (13:40 +0100)
SL/Controller/CsvImport.pm
SL/DB/Helper/CustomVariables.pm
SL/Template/Simple.pm
bin/mozilla/io.pl
doc/dokumentenvorlagen-und-variablen.html
templates/webpages/csv_import/_errors.html
templates/webpages/io/select_item.html

index c30634b..9cca6cd 100644 (file)
@@ -168,6 +168,8 @@ sub test_and_import {
 
   my $worker = $self->create_worker($file);
   $worker->run;
+
+  $self->num_imported(0);
   $worker->save_objects if !$params{test};
 
   $self->num_importable(scalar grep { !$_ } map { scalar @{ $_->{errors} } } @{ $self->data || [] });
index 2519c36..ef6a0a9 100644 (file)
@@ -44,7 +44,7 @@ sub make_cvar_accessor {
   my ($caller_package, %params) = @_;
 
   my @module_filter = $params{module} ?
-    ("config.module" => $params{module}) :
+    ("config_id" => [ \"(SELECT custom_variable_configs.id FROM custom_variable_configs WHERE custom_variable_configs.module = '$params{module}')" ]) :
     ();
 
   $caller_package->meta->add_relationships(
@@ -52,7 +52,6 @@ sub make_cvar_accessor {
       type         => 'one to many',
       class        => 'SL::DB::CustomVariable',
       column_map   => { ($params{id} || 'id') => 'trans_id' },
-      manager_args => { with_objects => 'config' },
       query_args   => [ sub_module => $params{sub_module}, @module_filter ],
     }
   );
index 9960908..d29ec8f 100644 (file)
@@ -125,10 +125,12 @@ sub substitute_vars {
 
   while ($text =~ /$self->{substitute_vars_re}/) {
     my ($tag_pos, $tag_len) = ($-[0], $+[0] - $-[0]);
-    my ($var, @options)     = split(/\s+/, $1);
+    my ($var, @option_list) = split(/\s+/, $1);
+    my %options             = map { ($_ => 1) } @option_list;
 
     my $value               = $self->_get_loop_variable($var, 0, @indices);
-    $value                  = $self->format_string($value) unless (grep(/^NOESCAPE$/, @options));
+    $value                  = $form->parse_amount({ numberformat => $::myconfig{output_numberformat} || $::myconfig{numberformat} }, $value) if     $options{NOFORMAT};
+    $value                  = $self->format_string($value)                                                                                   unless $options{NOESCAPE};
 
     substr($text, $tag_pos, $tag_len, $value);
   }
index 2d23c76..c569ef8 100644 (file)
@@ -1341,6 +1341,10 @@ sub print_form {
     $output_longdates = 1;
   }
 
+  # Store the output number format so that the template modules know
+  # how to parse the amounts back if requested.
+  $myconfig{output_numberformat} = $output_numberformat || $myconfig{numberformat};
+
   ($form->{employee}) = split /--/, $form->{employee};
 
   # create the form variables
index c9a7ebb..91e245d 100644 (file)
@@ -48,6 +48,9 @@ td {
   <li><a href="dokumentenvorlagen-und-variablen.html#zuordnung_dateinamen">
     Zuordnung von Dateinamen zu den Funktionen</a></li>
 
+  <li><a href="#variablen_ausgeben">Variablen ausgeben</a>
+  </li>
+
   <li><a href="dokumentenvorlagen-und-variablen.html#tag_style">
     Anfang und Ende der Tags ver&auml;ndern</a></li>
 
@@ -192,6 +195,43 @@ td {
    zum Inhaltsverzeichnis</a></small><br>
  <hr>
 
+ <h2><a name="variablen_ausgeben">Variablen ausgeben</a></h2>
+
+ <p>Um eine Variable auszugeben, müssen sie einfach nur zwischen die
+  Tags geschrieben werden, also
+  z.B. <code>&lt;%variablenname%&gt;</code>.</p>
+
+ <p>
+  Optional kann man auch mit Leerzeichen getrennte Flags angeben, die
+  man aber nur selten brauchen wird. Die Syntax sieht also so
+  aus: <code>&lt;%variablenname FLAG1 FLAG2%&gt;</code>. Momentan werden
+  die folgenden Flags unterstützt:
+ </p>
+
+ <ul>
+  <li>
+   <code>NOFORMAT</code> gilt nur für Zahlenwerte und gibt den Wert
+   ohne Formatierung, also ohne Tausendertrennzeichen mit mit einem
+   Punkt als Dezimaltrennzeichen aus. Nützlich z.B., wenn damit in der
+   Vorlage z.B. von LaTeX gerechnet werden soll.
+  </li>
+
+  <li>
+   <code>NOESCAPE</code> unterdrückt das Escapen von Sonderzeichen für
+   die Vorlagensprache. Wenn also in einer Variablen bereits gültiger
+   LaTeX-Code steht und dieser von LaTeX auch ausgewertet und nicht
+   wortwörtlich angezeigt werden soll, so ist dieses Flag sinnvoll.
+  </li>
+ </ul>
+
+ <p>
+  Beispiel: <code class="blue">&lt;%quototal NOFORMAT%&gt;</code>
+ </p>
+
+ <small><a href="dokumentenvorlagen-und-variablen.html#inhaltsverzeichnis">
+   zum Inhaltsverzeichnis</a></small><br>
+ <hr>
+
  <h2><a name="tag_style">
    Anfang und Ende der Tags ver&auml;ndern</a></h2>
 
index e96ac50..1a7d661 100644 (file)
@@ -11,7 +11,7 @@
   <th>[%- LxERP.t8('Error') %]</th>
  </tr>
  [% FOREACH err = SELF.errors %]
-  <tr>
+  <tr class="listrow[% loop.count % 2 %]">
    <td>[% err.4 %]:[% err.3 %]</td>
    <td>[% err.0 %]</td>
    <td>[% err.2 %]</td>
index 2e3c91d..f57ef77 100644 (file)
     <td><input name="select_item_id" class="radio" type="radio" value="[% HTML.escape(item.id) %]"[% IF loop.first %] checked[% END %]></td>
     <td>[% HTML.escape(item.partnumber) %]</td>
     <td>[% HTML.escape(item.description) %]</td>
+    <td align="right">[% LxERP.format_amount(item.display_sellprice, 2) %]</td>
     [%- IF IS_PURCHASE %]
      <td align="right">[% LxERP.format_amount(item.rop, '') %]</td>
     [%- END %]
-    <td align="right">[% LxERP.format_amount(item.display_sellprice, 2) %]</td>
     <td align="right">[% LxERP.format_amount(item.onhand, '') %]</td>
     <td>[% HTML.escape(item.unit) %]</td>
    </tr>