my $verbose = shift;
my ($d_sec,$d_min,$d_hour,$d_mday,$d_mon,$d_year,$d_wday,$d_isdst) = localtime();
my $query = q{SELECT start::date,to_char(start, 'HH24:MI') AS starttime,customer,time,task FROM stempel WHERE time IS NOT NULL };
+ my $display_sum = 0;
+ my $sum = 0;
if ($month =~ /^(\d{4})-?(\d\d?)$/) {
my $pivot = $1 . '-' . $2 . '-01';
$query .= "AND start >= '$pivot' AND start <= '$pivot'::date + interval '1 month' ";
} elsif (length $month && $month eq 'today') {
$query .= "AND start::date = now()::date ";
+ $display_sum = 1;
} elsif (length $month && $month =~ /^yester(day)?$/) {
$query .= "AND start::date = (now() - interval '1 day')::date ";
+ $display_sum = 1;
} elsif (length $month && $month !~ /^(all|current)$/) {
$query .= "AND task LIKE '%${month}%' ";
+ $display_sum = 1;
} elsif ($month !~ /^all$/ || $month eq 'current') {
my $pivot = sprintf('%04d-%02d-01', $d_year+1900, $d_mon+1);
$query .= "AND start >= '$pivot' AND start <= '$pivot'::date + interval '1 month' ";
$color++;
}
}
+ $sum += $row->{time};
my $time = min2hour $row->{time};
print color($colors[$color]) if -t STDOUT;
printf "%-15s %s %s %s", $row->{customer}, $row->{start}.($verbose ? ' '.$row->{starttime} : ''), $time, $row->{task};
}
}
}
+
+ if ($display_sum) {
+ printf "%-27s %s\n", "Summe", min2hour $sum;
+ }
+
exit 0;
}