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>
64 <TH CLASS="grid" BGCOLOR="#cccccc" STYLE="font-size: smaller;">Required</TH>
67 % my $conf = FS::Conf->new;
68 % foreach my $part_svc ( @part_svc ) {
69 % my $svcdb = $part_svc->svcdb;
70 % my $svc_x = "FS::$svcdb"->new( { svcpart => $part_svc->svcpart } );
71 % my @dfields = $svc_x->fields;
72 % push @dfields, 'usergroup' if $svcdb eq 'svc_acct' #double kludge
73 % or ($svcdb eq 'svc_broadband'
74 % and $conf->exists('svc_broadband-radius'));
76 % grep { my $col = $part_svc->part_svc_column($_);
77 % my $def = FS::part_svc->svc_table_fields($svcdb)->{$_};
79 % or $_ ne 'svcnum' && (
80 % $col->columnflag || ( $col->columnlabel !~ /^\S*$/
81 % && $col->columnlabel ne $def->{'label'}
84 % && !$def->{'required'}
89 % my $rowspan = scalar(@fields) || 1;
90 % $rowspan++ if $part_svc->restrict_edit_password;
91 % my $url = "${p}edit/part_svc.cgi?". $part_svc->svcpart;
93 % if ( $bgcolor eq $bgcolor1 ) {
94 % $bgcolor = $bgcolor2;
96 % $bgcolor = $bgcolor1;
102 <TD ROWSPAN=<% $rowspan %> CLASS="grid" BGCOLOR="<% $bgcolor %>">
103 <A HREF="<% $url %>"><% $part_svc->svcpart %></A>
106 % if ( $cgi->param('showdisabled') ) {
107 <TD ROWSPAN=<% $rowspan %> CLASS="grid" BGCOLOR="<% $bgcolor %>">
108 <% $part_svc->disabled
109 ? '<FONT COLOR="#FF0000"><B>Disabled</B></FONT>'
110 : '<FONT COLOR="#00CC00"><B>Enabled</B></FONT>'
115 <TD ROWSPAN=<% $rowspan %> CLASS="grid" BGCOLOR="<% $bgcolor %>">
116 <A HREF="<% $url %>">
119 % # any alternate names of the service
120 % my %msgcat = map { $_->locale => $_ } $part_svc->part_svc_msgcat;
121 % my %labels = map { $_ => FS::Locales->description($_) } keys %msgcat;
122 % my @locales = sort { $labels{$a} cmp $labels{$b} } keys %msgcat;
126 % foreach my $locale (@locales) {
127 <% $labels{$locale} %>: <% $msgcat{$locale}->get('svc') %>
134 <TD ROWSPAN=<% $rowspan %> CLASS="grid" BGCOLOR="<% $bgcolor %>">
137 <TD ROWSPAN=<% $rowspan %> CLASS="grid" BGCOLOR="<% $bgcolor %>">
138 % my $svcurl_active = svc_url( 'ahref' => 1, 'm' => $m, 'action' => 'search', 'part_svc' => $part_svc, 'query' => "svcpart=". $part_svc->svcpart . "&cancelled=0");
139 % my $svcurl_cancel = svc_url( 'ahref' => 1, 'm' => $m, 'action' => 'search', 'part_svc' => $part_svc, 'query' => "svcpart=". $part_svc->svcpart . "&cancelled=1");
140 <FONT COLOR="#00CC00"><B><% $num_cust_svc_active{$part_svc->svcpart} %></B></FONT> <% $num_cust_svc_active{$part_svc->svcpart} ? $svcurl_active : '' %>active<% $num_cust_svc_active{$part_svc->svcpart} ? '</A>' : '' %>
141 % if ( $num_cust_svc_cancelled{$part_svc->svcpart} ) {
142 <BR><FONT COLOR="#FF0000"><B><% $num_cust_svc_cancelled{$part_svc->svcpart} %></B></FONT> <% $svcurl_cancel %>cancelled</A>
144 % if ( $num_cust_svc{$part_svc->svcpart} ) {
145 <BR><FONT SIZE="-1">[ <A HREF="<%$p%>edit/bulk-cust_svc.html?svcpart=<% $part_svc->svcpart %>">change</A> ]</FONT>
150 % tie my %selfservice_access, 'Tie::IxHash', #false laziness w/edit/part_svc.cgi
152 % 'hidden' => 'Hidden',
153 % 'readonly' => 'Read-only',
155 <TD ROWSPAN=<% $rowspan %> CLASS="grid" BGCOLOR="<% $bgcolor %>" ALIGN="center">
156 <% $selfservice_access{$part_svc->selfservice_access} %></TD>
158 <TD ROWSPAN=<% $rowspan %> CLASS="inv" BGCOLOR="<% $bgcolor %>">
162 %map { qsearchs('part_export', { exportnum => $_->exportnum } ) } qsearch('export_svc', { svcpart => $part_svc->svcpart } ) ;
163 % foreach my $part_export (
164 % map { qsearchs('part_export', { exportnum => $_->exportnum } ) }
165 % qsearch('export_svc', { svcpart => $part_svc->svcpart } )
170 <TD><A HREF="<% $p %>edit/part_export.cgi?<% $part_export->exportnum %>"><% $part_export->label_html %></A></TD>
177 % unless ( @fields ) {
179 <TD CLASS="grid" BGCOLOR="<% $bgcolor %>"</TD>
184 % foreach my $field ( sort @fields ) {
186 % #a few lines of false laziness w/edit/part_svc.cgi
187 % my $def = FS::part_svc->svc_table_fields($svcdb)->{$field};
188 % my $formatter = $def->{format} || sub { shift };
190 % my $part_svc_column = $part_svc->part_svc_column($field);
191 % my $label = $part_svc_column->columnlabel || $def->{'label'};
192 % my $flag = $part_svc_column->columnflag;
195 <TD CLASS="grid" BGCOLOR="<% $bgcolor %>"><% $field %></TD>
196 <TD CLASS="grid" BGCOLOR="<% $bgcolor %>"><% $label %></TD>
197 <TD CLASS="grid" BGCOLOR="<% $bgcolor %>"><% $flag{$flag} %></TD>
198 <TD CLASS="grid" BGCOLOR="<% $bgcolor %>">
199 % my $value = &$formatter($part_svc->part_svc_column($field)->columnvalue);
200 % if ( $flag =~ /^[MAH]$/ ) {
201 % my $select_table = ($flag eq 'H') ? 'hardware_class' : 'inventory_class';
202 % foreach my $classnum ( split(',', $value) ) {
203 % $select_class{$classnum} =
204 % qsearchs($select_table, { 'classnum' => $classnum } );
206 <% $select_class{$classnum}
207 ? $select_class{$classnum}->classname
208 : "WARNING: $select_table.classnum $classnum not found" %><BR>
216 <TD CLASS="grid" BGCOLOR="<% $bgcolor %>">
217 % if ($part_svc_column->required) {
223 % if ( $part_svc->restrict_edit_password ) {
225 <TD CLASS="grid" BGCOLOR="<% $bgcolor %>" COLSPAN=4 ALIGN="left">
226 <B><% emt('Password editing restricted.') %></B>
232 % } #foreach $part_svc
240 unless $FS::CurrentUser::CurrentUser->access_right('Configuration');
242 #code duplication w/ edit/part_svc.cgi, should move this hash to part_svc.pm
246 'F' => 'Fixed (unchangeable)',
247 'S' => 'Selectable choice',
248 #'M' => 'Manual selection from inventory',
249 'M' => 'Manual selected from inventory',
250 #'A' => 'Automatically fill in from inventory',
251 'A' => 'Automatically filled in from inventory',
252 'H' => 'Selected from hardware class',
257 if ( $cgi->param('showdisabled') ) {
260 %search = ( 'disabled' => '' );
264 sort { $a->getfield('svcpart') <=> $b->getfield('svcpart') }
265 qsearch('part_svc', \%search );
266 my $total = scalar(@part_svc);
268 ## The Active/Cancelled distinction is a bit awkward,
269 ## active currently includes unattached and suspended services,
270 ## but we've previously referred to EVERY existing cust_svc as "Active",
271 ## and we don't really want to know numbers by individual package status,
272 ## so for now the UI will distinguish these as "Active" and "Cancelled",
273 ## but please let's not go so far as to introduce the idea of "Service Status"
275 my %num_cust_svc_active;
276 my %num_cust_svc_cancelled;
278 foreach my $part_svc (@part_svc) {
279 $num_cust_svc{$part_svc->svcpart} = $part_svc->num_cust_svc;
280 $num_cust_svc_cancelled{$part_svc->svcpart} = $part_svc->num_cust_svc_cancelled;
281 $num_cust_svc_active{$part_svc->svcpart} = $num_cust_svc{$part_svc->svcpart} - $num_cust_svc_cancelled{$part_svc->svcpart};
284 if ( $cgi->param('orderby') eq 'active' ) {
285 @part_svc = sort { $num_cust_svc{$b->svcpart} <=>
286 $num_cust_svc{$a->svcpart} } @part_svc;
287 } elsif ( $cgi->param('orderby') eq 'svc' ) {
288 @part_svc = sort { lc($a->svc) cmp lc($b->svc) } @part_svc;
291 my %select_class = ();