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). "edit/svc_cert.cgi?$svcnum" %>';
17 % $cgi->param('error', $error);
18 <% $cgi->redirect(popurl(2). "svc_cert.cgi?". $cgi->query_string ) %>
20 %#change link when we make a non-generic view
21 %#<% $cgi->redirect(popurl(3). "view/svc_cert.cgi?$svcnum") %>
22 <% $cgi->redirect(popurl(3). "view/svc_Common.html?svcdb=svc_cert;svcnum=$svcnum") %>
27 unless $FS::CurrentUser::CurrentUser->access_right('Provision customer service'); #something else more specific?
29 $cgi->param('svcnum') =~ /^(\d*)$/ or die "Illegal svcnum!";
32 my $new = new FS::svc_cert ( {
34 $_, scalar($cgi->param($_));
35 } ( fields('svc_cert'), qw( pkgnum svcpart ) )
40 $old = qsearchs('svc_cert', { 'svcnum' => $svcnum } ) #agent virt;
41 or die 'unknown svcnum';
42 $new->$_( $old->$_ ) for grep $old->$_, qw( privatekey );
47 if ( $cgi->param('privatekey') eq '_generate' ) { #generate
49 $title = 'Key generated';
51 $cgi->param('keysize') =~ /^(\d+)$/ or die 'illegal keysize';
53 $new->generate_privatekey($keysize);
55 } elsif ( $cgi->param('privatekey') =~ /\S/ ) { #import
57 $title = 'Key imported';
59 $new->privatekey( $cgi->param('privatekey') );
61 } #elsif ( $cgi->param('privatekey') eq '_clear' ) { #import
64 if ($cgi->param('svcnum')) {
65 $error = $new->replace();
67 $error = $new->insert;
68 $svcnum = $new->svcnum;