X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=httemplate%2Fbrowse%2Fpart_svc.cgi;h=8b596752f814ebd7fe959fed66d24103cfc0752f;hp=145874774895b55a6bf2f735ef8066a204bf7c81;hb=3f2a7b01b59902faed5767d81e2959e131bdbdfd;hpb=c473d21fdd01251030b0a90d67d85d1bedfd76ba diff --git a/httemplate/browse/part_svc.cgi b/httemplate/browse/part_svc.cgi index 145874774..8b596752f 100755 --- a/httemplate/browse/part_svc.cgi +++ b/httemplate/browse/part_svc.cgi @@ -1,60 +1,299 @@ - -<%= header('Service Part Listing', menubar( 'Main Menu' => $p) ) %> +<% include('/elements/header.html', 'Service Definition Listing') %> - Services are items you offer to your customers.

- - - - - - - + + + Service definitions are the templates for items you offer to your customers.

+ + +Add a new service definition +% if ( @part_svc ) { + or  +% } + +
-<% foreach my $part_svc ( sort { - $a->getfield('svcpart') <=> $b->getfield('svcpart') - } qsearch('part_svc',{}) ) { - my($hashref)=$part_svc->hashref; - my($svcdb)=$hashref->{svcdb}; - my(@rows)= - grep $hashref->{${svcdb}.'__'.$_.'_flag'}, - map { /^${svcdb}__(.*)$/; $1 } - grep ! /_flag$/, - grep /^${svcdb}__/, - fields('part_svc') - ; - my($rowspan)=scalar(@rows) || 1; - my $url = "${p}edit/part_svc.cgi?$hashref->{svcpart}"; +<% $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') ) ); + +<% include('/elements/table-grid.html') %> +% my $bgcolor1 = '#eeeeee'; +% my $bgcolor2 = '#ffffff'; +% my $bgcolor = ''; - - - - -<% my($n1)=''; - my($row); - foreach $row ( @rows ) { - my($flag)=$part_svc->getfield($svcdb.'__'.$row.'_flag'); -%> - <%= $n1 %> -<% $n1=""; - } -%> + + +% if ( $cgi->param('showdisabled') ) { + +% } + + + + + + + + + + + + + + + + + + + -<% } %> +% 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' #double kludge +% or ($svcdb eq 'svc_broadband' +% and $conf->exists('svc_broadband-radius')); +% my @fields = +% grep { my $col = $part_svc->part_svc_column($_); +% my $def = FS::part_svc->svc_table_fields($svcdb)->{$_}; +% $svc_x->pvf($_) +% or $_ ne 'svcnum' && ( +% $col->columnflag || ( $col->columnlabel !~ /^\S*$/ +% && $col->columnlabel ne $def->{'label'} +% ) +% || ( $col->required +% && !$def->{'required'} +% ) +% ) +% } +% @dfields ; +% my $rowspan = scalar(@fields) || 1; +% $rowspan++ if $part_svc->restrict_edit_password; +% my $url = "${p}edit/part_svc.cgi?". $part_svc->svcpart; +% +% if ( $bgcolor eq $bgcolor1 ) { +% $bgcolor = $bgcolor2; +% } else { +% $bgcolor = $bgcolor1; +% } + - + + + +% if ( $cgi->param('showdisabled') ) { + +% } + + + + + + + +% tie my %selfservice_access, 'Tie::IxHash', #false laziness w/edit/part_svc.cgi +% '' => 'Yes', +% 'hidden' => 'Hidden', +% 'readonly' => 'Read-only', +% ; + + + + +% unless ( @fields ) { +% for ( 1..5 ) { + + + + + +% $n1=""; +% } #foreach $field +% if ( $part_svc->restrict_edit_password ) { + + + +% } + +% } #foreach $part_svc +
ServiceTableFieldModifier
> - <%= $hashref->{svcpart} %>> - <%= $hashref->{svc} %>> - <%= $hashref->{svcdb} %><%= $row %> -<% if ( $flag eq "D" ) { print "Default"; } - elsif ( $flag eq "F" ) { print "Fixed"; } - else { print "(Unknown!)"; } -%> - <%= $part_svc->getfield($svcdb."__".$row) %>
#StatusServiceTableCustomer
Services
Customer
Self-service
ExportFieldLabelModifierRequired
Add new service CLASS="grid" BGCOLOR="<% $bgcolor %>"> + <% $part_svc->svcpart %> + CLASS="grid" BGCOLOR="<% $bgcolor %>"> + <% $part_svc->disabled + ? 'Disabled' + : 'Enabled' + %> + CLASS="grid" BGCOLOR="<% $bgcolor %>"> + + <% $part_svc->svc %> + +% # any alternate names of the service +% my %msgcat = map { $_->locale => $_ } $part_svc->part_svc_msgcat; +% my %labels = map { $_ => FS::Locales->description($_) } keys %msgcat; +% my @locales = sort { $labels{$a} cmp $labels{$b} } keys %msgcat; +% if ( @locales ) { +
+ +% foreach my $locale (@locales) { + <% $labels{$locale} %>: <% $msgcat{$locale}->get('svc') %> +
+% } +
+% } +
CLASS="grid" BGCOLOR="<% $bgcolor %>"> + <% $svcdb %> CLASS="grid" BGCOLOR="<% $bgcolor %>"> +% 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} || $disable_counts ? $svcurl_active : '' %>active<% $num_cust_svc_active{$part_svc->svcpart} || $disable_counts ? '' : '' %> +% if ( $num_cust_svc_cancelled{$part_svc->svcpart} || $disable_counts ) { +
<% $num_cust_svc_cancelled{$part_svc->svcpart} %> <% $svcurl_cancel %>cancelled +% } +% if ( $num_cust_svc{$part_svc->svcpart} || $disable_counts ) { +
[ change ] +% } + +
CLASS="grid" BGCOLOR="<% $bgcolor %>" ALIGN="center"> + <% $selfservice_access{$part_svc->selfservice_access} %> CLASS="inv" BGCOLOR="<% $bgcolor %>"> + +% +%# 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->label_html %>
+
+% } +% } +% +% my($n1)=''; +% 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}; +% my $formatter = $def->{format} || sub { shift }; +% +% my $part_svc_column = $part_svc->part_svc_column($field); +% my $label = $part_svc_column->columnlabel || $def->{'label'}; +% my $flag = $part_svc_column->columnflag; + + <% $n1 %> + <% $field %><% $label %><% $flag{$flag} %> +% my $value = &$formatter($part_svc->part_svc_column($field)->columnvalue); +% if ( $flag =~ /^[MAH]$/ ) { +% my $select_table = ($flag eq 'H') ? 'hardware_class' : 'inventory_class'; +% foreach my $classnum ( split(',', $value) ) { +% $select_class{$classnum} = +% qsearchs($select_table, { 'classnum' => $classnum } ); +% + <% $select_class{$classnum} + ? $select_class{$classnum}->classname + : "WARNING: $select_table.classnum $classnum not found" %>
+% } +% } else { + + <% $value %> +% } + +
+% if ($part_svc_column->required) { + Yes +% } +
+ <% emt('Password editing restricted.') %> +
+<%init> + +die "access denied" + unless $FS::CurrentUser::CurrentUser->access_right('Configuration'); + +my $conf = FS::Conf->new; +my $disable_counts = $conf->exists('config-disable_counts') ? 1 : 0; + +#code duplication w/ edit/part_svc.cgi, should move this hash to part_svc.pm +my %flag = ( + '' => '', + 'D' => 'Default', + 'F' => 'Fixed (unchangeable)', + 'S' => 'Selectable choice', + #'M' => 'Manual selection from inventory', + 'M' => 'Manual selected from inventory', + #'A' => 'Automatically fill in from inventory', + 'A' => 'Automatically filled in from inventory', + 'H' => 'Selected from hardware class', + 'X' => 'Excluded', + 'P' => 'From package 477 information', +); + +my %search; +if ( $cgi->param('showdisabled') ) { + %search = (); +} else { + %search = ( 'disabled' => '' ); +} + +my @part_svc = + sort { $a->getfield('svcpart') <=> $b->getfield('svcpart') } + qsearch('part_svc', \%search ); +my $total = scalar(@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; + +unless ( $disable_counts ) { + 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_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; +} + +my %select_class = (); + +