sub close_task
{
+ my $really = shift;
my ($d_sec,$d_min,$d_hour,$d_mday,$d_mon,$d_year,$d_wday,$d_isdst) = localtime();
+ my $today = 1;
my $query = q{SELECT oid,start FROM stempel WHERE stop IS NULL};
my $sth = $dbh->prepare ($query);
my @d = split(/-/, $arr[0]);
if ($d[0] != $d_year+1900 || $d[1] != $d_mon+1 || $d[2] != $d_mday) {
- printf "Task not started today, aborting.\n";
- next;
+ if ($really) {
+ printf "Task not started today.\n";
+ $today = 0;
+ } else {
+ printf "Task not started today, aborting, use -D if this is intentional.\n";
+ next;
+ }
}
my @t = split(/:/, $arr[1]);
my $int = quarter(hdiff($t[0], $t[1], $d_hour, $d_min));
+ $int += 24 * 60 unless $today;
$query = sprintf('UPDATE stempel SET stop=now(),time=%d WHERE oid = %d',
$int, $row->{oid});
my $exit = shift;
my ($d_sec,$d_min,$d_hour,$d_mday,$d_mon,$d_year,$d_wday,$d_isdst) = localtime();
my $query = q{SELECT customer,start,task FROM stempel WHERE time IS NULL ORDER BY start,customer};
+ my $today = 1;
my $sth = $dbh->prepare ($query);
if ($sth && $sth->execute > 0) {
if ($d[0] != $d_year+1900 || $d[1] != $d_mon+1 || $d[2] != $d_mday) {
printf "Task not started today.\n";
- next if $exit eq 1;
+ $today = 0;
+ next if defined $exit && $exit eq 1;
}
my @t = split(/:/, $arr[1]);
my $time = sprintf('%02d:%02d', $t[0], $t[1]);
my $int = quarter(hdiff($t[0], $t[1], $d_hour, $d_min));
+ $int += 24 * 60 unless $today;
printf "%-15s %s %s (%s) %s\n", $row->{customer}, $day, $time, min2hour($int), $row->{task};
}
--close time close open task
--help this text
--end|-d terminate task
+ -D terminate task not started today
--delete delete open task
--reopen re-open last task
--task alter task content
'reopen' => \&reopen_task,
'task|t' => \&alter_task,
'terminate|end|d' => \&close_task,
+ 'D' => sub {close_task(1);},
);
GetOptions %options;