X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=httemplate%2Fbrowse%2Fpart_svc.cgi;h=dee439466f43b544436aa2e92e55cea0c1398081;hb=46d8aa8b9d1fc12af33bb8b517301789f871d864;hp=ec5f321dda975ad33731841fbe2b86d34a583e30;hpb=4fda726fa9f8e709c68ec823edc5ae702723281c;p=freeside.git
diff --git a/httemplate/browse/part_svc.cgi b/httemplate/browse/part_svc.cgi
index ec5f321dd..dee439466 100755
--- a/httemplate/browse/part_svc.cgi
+++ b/httemplate/browse/part_svc.cgi
@@ -119,9 +119,13 @@ function part_export_areyousure(href) {
<% $svcdb %>
CLASS="grid" BGCOLOR="<% $bgcolor %>">
- <% $num_active_cust_svc{$part_svc->svcpart} %> <% $num_active_cust_svc{$part_svc->svcpart} ? svc_url( 'ahref' => 1, 'm' => $m, 'action' => 'search', 'part_svc' => $part_svc, 'query' => "svcpart=". $part_svc->svcpart ) : '' %>active
-
-% if ( $num_active_cust_svc{$part_svc->svcpart} ) {
+% my $svcurl_active = svc_url( 'ahref' => 1, 'm' => $m, 'action' => 'search', 'part_svc' => $part_svc, 'query' => "svcpart=". $part_svc->svcpart . "&cancelled=0");
+% my $svcurl_cancel = svc_url( 'ahref' => 1, 'm' => $m, 'action' => 'search', 'part_svc' => $part_svc, 'query' => "svcpart=". $part_svc->svcpart . "&cancelled=1");
+ <% $num_cust_svc_active{$part_svc->svcpart} %> <% $num_cust_svc_active{$part_svc->svcpart} ? $svcurl_active : '' %>active<% $num_cust_svc_active{$part_svc->svcpart} ? '' : '' %>
+% if ( $num_cust_svc_cancelled{$part_svc->svcpart} ) {
+ <% $num_cust_svc_cancelled{$part_svc->svcpart} %> <% $svcurl_cancel %>cancelled
+% }
+% if ( $num_cust_svc{$part_svc->svcpart} ) {
[ change ]
% }
@@ -161,7 +165,7 @@ function part_export_areyousure(href) {
% }
%
% my($n1)='';
-% foreach my $field ( @fields ) {
+% foreach my $field ( sort @fields ) {
%
% #a few lines of false laziness w/edit/part_svc.cgi
% my $def = FS::part_svc->svc_table_fields($svcdb)->{$field};
@@ -245,11 +249,25 @@ my @part_svc =
qsearch('part_svc', \%search );
my $total = scalar(@part_svc);
-my %num_active_cust_svc = map { $_->svcpart => $_->num_cust_svc } @part_svc;
+## The Active/Cancelled distinction is a bit awkward,
+## active currently includes unattached and suspended services,
+## but we've previously referred to EVERY existing cust_svc as "Active",
+## and we don't really want to know numbers by individual package status,
+## so for now the UI will distinguish these as "Active" and "Cancelled",
+## but please let's not go so far as to introduce the idea of "Service Status"
+
+my %num_cust_svc_active;
+my %num_cust_svc_cancelled;
+my %num_cust_svc;
+foreach my $part_svc (@part_svc) {
+ $num_cust_svc{$part_svc->svcpart} = $part_svc->num_cust_svc;
+ $num_cust_svc_cancelled{$part_svc->svcpart} = $part_svc->num_cust_svc_cancelled;
+ $num_cust_svc_active{$part_svc->svcpart} = $num_cust_svc{$part_svc->svcpart} - $num_cust_svc_cancelled{$part_svc->svcpart};
+}
if ( $cgi->param('orderby') eq 'active' ) {
- @part_svc = sort { $num_active_cust_svc{$b->svcpart} <=>
- $num_active_cust_svc{$a->svcpart} } @part_svc;
+ @part_svc = sort { $num_cust_svc{$b->svcpart} <=>
+ $num_cust_svc{$a->svcpart} } @part_svc;
} elsif ( $cgi->param('orderby') eq 'svc' ) {
@part_svc = sort { lc($a->svc) cmp lc($b->svc) } @part_svc;
}
|