<%args>
    $workflow_type => undef
    $role          => undef
    $profile       => undef
    $subject_style => undef
    $keygen        => undef
    $pkcs10        => undef
    $subject       => undef
    $subject_alt_name => undef
    $info          => undef
    $CONFIG        => undef
</%args>

<& /service/open_form.mhtml &>

<& /lib/html/hidden.mhtml, 'name' => 'workflow_type', 'value' => $workflow_type &>
<& /lib/html/hidden.mhtml, 'name' => 'role',          'value' => $role &>
<& /lib/html/hidden.mhtml, 'name' => 'profile',       'value' => $profile &>
<& /lib/html/hidden.mhtml, 'name' => 'subject_style', 'value' => $subject_style &>
<& /lib/html/hidden.mhtml, 'name' => 'keygen',        'value' => $keygen &>
<& /lib/html/hidden.mhtml, 'name' => 'pkcs10',        'value' => $pkcs10 &>
<& /lib/html/hidden.mhtml, 'name' => 'subject',       'value' => $subject &>
<& /lib/html/hidden.mhtml, 'name' => 'subject_alt_name',   'value' => $subject_alt_name &>
<& /lib/html/hidden.mhtml, 'name' => 'FILLED_INFO_FORM', 'value' => 1 &>

<h1><% i18nGettext ('I18N_OPENXPKI_CLIENT_HTML_MASON_CREATE_CSR_GET_INFO_TITLE') %></h1>
<p>
  <% i18nGettext('I18N_OPENXPKI_CLIENT_HTML_MASON_CREATE_CSR_GET_INFO_DESCRIPTION') %>
</p>

<table>
% foreach my $item (@{$CONFIG->{$subject_style}->{INFOS}})
% {
    <tr>
      <td><% i18nGettext ($item->{LABEL}) %></td>
      <td>
        <& /lib/html/input.mhtml, 'type' => $item->{TYPE}, 'name' => $item->{NAME} &>
      </td>
    </tr>
% }
</table>

<& /service/send_form.mhtml &>
<& /service/close_form.mhtml &>

<& /service/create_csr/print_descriptions.mhtml, descriptions => \%descriptions &>

<%init>
    return $info if (defined $info);
    my @errors = ();
    my $ARGS   = {$m->request_args()};

    if ($ARGS->{'FILLED_INFO_FORM'})
    {
        # try to build info
        foreach my $item (@{$CONFIG->{$subject_style}->{INFOS}})
        {
            $info->{$item->{NAME}} = $ARGS->{$item->{NAME}};
        }

        ## serialize info
        ## warnings we must be safe against \n truncation
        my $serializer = OpenXPKI::Serialization::Simple->new({SEPARATOR => "-"});
        $info = $serializer->serialize($info);
        return $info;
    }

    ## ok we have to display the whole stuff
    my %descriptions = ();
    foreach my $item (@{$CONFIG->{$subject_style}->{INFOS}})
    {
        $descriptions{i18nGettext ($item->{LABEL})} =
            i18nGettext ($item->{DESCRIPTION});
    }
</%init>
