form_footer 2. Version
authorSven Schöling <s.schoeling@linet-services.de>
Tue, 27 Oct 2009 11:49:23 +0000 (12:49 +0100)
committerSven Schöling <s.schoeling@linet-services.de>
Thu, 29 Oct 2009 14:06:33 +0000 (15:06 +0100)
SL/Template/Plugin/LxERP.pm
bin/mozilla/is.pl
templates/webpages/is/_payments_de.html [new file with mode: 0644]
templates/webpages/is/_payments_master.html
templates/webpages/is/form_footer_de.html
templates/webpages/is/form_footer_master.html

index 66f3268..c26988b 100644 (file)
@@ -23,6 +23,13 @@ sub format_amount {
   return '';
 }
 
+sub round_amount {
+  my ($self, $var, $places, $skip_zero) = @_;
+
+  return $main::form->round_amount($var * 1, $places) unless $skip_zero && $var == 0;
+  return '';
+}
+
 sub format_amount_units {
   my ($self, $amount, $amount_unit, $part_unit) = @_;
 
index a732e4d..5dc3b1a 100644 (file)
@@ -397,73 +397,60 @@ sub form_footer {
   $form->{rows} = ($rows > $introws) ? $rows : $introws;
 
   my ($tax, $subtotal);
-  if (!$form->{taxincluded}) {
+  $form->{taxaccounts_array} = [ split / /, $form->{taxaccounts} ];
 
-    foreach my $item (split / /, $form->{taxaccounts}) {
-      if ($form->{"${item}_base"}) {
+  foreach my $item (@{ $form->{taxaccounts_array} }) {
+    if ($form->{"${item}_base"}) {
+      if ($form->{taxincluded}) {
+        $form->{"${item}_total"} = $form->round_amount( ($form->{"${item}_base"} * $form->{"${item}_rate"}
+                                                                                 / (1 + $form->{"${item}_rate"})), 2);
+        $form->{"${item}_netto"} = $form->round_amount( ($form->{"${item}_base"} - $form->{"${item}_total"}), 2);
+      } else {
         $form->{"${item}_total"} = $form->round_amount( $form->{"${item}_base"} * $form->{"${item}_rate"}, 2);
         $form->{invtotal} += $form->{"${item}_total"};
-        $form->{"${item}_total"} = $form->format_amount(\%myconfig, $form->{"${item}_total"}, 2);
-
-        $tax .= qq|
-             <tr>
-                <th align="right">$form->{"${item}_description"}&nbsp;| . $form->{"${item}_rate"} * 100 .qq|%</th>
-                <td align="right">$form->{"${item}_total"}</td>
-             </tr> |;
       }
     }
-
-#    $form->{invsubtotal} = $form->format_amount(\%myconfig, $form->{invsubtotal}, 2, 0);
-
-    $subtotal = qq|
-             <tr>
-               <th align="right">| . $locale->text('Subtotal') . qq|</th>
-               <td align="right">$form->{invsubtotal}</td>
-             </tr>
-|;
-
-  }
-
-  if ($form->{taxincluded}) {
-    $form->{taxaccounts_array} = [ split / /, $form->{taxaccounts} ];
-    foreach my $item (split / /, $form->{taxaccounts}) {
-      if ($form->{"${item}_base"}) {
-        $form->{"${item}_total"} = $form->round_amount( ($form->{"${item}_base"} * $form->{"${item}_rate"} / (1 + $form->{"${item}_rate"})), 2);
-        $form->{"${item}_netto"} = $form->round_amount( ($form->{"${item}_base"} - $form->{"${item}_total"}), 2);
-        $form->{"${item}_total"} = $form->format_amount(\%myconfig, $form->{"${item}_total"}, 2);
-        $form->{"${item}_netto"} = $form->format_amount(\%myconfig, $form->{"${item}_netto"}, 2);
-
-#        $tax .= qq|
-#            <tr>
-#              <th align="right">Enthaltene $form->{"${item}_description"}&nbsp;|
-#                                  . $form->{"${item}_rate"} * 100 .qq|%</th>
-#              <td align="right">$form->{"${item}_total"}</td>
-#            </tr>
-#            <tr>
-#              <th align="right">Nettobetrag</th>
-#              <td align="right">$form->{"${item}_netto"}</td>
-#            </tr>
-#|;
-      }
-    }
-
   }
 
   $form->{oldinvtotal} = $form->{invtotal};
-#  $form->{invtotal}    = $form->format_amount(\%myconfig, $form->{invtotal}, 2, 0);
 
   # unfortunately locales doesn't support extended syntax
   if ($form->{id}) {
     my $follow_ups = FU->follow_ups('trans_id' => $form->{id});
     if (@{ $follow_ups} ) {
-      $form->{follow_ups_text} = $locale->text("There are #1 unfinished follow-ups of which #2 are due.",
-                                               scalar @{ $follow_ups },
+      $form->{follow_up_text} = $locale->text("There are #1 unfinished follow-ups of which #2 are due.",
+                                               scalar(@{ $follow_ups }),
                                                sum map { $_->{due} * 1 } @{ $follow_ups });
     }
   }
 
 
+# payments
+  my $totalpaid = 0;
+
+  $form->{paidaccounts}++ if ($form->{"paid_$form->{paidaccounts}"});
+  $form->{paid_indices} = [ 1 .. $form->{paidaccounts} ];
+
+  for my $i (1 .. $form->{paidaccounts}) {
+    $form->{"selectAR_paid_$i"} = $form->{selectAR_paid};
+    $form->{"selectAR_paid_$i"} =~ s/option>\Q$form->{"AR_paid_$i"}\E/option selected>$form->{"AR_paid_$i"}/;
+
+    # format amounts
+    $totalpaid += $form->{"paid_$i"};
+    if ($form->{"paid_$i"}) {
+      $form->{"paid_$i"} = $form->format_amount(\%myconfig, $form->{"paid_$i"}, 2);
+    }
+    $form->{"exchangerate_$i"} = $form->format_amount(\%myconfig, $form->{"exchangerate_$i"});
+    $form->{"exchangerate_$i"} ||= "";
+  }
+
+
+  $form->{print_options} = print_options(inline => 1);
+
   print $form->parse_html_template('is/form_footer');
+# print $form->parse_html_template('is/_payments'); # parser
+
+
 
 #  print qq|
 #  <tr>
diff --git a/templates/webpages/is/_payments_de.html b/templates/webpages/is/_payments_de.html
new file mode 100644 (file)
index 0000000..048569f
--- /dev/null
@@ -0,0 +1,85 @@
+[%- USE LxERP %]
+  <tr>
+   <td>
+    <table width="100%">
+     <tr class="listheading">
+[% IF is_credit_note %]
+      <th colspan="6" class="listheading">Zahlungsausgänge</th>
+[% ELSE %]
+      <th colspan="6" class="listheading">Zahlungseingänge</th>
+[%- END %]
+     </tr>
+
+
+     <tr>
+      <th>Datum</th>
+      <th>Beleg</th>
+      <th>Memo</th>
+      <th>Betrag</th>
+[% IF show_exchangerate %]
+      <th>Wechselkurs.</th>
+[% END %]
+      <th>Konto</th>
+     </tr>
+
+
+[% paidaccounts %]
+
+[% FOREACH i = paid_indices %]
+[% SET row = {} %]
+  [% SET row.datepaid    = 'datepaid_'    _ i %]
+  [% SET row.source      = 'source_'      _ i %]
+  [% SET row.memo        = 'memo_'        _ i %]
+  [% SET row.paid        = 'paid_'        _ i %]
+
+     <tr>
+
+    <td align="center">
+      <input id="datepaid_[% i %]" name="datepaid_[% i %]" size="11" title="$myconfig{dateformat}" value="[% row.datepaid %]" onBlur=\"check_right_date_format(this)\">
+      <input type="button" name="datepaid_[% i %]" id="trigger_datepaid_[% i %]" value="?">
+     </td>
+     <td align=center><input name="source_[% i %]" size="11" value="[% row.source %]"></td>|;
+     <td align="center"><input name="memo_[% i %]" size="11" value="[% row.memo %]"></td>|;
+     <td align="center"><input name="paid_[% i %]" size="11" value="[% row.paid %]" onBlur=\"check_right_number_format(this)\"></td>|;
+     <td align="center">
+[% IF show_exchangerate %]
+  [% SET row.forex        = 'forex_'        _ i %]
+  [% SET row.exchangerate = 'exchangerate_' _ i %]
+  [% IF row.forex %]
+        <input type="hidden" name="exchangerate_[% i %]" value="[% row.exchangerate %]">
+        [% row.exchangerate | html %]
+  [% ELSE %]
+        <input name="exchangerate_[% i %]" size="10" value="[% row.exchangerate %]">
+  [% END %]
+        <input type="hidden" name="forex_[% i %]" value="[% row.forex %]">;
+[% END %]
+     </td>
+     <td align="center"><select name="AR_paid_$i">$form->{"selectAR_paid_$i"}</select></td>|;
+
+    </tr>
+[%#     push(@triggers, "datepaid_$i", "BL", "trigger_datepaid_$i"); %]
+
+[% END # foreach %]
+
+    <tr>
+      <td></td>
+      <td></td>
+      <td align="center">Summe</td>
+      <td align="center">[% LxERP.foramt_amount(totalpaid, 2) | html %]</td>
+    </tr>
+    <tr>
+      <td></td>
+      <td></td>
+      <td align="center">Fehlbetrag</td>
+      <td align="center">[% LxERP.format_amount(paid_missing, 2) | html %]</td>
+    </tr>
+
+  <input type="hidden" name="paidaccounts" value="[% paidaccounts %]">
+  <input type="hidden" name="selectAR_paid" value="[% selectAR_paid %]">
+  <input type="hidden" name="oldinvtotal" value="[% rowcount %]">
+
+  <input type="hidden" name="oldtotalpaid" value="$totalpaid">
+    </table>
+
+    </td>
+  </tr>
index 09c0812..0549e28 100644 (file)
+[%- USE LxERP %]
+  <tr>
+   <td>
+    <table width="100%">
+     <tr class="listheading">
+[% IF is_credit_note %]
+      <th colspan="6" class="listheading"><translate>Payments</translate></th>
+[% ELSE %]
+      <th colspan="6" class="listheading"><translate>Incoming Payments</translate></th>
+[%- END %]
+     </tr>
+
+
+     <tr>
+      <th><translate>Date</translate></th>
+      <th><translate>Source</translate></th>
+      <th><translate>Memo</translate></th>
+      <th><translate>Amount</translate></th>
+[% IF show_exchangerate %]
+      <th><translate>Exch</translate></th>
+[% END %]
+      <th><translate>Account</translate></th>
+     </tr>
+
+
+[% paidaccounts %]
+
+[% FOREACH i = paid_indices %]
+[% SET row = {} %]
+  [% SET row.datepaid    = 'datepaid_'    _ i %]
+  [% SET row.source      = 'source_'      _ i %]
+  [% SET row.memo        = 'memo_'        _ i %]
+  [% SET row.paid        = 'paid_'        _ i %]
+
+     <tr>
+
+    <td align="center">
+      <input id="datepaid_[% i %]" name="datepaid_[% i %]" size="11" title="$myconfig{dateformat}" value="[% row.datepaid %]" onBlur=\"check_right_date_format(this)\">
+      <input type="button" name="datepaid_[% i %]" id="trigger_datepaid_[% i %]" value="?">
+     </td>
+     <td align=center><input name="source_[% i %]" size="11" value="[% row.source %]"></td>|;
+     <td align="center"><input name="memo_[% i %]" size="11" value="[% row.memo %]"></td>|;
+     <td align="center"><input name="paid_[% i %]" size="11" value="[% row.paid %]" onBlur=\"check_right_number_format(this)\"></td>|;
+     <td align="center">
+[% IF show_exchangerate %]
+  [% SET row.forex        = 'forex_'        _ i %]
+  [% SET row.exchangerate = 'exchangerate_' _ i %]
+  [% IF row.forex %]
+        <input type="hidden" name="exchangerate_[% i %]" value="[% row.exchangerate %]">
+        [% row.exchangerate | html %]
+  [% ELSE %]
+        <input name="exchangerate_[% i %]" size="10" value="[% row.exchangerate %]">
+  [% END %]
+        <input type="hidden" name="forex_[% i %]" value="[% row.forex %]">;
+[% END %]
+     </td>
+     <td align="center"><select name="AR_paid_$i">$form->{"selectAR_paid_$i"}</select></td>|;
 
+    </tr>
+[%#     push(@triggers, "datepaid_$i", "BL", "trigger_datepaid_$i"); %]
 
-
-
-
-
-  my @column_index;
-  if ($form->{currency} eq $form->{defaultcurrency}) {
-    @column_index = qw(datepaid source memo paid AR_paid);
-  } else {
-    @column_index = qw(datepaid source memo paid exchangerate AR_paid);
-  }
-
-  my %column_data;
-  $column_data{datepaid}     = "<th>" . $locale->text('Date') . "</th>";
-  $column_data{paid}         = "<th>" . $locale->text('Amount') . "</th>";
-  $column_data{exchangerate} = "<th>" . $locale->text('Exch') . "</th>";
-  $column_data{AR_paid}      = "<th>" . $locale->text('Account') . "</th>";
-  $column_data{source}       = "<th>" . $locale->text('Source') . "</th>";
-  $column_data{memo}         = "<th>" . $locale->text('Memo') . "</th>";
-
-    <tr>
-
-  map { print "$column_data{$_}\n" } @column_index;
-
-        </tr>
-
-  my @triggers  = ();
-  my $totalpaid = 0;
-
-  $form->{paidaccounts}++ if ($form->{"paid_$form->{paidaccounts}"});
-
-
-
-  [% FOREACH i = 1 .. paidaccounts %]
-
-        <tr>
-
-
-    $form->{"selectAR_paid_$i"} = $form->{selectAR_paid};
-    $form->{"selectAR_paid_$i"} =~
-      s/option>\Q$form->{"AR_paid_$i"}\E/option selected>$form->{"AR_paid_$i"}/;
-
-    # format amounts
-    $totalpaid += $form->{"paid_$i"};
-    if ($form->{"paid_$i"}) {
-      $form->{"paid_$i"} = $form->format_amount(\%myconfig, $form->{"paid_$i"}, 2);
-    }
-    $form->{"exchangerate_$i"} = $form->format_amount(\%myconfig, $form->{"exchangerate_$i"});
-
-    if ($form->{"exchangerate_$i"} == 0) {
-      $form->{"exchangerate_$i"} = "";
-    }
-    my $exchangerate = qq|&nbsp;|;
-    if ($form->{currency} ne $form->{defaultcurrency}) {
-      if ($form->{"forex_$i"}) {
-        $exchangerate = qq|<input type="hidden" name="exchangerate_$i" value="$form->{"exchangerate_$i"}">$form->{"exchangerate_$i"}|;
-      } else {
-        $exchangerate = qq|<input name="exchangerate_$i" size="10" value="$form->{"exchangerate_$i"}">|;
-      }
-    }
-
-    $exchangerate .= qq|<input type="hidden" name="forex_$i" value="$form->{"forex_$i"}">|;
-
-    $column_data{"paid_$i"} =
-      qq|<td align="center"><input name="paid_$i" size="11" value="$form->{"paid_$i"}" onBlur=\"check_right_number_format(this)\"></td>|;
-    $column_data{"exchangerate_$i"} = qq|<td align="center">$exchangerate</td>|;
-    $column_data{"AR_paid_$i"}      =
-      qq|<td align="center"><select name="AR_paid_$i">$form->{"selectAR_paid_$i"}</select></td>|;
-    $column_data{"datepaid_$i"} =
-      qq|<td align="center"><input id="datepaid_$i" name="datepaid_$i"  size="11" title="$myconfig{dateformat}" value="$form->{"datepaid_$i"}" onBlur=\"check_right_date_format(this)\">
-         <input type="button" name="datepaid_$i" id="trigger_datepaid_$i" value="?"></td>|;
-    $column_data{"source_$i"} =
-      qq|<td align=center><input name="source_$i" size="11" value="$form->{"source_$i"}"></td>|;
-    $column_data{"memo_$i"} =
-      qq|<td align="center"><input name="memo_$i" size="11" value="$form->{"memo_$i"}"></td>|;
-
-    map { print qq|$column_data{"${_}_$i"}\n| } @column_index;
-    print "
-        </tr>\n";
-    push(@triggers, "datepaid_$i", "BL", "trigger_datepaid_$i");
-  }
+[% END # foreach %]
 
     <tr>
       <td></td>
       <td></td>
-      <td align="center">| . $locale->text('Total') . qq|</td>
-      <td align="center">| . H($form->format_amount(\%myconfig, $totalpaid, 2)) . qq|</td>
+      <td align="center"><translate>Total</translate></td>
+      <td align="center">[% LxERP.foramt_amount(totalpaid, 2) | html %]</td>
     </tr>
     <tr>
       <td></td>
       <td></td>
-      <td align="center">| . $locale->text('Missing amount') . qq|</td>
-      <td align="center">| . H($form->format_amount(\%myconfig, $paid_missing, 2)) . qq|</td>
+      <td align="center"><translate>Missing amount</translate></td>
+      <td align="center">[% LxERP.format_amount(paid_missing, 2) | html %]</td>
     </tr>
 
-  map({ print($cgi->hidden("-name" => $_, "-value" => $form->{$_})); } qw(paidaccounts selectAR_paid oldinvtotal));
+  <input type="hidden" name="paidaccounts" value="[% paidaccounts %]">
+  <input type="hidden" name="selectAR_paid" value="[% selectAR_paid %]">
+  <input type="hidden" name="oldinvtotal" value="[% rowcount %]">
 
   <input type="hidden" name="oldtotalpaid" value="$totalpaid">
     </table>
+
+    </td>
+  </tr>
index eeae756..cc974d5 100644 (file)
   [%- END %]
        <table>
 
-        $subtotal
+[%#- subtotal %]
+[%- UNLESS taxincluded %]
+        <tr>
+         <th align="right">Zwischensumme</th>
+         <td align="right">[% LxERP.format_amount(invsubtotal, 2) %]</td>
+       </tr>
+[%- END %]
 
 [%# tax %]
 [% FOREACH item = taxaccounts_array %]
-[% SET description_ref = item _ 'description' %]
-[% SET rate_ref        = item _ 'rate' %]
-[% SET total_ref       = item _ 'total' %]
-[% SET netto_ref       = item _ 'netto' %]
+[% SET description_ref = item _ '_description' %]
+[% SET rate_ref        = item _ '_rate' %]
+[% SET total_ref       = item _ '_total' %]
+[% SET netto_ref       = item _ '_netto' %]
        <tr>
-        <th align="right">Enthaltene [% $description_ref %]&nbsp;[% $rate_ref * 100 %]%</th>
-        <td align="right">[% $total_ref %]</td>
+        <th align="right">Enthaltene [% $description_ref | html %]&nbsp;[% $rate_ref * 100 %]%</th>
+        <td align="right">[% LxERP.format_amount($total_ref, 2) %]</td>
        </tr>
+  [%- IF taxincluded %]
        <tr>
         <th align="right">Nettobetrag</th>
-        <td align="right">[% $netto_ref %]</td>
+        <td align="right">[% LxERP.format_amount($netto_ref, 2) %]</td>
        </tr>
+  [%- END %]
 [%- END %]
 
         <tr>
@@ -87,6 +95,7 @@
    </td>
   </tr>
 
+[%#--------------------------- WEB DAV BLOCK %]
 [%- IF webdav %]
   <tr>
    <td><hr size="3" noshade></td>
    </table>
   </tr>
 [% END %]
+[%#--------------------------- WEB DAV BLOCK %]
 
 
-  <tr>
-   <td>
-    <table width="100%">
-     <tr class="listheading">
-[% IF is_credit_note %]
-      <th colspan="6" class="listheading">Zahlungsausgänge</th>
-[% ELSE %]
-      <th colspan="6" class="listheading">Zahlungseingänge</th>
-[%- END %]
-     </tr>
-
+[% PROCESS 'is/_payments_de.html' %]
 
-[%# INCLUDE _payments %]
 
 
-    </td>
-  </tr>
   <tr>
     <td><hr size="3" noshade></td>
   </tr>
   <tr>
     <td>
-  [% print_options %]
+[% print_options %]
     </td>
   </tr>
-</table>
+ </table>
+
+
 
   [% IF id %]
 
     <input class="submit" type="submit" name="action" value="Löschen">
 [% END %]
 
-  [%- IF invdate > closedto %]
+  [%- UNLESS locked %]
        <input class="submit" type="submit" name="action" value="Auftrag">
   [%- END %]
 
     <input type="button" class="submit" onclick="follow_up_window()" value="Wiedervorlage">
 
  [% ELSE # no id %]
-   [% IF invdate > closedto %]
+   [% UNLESS locked %]
       <input class="submit" type="submit" name="action" id="update_button" value="Erneuern">
       <input class="submit" type="submit" name="action" value="Lieferadresse">
       <input class="submit" type="submit" name="action" value="Druckvorschau">
index cc18108..b7548d7 100644 (file)
   [%- END %]
        <table>
 
-        $subtotal
+[%#- subtotal %]
+[%- UNLESS taxincluded %]
+        <tr>
+         <th align="right"><translate>Subtotal</translate></th>
+         <td align="right">[% LxERP.format_amount(invsubtotal, 2) %]</td>
+       </tr>
+[%- END %]
 
 [%# tax %]
 [% FOREACH item = taxaccounts_array %]
-[% SET description_ref = item _ 'description' %]
-[% SET rate_ref        = item _ 'rate' %]
-[% SET total_ref       = item _ 'total' %]
-[% SET netto_ref       = item _ 'netto' %]
+[% SET description_ref = item _ '_description' %]
+[% SET rate_ref        = item _ '_rate' %]
+[% SET total_ref       = item _ '_total' %]
+[% SET netto_ref       = item _ '_netto' %]
        <tr>
-        <th align="right">Enthaltene [% $description_ref %]&nbsp;[% $rate_ref * 100 %]%</th>
-        <td align="right">[% $total_ref %]</td>
+        <th align="right">Enthaltene [% $description_ref | html %]&nbsp;[% $rate_ref * 100 %]%</th>
+        <td align="right">[% LxERP.format_amount($total_ref, 2) %]</td>
        </tr>
+  [%- IF taxincluded %]
        <tr>
         <th align="right">Nettobetrag</th>
-        <td align="right">[% $netto_ref %]</td>
+        <td align="right">[% LxERP.format_amount($netto_ref, 2) %]</td>
        </tr>
+  [%- END %]
 [%- END %]
 
         <tr>
@@ -87,6 +95,7 @@
    </td>
   </tr>
 
+[%#--------------------------- WEB DAV BLOCK %]
 [%- IF webdav %]
   <tr>
    <td><hr size="3" noshade></td>
    </table>
   </tr>
 [% END %]
+[%#--------------------------- WEB DAV BLOCK %]
 
 
-  <tr>
-   <td>
-    <table width="100%">
-     <tr class="listheading">
-[% IF is_credit_note %]
-      <th colspan="6" class="listheading"><translate>Payments</translate></th>
-[% ELSE %]
-      <th colspan="6" class="listheading"><translate>Incoming Payments</translate></th>
-[%- END %]
-     </tr>
-
+[% PROCESS 'is/_payments_<translate>master</translate>.html' %]
 
-[%# INCLUDE _payments %]
 
 
-    </td>
-  </tr>
   <tr>
     <td><hr size="3" noshade></td>
   </tr>
   <tr>
     <td>
-  [% print_options %]
+[% print_options %]
     </td>
   </tr>
-</table>
+ </table>
+
+
 
   [% IF id %]
 
     <input class="submit" type="submit" name="action" value="<translate>Delete</translate>">
 [% END %]
 
-  [%- IF invdate > closedto %]
+  [%- UNLESS locked %]
        <input class="submit" type="submit" name="action" value="<translate>Order</translate>">
   [%- END %]
 
     <input type="button" class="submit" onclick="follow_up_window()" value="<translate>Follow-Up</translate>">
 
  [% ELSE # no id %]
-   [% IF invdate > closedto %]
+   [% UNLESS locked %]
       <input class="submit" type="submit" name="action" id="update_button" value="<translate>Update</translate>">
       <input class="submit" type="submit" name="action" value="<translate>Ship to</translate>">
       <input class="submit" type="submit" name="action" value="<translate>Preview</translate>">