- if ( $done_Y and not $done_N ) {
- push @search, "cust_event.no_action IS NULL";
- } elsif ( $done_N and not $done_Y ) {
- push @search, "cust_event.no_action = 'Y'";
- } # else they're both true, so don't add a constraint, or both false,
- # and it doesn't matter.
+ # done_S status should include only those where statustext is not null,
+ # and done_Y should include only those where it is.
+ if ( $done_Y and $done_N and $done_S ) {
+ # then not necessary
+ } else {
+ my @done_status;
+ if ( $done_Y ) {
+ push @done_status, "(cust_event.no_action IS NULL AND cust_event.statustext IS NULL)";
+ }
+ if ( $done_N ) {
+ push @done_status, "(cust_event.no_action = 'Y')";
+ }
+ if ( $done_S ) {
+ push @done_status, "(cust_event.no_action IS NULL AND cust_event.statustext IS NOT NULL)";
+ }
+ push @search, join(' OR ', @done_status) if @done_status;
+ }