web interface: reorder input fields in certificate search page
[openxpki.git] / trunk / clients / perl / OpenXPKI-Client-HTML-Mason / htdocs / service / workflow / show_csr_brief.html
blob06ae73b358180f797d2bb4559fce2e3130932cff
1 <%args>
2 $type => undef
3 $id => undef
4 $msg => undef
5 $activities => undef
6 </%args>
7 % if (! defined $type) {
8 % $type = $context->{client}->send_receive_command_msg(
9 % 'get_workflow_type_for_id',
10 % {
11 % ID => $id,
12 % },
13 % )->{PARAMS};
14 % }
15 % if ($type eq 'I18N_OPENXPKI_WF_TYPE_SCEP_REQUEST') {
16 <h1><% i18nGettext ('I18N_OPENXPKI_CLIENT_HTML_MASON_WORKFLOW_SHOW_CSR_BRIEF_TITLE_SCEP', '__WORKFLOWID__' => $msg->{PARAMS}->{WORKFLOW}->{ID}, '__STATE__' => $msg->{PARAMS}->{WORKFLOW}->{STATE} ) %></h1>
17 % }
18 % elsif ($type eq 'I18N_OPENXPKI_WF_TYPE_SMARTCARD_PERSONALIZATION') {
19 <h1><% i18nGettext ('I18N_OPENXPKI_CLIENT_HTML_MASON_WORKFLOW_SHOW_CSR_BRIEF_TITLE_SMARTCARD', '__WORKFLOWID__' => $msg->{PARAMS}->{WORKFLOW}->{ID}, '__STATE__' => $msg->{PARAMS}->{WORKFLOW}->{STATE} ) %></h1>
20 % }
21 % else {
22 <h1><% i18nGettext ('I18N_OPENXPKI_CLIENT_HTML_MASON_WORKFLOW_SHOW_CSR_BRIEF_TITLE', '__WORKFLOWID__' => $msg->{PARAMS}->{WORKFLOW}->{ID}, '__STATE__' => $msg->{PARAMS}->{WORKFLOW}->{STATE} ) %></h1>
23 % }
24 <p>
26 <table>
27 <tr>
28 % foreach my $action (qw(
29 % I18N_OPENXPKI_WF_ACTION_PERSIST_CSR
30 % I18N_OPENXPKI_WF_ACTION_APPROVE_CSR
31 % I18N_OPENXPKI_WF_ACTION_CANCEL_CSR_APPROVAL
32 % I18N_OPENXPKI_WF_ACTION_REJECT_CSR
33 % I18N_OPENXPKI_WF_ACTION_CHANGE_NOTBEFORE
34 % I18N_OPENXPKI_WF_ACTION_CHANGE_NOTAFTER
35 % )) {
36 % my $filename = lc($action);
37 % $filename =~ s/i18n_openxpki_wf_action_//;
38 % if (exists $actions{i18nGettext($action)}) {
39 <td>
40 <& /service/open_form.mhtml, 'action' => $context->{menu}->get_root()."/service/workflow/activity/$filename.html" &>
41 <& /lib/html/hidden.mhtml, 'name' => 'type', 'value' => $type &>
42 <& /lib/html/hidden.mhtml, 'name' => 'id', 'value' => $id &>
43 <& /lib/html/hidden.mhtml, 'name' => 'context_hash', 'value' => $context_hash &>
44 <& /lib/html/input.mhtml, 'type' => 'submit', 'value' => i18nGettext($action) &>
45 <& /service/close_form.mhtml &>
46 </td>
47 % }
48 % }
49 </tr>
50 </table>
51 <table>
52 % if ($creator ne '') {
53 <tr>
54 <td><% i18nGettext('I18N_OPENXPKI_CLIENT_HTML_MASON_CREATOR') %>:</td>
55 <td>
56 <& /lib/html/a.mhtml,
57 target => $context->{menu}->get_root()."/service/workflow/show_pending_requests.html",
58 params => [
59 [ 'creator', $creator ],
60 [ 'show_approval_buttons', 1],
62 label => $creator &>
63 % if (defined $mail) {
64 (<a href="mailto:<% $mail %>">mail</a>)
65 % }
66 </td>
67 </tr>
68 % }
69 <!-- TODO - add type (basic, PKCS#10, SPKAC, IE) -->
71 % if (scalar @tickets) {
72 <tr>
73 <td><% i18nGettext('I18N_OPENXPKI_CLIENT_HTML_MASON_TICKETS') %>:</td>
74 <td>
75 % my $tickets = join(q{, }, @tickets);
76 <% $tickets | n %>
77 </td>
78 </tr>
79 % }
80 <tr>
81 <td><% i18nGettext('I18N_OPENXPKI_CLIENT_HTML_MASON_WORKFLOW_LAST_UPDATE') %></td>
82 <td><% $last_update %></td>
83 </tr>
84 % if ($type ne 'I18N_OPENXPKI_WF_TYPE_SMARTCARD_PERSONALIZATION') {
85 <tr>
86 <td><& '/lib/field_to_i18n.mhtml', 'field' => 'cert_role' &>
87 % if (exists $sources->{'cert_role'} && $sources->{'cert_role'} ne 'USER') {
88 (<% i18nGettext('I18N_OPENXPKI_CLIENT_HTML_MASON_SOURCE') %>: <% $sources->{'cert_role'} %>)
89 % }
90 / <& '/lib/field_to_i18n.mhtml', field => 'cert_profile' &>
91 % if (exists $sources->{'cert_role'} && $sources->{'cert_profile'} ne 'USER') {
92 (<% i18nGettext('I18N_OPENXPKI_CLIENT_HTML_MASON_SOURCE') %>: <% $sources->{'cert_profile'} %>)
93 % }
94 </td>
95 <td>
96 <table><tr><td>
97 <% $role %>
98 </td><td>
99 % if (exists $actions{i18nGettext('I18N_OPENXPKI_WF_ACTION_CHANGE_CSR_ROLE')}) {
100 <& /service/open_form.mhtml, 'action' => $context->{menu}->get_root()."/service/workflow/activity/change_csr_role.html" &>
101 <& /lib/html/hidden.mhtml, 'name' => 'type', 'value' => $type &>
102 <& /lib/html/hidden.mhtml, 'name' => 'id', 'value' => $id &>
103 <& /lib/html/input.mhtml, 'type' => 'submit', 'value' => i18nGettext('I18N_OPENXPKI_HTML_MASON_CHANGE') &>
104 <& /service/close_form.mhtml &>
106 </td><td>
107 / <% i18nGettext($profile) %>
108 </td><td>
109 % if (exists $actions{i18nGettext('I18N_OPENXPKI_WF_ACTION_CHANGE_CSR_PROFILE')}) {
110 <& /service/open_form.mhtml, 'action' => $context->{menu}->get_root()."/service/workflow/activity/change_csr_profile.html" &>
111 <& /lib/html/hidden.mhtml, 'name' => 'type', 'value' => $type &>
112 <& /lib/html/hidden.mhtml, 'name' => 'id', 'value' => $id &>
113 <& /lib/html/input.mhtml, 'type' => 'submit', 'value' => i18nGettext('I18N_OPENXPKI_HTML_MASON_CHANGE') &>
114 <& /service/close_form.mhtml &>
116 </td></tr></table>
117 </td>
118 </tr>
120 <tr>
121 <td><& '/lib/field_to_i18n.mhtml', 'field' => 'cert_subject' &></td>
122 <td>
123 <table><tr><td>
125 <& /lib/html/a.mhtml,
126 target => $context->{menu}->get_root()."/service/api/cert_list.html",
127 params => [
128 [ 'subject', $subject ],
130 label => $breakable_subject &>
131 % if (exists $sources->{'cert_subject_parts'} && $sources->{'cert_subject_parts'} ne 'USER') {
132 (<% i18nGettext('I18N_OPENXPKI_CLIENT_HTML_MASON_SOURCE') %>: <% $sources->{'cert_subject_parts'} %>)
134 </td>
135 <td>
136 % if (exists $actions{i18nGettext('I18N_OPENXPKI_WF_ACTION_CHANGE_CSR_SUBJECT')}) {
137 <& /service/open_form.mhtml, 'action' => $context->{menu}->get_root()."/service/workflow/activity/change_csr_subject.html" &>
138 <& /lib/html/hidden.mhtml, 'name' => 'type', 'value' => $type &>
139 <& /lib/html/hidden.mhtml, 'name' => 'id', 'value' => $id &>
140 <& /lib/html/input.mhtml, 'type' => 'submit', 'value' => i18nGettext('I18N_OPENXPKI_HTML_MASON_CHANGE') &>
141 <& /service/close_form.mhtml &>
142 % }
143 </td></tr></table>
144 </td>
145 </tr>
146 % if (scalar @sans) {
147 <tr>
148 <td><& '/lib/field_to_i18n.mhtml', field => 'cert_subject_alt_name' &>
149 % if ($sources->{'cert_subject_alt_name_parts'} ne 'USER') {
150 (<% i18nGettext('I18N_OPENXPKI_CLIENT_HTML_MASON_SOURCE') %>: <% $sources->{'cert_subject_alt_name_parts'} %>)
152 % if (exists $actions{i18nGettext('I18N_OPENXPKI_WF_ACTION_CHANGE_CSR_SUBJECT_ALT_NAME')}) {
153 <& /service/open_form.mhtml, 'action' => $context->{menu}->get_root()."/service/workflow/activity/change_csr_subject_alt_name.html" &>
154 <& /lib/html/hidden.mhtml, 'name' => 'type', 'value' => $type &>
155 <& /lib/html/hidden.mhtml, 'name' => 'id', 'value' => $id &>
156 <& /lib/html/input.mhtml, 'type' => 'submit', 'value' => i18nGettext('I18N_OPENXPKI_HTML_MASON_CHANGE') &>
157 <& /service/close_form.mhtml &>
158 % }
159 </td>
160 <td>
161 % foreach my $san (@sans) {
162 % if ($san->[0] =~ m{ \A DNS \z }xms) {
163 % if (! gethostbyname($san->[1])) {
164 <br><small><font color="#ff0000"><% $san->[0] %>: <% $san->[1] %></font></small>
166 % else {
167 <br><small><font color="#009900"><% $san->[0] %>: <% $san->[1] %></font></small>
170 % else {
171 <br><small><% $san->[0] %>: <% $san->[1] %></small>
174 </td>
175 </tr>
177 % foreach my $key (keys %cert_info) {
178 % # comments, etc.
179 % if (defined $cert_info{$key} && $cert_info{$key} ne '') {
180 <tr>
181 <td><& '/lib/field_to_i18n.mhtml', field => $key &></td>
182 <td><% $cert_info{$key} %></td>
183 </tr>
186 </table>
188 <& /lib/html/a.mhtml,
189 target => $context->{menu}->get_root()."/service/workflow/show_instance.html",
190 params => [
191 [ 'id', $id ],
192 [ 'type', $type ],
194 label => i18nGettext('I18N_OPENXPKI_CLIENT_HTML_MASON_SHOW_CSR_BRIEF_DETAILED_LINK') &>
195 </p>
196 <%once>
197 use Encode qw(encode decode);
198 </%once>
199 <%init>
200 if (not defined $msg or
201 not ref $msg or
202 not ref $msg eq "HASH")
204 if (! defined $type) {
205 # type was not specified, get it from the server
206 my $type_msg = $context->{client}->send_receive_command_msg(
207 'get_workflow_type_for_id',
209 'ID' => $id,
212 $type = $type_msg->{PARAMS};
214 ## ok we have to get the info from the server
215 $msg = $context->{client}->send_receive_command_msg
217 "get_workflow_info",
219 "WORKFLOW" => $type,
220 "ID" => $id
224 else
226 ## sometimes we have only the message
227 $id = $msg->{PARAMS}->{WORKFLOW}->{ID} if (not defined $id);
228 $type = $msg->{PARAMS}->{WORKFLOW}->{TYPE} if (not defined $type);
230 if (not defined $activities)
232 ## ok we have to get the info from the server
233 ## FIXME: this fails if type and id are undefined, id can
234 ## be extracted from $msg, but what about type?
235 my $hmsg = $context->{client}->send_receive_command_msg
237 "get_workflow_activities",
239 "WORKFLOW" => $type,
240 "ID" => $id
243 $activities = $hmsg->{PARAMS};
246 my %actions = ();
247 foreach my $key (@{$activities})
249 ## I hope that nobody will translate two actions with the same string
250 $actions{i18nGettext($key)} = $key;
253 my $creator = $msg->{PARAMS}->{WORKFLOW}->{CONTEXT}->{creator};
254 my $mail;
255 if ($creator =~ m{ \@ }xms) {
256 # looks like an e-mail address, let's make it a link
257 $mail = $creator;
259 my $last_update = $msg->{PARAMS}->{WORKFLOW}->{LAST_UPDATE};
260 $last_update =~ s{T}{ }xms;
262 my $ser = OpenXPKI::Serialization::Simple->new();
264 my $sources = {};
265 my $sources_ser = $msg->{PARAMS}->{WORKFLOW}->{CONTEXT}->{sources};
266 if (defined $sources_ser && $sources_ser ne '') {
267 $sources = $ser->deserialize($sources_ser);
270 my $subject = $msg->{PARAMS}->{WORKFLOW}->{CONTEXT}->{cert_subject};
271 if ($type eq 'I18N_OPENXPKI_WF_TYPE_SMARTCARD_PERSONALIZATION') {
272 # Smartcard personalization workflow context has different structure
273 my $cert_iss_data = OpenXPKI::Serialization::Simple->new()->deserialize($msg->{PARAMS}->{WORKFLOW}->{CONTEXT}->{cert_issuance_data});
274 my @subjects = map { $_->{'cert_subject'} } @{ $cert_iss_data };
275 $subject = join q{<br>}, @subjects;
277 my $breakable_subject = $subject;
278 $breakable_subject =~ s{,}{, }xmsg;
280 my @sans;
281 my $san_ser = $msg->{PARAMS}->{WORKFLOW}->{CONTEXT}->{cert_subject_alt_name};
282 if (defined $san_ser && $san_ser ne '') {
283 my $san_ref = $ser->deserialize($san_ser);
284 if (ref $san_ref eq 'ARRAY') {
285 @sans = @{ $san_ref };
289 my $role = $msg->{PARAMS}->{WORKFLOW}->{CONTEXT}->{cert_role};
290 my $profile = $msg->{PARAMS}->{WORKFLOW}->{CONTEXT}->{cert_profile};
292 my @tickets = ();
293 my $ticket_ser = $msg->{PARAMS}->{WORKFLOW}->{CONTEXT}->{ticket};
294 if (defined $ticket_ser) {
295 my $tickets = $ser->deserialize($ticket_ser);
296 foreach my $key (keys %{ $tickets }) {
297 my $ticket_entry;
298 $ticket_entry->{ID} = $tickets->{$key};
299 my $url_msg = $context->{client}->send_receive_command_msg(
300 'get_url_for_ticket',
302 NOTIFIER => $key,
303 TICKET => $tickets->{$key},
306 $ticket_entry->{URL} = $url_msg->{PARAMS};
307 push @tickets, qq{<a href="$url_msg->{PARAMS}">$tickets->{$key}</a>};
311 my %cert_info;
312 my $cert_info_ser = $msg->{PARAMS}->{WORKFLOW}->{CONTEXT}->{cert_info};
313 if (defined $cert_info_ser) {
314 my $cert_info_deser = $ser->deserialize($cert_info_ser);
315 if (ref $cert_info_deser eq 'HASH') {
316 %cert_info = %{ $cert_info_deser };
320 my $context_hash = $m->comp('/service/workflow/context_hash.mhtml',
321 'context' => $msg->{PARAMS}->{WORKFLOW}->{CONTEXT},
323 </%init>