Revision 566 (by ahitrov, 2016/04/19 21:56:45) Bug during existing phone storing

% if ( $state->{users}->use_credentials && $object->id ) {
<script type="text/javascript">
<!--
function check_<% $name %>_valid( nID ){
}

$(document).ready(function(){

% foreach my $cred ( @credentials ) {
	$('#<% $name %>_name_orig_<% $cred->id %>_text').focusout(function(){
		var oPhone = $(this);
		$.get('/contenido/ajax/credential_phone_valid.html', { 'id' : '<% $object->id %>', 'phone' : $(oPhone).val() }, function(data){
			if ( data.error ) {
				$('#<% $name %>_<% $cred->id %>_check').attr('title', data.error).html('<span style="color:red">Error</span>');
			} else {
				$('#<% $name %>_<% $cred->id %>_check').attr('title', '').html('<span style="color:green">Ok</span>');
			}
		}, 'json');
	});
% }

	$('#<% $name %>_name_orig__text').focusout(function(){
		var oPhone = $(this);
		$.get('/contenido/ajax/credential_phone_valid.html', { 'id' : '<% $object->id %>', 'phone' : $(oPhone).val() }, function(data){
			if ( data.error ) {
				$('#<% $name %>_new_check').attr('title', data.error).html('<span style="color:red">Error</span>');
			} else if ( data.nothing ) {
				$('#<% $name %>_new_check').attr('title', '').html('');
			} else {
				$('#<% $name %>_new_check').attr('title', '').html('<span style="color:green">Ok</span>');
			}
		}, 'json');
	});

});
//-->
</script>
<div style="border:1px solid gray; padding:2px; width:95%;">
<table width="100%" cellpadding="5" cellspacing="0">
<tr bgcolor="white">
<th>Main</th>
<th>Телефон</th>
<th>ID</th>
<th>Активен</th>
<th>Удалить</th>
<th></th>
</tr>
%	foreach my $cred ( @credentials ) {
%		my $checked = $cred->main ? ' checked' : '';
%		my $bgcolor = $i++ % 2 ? 'white' : '#e0e0e0';
%		my $active = $cred->status == 1 ? ' checked' : '';
<tr bgcolor="<% $bgcolor %>">
<td width="1%"><input type="radio" name="<% $name %>.main" value="<% $cred->id %>"<% $checked %>></td>
<td width="84%"><& /contenido/components/inputs/string.msn, name => $name.'_name_orig_'.$cred->id, prop => $prop, check => $cred->name_orig, object => $object &></td>
<td width="12%"><& /contenido/components/inputs/string.msn, name => $name.'_name_'.$cred->id, prop => $prop, check => $cred->name, object => $object &></td>
<td width="1%"><input type="checkbox" name="<% $name %>_active_<% $cred->id %>" value="1"<% $active %>></td>
<td width="1%"><input type="checkbox" name="<% $name %>.delete" value="<% $cred->id %>"></td>
<td width="1%" id="<% $name %>_<% $cred->id %>_check"><span style="color:green">Ok</span></td>
</tr>
%	}
<tr bgcolor="<% $i++ % 2 ? 'white' : '#e0e0e0' %>">
<td><input type="radio" name="<% $name %>.main" value=""></td>
<td><& /contenido/components/inputs/string.msn, name => $name.'_name_orig_', prop => $prop, check => '', object => $object &></td>
<td></td>
<td><input type="checkbox" name="<% $name %>_active_" value="1"></td>
<td></td>
<td id="<% $name %>_new_check"></td>
</tr>
</table>
</div>
% } else {
<& /contenido/components/inputs/string.msn, %ARGS &>
% }
<%args>

	$name	=> undef
	$check	=> undef
	$prop	=> {}
	$object	=> undef

</%args>
<%init>

    my @credentials;
    if ( $state->{users}->use_credentials ) {
	@credentials = $keeper->get_documents(
			class	=> 'users::Phone',
			uid	=> $object->id,
			order_by	=> 'main desc, name',
		);
    }
    my $i = 0;

</%init>