Revision 7848e9c8
Von Udo Spallek vor etwa 18 Jahren hinzugefügt
SL/Form.pm | ||
---|---|---|
2413 | 2413 |
|
2414 | 2414 |
} |
2415 | 2415 |
|
2416 |
|
|
2417 |
sub all_years { |
|
2418 |
# usage $form->all_years($myconfig, [$dbh]) |
|
2419 |
# return list of all years where bookings found |
|
2420 |
# (@all_years) |
|
2421 |
|
|
2422 |
$main::lxdebug->enter_sub(); |
|
2423 |
|
|
2424 |
my ($self, $myconfig, $dbh) = @_; |
|
2425 |
|
|
2426 |
my $disconnect = 0; |
|
2427 |
if (! $dbh) { |
|
2428 |
$dbh = $self->dbconnect($myconfig); |
|
2429 |
$disconnect = 1; |
|
2430 |
} |
|
2431 |
|
|
2432 |
# get years |
|
2433 |
my $query = qq|SELECT (SELECT MIN(transdate) FROM acc_trans), |
|
2434 |
(SELECT MAX(transdate) FROM acc_trans) |
|
2435 |
FROM defaults|; |
|
2436 |
my ($startdate, $enddate) = $dbh->selectrow_array($query); |
|
2437 |
|
|
2438 |
if ($myconfig->{dateformat} =~ /^yy/) { |
|
2439 |
($startdate) = split /\W/, $startdate; |
|
2440 |
($enddate) = split /\W/, $enddate; |
|
2441 |
} else { |
|
2442 |
(@_) = split /\W/, $startdate; |
|
2443 |
$startdate = $_[2]; |
|
2444 |
(@_) = split /\W/, $enddate; |
|
2445 |
$enddate = $_[2]; |
|
2446 |
} |
|
2447 |
|
|
2448 |
my @all_years; |
|
2449 |
$startdate = substr($startdate,0,4); |
|
2450 |
$enddate = substr($enddate,0,4); |
|
2451 |
|
|
2452 |
while ($enddate >= $startdate) { |
|
2453 |
push @all_years, $enddate--; |
|
2454 |
} |
|
2455 |
|
|
2456 |
$dbh->disconnect if $disconnect; |
|
2457 |
|
|
2458 |
return @all_years; |
|
2459 |
|
|
2460 |
$main::lxdebug->leave_sub(); |
|
2461 |
} |
|
2462 |
|
|
2463 |
|
|
2416 | 2464 |
1; |
Auch abrufbar als: Unified diff
sub all_years hinzugefuegt. Gibt alle Jahreszahlen als List aus, in denen Buchungen stattgefunden haben.
Sinnvoll für Datumsauswahl von Reports, es werden nur Jahre zur Auswahl gestellt,
in denen tatsaechlich Buchungsdaten vorliegen