1 <% include('/elements/header.html', 'Service Definition Listing') %>
4 function part_export_areyousure(href) {
5 if (confirm("Are you sure you want to delete this export?") == true)
6 window.location.href = href;
10 Service definitions are the templates for items you offer to your customers.<BR><BR>
12 <FORM METHOD="POST" ACTION="<% $p %>edit/part_svc.cgi">
13 <A HREF="<% $p %>edit/part_svc.cgi"><I>Add a new service definition</I></A>
15 or <SELECT NAME="clone"><OPTION></OPTION>
16 % foreach my $part_svc ( @part_svc ) {
18 <OPTION VALUE="<% $part_svc->svcpart %>"><% $part_svc->svc %></OPTION>
21 </SELECT><INPUT TYPE="submit" VALUE="Clone existing service">
26 <% $total %> service definitions
27 <% $cgi->param('showdisabled')
28 ? do { $cgi->param('showdisabled', 0);
29 '( <a href="'. $cgi->self_url. '">hide disabled services</a> )'; }
30 : do { $cgi->param('showdisabled', 1);
31 '( <a href="'. $cgi->self_url. '">show disabled services</a> )'; }
33 % $cgi->param('showdisabled', ( 1 ^ $cgi->param('showdisabled') ) );
35 <% include('/elements/table-grid.html') %>
36 % my $bgcolor1 = '#eeeeee';
37 % my $bgcolor2 = '#ffffff';
42 <TH CLASS="grid" BGCOLOR="#cccccc"><A HREF="<% do { $cgi->param('orderby', 'svcpart'); $cgi->self_url } %>">#</A></TH>
44 % if ( $cgi->param('showdisabled') ) {
45 <TH CLASS="grid" BGCOLOR="#cccccc">Status</TH>
48 <TH CLASS="grid" BGCOLOR="#cccccc"><A HREF="<% do { $cgi->param('orderby', 'svc'); $cgi->self_url; } %>">Service</A></TH>
50 <TH CLASS="grid" BGCOLOR="#cccccc">Table</TH>
52 <TH CLASS="grid" BGCOLOR="#cccccc"><A HREF="<% do { $cgi->param('orderby', 'active'); $cgi->self_url; } %>"><FONT SIZE=-1>Customer<BR>Services</FONT></A></TH>
54 <TH CLASS="grid" BGCOLOR="#cccccc"><FONT SIZE=-1>Customer<BR>Self-service</FONT></TH>
56 <TH CLASS="grid" BGCOLOR="#cccccc">Export</TH>
58 <TH CLASS="grid" BGCOLOR="#cccccc">Field</TH>
60 <TH CLASS="grid" BGCOLOR="#cccccc">Label</TH>
62 <TH COLSPAN=2 CLASS="grid" BGCOLOR="#cccccc">Modifier</TH>
65 % my $conf = FS::Conf->new;
66 % foreach my $part_svc ( @part_svc ) {
67 % my $svcdb = $part_svc->svcdb;
68 % my $svc_x = "FS::$svcdb"->new( { svcpart => $part_svc->svcpart } );
69 % my @dfields = $svc_x->fields;
70 % push @dfields, 'usergroup' if $svcdb eq 'svc_acct' #double kludge
71 % or ($svcdb eq 'svc_broadband'
72 % and $conf->exists('svc_broadband-radius'));
74 % grep { my $col = $part_svc->part_svc_column($_);
75 % my $def = FS::part_svc->svc_table_fields($svcdb)->{$_};
77 % or $_ ne 'svcnum' && (
78 % $col->columnflag || ( $col->columnlabel !~ /^\S*$/
79 % && $col->columnlabel ne $def->{'label'}
84 % my $rowspan = scalar(@fields) || 1;
85 % $rowspan++ if $part_svc->restrict_edit_password;
86 % my $url = "${p}edit/part_svc.cgi?". $part_svc->svcpart;
88 % if ( $bgcolor eq $bgcolor1 ) {
89 % $bgcolor = $bgcolor2;
91 % $bgcolor = $bgcolor1;
97 <TD ROWSPAN=<% $rowspan %> CLASS="grid" BGCOLOR="<% $bgcolor %>">
98 <A HREF="<% $url %>"><% $part_svc->svcpart %></A>
101 % if ( $cgi->param('showdisabled') ) {
102 <TD ROWSPAN=<% $rowspan %> CLASS="grid" BGCOLOR="<% $bgcolor %>">
103 <% $part_svc->disabled
104 ? '<FONT COLOR="#FF0000"><B>Disabled</B></FONT>'
105 : '<FONT COLOR="#00CC00"><B>Enabled</B></FONT>'
110 <TD ROWSPAN=<% $rowspan %> CLASS="grid" BGCOLOR="<% $bgcolor %>"><A HREF="<% $url %>">
111 <% $part_svc->svc %></A></TD>
113 <TD ROWSPAN=<% $rowspan %> CLASS="grid" BGCOLOR="<% $bgcolor %>">
116 <TD ROWSPAN=<% $rowspan %> CLASS="grid" BGCOLOR="<% $bgcolor %>">
117 <FONT COLOR="#00CC00"><B><% $num_active_cust_svc{$part_svc->svcpart} %></B></FONT> <% $num_active_cust_svc{$part_svc->svcpart} ? svc_url( 'ahref' => 1, 'm' => $m, 'action' => 'search', 'part_svc' => $part_svc, 'query' => "svcpart=". $part_svc->svcpart ) : '<A NAME="zero">' %>active</A>
119 % if ( $num_active_cust_svc{$part_svc->svcpart} ) {
120 <BR><FONT SIZE="-1">[ <A HREF="<%$p%>edit/bulk-cust_svc.html?svcpart=<% $part_svc->svcpart %>">change</A> ]</FONT>
125 % tie my %selfservice_access, 'Tie::IxHash', #false laziness w/edit/part_svc.cgi
127 % 'hidden' => 'Hidden',
128 % 'readonly' => 'Read-only',
130 <TD ROWSPAN=<% $rowspan %> CLASS="grid" BGCOLOR="<% $bgcolor %>" ALIGN="center">
131 <% $selfservice_access{$part_svc->selfservice_access} %></TD>
133 <TD ROWSPAN=<% $rowspan %> CLASS="inv" BGCOLOR="<% $bgcolor %>">
137 %map { qsearchs('part_export', { exportnum => $_->exportnum } ) } qsearch('export_svc', { svcpart => $part_svc->svcpart } ) ;
138 % foreach my $part_export (
139 % map { qsearchs('part_export', { exportnum => $_->exportnum } ) }
140 % qsearch('export_svc', { svcpart => $part_svc->svcpart } )
145 <TD><A HREF="<% $p %>edit/part_export.cgi?<% $part_export->exportnum %>">
146 <% $part_export->exportnum %>:
147 % if ($part_export->exportname) {
148 <B><% $part_export->exportname %></B> (
150 <% $part_export->exporttype %> to <% $part_export->machine %>
151 % if ($part_export->exportname) {
161 % unless ( @fields ) {
163 <TD CLASS="grid" BGCOLOR="<% $bgcolor %>"</TD>
168 % foreach my $field ( @fields ) {
170 % #a few lines of false laziness w/edit/part_svc.cgi
171 % my $def = FS::part_svc->svc_table_fields($svcdb)->{$field};
172 % my $formatter = $def->{format} || sub { shift };
174 % my $part_svc_column = $part_svc->part_svc_column($field);
175 % my $label = $part_svc_column->columnlabel || $def->{'label'};
176 % my $flag = $part_svc_column->columnflag;
179 <TD CLASS="grid" BGCOLOR="<% $bgcolor %>"><% $field %></TD>
180 <TD CLASS="grid" BGCOLOR="<% $bgcolor %>"><% $label %></TD>
181 <TD CLASS="grid" BGCOLOR="<% $bgcolor %>"><% $flag{$flag} %></TD>
183 <TD CLASS="grid" BGCOLOR="<% $bgcolor %>">
184 % my $value = &$formatter($part_svc->part_svc_column($field)->columnvalue);
185 % if ( $flag =~ /^[MAH]$/ ) {
186 % my $select_table = ($flag eq 'H') ? 'hardware_class' : 'inventory_class';
187 % $select_class{$value} ||=
188 % qsearchs($select_table, { 'classnum' => $value } );
190 <% $select_class{$value}
191 ? $select_class{$value}->classname
192 : "WARNING: $select_table.classnum $value not found" %>
201 % if ( $part_svc->restrict_edit_password ) {
203 <TD CLASS="grid" BGCOLOR="<% $bgcolor %>" COLSPAN=4 ALIGN="left">
204 <B><% emt('Password editing restricted.') %></B>
210 % } #foreach $part_svc
218 unless $FS::CurrentUser::CurrentUser->access_right('Configuration');
220 #code duplication w/ edit/part_svc.cgi, should move this hash to part_svc.pm
224 'F' => 'Fixed (unchangeable)',
225 'S' => 'Selectable choice',
226 #'M' => 'Manual selection from inventory',
227 'M' => 'Manual selected from inventory',
228 #'A' => 'Automatically fill in from inventory',
229 'A' => 'Automatically filled in from inventory',
230 'H' => 'Selected from hardware class',
235 if ( $cgi->param('showdisabled') ) {
238 %search = ( 'disabled' => '' );
242 sort { $a->getfield('svcpart') <=> $b->getfield('svcpart') }
243 qsearch('part_svc', \%search );
244 my $total = scalar(@part_svc);
246 my %num_active_cust_svc = map { $_->svcpart => $_->num_cust_svc } @part_svc;
248 if ( $cgi->param('orderby') eq 'active' ) {
249 @part_svc = sort { $num_active_cust_svc{$b->svcpart} <=>
250 $num_active_cust_svc{$a->svcpart} } @part_svc;
251 } elsif ( $cgi->param('orderby') eq 'svc' ) {
252 @part_svc = sort { lc($a->svc) cmp lc($b->svc) } @part_svc;
255 my %select_class = ();