2 % if ( $error ) { #should redirect back to the posting page?
3 <% include("/elements/header-popup.html", "Error") %>
4 <P><FONT SIZE="+1" COLOR="#ff0000"><% $error |h %></FONT>
7 <BUTTON TYPE="button" onClick="parent.cClick();">Close</BUTTON>
10 <% include('/elements/header-popup.html', $title ) %>
11 <SCRIPT TYPE="text/javascript">
12 window.top.location = '<% popurl(3). "$popup/svc_cert.cgi?$svcnum" %>';
17 % $cgi->param('error', $error);
18 <% $cgi->redirect(popurl(2). "svc_cert.cgi?". $cgi->query_string ) %>
20 <% $cgi->redirect(popurl(3). "view/svc_cert.cgi?$svcnum") %>
25 unless $FS::CurrentUser::CurrentUser->access_right('Provision customer service'); #something else more specific?
27 $cgi->param('svcnum') =~ /^(\d*)$/ or die "Illegal svcnum!";
30 my $new = new FS::svc_cert ( {
32 $_, scalar($cgi->param($_));
33 } ( fields('svc_cert'), qw( pkgnum svcpart ) )
38 $old = qsearchs('svc_cert', { 'svcnum' => $svcnum } ) #agent virt;
39 or die 'unknown svcnum';
40 $new->$_( $old->$_ ) for grep $old->$_, qw( privatekey csr certificate cacert );
45 if ( $cgi->param('privatekey') eq '_generate' ) { #generate
47 $title = 'Key generated';
49 $cgi->param('keysize') =~ /^(\d+)$/ or die 'illegal keysize';
51 $new->generate_privatekey($keysize);
53 } elsif ( $cgi->param('privatekey') =~ /\S/ ) { #import
55 $title = 'Key imported';
57 $new->privatekey( $cgi->param('privatekey') );
59 #} #elsif ( $cgi->param('privatekey') eq '_clear' ) { #clear
61 } elsif ( $cgi->param('certificate') ) {
64 $title = 'Certificate imported';
66 $new->certificate( $cgi->param('certificate') );
67 $new->$_( $old->$_ ) for grep $old->$_, qw( recnum common_name organization organization_unit city state country cert_contact );
69 } elsif ( $cgi->param('cacert') ) {
72 $title = 'Certificate authority chain imported';
74 $new->cacert( $cgi->param('cacert') );
75 $new->$_( $old->$_ ) for grep $old->$_, qw( recnum common_name organization organization_unit city state country cert_contact );
80 if ($cgi->param('svcnum')) {
81 $error = $new->replace();
83 $error = $new->insert;
84 $svcnum = $new->svcnum;