+      push @bind_vars,    $value;
+    }
+  }
+
+  # special case smart search
+  if ($form->{all}) {
+    $form->{"l_$_"} = 1 for qw(partnumber description unit sellprice lastcost cvar_packaging linetotal);
+    push @where_tokens, "p.partnumber ILIKE ? OR p.description ILIKE ?";
+    push @bind_vars,    "%$form->{all}%", "%$form->{all}%";
+  }
+
+  # special case insertdate
+  if (grep { trim($form->{$_}) } qw(insertdatefrom insertdateto)) {
+    $form->{"l_insertdate"} = 1;
+    push @select_tokens, 'insertdate';
+
+    my $token_builder = $make_token_builder->();
+    my $token = $token_builder->('insertdate');
+
+    for (qw(insertdatefrom insertdateto)) {
+      my $value = trim($form->{$_});
+      next unless $value;
+      push @where_tokens, sprintf "$token %s ?", /from$/ ? '>=' : '<=';
+      push @bind_vars,    $value;