+ #if ( $param->{'failed'} ) {
+ # push @search, "statustext != ''",
+ # "statustext IS NOT NULL",
+ # "statustext != 'N/A'";
+ #}
+ # huh?
+
+ my @event_status = ref($param->{'event_status'})
+ ? @{ $param->{'event_status'} }
+ : split(',', $param->{'event_status'});
+ if ( @event_status ) {
+ my @status;
+
+ my ($done_Y, $done_N, $done_S);
+ # done_Y: action was taken
+ # done_N: action was not taken
+ # done_S: status message returned
+ foreach (@event_status) {
+ if ($_ eq 'done_Y') {
+ $done_Y = 1;
+ } elsif ( $_ eq 'done_N' ) {
+ $done_N = 1;
+ } elsif ( $_ eq 'done_S' ) {
+ $done_S = 1;
+ } else {
+ push @status, $_;
+ }
+ }
+ if ( $done_Y or $done_N or $done_S ) {
+ push @status, 'done';
+ }
+ if ( @status ) {
+ push @search, "cust_event.status IN(" .
+ join(',', map "'$_'", @status) .
+ ')';
+ }
+
+ # 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;
+ }
+
+ } # event_status
+
+ # always hide initialization
+ push @search, 'cust_event.status != \'initial\'';