X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FForm.pm;h=916969e8dcdb7d823e6946194d9eceabb72b2adf;hb=7ec334735373f140fb8ab48d9cdbe8dedecd99d0;hp=3b683f4f4e9512bcddc611774e2b077bdf4e570b;hpb=9c3fc229e43f79220c05500fcb9da805eb881688;p=kivitendo-erp.git
diff --git a/SL/Form.pm b/SL/Form.pm
index 3b683f4f4..916969e8d 100644
--- a/SL/Form.pm
+++ b/SL/Form.pm
@@ -146,7 +146,7 @@ sub new {
$self->{action} = lc $self->{action};
$self->{action} =~ s/( |-|,|\#)/_/g;
- $self->{version} = "2.3.9";
+ $self->{version} = "2.4-RC1";
$main::lxdebug->leave_sub();
@@ -219,6 +219,25 @@ sub unquote {
}
+sub quote_html {
+ $main::lxdebug->enter_sub(2);
+
+ my ($self, $str) = @_;
+
+ my %replace =
+ ('order' => ['"', '<', '>'],
+ '<' => '<',
+ '>' => '>',
+ '"' => '"',
+ );
+
+ map({ $str =~ s/$_/$replace{$_}/g; } @{ $replace{"order"} });
+
+ $main::lxdebug->leave_sub(2);
+
+ return $str;
+}
+
sub hide_form {
my $self = shift;
@@ -404,6 +423,7 @@ function fokus(){document.$self->{fokus}.focus();}
$jsscript
$ajax
$fokus
+
@@ -635,24 +655,29 @@ sub format_amount {
$main::lxdebug->enter_sub(2);
my ($self, $myconfig, $amount, $places, $dash) = @_;
+
+ if ($amount eq "") {
+ $amount = 0;
+ }
my $neg = ($amount =~ s/-//);
$amount = $self->round_amount($amount, $places) if ($places =~ /\d/);
my @d = map { s/\d//g; reverse split // } my $tmp = $myconfig->{numberformat}; # get delim chars
- my @p = split /\./, $amount ; # split amount at decimal point
+ my @p = split(/\./, $amount); # split amount at decimal point
$p[0] =~ s/\B(?=(...)*$)/$d[1]/g if $d[1]; # add 1,000 delimiters
$amount = $p[0];
$amount .= $d[0].$p[1].(0 x ($places - length $p[1])) if ($places || $p[1] ne '');
-
+
$amount = do {
($dash =~ /-/) ? ($neg ? "($amount)" : "$amount" ) :
($dash =~ /DRCR/) ? ($neg ? "$amount DR" : "$amount CR" ) :
($neg ? "-$amount" : "$amount" ) ;
};
-
+
+
$main::lxdebug->leave_sub(2);
return $amount;
}
@@ -1610,40 +1635,47 @@ sub create_links {
my ($query, $sth);
my $dbh = $self->dbconnect($myconfig);
-
my %xkeyref = ();
- # now get the account numbers
- $query = qq|SELECT c.accno, c.description, c.link, c.taxkey_id
- FROM chart c
- WHERE c.link LIKE '%$module%'
- ORDER BY c.accno|;
-
- $sth = $dbh->prepare($query);
- $sth->execute || $self->dberror($query);
-
- $self->{accounts} = "";
- while (my $ref = $sth->fetchrow_hashref(NAME_lc)) {
-
- foreach my $key (split /:/, $ref->{link}) {
- if ($key =~ /$module/) {
+ if (!$self->{id}) {
- # cross reference for keys
- $xkeyref{ $ref->{accno} } = $key;
-
- push @{ $self->{"${module}_links"}{$key} },
- { accno => $ref->{accno},
- description => $ref->{description},
- taxkey => $ref->{taxkey_id} };
-
- $self->{accounts} .= "$ref->{accno} " unless $key =~ /tax/;
+ my $transdate = "current_date";
+ if ($self->{transdate}) {
+ $transdate = qq|'$self->{transdate}'|;
+ }
+
+ # now get the account numbers
+ $query = qq|SELECT c.accno, c.description, c.link, c.taxkey_id, tk.tax_id
+ FROM chart c, taxkeys tk
+ WHERE c.link LIKE '%$module%' AND c.id=tk.chart_id AND tk.id = (SELECT id from taxkeys where taxkeys.chart_id =c.id AND startdate<=$transdate ORDER BY startdate desc LIMIT 1)
+ ORDER BY c.accno|;
+
+ $sth = $dbh->prepare($query);
+ $sth->execute || $self->dberror($query);
+
+ $self->{accounts} = "";
+ while (my $ref = $sth->fetchrow_hashref(NAME_lc)) {
+
+ foreach my $key (split(/:/, $ref->{link})) {
+ if ($key =~ /$module/) {
+
+ # cross reference for keys
+ $xkeyref{ $ref->{accno} } = $key;
+
+ push @{ $self->{"${module}_links"}{$key} },
+ { accno => $ref->{accno},
+ description => $ref->{description},
+ taxkey => $ref->{taxkey_id},
+ tax_id => $ref->{tax_id} };
+
+ $self->{accounts} .= "$ref->{accno} " unless $key =~ /tax/;
+ }
}
}
}
- $sth->finish;
# get taxkeys and description
- $query = qq|SELECT taxkey, taxdescription
+ $query = qq|SELECT id, taxkey, taxdescription
FROM tax|;
$sth = $dbh->prepare($query);
$sth->execute || $self->dberror($query);
@@ -1705,14 +1737,50 @@ sub create_links {
}
$sth->finish;
+
+ my $transdate = "current_date";
+ if ($self->{transdate}) {
+ $transdate = qq|'$self->{transdate}'|;
+ }
+
+ # now get the account numbers
+ $query = qq|SELECT c.accno, c.description, c.link, c.taxkey_id, tk.tax_id
+ FROM chart c, taxkeys tk
+ WHERE c.link LIKE '%$module%' AND (((tk.chart_id=c.id) AND NOT(c.link like '%_tax%')) OR (NOT(tk.chart_id=c.id) AND (c.link like '%_tax%'))) AND (((tk.id = (SELECT id from taxkeys where taxkeys.chart_id =c.id AND startdate<=$transdate ORDER BY startdate desc LIMIT 1)) AND NOT(c.link like '%_tax%')) OR (c.link like '%_tax%'))
+ ORDER BY c.accno|;
+
+ $sth = $dbh->prepare($query);
+ $sth->execute || $self->dberror($query);
+
+ $self->{accounts} = "";
+ while (my $ref = $sth->fetchrow_hashref(NAME_lc)) {
+
+ foreach my $key (split(/:/, $ref->{link})) {
+ if ($key =~ /$module/) {
+
+ # cross reference for keys
+ $xkeyref{ $ref->{accno} } = $key;
+
+ push @{ $self->{"${module}_links"}{$key} },
+ { accno => $ref->{accno},
+ description => $ref->{description},
+ taxkey => $ref->{taxkey_id},
+ tax_id => $ref->{tax_id} };
+
+ $self->{accounts} .= "$ref->{accno} " unless $key =~ /tax/;
+ }
+ }
+ }
+
+
# get amounts from individual entries
$query = qq|SELECT c.accno, c.description, a.source, a.amount, a.memo,
- a.transdate, a.cleared, a.project_id, p.projectnumber, a.taxkey, t.rate
+ a.transdate, a.cleared, a.project_id, p.projectnumber, a.taxkey, t.rate, t.id
FROM acc_trans a
JOIN chart c ON (c.id = a.chart_id)
LEFT JOIN project p ON (p.id = a.project_id)
- LEFT Join tax t ON (a.taxkey = t.taxkey)
- WHERE a.trans_id = $self->{id}
+ LEFT JOIN tax t ON (t.id=(SELECT tk.tax_id from taxkeys tk WHERE (tk.taxkey_id=a.taxkey) AND ((CASE WHEN a.chart_id IN (SELECT chart_id FROM taxkeys WHERE taxkey_id=a.taxkey) THEN tk.chart_id=a.chart_id ELSE 1=1 END) OR (c.link='%tax%')) AND startdate <=a.transdate ORDER BY startdate DESC LIMIT 1))
+ WHERE a.trans_id = $self->{id}
AND a.fx_transaction = '0'
ORDER BY a.oid,a.transdate|;
$sth = $dbh->prepare($query);
@@ -1741,8 +1809,8 @@ sub create_links {
push @{ $self->{acc_trans}{ $xkeyref{ $ref->{accno} } } }, $ref;
}
- $sth->finish;
+ $sth->finish;
$query = qq|SELECT d.curr AS currencies, d.closedto, d.revtrans,
(SELECT c.accno FROM chart c
WHERE d.fxgain_accno_id = c.id) AS fxgain_accno,
@@ -1776,7 +1844,7 @@ sub create_links {
if ($self->{"$self->{vc}_id"}) {
# only setup currency
- ($self->{currency}) = split /:/, $self->{currencies};
+ ($self->{currency}) = split(/:/, $self->{currencies});
} else {
@@ -1793,6 +1861,8 @@ sub create_links {
}
+ $sth->finish;
+
$dbh->disconnect;
$main::lxdebug->leave_sub();