+  # special case insertdate
+  if (grep { $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)) {
+      next unless $form->{$_};
+      push @where_tokens, sprintf "$token %s ?", /from$/ ? '>=' : '<=';
+      push @bind_vars,    $form->{$_};
+    }
+  }
+
+  if ($form->{"partsgroup_id"}) {
+    $form->{"l_partsgroup"} = '1'; # show the column
+    push @where_tokens, "pg.id = ?";
+    push @bind_vars, $form->{"partsgroup_id"};
+  }
+
+  if ($form->{shop} ne '') {
+    $form->{l_shop} = '1'; # show the column
+    if ($form->{shop} eq '0' || $form->{shop} eq 'f') {
+      push @where_tokens, 'NOT p.shop';
+      $form->{shop} = 'f';
+    } else {
+      push @where_tokens, 'p.shop';
+    }
+  }
+