Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 3aaf323a

Von Stephan Köhler vor etwa 19 Jahren hinzugefügt

  • ID 3aaf323a185bff9ff15d5384122b5600e969080f
  • Vorgänger b3db3071
  • Nachfolger 383022ae

Merge von 583 aus unstable:
format_amount an die neue round_amount angepasst, so dass wieder nachkommstellen ausgegeben werden
ein paar sachen aus sql-ledger eingefuegt

Unterschiede anzeigen:

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 =~ /-/) {
......
587 626
  return $rc;
588 627
}
589 628

  
629

  
630

  
590 631
sub parse_template {
591 632
  $main::lxdebug->enter_sub();
592 633

  
......
2083 2124
  $main::lxdebug->leave_sub();
2084 2125
}
2085 2126

  
2127

  
2128
sub audittrail {
2129
  my ($self, $dbh, $myconfig, $audittrail) = @_;
2130
  
2131
# table, $reference, $formname, $action, $id, $transdate) = @_;
2132

  
2133
  my $query;
2134
  my $rv;
2135
  my $disconnect;
2136

  
2137
  if (! $dbh) {
2138
    $dbh = $self->dbconnect($myconfig);
2139
    $disconnect = 1;
2140
  }
2141
    
2142
  # if we have an id add audittrail, otherwise get a new timestamp
2143
  
2144
  if ($audittrail->{id}) {
2145
    
2146
    $query = qq|SELECT audittrail FROM defaults|;
2147
    
2148
    if ($dbh->selectrow_array($query)) {
2149
      my ($null, $employee_id) = $self->get_employee($dbh);
2150

  
2151
      if ($self->{audittrail} && !$myconfig) {
2152
	chop $self->{audittrail};
2153
	
2154
	my @a = split /\|/, $self->{audittrail};
2155
	my %newtrail = ();
2156
	my $key;
2157
	my $i;
2158
	my @flds = qw(tablename reference formname action transdate);
2159

  
2160
	# put into hash and remove dups
2161
	while (@a) {
2162
	  $key = "$a[2]$a[3]";
2163
	  $i = 0;
2164
	  $newtrail{$key} = { map { $_ => $a[$i++] } @flds };
2165
	  splice @a, 0, 5;
2166
	}
2167
	
2168
	$query = qq|INSERT INTO audittrail (trans_id, tablename, reference,
2169
		    formname, action, employee_id, transdate)
2170
	            VALUES ($audittrail->{id}, ?, ?,
2171
		    ?, ?, $employee_id, ?)|;
2172
	my $sth = $dbh->prepare($query) || $self->dberror($query);
2173

  
2174
	foreach $key (sort { $newtrail{$a}{transdate} cmp $newtrail{$b}{transdate} } keys %newtrail) {
2175
	  $i = 1;
2176
	  for (@flds) { $sth->bind_param($i++, $newtrail{$key}{$_}) }
2177

  
2178
	  $sth->execute || $self->dberror;
2179
	  $sth->finish;
2180
	}
2181
      }
2182

  
2183
     
2184
      if ($audittrail->{transdate}) {
2185
	$query = qq|INSERT INTO audittrail (trans_id, tablename, reference,
2186
		    formname, action, employee_id, transdate) VALUES (
2187
		    $audittrail->{id}, '$audittrail->{tablename}', |
2188
		    .$dbh->quote($audittrail->{reference}).qq|',
2189
		    '$audittrail->{formname}', '$audittrail->{action}',
2190
		    $employee_id, '$audittrail->{transdate}')|;
2191
      } else {
2192
	$query = qq|INSERT INTO audittrail (trans_id, tablename, reference,
2193
		    formname, action, employee_id) VALUES ($audittrail->{id},
2194
		    '$audittrail->{tablename}', |
2195
		    .$dbh->quote($audittrail->{reference}).qq|,
2196
		    '$audittrail->{formname}', '$audittrail->{action}',
2197
		    $employee_id)|;
2198
      }
2199
      $dbh->do($query);
2200
    }
2201
  } else {
2202
    
2203
    $query = qq|SELECT current_timestamp FROM defaults|;
2204
    my ($timestamp) = $dbh->selectrow_array($query);
2205

  
2206
    $rv = "$audittrail->{tablename}|$audittrail->{reference}|$audittrail->{formname}|$audittrail->{action}|$timestamp|";
2207
  }
2208

  
2209
  $dbh->disconnect if $disconnect;
2210
  
2211
  $rv;
2212
  
2213
}
2214

  
2086 2215
package Locale;
2087 2216

  
2088 2217
sub new {

Auch abrufbar als: Unified diff