+ return \@res;
+}
+
+sub tasklist
+{
+ my $customer = shift;
+ my @res;
+
+ my $query = q{SELECT DISTINCT task FROM stempel WHERE start > now() - interval '1 month' AND customer = ? ORDER BY task};
+ my $sth = $dbh->prepare($query);
+ if ($sth && $sth->execute($customer) > 0) {
+ while ((my $row = $sth->fetchrow_hashref)) {
+ push @res, $row->{task};
+ }
+ }
+ return \@res;
+}
+
+sub complete_customer
+{
+ my ($customer, $text, $line, $start) = @_;
+
+ # return () unless exists $answers->{category} && length $answers->{category};
+
+ my $sql = sprintf("SELECT DISTINCT task FROM stempel WHERE start > now() - interval '1 month' AND customer = '%s' AND task LIKE '%s%%' ORDER BY task",
+ $customer,
+ $line);
+
+ my $sth = $dbh->prepare($sql);
+ $sth->execute;
+ my @complete;
+ while (my $row = $sth->fetchrow_hashref) {
+ $row->{task} = substr $row->{task}, $start if $start;
+ push @complete, $row->{task};
+ }
+
+ return @complete;