summaryrefslogtreecommitdiff
path: root/httemplate/edit/svc_cert.cgi
blob: dc2cc3200485eb4554db018ab59a3292d785f4d2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
<% include('/elements/header.html', "$action $svc", '') %>

<% include('/elements/error.html') %>

<FORM ACTION="<% $p %>edit/process/svc_cert.cgi" METHOD=POST>
<INPUT TYPE="hidden" NAME="svcnum" VALUE="<% $svcnum %>">
<INPUT TYPE="hidden" NAME="pkgnum" VALUE="<% $pkgnum %>">
<INPUT TYPE="hidden" NAME="svcpart" VALUE="<% $svcpart %>">

<% ntable("#cccccc",2) %>

<TR>
  <TD ALIGN="right">Private key</TD>
  <TD BGCOLOR="#ffffff">

% if ( $svc_cert->privatekey && $svc_cert->check_privatekey ) {

    <FONT COLOR="#33ff33">Verification OK</FONT>
%   # remove key & cert link?  just unprovision?

    </TD></TR>

%   if (0) { #( $svc_cert->csr_submitted ) { #XXX add field?  date? }

%     # just show the fields once the csr has been submitted

%   } else {

%     my $cust_main = $svc_cert->cust_svc->cust_pkg->cust_main;

      <TR>
        <TD ALIGN="right">Common name</TD>
        <TD><INPUT TYPE="text" NAME="common_name" SIZE=40 MAXLENGTH=80 VALUE="<% $svc_cert->common_name |h %>"></TD>
      </TR>

      <TR>
        <TD ALIGN="right">Organization</TD>
        <TD><INPUT TYPE="text" NAME="organization" SIZE=40 MAXLENGTH=80 VALUE="<% $svc_cert->organization || $cust_main->company |h %>"></TD>
      </TR>

      <TR>
        <TD ALIGN="right">Organization Unit</TD>
        <TD><INPUT TYPE="text" NAME="organization_unit" SIZE=40 MAXLENGTH=80 VALUE="<% $svc_cert->organization_unit |h %>"></TD>
      </TR>

      <TR>
        <TD ALIGN="right">City</TD>
        <TD><% include('/elements/city.html',
                         'city'    => $svc_cert->city    || $cust_main->city,
                         'state'   => $svc_cert->state   || $cust_main->state,
                         'country' => $svc_cert->country || $cust_main->country,
                      )
            %>
        </TD>
      </TR>

      <TR>
        <TD ALIGN="right">State</TD>
        <TD><% include('/elements/select-state.html',
                         'city'    => $svc_cert->city    || $cust_main->city,
                         'state'   => $svc_cert->state   || $cust_main->state,
                         'country' => $svc_cert->country || $cust_main->country,
                      )
            %>
        </TD>
      </TR>

      <TR>
        <TD ALIGN="right">Country</TD>
        <TD><% include('/elements/select-country.html',
                         'city'    => $svc_cert->city    || $cust_main->city,
                         'state'   => $svc_cert->state   || $cust_main->state,
                         'country' => $svc_cert->country || $cust_main->country,
                      )
            %>
        </TD>
      </TR>

      <TR>
        <TD ALIGN="right">Contact email</TD>
        <TD><INPUT TYPE="text" NAME="cert_contact" SIZE=40 MAXLENGTH=80 VALUE="<% $svc_cert->cert_contact || ($cust_main->invoicing_list_emailonly)[0] |h %>"></TD>
      </TR>

%   }

% } else {
%   my $re = '';
%   if ( $svc_cert->privatekey ) {
      <FONT COLOR="#ff0000">Verification error</FONT>
%     $re = 'Clear and Re-';
%   }
    <% include('/elements/popup_link.html', {
        'action'         => "svc_cert/generate_privatekey.html$link_query",
        'label'          => $re.'Generate',
        'actionlabel'    => 'Generate private key',
        #opt
        'width'          => '350',
        'height'         => '150'
        #'color'          => '#ff0000',
        #'closetext'      => 'Go Away',      # the value '' removes the link
    })%>

    or

    <% include('/elements/popup_link.html', {
        'action'         => "svc_cert/import_privatekey.html$link_query",
        'label'          => $re.'Import',
        'actionlabel'    => 'Import private key',
        #opt
        'width'          => '544',
        'height'         => '368',
        #'color'          => '#ff0000',
        #'closetext'      => 'Go Away',      # the value '' removes the link
    })%>
%   if ( $svc_cert->privatekey ) {
      <PRE><% $svc_cert->privatekey |h %></PRE>
%   }
  </TD>
</TR>
% }

</TABLE>
<BR>

<INPUT TYPE="submit" VALUE="Submit">

</FORM>

<% include('/elements/footer.html') %>

<%init>

die "access denied"
  unless $FS::CurrentUser::CurrentUser->access_right('Provision customer service'); #something else more specific?

my $conf = new FS::Conf;

my($svcnum, $pkgnum, $svcpart, $part_svc, $svc_cert );
if ( $cgi->param('error') ) {

  $svc_cert = new FS::svc_cert ( {
    map { $_, scalar($cgi->param($_)) } fields('svc_cert')
  } );
  $svcnum = $svc_cert->svcnum;
  $pkgnum = $cgi->param('pkgnum');
  $svcpart = $cgi->param('svcpart');
  $part_svc = qsearchs('part_svc', { 'svcpart' => $svcpart } );
  die "No part_svc entry!" unless $part_svc;

} elsif ( $cgi->param('pkgnum') && $cgi->param('svcpart') ) { #adding

  $cgi->param('pkgnum') =~ /^(\d+)$/ or die 'unparsable pkgnum';
  $pkgnum = $1;
  $cgi->param('svcpart') =~ /^(\d+)$/ or die 'unparsable svcpart';
  $svcpart = $1;

  $part_svc=qsearchs('part_svc',{'svcpart'=>$svcpart});
  die "No part_svc entry!" unless $part_svc;

  $svc_cert = new FS::svc_cert({});

  $svcnum='';

  $svc_cert->set_default_and_fixed;

} else { #editing

  my($query) = $cgi->keywords;
  $query =~ /^(\d+)$/ or die "unparsable svcnum";
  $svcnum=$1;
  $svc_cert=qsearchs('svc_cert',{'svcnum'=>$svcnum})
    or die "Unknown (svc_cert) svcnum!";

  my($cust_svc)=qsearchs('cust_svc',{'svcnum'=>$svcnum})
    or die "Unknown (cust_svc) svcnum!";

  $pkgnum=$cust_svc->pkgnum;
  $svcpart=$cust_svc->svcpart;

  $part_svc=qsearchs('part_svc',{'svcpart'=>$svcpart});
  die "No part_svc entry!" unless $part_svc;

}
my $action = $svcnum ? 'Edit' : 'Add';

my $svc = $part_svc->getfield('svc');

my $p1 = popurl(1);

my $link_query = "?svcnum=$svcnum;pkgnum=$pkgnum;svcpart=$svcpart";

</%init>