Line # Revision Author
1 523 ahitrov % if ( $state->{users}->use_credentials && $object->id ) {
2 <script type="text/javascript">
3 <!--
4 function check_<% $name %>_valid( nID ){
5 }
6
7 $(document).ready(function(){
8
9 % foreach my $cred ( @credentials ) {
10 566 ahitrov $('#<% $name %>_name_orig_<% $cred->id %>_text').focusout(function(){
11 523 ahitrov var oPhone = $(this);
12 $.get('/contenido/ajax/credential_phone_valid.html', { 'id' : '<% $object->id %>', 'phone' : $(oPhone).val() }, function(data){
13 if ( data.error ) {
14 $('#<% $name %>_<% $cred->id %>_check').attr('title', data.error).html('<span style="color:red">Error</span>');
15 } else {
16 $('#<% $name %>_<% $cred->id %>_check').attr('title', '').html('<span style="color:green">Ok</span>');
17 }
18 }, 'json');
19 });
20 % }
21
22 566 ahitrov $('#<% $name %>_name_orig__text').focusout(function(){
23 523 ahitrov var oPhone = $(this);
24 $.get('/contenido/ajax/credential_phone_valid.html', { 'id' : '<% $object->id %>', 'phone' : $(oPhone).val() }, function(data){
25 if ( data.error ) {
26 $('#<% $name %>_new_check').attr('title', data.error).html('<span style="color:red">Error</span>');
27 } else if ( data.nothing ) {
28 $('#<% $name %>_new_check').attr('title', '').html('');
29 } else {
30 $('#<% $name %>_new_check').attr('title', '').html('<span style="color:green">Ok</span>');
31 }
32 }, 'json');
33 });
34
35 });
36 //-->
37 </script>
38 <div style="border:1px solid gray; padding:2px; width:95%;">
39 <table width="100%" cellpadding="5" cellspacing="0">
40 <tr bgcolor="white">
41 <th>Main</th>
42 <th>Телефон</th>
43 566 ahitrov <th>ID</th>
44 523 ahitrov <th>Активен</th>
45 <th>Удалить</th>
46 <th></th>
47 </tr>
48 % foreach my $cred ( @credentials ) {
49 % my $checked = $cred->main ? ' checked' : '';
50 % my $bgcolor = $i++ % 2 ? 'white' : '#e0e0e0';
51 % my $active = $cred->status == 1 ? ' checked' : '';
52 <tr bgcolor="<% $bgcolor %>">
53 <td width="1%"><input type="radio" name="<% $name %>.main" value="<% $cred->id %>"<% $checked %>></td>
54 566 ahitrov <td width="84%"><& /contenido/components/inputs/string.msn, name => $name.'_name_orig_'.$cred->id, prop => $prop, check => $cred->name_orig, object => $object &></td>
55 <td width="12%"><& /contenido/components/inputs/string.msn, name => $name.'_name_'.$cred->id, prop => $prop, check => $cred->name, object => $object &></td>
56 523 ahitrov <td width="1%"><input type="checkbox" name="<% $name %>_active_<% $cred->id %>" value="1"<% $active %>></td>
57 <td width="1%"><input type="checkbox" name="<% $name %>.delete" value="<% $cred->id %>"></td>
58 <td width="1%" id="<% $name %>_<% $cred->id %>_check"><span style="color:green">Ok</span></td>
59 </tr>
60 % }
61 <tr bgcolor="<% $i++ % 2 ? 'white' : '#e0e0e0' %>">
62 <td><input type="radio" name="<% $name %>.main" value=""></td>
63 566 ahitrov <td><& /contenido/components/inputs/string.msn, name => $name.'_name_orig_', prop => $prop, check => '', object => $object &></td>
64 523 ahitrov <td></td>
65 <td><input type="checkbox" name="<% $name %>_active_" value="1"></td>
66 <td></td>
67 <td id="<% $name %>_new_check"></td>
68 </tr>
69 </table>
70 </div>
71 % } else {
72 <& /contenido/components/inputs/string.msn, %ARGS &>
73 % }
74 <%args>
75
76 $name => undef
77 $check => undef
78 $prop => {}
79 $object => undef
80
81 </%args>
82 <%init>
83
84 my @credentials;
85 if ( $state->{users}->use_credentials ) {
86 @credentials = $keeper->get_documents(
87 class => 'users::Phone',
88 uid => $object->id,
89 order_by => 'main desc, name',
90 );
91 }
92 my $i = 0;
93
94 </%init>