continue attempting to handle mysql hanging on queries, RT#10574
[freeside.git] / httemplate / edit / svc_cert.cgi
1 <% include('/elements/header.html', "$action $svc", '') %>
2
3 <% include('/elements/error.html') %>
4
5 <FORM ACTION="<% $p %>edit/process/svc_cert.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">Private key</TD>
14   <TD BGCOLOR="#ffffff">
15
16 % if ( $svc_cert->privatekey && $svc_cert->check_privatekey ) {
17
18     <FONT COLOR="#33ff33">Verification OK</FONT>
19 %   # remove key & cert link?  just unprovision?
20
21     </TD></TR>
22
23 %   if (0) { #( $svc_cert->csr_submitted ) { #XXX add field?  date? }
24
25 %     # just show the fields once the csr has been submitted
26
27 %   } else {
28
29 %     my $cust_main = $svc_cert->cust_svc->cust_pkg->cust_main;
30
31       <TR>
32         <TD ALIGN="right">Common name</TD>
33         <TD><INPUT TYPE="text" NAME="common_name" SIZE=40 MAXLENGTH=80 VALUE="<% $svc_cert->common_name |h %>"></TD>
34       </TR>
35
36       <TR>
37         <TD ALIGN="right">Organization</TD>
38         <TD><INPUT TYPE="text" NAME="organization" SIZE=40 MAXLENGTH=80 VALUE="<% $svc_cert->organization || $cust_main->company |h %>"></TD>
39       </TR>
40
41       <TR>
42         <TD ALIGN="right">Organization Unit</TD>
43         <TD><INPUT TYPE="text" NAME="organization_unit" SIZE=40 MAXLENGTH=80 VALUE="<% $svc_cert->organization_unit |h %>"></TD>
44       </TR>
45
46       <TR>
47         <TD ALIGN="right">City</TD>
48         <TD><% include('/elements/city.html',
49                          'city'    => $svc_cert->city    || $cust_main->city,
50                          'state'   => $svc_cert->state   || $cust_main->state,
51                          'country' => $svc_cert->country || $cust_main->country,
52                       )
53             %>
54         </TD>
55       </TR>
56
57       <TR>
58         <TD ALIGN="right">State</TD>
59         <TD><% include('/elements/select-state.html',
60                          'city'    => $svc_cert->city    || $cust_main->city,
61                          'state'   => $svc_cert->state   || $cust_main->state,
62                          'country' => $svc_cert->country || $cust_main->country,
63                       )
64             %>
65         </TD>
66       </TR>
67
68       <TR>
69         <TD ALIGN="right">Country</TD>
70         <TD><% include('/elements/select-country.html',
71                          'city'    => $svc_cert->city    || $cust_main->city,
72                          'state'   => $svc_cert->state   || $cust_main->state,
73                          'country' => $svc_cert->country || $cust_main->country,
74                       )
75             %>
76         </TD>
77       </TR>
78
79       <TR>
80         <TD ALIGN="right">Contact email</TD>
81         <TD><INPUT TYPE="text" NAME="cert_contact" SIZE=40 MAXLENGTH=80 VALUE="<% $svc_cert->cert_contact || ($cust_main->invoicing_list_emailonly)[0] |h %>"></TD>
82       </TR>
83
84 %   }
85
86 % } else {
87 %   my $re = '';
88 %   if ( $svc_cert->privatekey ) {
89       <FONT COLOR="#ff0000">Verification error</FONT>
90 %     $re = 'Clear and Re-';
91 %   }
92     <% include('/elements/popup_link.html', {
93         'action'         => "svc_cert/generate_privatekey.html$link_query",
94         'label'          => $re.'Generate',
95         'actionlabel'    => 'Generate private key',
96         #opt
97         'width'          => '350',
98         'height'         => '150'
99         #'color'          => '#ff0000',
100         #'closetext'      => 'Go Away',      # the value '' removes the link
101     })%>
102
103     or
104
105     <% include('/elements/popup_link.html', {
106         'action'         => "svc_cert/import_privatekey.html$link_query",
107         'label'          => $re.'Import',
108         'actionlabel'    => 'Import private key',
109         #opt
110         'width'          => '544',
111         'height'         => '368',
112         #'color'          => '#ff0000',
113         #'closetext'      => 'Go Away',      # the value '' removes the link
114     })%>
115 %   if ( $svc_cert->privatekey ) {
116       <PRE><% $svc_cert->privatekey |h %></PRE>
117 %   }
118   </TD>
119 </TR>
120 % }
121
122 </TABLE>
123 <BR>
124
125 <INPUT TYPE="submit" VALUE="Submit">
126
127 </FORM>
128
129 <% include('/elements/footer.html') %>
130
131 <%init>
132
133 die "access denied"
134   unless $FS::CurrentUser::CurrentUser->access_right('Provision customer service'); #something else more specific?
135
136 my $conf = new FS::Conf;
137
138 my($svcnum, $pkgnum, $svcpart, $part_svc, $svc_cert );
139 if ( $cgi->param('error') ) {
140
141   $svc_cert = new FS::svc_cert ( {
142     map { $_, scalar($cgi->param($_)) } fields('svc_cert')
143   } );
144   $svcnum = $svc_cert->svcnum;
145   $pkgnum = $cgi->param('pkgnum');
146   $svcpart = $cgi->param('svcpart');
147   $part_svc = qsearchs('part_svc', { 'svcpart' => $svcpart } );
148   die "No part_svc entry!" unless $part_svc;
149
150 } elsif ( $cgi->param('pkgnum') && $cgi->param('svcpart') ) { #adding
151
152   $cgi->param('pkgnum') =~ /^(\d+)$/ or die 'unparsable pkgnum';
153   $pkgnum = $1;
154   $cgi->param('svcpart') =~ /^(\d+)$/ or die 'unparsable svcpart';
155   $svcpart = $1;
156
157   $part_svc=qsearchs('part_svc',{'svcpart'=>$svcpart});
158   die "No part_svc entry!" unless $part_svc;
159
160   $svc_cert = new FS::svc_cert({});
161
162   $svcnum='';
163
164   $svc_cert->set_default_and_fixed;
165
166 } else { #editing
167
168   my($query) = $cgi->keywords;
169   $query =~ /^(\d+)$/ or die "unparsable svcnum";
170   $svcnum=$1;
171   $svc_cert=qsearchs('svc_cert',{'svcnum'=>$svcnum})
172     or die "Unknown (svc_cert) svcnum!";
173
174   my($cust_svc)=qsearchs('cust_svc',{'svcnum'=>$svcnum})
175     or die "Unknown (cust_svc) svcnum!";
176
177   $pkgnum=$cust_svc->pkgnum;
178   $svcpart=$cust_svc->svcpart;
179
180   $part_svc=qsearchs('part_svc',{'svcpart'=>$svcpart});
181   die "No part_svc entry!" unless $part_svc;
182
183 }
184 my $action = $svcnum ? 'Edit' : 'Add';
185
186 my $svc = $part_svc->getfield('svc');
187
188 #my $otaker = getotaker;
189
190 my $p1 = popurl(1);
191
192 my $link_query = "?svcnum=$svcnum;pkgnum=$pkgnum;svcpart=$svcpart";
193
194 </%init>