T8 Filter für Templates und Anwendungsbeispiel _payments
authorSven Schöling <s.schoeling@linet-services.de>
Thu, 17 Dec 2009 10:47:04 +0000 (11:47 +0100)
committerSven Schöling <s.schoeling@linet-services.de>
Thu, 17 Dec 2009 10:47:04 +0000 (11:47 +0100)
SL/Template/Plugin/T8.pm [new file with mode: 0644]
scripts/templ2t8.pl [new file with mode: 0755]
templates/webpages/is/_payments_de.html [changed from file to symlink]
templates/webpages/is/_payments_master.html

diff --git a/SL/Template/Plugin/T8.pm b/SL/Template/Plugin/T8.pm
new file mode 100644 (file)
index 0000000..79fab96
--- /dev/null
@@ -0,0 +1,24 @@
+package SL::Template::Plugin::T8;
+
+use Template::Plugin::Filter;
+use base qw( Template::Plugin::Filter );
+
+my $locale = undef;
+
+sub init {
+    my $self = shift;
+
+    $locale ||= Locale->new($main::myconfig{countrycode}, 'all');
+
+    # first arg can specify filter name
+    $self->install_filter($self->{ _ARGS }->[0] || 'T8');
+
+    return $self;
+}
+
+sub filter {
+    my ($self, $text, $args) = @_;
+    return $locale->text($text, @{ $args || [] });
+}
+
+return 'SL::Template::Plugin::T8';
diff --git a/scripts/templ2t8.pl b/scripts/templ2t8.pl
new file mode 100755 (executable)
index 0000000..f1e5bf6
--- /dev/null
@@ -0,0 +1,14 @@
+#!/usr/bin/perl -pli.orig
+
+#
+# template converter -> T8 converter
+#
+# wanna get rid of those <translate> tags?
+# no problem. use this script to fix most it.
+#
+# use: perl tmpl2t8.pl <file>
+#
+# will save the original file as file.orig
+#
+s/$/[% USE T8 %]/ if $. == 1;
+s/<translate>([^<]+)<\/translate>/[%- '$1' | \$T8 %]/xg;
deleted file mode 100644 (file)
index aa83860f9257d14ef4879e9b9c8f009a81ec72be..0000000000000000000000000000000000000000
+++ /dev/null
@@ -1,87 +0,0 @@
-[%- USE LxERP %]
-  <tr>
-   <td>
-    <table width="100%">
-     <tr class="listheading">
-[% IF is_type_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>
-
-
-[% FOREACH i = paid_indices %]
-  [% SET datepaid      = 'datepaid_'      _ i %]
-  [% SET source        = 'source_'        _ i %]
-  [% SET memo          = 'memo_'          _ i %]
-  [% SET paid          = 'paid_'          _ i %]
-  [% SET selectAR_paid_ref = 'selectAR_paid_' _ i %]
-
-     <tr>
-
-    <td align="center">
-      <input id="datepaid_[% i %]" name="datepaid_[% i %]" size="11" title="[% dateformat %]" value="[% $datepaid %]">
-      <input type="button" name="datepaid_[% i %]" id="trigger_datepaid_[% i %]" value="?">
-     </td>
-     <td align=center><input name="source_[% i %]" size="11" value="[% $source %]"></td>
-     <td align="center"><input name="memo_[% i %]" size="11" value="[% $memo %]"></td>
-     <td align="center"><input name="paid_[% i %]" size="11" value="[% LxERP.format_amount($paid, 2, 1) %]"></td>
-[% IF show_exchangerate %]
-     <td align="center">
-  [% SET forex        = 'forex_'        _ i %]
-  [% SET exchangerate = 'exchangerate_' _ i %]
-  [% IF forex %]
-        <input type="hidden" name="exchangerate_[% i %]" value="[% LxERP.format_amount($exchangerate, 2) %]">
-        [% LxERP.format_amount(exchangerate, 2) %]
-  [% ELSE %]
-        <input name="exchangerate_[% i %]" size="10" value="[% LxERP.format_amount($exchangerate, 2, 1) %]">
-  [% END %]
-        <input type="hidden" name="forex_[% i %]" value="[% $forex %]">;
-     </td>
-[% END %]
-     <td align="center"><select name="AR_paid_[% i %]">[% $selectAR_paid_ref %]</select></td>
-
-    </tr>
-    <script type='text/javascript'>
-     Calendar.setup({ inputField : "datepaid_[% i %]", ifFormat :"[% myconfig_jsc_dateformat %]", align : "TR", button : "trigger_datepaid_[% i %]" });
-     $('input[name="paid_[% i %]"]').blur(function(){ check_right_number_format(this) });
-     $('#datepaid_[% i %]').blur(function(){ check_right_date_format(this) });
-    </script>
-
-[% 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="[% oldinvtotal %]">
-
-     <input type="hidden" name="oldtotalpaid" value="[% totalpaid %]">
-    </table>
-
-    </td>
-  </tr>
new file mode 120000 (symlink)
index 0000000000000000000000000000000000000000..d2ad321ac099e3ce96a27a83e2152b0ed454056b
--- /dev/null
@@ -0,0 +1 @@
+_payments_master.html
\ No newline at end of file
index 5216661..1c39b20 100644 (file)
@@ -1,25 +1,25 @@
-[%- USE LxERP %]
+[%- USE LxERP %][% USE T8 %]
   <tr>
    <td>
     <table width="100%">
      <tr class="listheading">
 [% IF is_type_credit_note %]
-      <th colspan="6" class="listheading"><translate>Payments</translate></th>
+      <th colspan="6" class="listheading">[%- 'Payments' | $T8 %]</th>
 [% ELSE %]
-      <th colspan="6" class="listheading"><translate>Incoming Payments</translate></th>
+      <th colspan="6" class="listheading">[%- 'Incoming Payments' | $T8 %]</th>
 [%- END %]
      </tr>
 
 
      <tr>
-      <th><translate>Date</translate></th>
-      <th><translate>Source</translate></th>
-      <th><translate>Memo</translate></th>
-      <th><translate>Amount</translate></th>
+      <th>[%- 'Date' | $T8 %]</th>
+      <th>[%- 'Source' | $T8 %]</th>
+      <th>[%- 'Memo' | $T8 %]</th>
+      <th>[%- 'Amount' | $T8 %]</th>
 [% IF show_exchangerate %]
-      <th><translate>Exch</translate></th>
+      <th>[%- 'Exch' | $T8 %]</th>
 [% END %]
-      <th><translate>Account</translate></th>
+      <th>[%- 'Account' | $T8 %]</th>
      </tr>
 
 
     <tr>
       <td></td>
       <td></td>
-      <td align="center"><translate>Total</translate></td>
+      <td align="center">[%- 'Total' | $T8 %]</td>
       <td align="center">[% LxERP.foramt_amount(totalpaid, 2) | html %]</td>
     </tr>
     <tr>
       <td></td>
       <td></td>
-      <td align="center"><translate>Missing amount</translate></td>
+      <td align="center">[%- 'Missing amount' | $T8 %]</td>
       <td align="center">[% LxERP.format_amount(paid_missing, 2) | html %]</td>
     </tr>