@extends('layouts.app')

@section('title',"Agregar entidad")

@section('content')
<div class="alert alert-secundary p-2 mb-0"><a href="{{ url('entidad') }}"><i class="icon-arrow-left13"></i> Volver al listado de entidad</a></div>
<div class="card ">
	<div class="card-body">
		<div class="response-data">
			
		</div>
		<form action="{{ url('entidad') }}" class="form-login" onsubmit="createform(this); return false">
			<input type="hidden" name="action" value="add">
			<div class="row">
				<div class="col-12 text-center text-uppercase ">
					<h3 class="font-weight-light">Crear  entidad</h3>
				</div>
			</div>
			<br/>
			<div class="row">
				<div class="col-2">
					<select name="persona_nacionalidad" class="form-control"  id="persona" required="" onchange="tipe_person(this); return false" >
						<option value="">Nacionalidad</option>
						<option value="n">Nacional</option>
						<option value="e">Extranjero</option>
					</select>
				</div>
				<div class="col-2">
					<select name="persona_tipe" class="form-control"  id="input-cont" required="" >
						<option value="">Persona</option>
						<option value="j">Juridica</option>
						<option value="n">Natural</option>
					</select>
				</div>
				<div class="col-2">
					<select name="identidad_document_id" class="form-control"  id="input-cont" onchange="change_document(); return false"  >
						<option value="">Tipo</option>
						@if($identidad->isNotEmpty())
							@foreach ($identidad as $i)
								<option value="{{ $i->id }}" data-codigo="{{ $i->codigo }}">{{$i->abrv}} || {{ $i->descripcion }}</option>
							@endforeach
						@endif
					</select>
				</div>
				<div class="col-2">
					<input type="text" class="form-control" id="tipe_c"  name="numero" placeholder="Numero de  documento" required="" onkeyup="tipe_ciudadano(this); return false">
				</div>
				<div class="col-2 text-left">
					<input type="checkbox"   id="input-cont" name="is_aduanas"  value="1"> <span id="input-label">Agente Aduanas </span>
				</div>
				<div class="col-2">
					<a  href="#" onclick="search_document(this); return false " data-type="POST" data-url="{{ url('utilitarios') }}" class="btn btn-warning btn-sm btn-search hide">Buscar</a>
				</div>
			</div>
			<hr>
			<div class="row">
				<div class="col-4">
					<input type="text" class="form-control" id="input-cont"  name="nsocial" placeholder="Razon social">
				</div>
				<div class="col-4">
					<input type="text" class="form-control" id="input-cont"  name="nomenclatura" placeholder="Nomenclatura">
				</div>
				<div class="col-4">
					<input type="email" class="form-control" id="input-cont"  name="email" placeholder="example@gmail.com">
				</div>
			</div>
			<hr>
			<div class="row">
				<div class="col-4">
					<input type="text" class="form-control" id="input-cont"  name="direccion" placeholder="Direccion ">
				</div>
				<div class="col-2">
					<input type="text" class="form-control ubigeo_input" id="input-cont"   name="ubigeo"  placeholder="Ubigeo">
				</div>
				<div class="col-2">
					<a href="#" class="btn btn-primary btn-sm" data-tipe="add" onclick="search_ubigeo(); return false">Bucar ubigeo</a>
				</div>
				<div class="col-4">
					<input type="text" class="form-control" id="input-cont"  name="departamento" placeholder="Departamento">
				</div>
			</div>

			<hr>
			<div class="content-natural hide">
				<div class="row">
					<div class="col-3">
						<input type="text" class="form-control names_natural" id="input-cont"  name="nombre1" placeholder="Ingrese su primer nombre">
					</div>
					<div class="col-3">
						<input type="text" class="form-control names_natural" id="input-cont"  name="nombre2" placeholder="Ingrese su segundo nombre">
					</div>
					<div class="col-3">
						<input type="text" class="form-control names_natural" id="input-cont"  name="apaterno" placeholder="Ingrese su apellido paterno">
					</div>
                    <div class="col-3">
						<input type="text" class="form-control names_natural" id="input-cont"  name="amaterno" placeholder="Ingrese su apellido materno">
					</div>
				</div>
				<hr>
			</div>
			<div class="row">
				<div class="col-12 text-center">
					<a href="#" id="reload_selects" data-tipe="add" > Seleccionar Ubicación manualmente</a>
				</div>
			</div>
			<div class="row ">
				<div class="col-4">
					<select name="departamentos_id"  data-tipe="provincias"  id="dynamic_selects"   class="form-control dynamic_selects selectpicker" data-live-search="true" >
						<option value="">Seleccionar..</option>
					</select>
				</div>
				<div class="col-4">
					<select name="provincias_id"  data-tipe="distritos"  id="provincias"   class="form-control dynamic_selects selectpicker" disabled="" data-live-search="true">

					</select>
				</div>
				<div class="col-4">
					<select name="distritos_id"  data-tipe="ubigeo"  id="distritos" class="form-control dynamic_selects selectpicker"  data-live-search="true" disabled="">
					</select>
				</div>
			</div>
			<hr>
			<div class="services_entidad hide" >
				@if($services->isNotEmpty())
					<div class="row mt-2">
						<div class="col-12">
							tabla 31 
							<select name="entidad_table31_id"  id="input-cont"  class="form-control services_id">
								@foreach ($services as $s)
									@if($s->table_tipe == '31')
										<option value="{{ $s->id }}">{{ $s->descripcion }}</option>
									@endif
								@endforeach
							</select>
						</div>
					</div>
					<div class="row mt-2">
						<div class="col-12">
							tabla 32
							<select name="entidad_table32_id"  id="input-cont"  class="form-control services_id">
								@foreach ($services as $s)
									@if($s->table_tipe == '32')
										<option value="{{ $s->id }}">{{ $s->descripcion }}</option>
									@endif
								@endforeach
							</select>
						</div>
					</div>
					<div class="row mt-2">
						<div class="col-12">
							tabla 33
							<select name="entidad_table33_id"  id="input-cont"  class="form-control services_id">
								@foreach ($services as $s)
									@if($s->table_tipe == '33')
										<option value="{{ $s->id }}">{{ $s->descripcion }}</option>
									@endif
								@endforeach
							</select>
						</div>
					</div>
					<div class="row mt-2">
						<div class="col-12">
							tabla 25 
							<select name="entidad_table25_id"  id="input-cont"  class="form-control services_id">
								@foreach ($services as $s)
									@if($s->table_tipe == '25')
										<option value="{{ $s->id }}">{{ $s->descripcion }}</option>
									@endif
								@endforeach
							</select>
						</div>
					</div>
				@endif
				<hr>
			</div>

			<div class="row">
				<div class="col-12 text-center">
					<br>
					<button class="btn btn-primary"><i class="icon-floppy-disk "></i> Guardar</button>
				</div>
			</div>
		</form>
	</div>
</div>
<script>
	var departamentos = @json($localidad['departamentos']);
	var provincias = @json($localidad['provincias']);
	var distrito = @json($localidad['distritos']);
	var ubigeourl = '{{ url("utilitarios") }}';
</script>
	@section('scripts')
		<script src="{!! asset('assets/views_functions/entidad.js') !!}"></script>
	@endsection
@endsection