<%args>
    $wf_info => undef
    $steps   => undef
</%args>
<%init>
    my $cert_issuance_data = $wf_info->{CONTEXT}->{cert_issuance_data};
    my @begins = ($cert_issuance_data =~ m{-----BEGIN\ CERTIFICATE\ REQUEST-----}xmsg); 
    my $nr_of_already_created_csrs = scalar @begins;
    my $current_csr = $nr_of_already_created_csrs + 1;
    my $total_csrs = $wf_info->{CONTEXT}->{nr_of_certs};
    my $current_step = $current_csr;
</%init>

% if ($current_csr > 1) { # it is not the first time we are called, but there are more certificate requests to be generated
<h1> <% i18nGettext('I18N_OPENXPKI_HTML_SMARTCARD_MORE_CSRS_TITLE',
                    '__CURRENTSTEP__' => $current_step,
                    '__STEPS__' => $steps) %> </h1>
<p> <% i18nGettext('I18N_OPENXPKI_HTML_SMARTCARD_MORE_CERTIFICATE_REQUESTS_TO_BE_GENERATED', '__CURRENTCSR__' => $current_csr, '__TOTALCSRS__', $total_csrs) %></p>
% }
% else { # first page
<h1> <% i18nGettext('I18N_OPENXPKI_HTML_SMARTCARD_WELCOME_SCREEN_TITLE',
                    '__CURRENTSTEP__' => $current_step,
                    '__STEPS__' => $steps) %> </h1>
<p> <% i18nGettext('I18N_OPENXPKI_HTML_SMARTCARD_WELCOME_SCREEN_INTRO_TEXT') %> </p>
<table>
%     my @map_array = split/, /, $wf_info->{CONTEXT}->{display_mapping};
%     foreach (@map_array) {
%        my ($key, $value) = /(.*) -> (.*)/;
<tr>
  <td><% i18nGettext($value) %></td>
  <td><% $wf_info->{CONTEXT}->{'ldap_' . $key} %></td>
</tr>
%     }
% }
</table>
<p>
<script type="text/javascript">
<!--
    function DisableButtonAndCreateCSR() {
        CreateCSR('silent');
        document.OpenXPKI.Submit.disabled = true;
        //document.OpenXPKI.Submit.style.display = 'none';
        document.OpenXPKI.submit();
    }
-->
</script>
<& /service/open_form.mhtml &>
%    my $csp = $wf_info->{CONTEXT}->{client_csp};
%    my $bitlength = $wf_info->{CONTEXT}->{client_bitlength};
<& /lib/html/hidden.mhtml, 'name' => 'csp', 'value' => $csp &>
<& /lib/html/hidden.mhtml, 'name' => 'bits', 'value' => $bitlength &>
<& /lib/html/hidden.mhtml, 'name' => 'pkcs10', 'value' => '' &>
<& /lib/html/hidden.mhtml, 'name' => 'ie_subject', 'value' => 'dc=dummy,dc=subject,dc=for,cn=MSIE' &>
<input type="button"
       name="Submit"
       value="<% i18nGettext('I18N_OPENXPKI_HTML_SMARTCARD_CREATE_IE_CSR') %>"
       onClick="DisableButtonAndCreateCSR()"/>
<& /service/close_form.mhtml &>
