<?php $__env->startSection('titulo', 'Crear paciente'); ?>
<?php $__env->startSection('css'); ?>
	<?php echo Html::style('css/jquery.datetimepicker.min.css'); ?>

<?php $__env->stopSection(); ?>
<?php $__env->startSection('botonera'); ?>
	<?php echo $__env->make('componentes.boton-volver-al-listado-de-pacientes', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>
	<?php echo $__env->make('componentes.boton-salir-con-aviso', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>
<?php $__env->stopSection(); ?>
<?php $__env->startSection('content'); ?>

	<?php /* modals */ ?>
	<?php echo $__env->make('componentes.modal-salir', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>
	<?php echo $__env->make('componentes.modal-volver-al-listado-de-pacientes', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>
	<?php echo $__env->make('alerts.request', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>

	<?php echo Form::open(['route'=>'paciente.store', 'method'=>'POST']); ?>

		<?php echo $__env->make('paciente.forms.paciente', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>
		<hr>
		<div class="row">
			<div class="col-xs-12">
				<div class="form-group">
					<?php echo Form::submit('Guardar', ['class'=>'btn btn-primary']); ?>

				</div>
			</div>
		</div>
	<?php echo Form::close(); ?>


<?php $__env->stopSection(); ?>
<?php $__env->startSection('scripts'); ?>

	<script type="text/javascript">
		$(document).ready(function(){

			var selectDepartamento = $('#departamento');
			var selectMunicipio = $('#municipio');
			var selectBarrio = $('#barrio');

			selectDepartamento.change(function(){
				if (selectDepartamento.val() != 0) {
					route = '<?php echo e(URL::to("cargar-municipios-con-departamento")); ?>/' + selectDepartamento.val();
					$.get(route, function(respuesta){
						selectMunicipio.html('<option value="0">Ninguno seleccionado</option>');
						$(respuesta).each(function(key, value){
							selectMunicipio.append('<option value="' + value.id + '"">' + value.nombre + '</option>');
						});
						selectMunicipio.prop('disabled', false);
						selectBarrio.prop('disabled', true);
						selectBarrio.html('<option value="0">Ninguno seleccionado</option>');
					});
				} else {
					selectMunicipio.prop('disabled', true);
					selectMunicipio.html('<option value="0">Ninguno seleccionado</option>');
					selectBarrio.prop('disabled', true);
					selectBarrio.html('<option value="0">Ninguno seleccionado</option>');
				}
			});

			selectMunicipio.change(function(){
				if (selectMunicipio.val() != 0) {
					route = '<?php echo e(URL::to("cargar-barrios-con-municipio")); ?>/' + selectMunicipio.val();
					$.get(route, function(respuesta){
						selectBarrio.html('<option value="0">Ninguno seleccionado</option>');
						$(respuesta).each(function(key, value){
							selectBarrio.append('<option value="' + value.id + '"">' + value.nombre + '</option>');
						});
						selectBarrio.prop('disabled', false);
					});
				} else {
					selectBarrio.prop('disabled', true);
					selectBarrio.html('<option value="0">Ninguno seleccionado</option>');
				}
			});
		
			// Inicializar el calendario
			$('#nacimiento').datetimepicker({
				timepicker:false,
					format:'d M Y'
			});
		});

		<?php echo $__env->make('componentes.script-mostrar-modal-request', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>

	</script>

	<?php echo $__env->make('paciente.js.verificar-disponibilidad-de-documento', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>

	<?php echo Html::script('js/jquery.datetimepicker.full.js'); ?>


<?php $__env->stopSection(); ?>
<?php echo $__env->make('layouts.admin-bloqueo-vista', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>