Merge branch 'ir_templates'
authorSven Schöling <s.schoeling@linet-services.de>
Wed, 30 Dec 2009 15:26:04 +0000 (16:26 +0100)
committerSven Schöling <s.schoeling@linet-services.de>
Wed, 30 Dec 2009 15:26:04 +0000 (16:26 +0100)
Conflicts:
SL/OP.pm

13 files changed:
SL/CP.pm
SL/IC.pm
SL/OE.pm
SL/OP.pm [deleted file]
SL/Template/Plugin/T8.pm [new file with mode: 0644]
bin/mozilla/cp.pl
bin/mozilla/is.pl
doc/INSTALL.texi
doc/dokumentenvorlagen-und-variablen.html
locale/de/locales.pl
scripts/templ2t8.pl [new file with mode: 0755]
templates/webpages/is/_payments_de.html
templates/webpages/is/_payments_master.html

index 64fd988..b7e6241 100644 (file)
--- a/SL/CP.pm
+++ b/SL/CP.pm
@@ -358,15 +358,12 @@ sub process_payment {
     }
   }
 
-  # record a AR/AP with a payment
-  if ($form->round_amount($paymentamount, 2) > 0) {
-    $form->{invnumber} = "";
-    OP::overpayment("", $myconfig, $form, $dbh, $paymentamount, $ml, 1);
-  }
-
   my $rc;
   if ($form->round_amount($paymentamount, 2) < 0) {
-    $dbh->rollback;
+               # Hier werden negativen Zahlungseingänge abgefangen
+               # Besser: in Oberfläche schon prüfen
+               # Zahlungsein- und ausgänge sind immer positiv
+    $dbh->rollback;    
     $rc = 0;
   }
   if ($form->round_amount($paymentamount, 2) == 0) {
index 54cca39..080aedf 100644 (file)
--- a/SL/IC.pm
+++ b/SL/IC.pm
@@ -1446,7 +1446,7 @@ sub follow_account_chain {
     qq|  cnew.accno | .
     qq|FROM chart c | .
     qq|LEFT JOIN chart cnew ON c.new_chart_id = cnew.id | .
-    qq|WHERE (c.id = ?) AND NOT c.new_chart_id ISNULL AND (c.new_chart_id > 0)|;
+    qq|WHERE (c.id = ?) AND NOT c.new_chart_id IS NULL AND (c.new_chart_id > 0)|;
   $sth = prepare_query($form, $dbh, $query);
 
   while (1) {
index b731dc1..b1e1f9f 100644 (file)
--- a/SL/OE.pm
+++ b/SL/OE.pm
@@ -1277,6 +1277,39 @@ sub project_description {
   return $value;
 }
 
+##########################
+# Get data for the submitted order id
+# from database
+#
+sub get_order_data_by_ordnumber {
+  $main::lxdebug->enter_sub();
+
+  my $self      = shift;
+  my %params    = @_;
+
+  Common::check_params(\%params, qw(ordnumber));
+
+  my $form     = $main::form;
+  my %myconfig = %main::myconfig;
+  my $dbh      = $form->get_standard_dbh();
+
+  my @values = ($params{ordnumber});
+
+  # We query the database for the fields we need using the submitted "ordnumber"
+  my $query = <<SQL;
+    SELECT o.payment_id, o.salesman_id, o.transdate AS orddate, o.taxzone_id, o.quonumber
+    FROM oe o
+    WHERE o.ordnumber = ?;
+SQL
+
+  # Do the actual query and return the results for later processing by our "frontend"
+  my $result = selectfirst_hashref_query($form, $dbh, $query, @values);
+
+  $main::lxdebug->leave_sub();
+
+  return $result;
+}
+
 1;
 
 __END__
diff --git a/SL/OP.pm b/SL/OP.pm
deleted file mode 100644 (file)
index 808972f..0000000
--- a/SL/OP.pm
+++ /dev/null
@@ -1,105 +0,0 @@
-#=====================================================================
-# LX-Office ERP
-# Copyright (C) 2004
-# Based on SQL-Ledger Version 2.1.9
-# Web http://www.lx-office.org
-#
-#=====================================================================
-# SQL-Ledger Accounting
-# Copyright (C) 2003
-#
-#  Author: Dieter Simader
-#   Email: dsimader@sql-ledger.org
-#     Web: http://www.sql-ledger.org
-#
-#  Contributors:
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-#======================================================================
-#
-# Overpayment function
-# used in AR, AP, IS, IR, OE, CP
-#======================================================================
-
-package OP;
-
-use SL::DBUtils;
-
-use strict;
-
-sub overpayment {
-  $main::lxdebug->enter_sub();
-
-  my ($self, $myconfig, $form, $dbh, $amount, $ml) = @_;
-
-  my $fxamount = $form->round_amount($amount * $form->{exchangerate}, 2);
-  my ($paymentaccno) = split(/--/, $form->{account});
-
-  my $vc_id = $form->{vc} eq "customer" ? "customer_id" : "vendor_id";
-  my $arap = $form->{arap} eq "ar" ? "ar" : "ap";
-
-  my $query = qq|SELECT nextval('glid')|;
-  my ($new_id) = selectrow_query($form, $dbh, $query);
-
-  # add AR/AP header transaction with a payment
-  $query =
-    qq|INSERT INTO $arap (id, invnumber, employee_id) | .
-    qq|VALUES (?, ?, (SELECT id FROM employee WHERE login = ?))|;
-  my @values = ($new_id, $form->{login}, $form->{login});
-  do_query($form, $dbh, $query, @values);
-
-  my $invnumber = ($form->{invnumber}) ? $form->{invnumber} : $new_id;
-  $query =
-    qq|UPDATE $arap SET invnumber = ?, $vc_id = ?, transdate = ?, datepaid = ?, | .
-    qq|duedate = ?, netamount = ?, amount = ?, paid = ?, | .
-    qq|curr = ?, department_id = ? | .
-    qq|WHERE id = ?|;
-  @values = ($invnumber, $form->{$vc_id},
-             conv_date($form->{datepaid}), conv_date($form->{datepaid}),
-             conv_date($form->{datepaid}), 0, 0, $fxamount, $form->{currency},
-             $form->{department_id}, $new_id);
-  do_query($form, $dbh, $query, @values);
-
-  # add AR/AP
-  my ($accno) = split /--/, $form->{ $form->{ARAP} };
-
-  $query =
-    qq|INSERT INTO acc_trans (trans_id, chart_id, transdate, amount) | .
-    qq|VALUES (?, (SELECT id FROM chart WHERE accno = ? ), ?, ?)|;
-  @values = ($new_id, $accno, conv_date($form->{datepaid}), $fxamount * $ml);
-  do_query($form, $dbh, $query, @values);
-
-  # add payment
-  $query =
-    qq|INSERT INTO acc_trans (trans_id, chart_id, transdate, amount, source, memo) | .
-    qq|VALUES (?, (SELECT id FROM chart WHERE accno = ?), ?, ?, ?, ?)|;
-  @values = ($new_id, $paymentaccno, conv_date($form->{datepaid}),
-             $amount * $ml * -1, $form->{source}, $form->{memo});
-  do_query($form, $dbh, $query, @values);
-
-  # add exchangerate difference
-  if ($fxamount != $amount) {
-    $query =
-      qq|INSERT INTO acc_trans (trans_id, chart_id, transdate, amount, cleared, fx_transaction) | .
-      qq|VALUES (?, (SELECT id FROM chart WHERE accno = ?), ?, ?, ?, ?)|;
-    @values = ($new_id, $paymentaccno, conv_date($form->{datepaid}),
-               (($fxamount - $amount) * $ml * -1), 1, 1);
-    do_query($form, $dbh, $query, @values);
-  }
-
-  $main::lxdebug->leave_sub();
-}
-
-1;
-
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';
index 94f82e6..5162433 100644 (file)
@@ -32,7 +32,6 @@
 #======================================================================
 
 use SL::CP;
-use SL::OP;
 use SL::IS;
 use SL::IR;
 
index 4b9b1a5..b90209f 100644 (file)
@@ -34,6 +34,7 @@
 use SL::FU;
 use SL::IS;
 use SL::PE;
+use SL::OE;
 use Data::Dumper;
 use List::Util qw(max sum);
 
@@ -155,6 +156,14 @@ sub invoice_links {
     $ref->{name} = $form->quote($ref->{name});
   }
 
+  # Load data for a specific order and update form fields
+  my $order_data = OE->get_order_data_by_ordnumber(%$form) if $form->{ordnumber};
+
+  # Copy the fields we need to %form
+  for my $key (qw(payment_id salesman_id orddate taxzone_id quonumber)) {
+    $form->{$key} = $order_data->{$key};
+  }
+
   $form->restore_vars(qw(id));
 
   IS->retrieve_invoice(\%myconfig, \%$form);
@@ -162,6 +171,7 @@ sub invoice_links {
   $form->restore_vars(qw(taxincluded)) if $form->{id};
   $form->restore_vars(qw(salesman_id)) if $main::editing;
 
+
   # build vendor/customer drop down comatibility... don't ask
   if (@{ $form->{"all_customer"} }) {
     $form->{"selectcustomer"} = 1;
index 0de2931..43eeda9 100644 (file)
@@ -145,6 +145,12 @@ Verzeichnisse auf einem Debian/Ubuntu-System:
 
 @code{chown -R www-data lx-office-erp/users lx-office-erp/spool lx-office-erp/webdav}
 
+Weiterhin muss der Webserver-Benutzer im Verzeichnis @code{templates} Verzeichnisse für
+jeden neuen Benutzer, der in lx-office angelegt wird, anlegen dürfen:
+
+@code{chgrp www-data lx-office-erp/templates; chmod g+w lx-office-erp/templates}
+
+
 @c ---------------------------------------------------------------
 
 @node Anpassung der PostgreSQL-Konfiguration
@@ -185,6 +191,8 @@ Wurde PostgreSQL nicht mit UTF-8 als Encoding initialisiert und ist
 ein Neuanlegen eines weiteren Clusters nicht möglich, so kann
 Lx-Office mit ISO-8859-15 als Encoding betrieben werden.
 
+Das Encoding einer Datenbank kann in @code{psql} mit @code{\l} geprüft werden.
+
 @node Änderungen an Konfigurationsdateien
 @section Änderungen an Konfigurationsdateien
 
@@ -237,7 +245,7 @@ lancompiler 'pl/pgsql';}
 Bitte beachten Sie, dass der Pfad zur Datei @code{plpgsql.so} von
 Distribution zu Distribution verschiedlich sein kann. Bei
 Debian/Ubuntu befindet sie sich unter
-@code{/usr/lib/postgresql/lib/plpgsql.so}.
+@code{/usr/lib/postgresql/lib/plpgsql.so}, bei Ubuntu 9.10 unter @code{/usr/lib/postgresql/8.4/lib/plpgsql.so}.
 
 
 @c ---------------------------------------------------------------
index 16e7fb0..b2b90cd 100644 (file)
@@ -981,6 +981,10 @@ td {
     <td><code>dunning_duedate</code></td>
     <td>F&auml;lligkeitsdatum f&uuml;r diese Mahhnung</td>
    </tr>
+   <tr>
+    <td><code>dunning_id</code></td>
+    <td>Mahnungsnummer</td>
+   </tr>
    <tr>
     <td><code>fee</code></td>
     <td>Kummulative Mahngeb&uuml;hren</td>
index 7cc3c53..bb30c7a 100755 (executable)
@@ -558,6 +558,25 @@ sub scanhtmlfile {
         $plugins{needed}->{$plugin} = 1 if (first { $_ eq $plugin } qw(HTML LxERP JavaScript MultiColumnIterator));
       }
 
+      while ($line =~ m/\[\%            # Template-Start-Tag
+                        [\-~#]          # Whitespace-Unterdrückung
+                        \s*             # Optional beliebig viele Whitespace
+                        [\'\"]          # Anfang des zu übersetzenden Strings
+                        (.*?)           # Der zu übersetzende String
+                        [\'\"]          # Ende des zu übersetzenden Strings
+                        \s*\|\s*        # Pipe-Zeichen mit optionalen Whitespace davor und danach
+                        \$T8            # Filteraufruf
+                        .*?             # Optionale Argumente für den Filter und Whitespaces
+                        [\-~#]          # Whitespace-Unterdrückung
+                        \%\]            # Template-Ende-Tag
+                       /ix) {
+        print "Found filter >>>$1<<<\n";
+        $cached{$_[0]}{all}{$1}  = 1;
+        $cached{$_[0]}{html}{$1} = 1;
+        $plugins{needed}->{T8}   = 1;
+        substr $line, $-[1], $+[0] - $-[0], '';
+      }
+
       while ("" ne $line) {
         if (!$copying) {
           if ($line =~ m|<translate>|i) {
@@ -608,9 +627,9 @@ sub scanhtmlfile {
   }
 
   # copy back into global arrays
-  map { $alllocales{$_} = 1 }  keys %{$cached{$_[0]}{all}};
-  map { $htmllocales{$_} = 1 } keys %{$cached{$_[0]}{html}};
-  map { $submit{$_} = 1 }      keys %{$cached{$_[0]}{submit}};
+  map { $alllocales{$_} = 1 } keys %{$cached{$_[0]}{all}};
+  map { $htmllocale{$_} = 1 } keys %{$cached{$_[0]}{html}};
+  map { $submit{$_} = 1 }     keys %{$cached{$_[0]}{submit}};
 }
 
 sub converthtmlfile {
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;
index aa83860..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">Zahlungsausgänge</th>
+      <th colspan="6" class="listheading">[%- 'Payments' | $T8 %]</th>
 [% ELSE %]
-      <th colspan="6" class="listheading">Zahlungseingänge</th>
+      <th colspan="6" class="listheading">[%- 'Incoming Payments' | $T8 %]</th>
 [%- END %]
      </tr>
 
 
      <tr>
-      <th>Datum</th>
-      <th>Beleg</th>
-      <th>Memo</th>
-      <th>Betrag</th>
+      <th>[%- 'Date' | $T8 %]</th>
+      <th>[%- 'Source' | $T8 %]</th>
+      <th>[%- 'Memo' | $T8 %]</th>
+      <th>[%- 'Amount' | $T8 %]</th>
 [% IF show_exchangerate %]
-      <th>Wechselkurs.</th>
+      <th>[%- 'Exch' | $T8 %]</th>
 [% END %]
-      <th>Konto</th>
+      <th>[%- 'Account' | $T8 %]</th>
      </tr>
 
 
     <tr>
       <td></td>
       <td></td>
-      <td align="center">Summe</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">Fehlbetrag</td>
+      <td align="center">[%- 'Missing amount' | $T8 %]</td>
       <td align="center">[% LxERP.format_amount(paid_missing, 2) | html %]</td>
     </tr>
 
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>