ee7a2622aeca4671c001b2794aa06303e3c99964
[freeside.git] / httemplate / browse / part_svc.cgi
1 <!-- mason kludge -->
2 <% 
3
4 my %search;
5 if ( $cgi->param('showdisabled') ) {
6   %search = ();
7 } else {
8   %search = ( 'disabled' => '' );
9 }
10
11 my @part_svc =
12   sort { $a->getfield('svcpart') <=> $b->getfield('svcpart') }
13     qsearch('part_svc', \%search );
14 my $total = scalar(@part_svc);
15
16 %>
17 <%= header('Service Definition Listing', menubar( 'Main Menu' => $p) ) %>
18
19 <SCRIPT>
20 function part_export_areyousure(href) {
21   if (confirm("Are you sure you want to delete this export?") == true)
22     window.location.href = href;
23 }
24 </SCRIPT>
25
26     Services are items you offer to your customers.<BR><BR>
27
28 <FORM METHOD="POST" ACTION="<%= $p %>edit/part_svc.cgi">
29 <A HREF="<%= $p %>edit/part_svc.cgi"><I>Add a new service definition</I></A><% if ( @part_svc ) { %>&nbsp;or&nbsp;<SELECT NAME="clone"><OPTION></OPTION>
30 <% foreach my $part_svc ( @part_svc ) { %>
31   <OPTION VALUE="<%= $part_svc->svcpart %>"><%= $part_svc->svc %></OPTION>
32 <% } %>
33 </SELECT><INPUT TYPE="submit" VALUE="Clone existing service">
34 <% } %>
35 </FORM><BR>
36
37 <%= $total %> services
38 <%= $cgi->param('showdisabled')
39       ? do { $cgi->param('showdisabled', 0);
40              '( <a href="'. $cgi->self_url. '">hide disabled services</a> )'; }
41       : do { $cgi->param('showdisabled', 1);
42              '( <a href="'. $cgi->self_url. '">show disabled services</a> )'; }
43 %>
44 <%= table() %>
45   <TR>
46     <TH COLSPAN=<%= $cgi->param('showdisabled') ? 2 : 3 %>>Service</TH>
47     <TH>Table</TH>
48     <TH>Export</TH>
49     <TH>Field</TH>
50     <TH COLSPAN=2>Modifier</TH>
51   </TR>
52
53 <% foreach my $part_svc ( @part_svc ) {
54      my $hashref = $part_svc->hashref;
55      my $svcdb = $hashref->{svcdb};
56      my @dfields = fields($svcdb);
57      push @dfields, 'usergroup' if $svcdb eq 'svc_acct'; #kludge
58      my @fields =
59        grep { $_ ne 'svcnum' && $part_svc->part_svc_column($_)->columnflag }
60             @dfields;
61
62      my $rowspan = scalar(@fields) || 1;
63      my $url = "${p}edit/part_svc.cgi?$hashref->{svcpart}";
64 %>
65
66   <TR>
67     <TD ROWSPAN=<%= $rowspan %>><A HREF="<%= $url %>">
68       <%= $hashref->{svcpart} %></A></TD>
69 <% unless ( $cgi->param('showdisabled') ) { %>
70     <TD ROWSPAN=<%= $rowspan %>>
71       <%= $hashref->{disabled} ? 'DISABLED' : '' %></TD>
72 <% } %>
73     <TD ROWSPAN=<%= $rowspan %>><A HREF="<%= $url %>">
74       <%= $hashref->{svc} %></A></TD>
75     <TD ROWSPAN=<%= $rowspan %>>
76       <%= $hashref->{svcdb} %></TD>
77     <TD ROWSPAN=<%= $rowspan %>><%= itable() %>
78 <%
79 #  my @part_export =
80 map { qsearchs('part_export', { exportnum => $_->exportnum } ) } qsearch('export_svc', { svcpart => $part_svc->svcpart } ) ;
81   foreach my $part_export (
82     map { qsearchs('part_export', { exportnum => $_->exportnum } ) } 
83       qsearch('export_svc', { svcpart => $part_svc->svcpart } )
84   ) {
85 %>
86       <TR>
87         <TD><A HREF="<%= $p %>edit/part_export.cgi?<%= $part_export->exportnum %>"><%= $part_export->exportnum %>:&nbsp;<%= $part_export->exporttype %>&nbsp;to&nbsp;<%= $part_export->machine %></A></TD></TR>
88 <%  } %>
89       </TABLE></TD>
90
91 <%   my($n1)='';
92      foreach my $field ( @fields ) {
93        my $flag = $part_svc->part_svc_column($field)->columnflag;
94 %>
95      <%= $n1 %><TD><%= $field %></TD><TD>
96
97 <%     if ( $flag eq "D" ) { print "Default"; }
98          elsif ( $flag eq "F" ) { print "Fixed"; }
99          else { print "(Unknown!)"; }
100 %>
101        </TD><TD><%= $part_svc->part_svc_column($field)->columnvalue%></TD>
102 <%     $n1="</TR><TR>";
103      }
104 %>
105   </TR>
106 <% } %>
107 </TABLE>
108 </BODY>
109 </HTML>