X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=httemplate%2Fbrowse%2Fpart_svc.cgi;h=805bd88b921762e71615e0a2ab4affe9ed4418aa;hb=9608be1f5c73517fc348f1ab458892b34ed7facb;hp=4c9b1bd957655a05e21a441510f64a015befc79a;hpb=e6ea57971831f25d682d97a0ba508c39b66ecd8b;p=freeside.git diff --git a/httemplate/browse/part_svc.cgi b/httemplate/browse/part_svc.cgi index 4c9b1bd95..805bd88b9 100755 --- a/httemplate/browse/part_svc.cgi +++ b/httemplate/browse/part_svc.cgi @@ -1,6 +1,17 @@ - <% +#code duplication w/ edit/part_svc.cgi, should move this hash to part_svc.pm +my %flag = ( + '' => '', + 'D' => 'Default', + 'F' => 'Fixed (unchangeable)', + #'M' => 'Manual selection from inventory', + 'M' => 'Manual selected from inventory', + #'A' => 'Automatically fill in from inventory', + 'A' => 'Automatically filled in from inventory', + 'X' => 'Excluded', +); + my %search; if ( $cgi->param('showdisabled') ) { %search = (); @@ -8,11 +19,24 @@ 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 = map { $_->svcpart => $_->num_cust_svc } @part_svc; + +if ( $cgi->param('orderby') eq 'active' ) { + @part_svc = sort { $num_active_cust_svc{$b->svcpart} <=> + $num_active_cust_svc{$a->svcpart} } @part_svc; +} elsif ( $cgi->param('orderby') eq 'svc' ) { + @part_svc = sort { lc($a->svc) cmp lc($b->svc) } @part_svc; +} + +my %inventory_class = (); + %> -<%= header('Service Definition Listing', menubar( 'Main Menu' => $p) ) %> +<%= include("/elements/header.html",'Service Definition Listing', menubar( 'Main Menu' => $p) ) %> - Services are items you offer to your customers.

-<%= $total %> services + Service definitions are the templates for items you offer to your customers.

+ +
+Add a new service definition<% if ( @part_svc ) { %> or  +<% } %> +

+ +<%= $total %> service definitions <%= $cgi->param('showdisabled') ? do { $cgi->param('showdisabled', 0); '( hide disabled services )'; } : do { $cgi->param('showdisabled', 1); '( show disabled services )'; } %> +<% $cgi->param('showdisabled', ( 1 ^ $cgi->param('showdisabled') ) ); %> <%= table() %> - param('showdisabled') ? 2 : 3 %>>Service + # + <% if ( $cgi->param('showdisabled') ) { %> + Status + <% } %> + Service Table + 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}; - my @dfields = fields($svcdb); +<% foreach my $part_svc ( @part_svc ) { + my $svcdb = $part_svc->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 } - @dfields; - + 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}"; + my $url = "${p}edit/part_svc.cgi?". $part_svc->svcpart; %> > - <%= $hashref->{svcpart} %> -<% unless ( $cgi->param('showdisabled') ) { %> + <%= $part_svc->svcpart %> +<% if ( $cgi->param('showdisabled') ) { %> > - <%= $hashref->{disabled} ? 'DISABLED' : '' %> + <%= $part_svc->disabled + ? 'Disabled' + : 'Enabled' + %> + <% } %> > - <%= $hashref->{svc} %> + <%= $part_svc->svc %> + > + <%= $svcdb %> > - <%= $hashref->{svcdb} %> + <%= $num_active_cust_svc{$part_svc->svcpart} %> active + <% if ( $num_active_cust_svc{$part_svc->svcpart} ) { %> +
[ change ] + <% } %> + ><%= itable() %> <% # my @part_export = @@ -74,7 +122,7 @@ map { qsearchs('part_export', { exportnum => $_->exportnum } ) } qsearch('export ) { %> - <%= $part_export->exporttype %> to <%= $part_export->machine %> + <%= $part_export->exportnum %>: <%= $part_export->exporttype %> to <%= $part_export->machine %> <% } %> @@ -82,22 +130,30 @@ map { qsearchs('part_export', { exportnum => $_->exportnum } ) } qsearch('export foreach my $field ( @fields ) { my $flag = $part_svc->part_svc_column($field)->columnflag; %> - <%= $n1 %><%= $field %> + <%= $n1 %> + <%= $field %> + <%= $flag{$flag} %> + + + <% my $value = $part_svc->part_svc_column($field)->columnvalue; + if ( $flag =~ /^[MA]$/ ) { + $inventory_class{$value} + ||= qsearchs('inventory_class', { 'classnum' => $value } ); + %> + <%= $inventory_class{$value} + ? $inventory_class{$value}->classname + : "WARNING: inventory_class.classnum $value not found" %> + <% } else { %> + <%= $value %> + <% } %> + + -<% if ( $flag eq "D" ) { print "Default"; } - elsif ( $flag eq "F" ) { print "Fixed"; } - else { print "(Unknown!)"; } -%> - <%= $part_svc->part_svc_column($field)->columnvalue%> <% $n1=""; } %> <% } %> - - - param('showdisabled') ? 7 : 8 %>>Add a new service definition -