Revision f92ef4f2
Von Philip Reetz vor mehr als 19 Jahren hinzugefügt
SL/Form.pm | ||
---|---|---|
192 | 192 |
return $str; |
193 | 193 |
} |
194 | 194 |
|
195 |
sub quote { |
|
196 |
my ($self, $str) = @_; |
|
197 |
|
|
198 |
if ($str && ! ref($str)) { |
|
199 |
$str =~ s/"/"/g; |
|
200 |
} |
|
201 |
|
|
202 |
$str; |
|
203 |
|
|
204 |
} |
|
205 |
|
|
206 |
|
|
207 |
sub unquote { |
|
208 |
my ($self, $str) = @_; |
|
209 |
|
|
210 |
if ($str && ! ref($str)) { |
|
211 |
$str =~ s/"/"/g; |
|
212 |
} |
|
213 |
|
|
214 |
$str; |
|
215 |
|
|
216 |
} |
|
217 |
|
|
218 |
|
|
219 |
sub hide_form { |
|
220 |
my $self = shift; |
|
221 |
|
|
222 |
if (@_) { |
|
223 |
for (@_) { print qq|<input type=hidden name="$_" value="|.$self->quote($self->{$_}).qq|">\n| } |
|
224 |
} else { |
|
225 |
delete $self->{header}; |
|
226 |
for (sort keys %$self) { print qq|<input type=hidden name="$_" value="|.$self->quote($self->{$_}).qq|">\n| } |
|
227 |
} |
|
228 |
|
|
229 |
} |
|
230 |
|
|
195 | 231 |
sub error { |
196 | 232 |
$main::lxdebug->enter_sub(); |
197 | 233 |
|
... | ... | |
348 | 384 |
<script type="text/javascript" src="js/jscalendar/calendar.js"></script> |
349 | 385 |
? <script type="text/javascript" src="js/jscalendar/lang/calendar-de.js"></script> |
350 | 386 |
? <script type="text/javascript" src="js/jscalendar/calendar-setup.js"></script> |
387 |
$self->{javascript} |
|
351 | 388 |
|; |
352 | 389 |
} |
353 | 390 |
|
... | ... | |
489 | 526 |
|
490 | 527 |
# is the amount negative |
491 | 528 |
my $negative = ($amount < 0); |
529 |
my $fillup = ""; |
|
492 | 530 |
|
493 | 531 |
if ($amount != 0) { |
494 | 532 |
if ($myconfig->{numberformat} && ($myconfig->{numberformat} ne '1000.00')) |
... | ... | |
496 | 534 |
my ($whole, $dec) = split /\./, "$amount"; |
497 | 535 |
$whole =~ s/-//; |
498 | 536 |
$amount = join '', reverse split //, $whole; |
537 |
$fillup = "0" x ($places - length($dec)); |
|
499 | 538 |
|
500 | 539 |
if ($myconfig->{numberformat} eq '1,000.00') { |
501 | 540 |
$amount =~ s/\d{3,}?/$&,/g; |
502 | 541 |
$amount =~ s/,$//; |
503 | 542 |
$amount = join '', reverse split //, $amount; |
504 |
$amount .= "\.$dec" if ($dec ne "");
|
|
543 |
$amount .= "\.$dec".$fillup;
|
|
505 | 544 |
} |
506 | 545 |
|
507 | 546 |
if ($myconfig->{numberformat} eq '1.000,00') { |
508 | 547 |
$amount =~ s/\d{3,}?/$&./g; |
509 | 548 |
$amount =~ s/\.$//; |
510 | 549 |
$amount = join '', reverse split //, $amount; |
511 |
$amount .= ",$dec" if ($dec ne "");
|
|
550 |
$amount .= ",$dec" .$fillup;
|
|
512 | 551 |
} |
513 | 552 |
|
514 | 553 |
if ($myconfig->{numberformat} eq '1000,00') { |
515 | 554 |
$amount = "$whole"; |
516 |
$amount .= ",$dec" if ($dec ne "");
|
|
555 |
$amount .= ",$dec" .$fillup;
|
|
517 | 556 |
} |
518 | 557 |
|
519 | 558 |
if ($dash =~ /-/) { |
... | ... | |
581 | 620 |
return $round_amount; |
582 | 621 |
} |
583 | 622 |
|
623 |
|
|
624 |
|
|
584 | 625 |
sub parse_template { |
585 | 626 |
$main::lxdebug->enter_sub(); |
586 | 627 |
|
... | ... | |
2037 | 2078 |
$main::lxdebug->leave_sub(); |
2038 | 2079 |
} |
2039 | 2080 |
|
2081 |
|
|
2082 |
sub audittrail { |
|
2083 |
my ($self, $dbh, $myconfig, $audittrail) = @_; |
|
2084 |
|
|
2085 |
# table, $reference, $formname, $action, $id, $transdate) = @_; |
|
2086 |
|
|
2087 |
my $query; |
|
2088 |
my $rv; |
|
2089 |
my $disconnect; |
|
2090 |
|
|
2091 |
if (! $dbh) { |
|
2092 |
$dbh = $self->dbconnect($myconfig); |
|
2093 |
$disconnect = 1; |
|
2094 |
} |
|
2095 |
|
|
2096 |
# if we have an id add audittrail, otherwise get a new timestamp |
|
2097 |
|
|
2098 |
if ($audittrail->{id}) { |
|
2099 |
|
|
2100 |
$query = qq|SELECT audittrail FROM defaults|; |
|
2101 |
|
|
2102 |
if ($dbh->selectrow_array($query)) { |
|
2103 |
my ($null, $employee_id) = $self->get_employee($dbh); |
|
2104 |
|
|
2105 |
if ($self->{audittrail} && !$myconfig) { |
|
2106 |
chop $self->{audittrail}; |
|
2107 |
|
|
2108 |
my @a = split /\|/, $self->{audittrail}; |
|
2109 |
my %newtrail = (); |
|
2110 |
my $key; |
|
2111 |
my $i; |
|
2112 |
my @flds = qw(tablename reference formname action transdate); |
|
2113 |
|
|
2114 |
# put into hash and remove dups |
|
2115 |
while (@a) { |
|
2116 |
$key = "$a[2]$a[3]"; |
|
2117 |
$i = 0; |
|
2118 |
$newtrail{$key} = { map { $_ => $a[$i++] } @flds }; |
|
2119 |
splice @a, 0, 5; |
|
2120 |
} |
|
2121 |
|
|
2122 |
$query = qq|INSERT INTO audittrail (trans_id, tablename, reference, |
|
2123 |
formname, action, employee_id, transdate) |
|
2124 |
VALUES ($audittrail->{id}, ?, ?, |
|
2125 |
?, ?, $employee_id, ?)|; |
|
2126 |
my $sth = $dbh->prepare($query) || $self->dberror($query); |
|
2127 |
|
|
2128 |
foreach $key (sort { $newtrail{$a}{transdate} cmp $newtrail{$b}{transdate} } keys %newtrail) { |
|
2129 |
$i = 1; |
|
2130 |
for (@flds) { $sth->bind_param($i++, $newtrail{$key}{$_}) } |
|
2131 |
|
|
2132 |
$sth->execute || $self->dberror; |
|
2133 |
$sth->finish; |
|
2134 |
} |
|
2135 |
} |
|
2136 |
|
|
2137 |
|
|
2138 |
if ($audittrail->{transdate}) { |
|
2139 |
$query = qq|INSERT INTO audittrail (trans_id, tablename, reference, |
|
2140 |
formname, action, employee_id, transdate) VALUES ( |
|
2141 |
$audittrail->{id}, '$audittrail->{tablename}', | |
|
2142 |
.$dbh->quote($audittrail->{reference}).qq|', |
|
2143 |
'$audittrail->{formname}', '$audittrail->{action}', |
|
2144 |
$employee_id, '$audittrail->{transdate}')|; |
|
2145 |
} else { |
|
2146 |
$query = qq|INSERT INTO audittrail (trans_id, tablename, reference, |
|
2147 |
formname, action, employee_id) VALUES ($audittrail->{id}, |
|
2148 |
'$audittrail->{tablename}', | |
|
2149 |
.$dbh->quote($audittrail->{reference}).qq|, |
|
2150 |
'$audittrail->{formname}', '$audittrail->{action}', |
|
2151 |
$employee_id)|; |
|
2152 |
} |
|
2153 |
$dbh->do($query); |
|
2154 |
} |
|
2155 |
} else { |
|
2156 |
|
|
2157 |
$query = qq|SELECT current_timestamp FROM defaults|; |
|
2158 |
my ($timestamp) = $dbh->selectrow_array($query); |
|
2159 |
|
|
2160 |
$rv = "$audittrail->{tablename}|$audittrail->{reference}|$audittrail->{formname}|$audittrail->{action}|$timestamp|"; |
|
2161 |
} |
|
2162 |
|
|
2163 |
$dbh->disconnect if $disconnect; |
|
2164 |
|
|
2165 |
$rv; |
|
2166 |
|
|
2167 |
} |
|
2168 |
|
|
2040 | 2169 |
package Locale; |
2041 | 2170 |
|
2042 | 2171 |
sub new { |
Auch abrufbar als: Unified diff
format_amount an die neue round_amount angepasst, so dass wieder nachkommstellen ausgegeben werden
ein paar sachen aus sql-ledger eingefuegt