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;
+}
+
sub open_task
{
my $term = new Term::ReadLine '';
my $customers = customerlist;
- $term->addhistory($_) foreach (@$customers);
-
my $attribs = $term->Attribs;
$attribs->{completion_entry_function} = $attribs->{list_completion_function};
$attribs->{completion_word} = $customers;
$term->addhistory($_) foreach (@$tasks);
$attribs->{completion_word} = $tasks;
+ $attribs->{completion_entry_function} = undef;
+ $term->{completion_function} = sub {return complete_customer $customer, @_};
while (1) {
my $task = $term->readline ('Aufgabe: ');
return unless length $task;