{% extends "@crud\\crud\\new.html.twig" %}
{% block jquery %}
{{ parent() }}
<script type="text/javascript">
$(function()
{
var submitted = false;
$('#searchForm').submit(function(e){
e.preventDefault();
if ($('#identificacion').val()=='')
{
showError(bootbox,"{{ 'usuario.error.identificacion' | trans({}, 'crud') }}");
}
else
{
$("#searchDiv").mask(" Buscando...");
var url='{{ path('busca_usuario', {'numeroId':'__ID__','routeClassName': routeClassName}) }}';
url = url.replace('__ID__',$("#identificacion").val());
$.getJSON(url, function(data) {
if (data.resultado=='NO_USER')
{
$("#idData").html($('#identificacion').val());
$("#searchDiv").unmask();
$("#searchDiv").addClass('hide');
$("#nouser").removeClass('hide');
}
else
{
$("#searchDiv").unmask();
$("#searchDiv").addClass('hide');
$("#personBDId").val(data.id);
$("#personId").html(data.identificacion);
$("#personNombre").html(data.nombre);
$("#personTelefono").html(data.telefono);
$("#personMovil").html(data.movil);
$("#personMail").html(data.mail);
$("#personDireccion").html(data.direccion);
if (data.foto != "")
$("#personFoto").html('<img width="100%" src="'+data.foto+'">');
else
$("#personFoto").html('<img width="100%" src="{{ asset('images/foto_hombre.jpg') }}">');
if (!data.availabe)
{
$("#inhabilitado").removeClass('hide');
$("#inhabilitadoData").html(data.rol);
$("#confirmar").addClass('hide');
}
$("#person").removeClass('hide');
}
});
}
});
$('#searchAgainNoUser').click(function(){
$('#nouser').addClass('hide');
$('#searchDiv').removeClass('hide');
submitted = false;
});
$('#searchAgainWrongPerson').click(function(){
$('#person').addClass('hide');
$('#inhabilitado').addClass('hide');
$("#confirmar").removeClass('hide');
$('#searchDiv').removeClass('hide');
submitted = false;
});
$('#confirmar').click(function(){
$("#person").mask(" Cargando...");
var url='{{ path('fast_create', { 'rol': rol, 'routeClassName': routeClassName, 'id': '__ID__'}) }}';
var id = $('#personBDId').val();
url = url.replace('__ID__', id);
document.location.href = url;
});
$('#crear').click(function(){
$("#nouser").addClass("hide");
$('#form_{{ routeClassName }}_username').val($('#identificacion').val());
$('#form_{{ routeClassName }}_username').attr('readonly',true);
$('#form_{{ routeClassName }}_nit').val($('#identificacion').val());
$("#crud_form_{{ routeClassName}}").removeClass("hide");
});
$('#searchAgainForm').click(function(e){
e.preventDefault();
$('#personaId').html('');
$('#searchDiv').removeClass('hide');
$("#crud_form_{{ routeClassName}} input").val('');
$("#crud_form_{{ routeClassName}} select").val('');
$("#span_{{ routeClassName}}_direccion").html('');
$("#crud_form_{{ routeClassName}}").addClass("hide");
submitted = false;
});
$(".address").change(function(){
var address = $('#form_{{ routeClassName }}_calle').val();
address += ' Nro: '+$('#form_{{ routeClassName }}_numero').val();
if ($('#form_{{ routeClassName }}_apartamento').val())
address += ' Apto: '+$('#form_{{ routeClassName }}_apartamento').val();
address += ' e/'+$('#form_{{ routeClassName }}_entreCalle').val();
if ($('#form_{{ routeClassName }}_reparto').val())
address += ', '+$('#form_{{ routeClassName }}_reparto').val();
if ($('#form_{{ routeClassName }}_municipio').val())
address += '. '+$('#form_{{ routeClassName }}_municipio option:selected').text();
$('#form_{{ routeClassName }}_direccion').val(address);
$('#span_{{ routeClassName }}_direccion').html(address);
});
});
</script>
{% endblock %}
{% block ico_heading %}
{% endblock %}
{% block formulario %}
{% include 'Usuario\\formulario_new.html.twig' %}
{#
<span id="personaId" class="hide"></span>
<div id="content-usuario">
<div id="searchDiv" class="row">
<form id="searchForm">
<div class="col-xs-12">
<h5 class="blue lighter">{{ 'usuario.datos.identificacionTip' | trans({}, 'crud') | upper }}</h5>
</div>
<div class="col-xs-12 col-sm-5">
<table class="table table-striped table-bordered table-hover">
<tr>
<th style="width: 30%;">
<label class=" required ">
{{ 'admin.fields.username' | trans({}, 'crud') | upper }}
</label>
</th>
<td>
<input id="identificacion" type="text" style="width: 100%" required="true">
</select>
</td>
</tr>
</table>
</div>
<div class="col-xs-12 col-sm-2">
<button id="searchBtn" class="btn btn-info">
<i class="fas fa-search"></i>
{{ 'botones.buscar' | trans({}, 'crud') | upper }}
</button>
</div>
</form>
</div>
<div id="nouser" class="hide">
<div class="alert alert-danger">
<strong>
<i class="fas fa-info-circle bigger-150"></i>
{{ 'usuario.error.noexist' | trans({}, 'crud') }}
</strong>
<br>
<br>
<table>
<tr>
<td> </td>
<td style="text-align: right">
<strong>{{ 'admin.fields.username' | trans({}, 'crud') }}:</strong>
</td>
<td> </td>
<td>
<span id='idData'></span>
</td>
</tr>
</table>
<br>
</div>
<div class="row">
<div class="col-xs-6" style="text-align: center">
<button id="crear" class="btn btn-success">
<i class="fas fa-plus"></i>
{{ 'botones.nuevo' | trans({}, 'crud') | upper }}
</button>
</div>
<div class="col-xs-6" style="text-align: center">
<button id="searchAgainNoUser" class="btn btn-info">
<i class="fas fa-search"></i>
{{ 'botones.rebuscar' | trans({}, 'crud') | upper }}
</button>
</div>
</div>
</div>
<div id="person" class="hide">
<input id="personBDId" type="hidden">
<div class="row">
<div id="personFoto" class="col-xs-12 col-sm-6 col-md-2" style="text-align: center">
</div>
<div class="col-xs-12 col-sm-6 col-md-10">
<div class="row">
<div class="col-xs-12 col-sm-6">
<table class="table table-striped table-bordered table-hover">
<tr>
<th style="width: 30%;">
<label>
{{ 'admin.fields.username' | trans({}, 'crud') }}
</label>
</th>
<td>
<span id="personId"></span>
</td>
</tr>
</table>
</div>
<div class="col-xs-12 col-sm-6">
<table class="table table-striped table-bordered table-hover">
<tr>
<th style="width: 30%;">
<label>
{{ 'admin.fields.nombreCompleto' | trans({}, 'crud') }}
</label>
</th>
<td>
<span id="personNombre"></span>
</td>
</tr>
</table>
</div>
</div>
<div class="row">
<div class="col-xs-12 col-sm-6">
<table class="table table-striped table-bordered table-hover">
<tr>
<th style="width: 30%;">
<label>
{{ 'admin.fields.telefono' | trans({}, 'crud') }}
</label>
</th>
<td>
<span id="personTelefono"></span>
</td>
</tr>
</table>
</div>
<div class="col-xs-12 col-sm-6">
<table class="table table-striped table-bordered table-hover">
<tr>
<th style="width: 30%;">
<label>
{{ 'admin.fields.movil' | trans({}, 'crud') }}
</label>
</th>
<td>
<span id="personMovil"></span>
</td>
</tr>
</table>
</div>
</div>
<div class="row">
<div class="col-xs-12 col-sm-6">
<table class="table table-striped table-bordered table-hover">
<tr>
<th style="width: 30%;">
<label>
{{ 'admin.fields.email' | trans({}, 'crud') }}
</label>
</th>
<td>
<span id="personMail"></span>
</td>
</tr>
</table>
</div>
<div class="col-xs-12 col-sm-6">
<table class="table table-striped table-bordered table-hover">
<tr>
<th style="width: 30%;">
<label>
{{ 'admin.fields.direccion' | trans({}, 'crud') }}
</label>
</th>
<td>
<span id="personDireccion"></span>
</td>
</tr>
</table>
</div>
</div>
</div>
</div>
<div id="inhabilitado" class="row hide">
<div class="col-xs-12">
<div class="hr hr-8 hr-dotted"></div>
<div class="alert alert-danger">
<strong>
<i class="fas fa-info-circle bigger-150"></i>
{{ 'usuario.inhabilitado.rol' | trans({}, 'crud') }}
</strong>
<br>
<br>
<span id="inhabilitadoData"><span>
<br>
</div>
</div>
</div>
<div class="hr hr-8 hr-dotted"></div>
<div class="row">
<div class="col-xs-6" style="text-align: center">
<button id="confirmar" class="btn btn-success">
<i class="fas fa-check"></i>
{{ 'botones.confirmar' | trans({}, 'crud') | upper }}
</button>
</div>
<div class="col-xs-6" style="text-align: center">
<button id="searchAgainWrongPerson" class="btn btn-info">
<i class="fas fa-search"></i>
{{ 'botones.rebuscar' | trans({}, 'crud') | upper }}
</button>
</div>
</div>
</div>
<div id="formDiv" class="hide">
<div id="formulario"></div>
</div>
</div>
#}
{% endblock formulario %}