Optimize "Customer has a referring customer" condition, RT#74452
[freeside.git] / httemplate / view / svc_cert.cgi
index 48494d2..964b808 100644 (file)
@@ -17,7 +17,7 @@ my %labels = map { $_ =>  ( ref($fields->{$_})
 
 my @fields = (
   { field=>'privatekey',
-    value=> sub {
+    value_callback=> sub {
       my $svc_cert = shift;
       if ( $svc_cert->privatekey && $svc_cert->check_privatekey ) {
         '<FONT COLOR="#33ff33">Verification OK</FONT>';
@@ -31,11 +31,33 @@ my @fields = (
   qw( common_name organization organization_unit city state country cert_contact
     ),
   { 'field'=>'csr',
-    'value'=> sub {
+    'value_callback'=> sub {
       my $svc_cert = shift;
-      if ( $svc_cert->csr ) { #display the subject etc?
-        '<PRE><FONT STYLE="font-family:monospace">'. "\n". $svc_cert->csr.
-        '</FONT></PRE>';
+      if ( $svc_cert->csr ) {
+
+        my $out = '';
+
+        my %hash = $svc_cert->check_csr;
+
+        $out .= include('/elements/table-grid.html'). #'<TABLE>'.
+                '<TR><TH COLSPAN=2 BGCOLOR="#cccccc" ALIGN="center">'.
+                'Requested by</TH></TR>';
+
+        my $col = $svc_cert->subj_col;
+
+        foreach my $key (keys %hash) {
+          $out .= "<TR><TD>". $labels{$col->{$key}}.  "</TD>".
+                      "<TD>". $hash{$key}. "</TD></TR>";
+        }
+
+        $out .= '</TABLE>';
+
+        $out .= 
+          '<PRE><FONT STYLE="font-family:monospace">'. $svc_cert->csr.
+          '</FONT></PRE>';
+
+        $out;
+
       } elsif ( $svc_cert->common_name ) {
         my $svcnum = $svc_cert->svcnum;
         qq(<A HREF="${p}misc/svc_cert-generate.html?action=generate_csr;svcnum=$svcnum">Generate</A>);
@@ -45,7 +67,7 @@ my @fields = (
     },
   },
   { 'field'=>'certificate',
-    'value'=> sub {
+    'value_callback'=> sub {
       my $svc_cert = shift;
       if ( $svc_cert->certificate ) {
 
@@ -115,7 +137,7 @@ my @fields = (
     },
   },
   { 'field'=>'cacert',
-    'value'=> sub {
+    'value_callback'=> sub {
       my $svc_cert = shift;
       if ( $svc_cert->cacert ) {