move "add" links to the top
[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"><A HREF="<%= $p %>edit/part_svc.cgi"><I>Add a new service definition</I></A>&nbsp;or&nbsp;<SELECT NAME="clone"><OPTION></OPTION>
29 <% foreach my $part_svc ( @part_svc ) { %>
30   <OPTION VALUE="<%= $part_svc->svcpart %>"><%= $part_svc->svc %></OPTION>
31 <% } %>
32 </SELECT><INPUT TYPE="submit" VALUE="Clone existing service">
33 </FORM><BR>
34
35 <%= $total %> services
36 <%= $cgi->param('showdisabled')
37       ? do { $cgi->param('showdisabled', 0);
38              '( <a href="'. $cgi->self_url. '">hide disabled services</a> )'; }
39       : do { $cgi->param('showdisabled', 1);
40              '( <a href="'. $cgi->self_url. '">show disabled services</a> )'; }
41 %>
42 <%= table() %>
43   <TR>
44     <TH COLSPAN=<%= $cgi->param('showdisabled') ? 2 : 3 %>>Service</TH>
45     <TH>Table</TH>
46     <TH>Export</TH>
47     <TH>Field</TH>
48     <TH COLSPAN=2>Modifier</TH>
49   </TR>
50
51 <% foreach my $part_svc ( @part_svc ) {
52      my $hashref = $part_svc->hashref;
53      my $svcdb = $hashref->{svcdb};
54      my @dfields = fields($svcdb);
55      push @dfields, 'usergroup' if $svcdb eq 'svc_acct'; #kludge
56      my @fields =
57        grep { $_ ne 'svcnum' && $part_svc->part_svc_column($_)->columnflag }
58             @dfields;
59
60      my $rowspan = scalar(@fields) || 1;
61      my $url = "${p}edit/part_svc.cgi?$hashref->{svcpart}";
62 %>
63
64   <TR>
65     <TD ROWSPAN=<%= $rowspan %>><A HREF="<%= $url %>">
66       <%= $hashref->{svcpart} %></A></TD>
67 <% unless ( $cgi->param('showdisabled') ) { %>
68     <TD ROWSPAN=<%= $rowspan %>>
69       <%= $hashref->{disabled} ? 'DISABLED' : '' %></TD>
70 <% } %>
71     <TD ROWSPAN=<%= $rowspan %>><A HREF="<%= $url %>">
72       <%= $hashref->{svc} %></A></TD>
73     <TD ROWSPAN=<%= $rowspan %>>
74       <%= $hashref->{svcdb} %></TD>
75     <TD ROWSPAN=<%= $rowspan %>><%= itable() %>
76 <%
77 #  my @part_export =
78 map { qsearchs('part_export', { exportnum => $_->exportnum } ) } qsearch('export_svc', { svcpart => $part_svc->svcpart } ) ;
79   foreach my $part_export (
80     map { qsearchs('part_export', { exportnum => $_->exportnum } ) } 
81       qsearch('export_svc', { svcpart => $part_svc->svcpart } )
82   ) {
83 %>
84       <TR>
85         <TD><A HREF="<%= $p %>edit/part_export.cgi?<%= $part_export->exportnum %>"><%= $part_export->exporttype %>&nbsp;to&nbsp;<%= $part_export->machine %></A></TD></TR>
86 <%  } %>
87       </TABLE></TD>
88
89 <%   my($n1)='';
90      foreach my $field ( @fields ) {
91        my $flag = $part_svc->part_svc_column($field)->columnflag;
92 %>
93      <%= $n1 %><TD><%= $field %></TD><TD>
94
95 <%     if ( $flag eq "D" ) { print "Default"; }
96          elsif ( $flag eq "F" ) { print "Fixed"; }
97          else { print "(Unknown!)"; }
98 %>
99        </TD><TD><%= $part_svc->part_svc_column($field)->columnvalue%></TD>
100 <%     $n1="</TR><TR>";
101      }
102 %>
103   </TR>
104 <% } %>
105 </TABLE>
106 </BODY>
107 </HTML>