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">Export</TH>
56 <TH CLASS="grid" BGCOLOR="#cccccc">Field</TH>
58 <TH CLASS="grid" BGCOLOR="#cccccc">Label</TH>
60 <TH COLSPAN=2 CLASS="grid" BGCOLOR="#cccccc">Modifier</TH>
64 % foreach my $part_svc ( @part_svc ) {
65 % my $svcdb = $part_svc->svcdb;
66 % my $svc_x = "FS::$svcdb"->new( { svcpart => $part_svc->svcpart } );
67 % my @dfields = $svc_x->fields;
68 % push @dfields, 'usergroup' if $svcdb eq 'svc_acct'; #kludge
70 % grep { my $col = $part_svc->part_svc_column($_);
71 % my $def = FS::part_svc->svc_table_fields($svcdb)->{$_};
73 % or $_ ne 'svcnum' && (
74 % $col->columnflag || ( $col->columnlabel !~ /^\S*$/
75 % && $col->columnlabel ne $def->{'label'}
80 % my $rowspan = scalar(@fields) || 1;
81 % my $url = "${p}edit/part_svc.cgi?". $part_svc->svcpart;
83 % if ( $bgcolor eq $bgcolor1 ) {
84 % $bgcolor = $bgcolor2;
86 % $bgcolor = $bgcolor1;
92 <TD ROWSPAN=<% $rowspan %> CLASS="grid" BGCOLOR="<% $bgcolor %>">
93 <A HREF="<% $url %>"><% $part_svc->svcpart %></A>
96 % if ( $cgi->param('showdisabled') ) {
97 <TD ROWSPAN=<% $rowspan %> CLASS="grid" BGCOLOR="<% $bgcolor %>">
98 <% $part_svc->disabled
99 ? '<FONT COLOR="#FF0000"><B>Disabled</B></FONT>'
100 : '<FONT COLOR="#00CC00"><B>Enabled</B></FONT>'
105 <TD ROWSPAN=<% $rowspan %> CLASS="grid" BGCOLOR="<% $bgcolor %>"><A HREF="<% $url %>">
106 <% $part_svc->svc %></A></TD>
108 <TD ROWSPAN=<% $rowspan %> CLASS="grid" BGCOLOR="<% $bgcolor %>">
111 <TD ROWSPAN=<% $rowspan %> CLASS="grid" BGCOLOR="<% $bgcolor %>">
112 <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>
114 % if ( $num_active_cust_svc{$part_svc->svcpart} ) {
115 <BR><FONT SIZE="-1">[ <A HREF="<%$p%>edit/bulk-cust_svc.html?svcpart=<% $part_svc->svcpart %>">change</A> ]</FONT>
120 <TD ROWSPAN=<% $rowspan %> CLASS="inv" BGCOLOR="<% $bgcolor %>">
124 %map { qsearchs('part_export', { exportnum => $_->exportnum } ) } qsearch('export_svc', { svcpart => $part_svc->svcpart } ) ;
125 % foreach my $part_export (
126 % map { qsearchs('part_export', { exportnum => $_->exportnum } ) }
127 % qsearch('export_svc', { svcpart => $part_svc->svcpart } )
132 <TD><A HREF="<% $p %>edit/part_export.cgi?<% $part_export->exportnum %>"><% $part_export->exportnum %>: <% $part_export->exporttype %> to <% $part_export->machine %></A></TD>
139 % unless ( @fields ) {
141 <TD CLASS="grid" BGCOLOR="<% $bgcolor %>"</TD>
146 % foreach my $field ( @fields ) {
148 % #a few lines of false laziness w/edit/part_svc.cgi
149 % my $def = FS::part_svc->svc_table_fields($svcdb)->{$field};
150 % my $formatter = $def->{format} || sub { shift };
152 % my $part_svc_column = $part_svc->part_svc_column($field);
153 % my $label = $part_svc_column->columnlabel || $def->{'label'};
154 % my $flag = $part_svc_column->columnflag;
157 <TD CLASS="grid" BGCOLOR="<% $bgcolor %>"><% $field %></TD>
158 <TD CLASS="grid" BGCOLOR="<% $bgcolor %>"><% $label %></TD>
159 <TD CLASS="grid" BGCOLOR="<% $bgcolor %>"><% $flag{$flag} %></TD>
161 <TD CLASS="grid" BGCOLOR="<% $bgcolor %>">
162 % my $value = &$formatter($part_svc->part_svc_column($field)->columnvalue);
163 % if ( $flag =~ /^[MA]$/ ) {
164 % $inventory_class{$value}
165 % ||= qsearchs('inventory_class', { 'classnum' => $value } );
168 <% $inventory_class{$value}
169 ? $inventory_class{$value}->classname
170 : "WARNING: inventory_class.classnum $value not found" %>
190 unless $FS::CurrentUser::CurrentUser->access_right('Configuration');
192 #code duplication w/ edit/part_svc.cgi, should move this hash to part_svc.pm
196 'F' => 'Fixed (unchangeable)',
197 'S' => 'Selectable choice',
198 #'M' => 'Manual selection from inventory',
199 'M' => 'Manual selected from inventory',
200 #'A' => 'Automatically fill in from inventory',
201 'A' => 'Automatically filled in from inventory',
206 if ( $cgi->param('showdisabled') ) {
209 %search = ( 'disabled' => '' );
213 sort { $a->getfield('svcpart') <=> $b->getfield('svcpart') }
214 qsearch('part_svc', \%search );
215 my $total = scalar(@part_svc);
217 my %num_active_cust_svc = map { $_->svcpart => $_->num_cust_svc } @part_svc;
219 if ( $cgi->param('orderby') eq 'active' ) {
220 @part_svc = sort { $num_active_cust_svc{$b->svcpart} <=>
221 $num_active_cust_svc{$a->svcpart} } @part_svc;
222 } elsif ( $cgi->param('orderby') eq 'svc' ) {
223 @part_svc = sort { lc($a->svc) cmp lc($b->svc) } @part_svc;
226 my %inventory_class = ();