merge NG auth, RT#21563
[freeside.git] / httemplate / edit / svc_domain.cgi
1 <% include('/elements/header.html', "$action $svc", '') %>
2
3 <% include('/elements/error.html') %>
4
5 <FORM ACTION="<% $p1 %>process/svc_domain.cgi" METHOD=POST>
6 <INPUT TYPE="hidden" NAME="svcnum" VALUE="<% $svcnum %>">
7 <INPUT TYPE="hidden" NAME="pkgnum" VALUE="<% $pkgnum %>">
8 <INPUT TYPE="hidden" NAME="svcpart" VALUE="<% $svcpart %>">
9
10 <% ntable("#cccccc",2) %>
11
12 <TR>
13   <TD ALIGN="right">Domain</TD>
14   <TD>
15 %   if ( !$svcnum || $conf->exists('svc_domain-edit_domain') ) {
16       <INPUT TYPE="text" NAME="domain" VALUE="<% $domain %>" SIZE=28 MAXLENGTH=63>
17 %   } else {
18       <B><% $domain %></B>
19       <INPUT TYPE="hidden" NAME="domain" VALUE="<% $domain %>">
20 %   }
21
22 % if ($export) {
23 <BR>
24 Available top-level domains: <% $export->option('tlds') %>
25 </TR>
26
27 <TR>
28 <INPUT TYPE="radio" NAME="action" VALUE="N"<% $kludge_action eq 'N' ? ' CHECKED' : '' %>>Register at <% $registrar->{'name'} %>
29 <BR>
30
31 <INPUT TYPE="radio" NAME="action" VALUE="M"<% $kludge_action eq 'M' ? ' CHECKED' : '' %>>Transfer to <% $registrar->{'name'} %>
32 <BR>
33
34 <INPUT TYPE="radio" NAME="action" VALUE="I"<% $kludge_action eq 'I' ? ' CHECKED' : '' %>>Registered elsewhere
35
36 </TR>
37
38 %    if($export->option('auoptions')) {
39 %       # XXX: this whole thing should be done like svc_Common with label_fixup, etc. eventually
40             <% include('/elements/tr-select.html',
41                         'field' => 'au_eligibiilty_type',
42                         'label' => 'AU Eligibility Type',
43                         'value' => $svc_domain->au_eligibility_type,
44                         'options' => $svc_domain->au_eligibility_type_values,
45                       )
46             %>
47             <% include('/elements/tr-input-text.html',
48                         'field' => 'au_registrant_name',
49                         'label' => 'AU Registrant Name',
50                         'value' => $svc_domain->au_registrant_name,
51                       )
52             %>
53 %    }
54
55 % }
56   </TD>
57 </TR>
58
59 <% include('svc_domain/communigate-basics.html',
60              'svc_domain'  => $svc_domain,
61              'part_svc'    => $part_svc,
62              'communigate' => $communigate,
63           )
64 %>
65
66 </TABLE>
67 <BR>
68
69 <% include('svc_domain/communigate-acct_defaults.html',
70              'svc_domain'  => $svc_domain,
71              'part_svc'    => $part_svc,
72              'communigate' => $communigate,
73           )
74 %>
75
76 <INPUT TYPE="submit" VALUE="Submit">
77
78 </FORM>
79
80 <% include('/elements/footer.html') %>
81
82 <%init>
83
84 die "access denied"
85   unless $FS::CurrentUser::CurrentUser->access_right('Provision customer service'); #something else more specific?
86
87 my $conf = new FS::Conf;
88
89 my($svcnum, $pkgnum, $svcpart, $kludge_action, $part_svc,
90    $svc_domain);
91 if ( $cgi->param('error') ) {
92
93   $svc_domain = new FS::svc_domain ( {
94     map { $_, scalar($cgi->param($_)) } fields('svc_domain')
95   } );
96   $svcnum = $svc_domain->svcnum;
97   $pkgnum = $cgi->param('pkgnum');
98   $svcpart = $cgi->param('svcpart');
99   $kludge_action = $cgi->param('action');
100   $part_svc = qsearchs('part_svc', { 'svcpart' => $svcpart } );
101   die "No part_svc entry!" unless $part_svc;
102
103 } elsif ( $cgi->param('pkgnum') && $cgi->param('svcpart') ) { #adding
104
105   $cgi->param('pkgnum') =~ /^(\d+)$/ or die 'unparsable pkgnum';
106   $pkgnum = $1;
107   $cgi->param('svcpart') =~ /^(\d+)$/ or die 'unparsable svcpart';
108   $svcpart = $1;
109
110   $part_svc=qsearchs('part_svc',{'svcpart'=>$svcpart});
111   die "No part_svc entry!" unless $part_svc;
112
113   $svc_domain = new FS::svc_domain({});
114
115   $svcnum='';
116
117   $svc_domain->set_default_and_fixed;
118
119 } else { #editing
120
121   $kludge_action = '';
122   my($query) = $cgi->keywords;
123   $query =~ /^(\d+)$/ or die "unparsable svcnum";
124   $svcnum=$1;
125   $svc_domain=qsearchs('svc_domain',{'svcnum'=>$svcnum})
126     or die "Unknown (svc_domain) svcnum!";
127
128   my($cust_svc)=qsearchs('cust_svc',{'svcnum'=>$svcnum})
129     or die "Unknown (cust_svc) svcnum!";
130
131   $pkgnum=$cust_svc->pkgnum;
132   $svcpart=$cust_svc->svcpart;
133
134   $part_svc=qsearchs('part_svc',{'svcpart'=>$svcpart});
135   die "No part_svc entry!" unless $part_svc;
136
137 }
138 my $action = $svcnum ? 'Edit' : 'Add';
139
140 my $svc = $part_svc->getfield('svc');
141
142 my $communigate = scalar($part_svc->part_export('communigate_pro'));
143                 # || scalar($part_svc->part_export('communigate_pro_singledomain'));
144
145 # Find the first export that does domain registration
146 my @exports = grep $_->can('registrar'), $part_svc->part_export;
147 my $export = $exports[0];
148 # If we have a domain registration export, get the registrar object
149 my $registrar = $export ? $export->registrar : '';
150
151 my $domain = $svc_domain->domain;
152
153 my $p1 = popurl(1);
154
155 </%init>