( select count(*) from cust_pkg
where cust_main.custnum = cust_pkg.custnum
and $recurring
- and cancel = 0 or cancel is null
+ and ( cancel = 0 or cancel is null )
) as uncancelled_pkgs,
( select count(*) from cust_pkg
where cust_main.custnum = cust_pkg.custnum
and $recurring
- and cancel = 0 or cancel is null
- and susp = 0 or susp is null
+ and ( cancel = 0 or cancel is null )
+ and ( susp = 0 or susp is null )
) as active_pkgs
END
,0
)
-order by lower(company), lower(last)
+order by coalesce(lower(company), ''), lower(last)
END
if ( $row->{uncancelled_pkgs} ) {
$status = 'Suspended';
$statuscol = 'FF9900';
- if ( $row->{active_pkgs} > $row->{uncancelled_pkgs} ) {
+ if ( $row->{active_pkgs} ) {
$status = 'Active';
$statuscol = '00CC00';
}
}
%>
<TR>
- <TD><A HREF="<%= $p %>view/cust_main.cgi?<%= $row->{'custnum'} %>">
+ <TD><A HREF="<%= $p %>view/cust_main.cgi?<%= $row->{'custnum'} %>"><%= $row->{'custnum'} %>:
<%= $row->{'company'} ? $row->{'company'}. ' (' : '' %><%= $row->{'last'}. ', '. $row->{'first'} %><%= $row->{'company'} ? ')' : '' %></A>
</TD>
<TD><B><FONT SIZE=-1 COLOR="#<%= $statuscol %>"><%= $status %></FONT></B></TD>