1d1f5e1336b0c32cf6cf1af5f751b7cdeea8090b
[freeside.git] / httemplate / misc / link.cgi
1 <!-- mason kludge -->
2 %
3 %
4 %my %link_field = (
5 %  'svc_acct'    => 'username',
6 %  'svc_domain'  => 'domain',
7 %);
8 %
9 %my %link_field2 = (
10 %  'svc_acct'    => { label => 'Domain',
11 %                     field => 'domsvc',
12 %                     type  => 'select',
13 %                     select_table => 'svc_domain',
14 %                     select_key   => 'svcnum',
15 %                     select_label => 'domain'
16 %                   },
17 %);
18 %
19 %my($query) = $cgi->keywords;
20 %my($pkgnum, $svcpart) = ('', '');
21 %foreach $_ (split(/-/,$query)) { #get & untaint pkgnum & svcpart
22 %  $pkgnum=$1 if /^pkgnum(\d+)$/;
23 %  $svcpart=$1 if /^svcpart(\d+)$/;
24 %}
25 %
26 %my $part_svc = qsearchs('part_svc',{'svcpart'=>$svcpart});
27 %my $svc = $part_svc->getfield('svc');
28 %my $svcdb = $part_svc->getfield('svcdb');
29 %my $link_field = $link_field{$svcdb};
30 %my $link_field2 = $link_field2{$svcdb};
31 %
32 %
33
34
35 <% include("/elements/header.html","Link to existing $svc") %>
36 <FORM ACTION="<% popurl(1) %>process/link.cgi" METHOD=POST>
37 % if ( $link_field ) { 
38
39   <INPUT TYPE="hidden" NAME="svcnum" VALUE="">
40   <INPUT TYPE="hidden" NAME="link_field" VALUE="<% $link_field %>">
41   <% $link_field %> of existing service: <INPUT TYPE="text" NAME="link_value">
42   <BR>
43 % if ( $link_field2 ) { 
44
45     <INPUT TYPE="hidden" NAME="link_field2" VALUE="<% $link_field2->{field} %>">
46     <% $link_field2->{'label'} %> of existing service: 
47 % if ( $link_field2->{'type'} eq 'select' ) { 
48 % if ( $link_field2->{'select_table'} ) { 
49
50         <SELECT NAME="link_value2">
51         <OPTION> </OPTION>
52 % foreach my $r ( qsearch( $link_field2->{'select_table'}, {})) { 
53 % my $key = $link_field2->{'select_key'}; 
54 % my $label = $link_field2->{'select_label'}; 
55
56           <OPTION VALUE="<% $r->$key() %>"><% $r->$label() %></OPTION>
57 % } 
58
59         </SELECT>
60 % } else { 
61
62         Don't know how to process secondary link field for <% $svcdb %>
63         (type=>select but no select_table)
64 % } 
65 % } else { 
66
67       Don't know how to process secondary link field for <% $svcdb %>
68         (unknown type <% $link_field2->{'type'} %>)
69 % } 
70
71     <BR>
72 % } 
73 % } else { 
74
75   Service # of existing service: <INPUT TYPE="text" NAME="svcnum" VALUE="">
76 % } 
77
78
79 <INPUT TYPE="hidden" NAME="pkgnum" VALUE="<% $pkgnum %>">
80 <INPUT TYPE="hidden" NAME="svcpart" VALUE="<% $svcpart %>">
81 <BR><INPUT TYPE="submit" VALUE="Link">
82     </FORM>
83   </BODY>
84 </HTML>