X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=httemplate%2Fbrowse%2Fpart_svc.cgi;h=ef0de13cccd3c1d8bfd61d4100409eaff25dbf5a;hb=dc91892bd1c4567013bbaf11dcb0c6064899a357;hp=c66b8ac631b3ab91292ed7ef7145f2889b373a83;hpb=b159f42fa3f48cc2ca3b43773e7661e17d2fb072;p=freeside.git
diff --git a/httemplate/browse/part_svc.cgi b/httemplate/browse/part_svc.cgi
index c66b8ac63..ef0de13cc 100755
--- a/httemplate/browse/part_svc.cgi
+++ b/httemplate/browse/part_svc.cgi
@@ -8,9 +8,25 @@ if ( $cgi->param('showdisabled') ) {
%search = ( 'disabled' => '' );
}
-my @part_svc = qsearch('part_svc', \%search );
+my @part_svc =
+ sort { $a->getfield('svcpart') <=> $b->getfield('svcpart') }
+ qsearch('part_svc', \%search );
my $total = scalar(@part_svc);
+my %num_active_cust_svc = ();
+if ( $cgi->param('active') ) {
+ my $active_sth = dbh->prepare(
+ 'SELECT COUNT(*) FROM cust_svc WHERE svcpart = ?'
+ ) or die dbh->errstr;
+ foreach my $part_svc ( @part_svc ) {
+ $active_sth->execute($part_svc->svcpart) or die $active_sth->errstr;
+ $num_active_cust_svc{$part_svc->svcpart} =
+ $active_sth->fetchrow_arrayref->[0];
+ }
+ @part_svc = sort { $num_active_cust_svc{$b->svcpart} <=>
+ $num_active_cust_svc{$a->svcpart} } @part_svc;
+}
+
%>
<%= header('Service Definition Listing', menubar( 'Main Menu' => $p) ) %>
@@ -21,8 +37,18 @@ function part_export_areyousure(href) {
}
- Services are items you offer to your customers.
-<%= $total %> services
+ Service definitions are the templates for items you offer to your customers.
+
+
+
+<%= $total %> service definitions
<%= $cgi->param('showdisabled')
? do { $cgi->param('showdisabled', 0);
'( hide disabled services )'; }
@@ -33,21 +59,25 @@ function part_export_areyousure(href) {
param('showdisabled') ? 2 : 3 %>>Service |
Table |
+<% if ( $cgi->param('active') ) { %>
+ Customer Services |
+<% } %>
Export |
Field |
Modifier |
-<% foreach my $part_svc ( sort {
- $a->getfield('svcpart') <=> $b->getfield('svcpart')
- } @part_svc ) {
- my($hashref)=$part_svc->hashref;
- my($svcdb)=$hashref->{svcdb};
+<% foreach my $part_svc ( @part_svc ) {
+ my $hashref = $part_svc->hashref;
+ my $svcdb = $hashref->{svcdb};
+ my $svc_x = "FS::$svcdb"->new( { svcpart => $part_svc->svcpart } );
+ my @dfields = $svc_x->fields;
+ push @dfields, 'usergroup' if $svcdb eq 'svc_acct'; #kludge
my @fields =
- grep { $_ ne 'svcnum' && $part_svc->part_svc_column($_)->columnflag }
- fields($svcdb);
-
- my($rowspan)=scalar(@fields) || 1;
+ grep { $svc_x->pvf($_)
+ or $_ ne 'svcnum' && $part_svc->part_svc_column($_)->columnflag }
+ @dfields ;
+ my $rowspan = scalar(@fields) || 1;
my $url = "${p}edit/part_svc.cgi?$hashref->{svcpart}";
%>
@@ -62,37 +92,23 @@ function part_export_areyousure(href) {
<%= $hashref->{svc} %>
>
<%= $hashref->{svcdb} %> |
+<% if ( $cgi->param('active') ) { %>
+ >
+ <%= $num_active_cust_svc{$hashref->{svcpart}} %> active
+ |
+<% } %>
><%= itable() %>
<%
- my @part_export = qsearch('part_export', { svcpart => $part_svc->svcpart } );
- foreach my $part_export ( @part_export ) {
+# my @part_export =
+map { qsearchs('part_export', { exportnum => $_->exportnum } ) } qsearch('export_svc', { svcpart => $part_svc->svcpart } ) ;
+ foreach my $part_export (
+ map { qsearchs('part_export', { exportnum => $_->exportnum } ) }
+ qsearch('export_svc', { svcpart => $part_svc->svcpart } )
+ ) {
%>
|
- <%= $part_export->exporttype %> to <%= $part_export->machine %> (edit | delete) |
-
- <%= itable() %>
- <% my %opt = $part_export->options;
- foreach my $opt ( keys %opt ) { %>
- |
<%= $opt %> | <%= $opt{$opt} %> |
- <% } %>
-
-
+ <%= $part_export->exportnum %>: <%= $part_export->exporttype %> to <%= $part_export->machine %> |
<% } %>
- Add a new export |
-<% if (@part_export) { %>
-
- |
-<% } %>
<% my($n1)='';
@@ -103,6 +119,7 @@ function part_export_areyousure(href) {
<% if ( $flag eq "D" ) { print "Default"; }
elsif ( $flag eq "F" ) { print "Fixed"; }
+ elsif ( not $flag ) { }
else { print "(Unknown!)"; }
%>
<%= $part_svc->part_svc_column($field)->columnvalue%> |
@@ -111,10 +128,6 @@ function part_export_areyousure(href) {
%>
<% } %>
-
-
- param('showdisabled') ? 7 : 8 %>>Add a new service definition |
-