<div class="hpanel">

	<div class="panel-body">

		<?php if($action == 'create'): ?>
		<h3>Agregar nueva sala</h3>
		<?php else: ?>
		<h3>Editar sala</h3>
		<?php endif; ?>
		
		<?php if( count($errors) > 0 ): ?>
		<div class="alert alert-danger">
			<ul>
				<?php foreach($errors->all() as $error): ?>
				<li><?php echo e($error); ?></li>
				<?php endforeach; ?>
			</ul>
		</div>
		<?php endif; ?>

		<form id="form-sala" method="post" data-validation="admin.sala.form" role="form">

			<input type="hidden" name="_token" value="<?php echo e(csrf_token()); ?>" />

			<input type="hidden" name="id" value="<?php echo e($sala->id); ?>" />
			
			<div class="form-group">
				<label for="nombre">Nombre de sala</label>
				<input type="text" id="nombre" name="nombre" value="<?php echo e($sala->nombre); ?>" class="form-control" required/>
				<div class="help-block with-errors"></div>
			</div>
			
			<div class="form-group">
				<label for="nombre">Hora de Apertura</label>
                <div class='input-group date' id='picker_ini'>
                    <input id="hora_ini" type='text' class="form-control" name="hora_ini" value="<?php echo e($sala->hora_ini); ?>" required/>
                    <span class="input-group-addon">
                        <span class="glyphicon glyphicon-calendar"></span>
                    </span>
                </div>
				<div class="help-block with-errors"></div>
            </div>
            <div class="form-group">
            	<label for="nombre">Hora de Cierre</label>
                <div class='input-group date' id='picker_fin'>
                	<input id="hora_fin" type='text' class="form-control" name="hora_fin" value="<?php echo e($sala->hora_fin); ?>" required/>
                    <span class="input-group-addon">
                        <span class="glyphicon glyphicon-calendar"></span>
                    </span>
                </div>
				<div class="help-block with-errors"></div>
            </div>

			<div class="form-group">
				<label for="concesionario">Concesionario</label>
				<select id="concesionario" name="concesionario" class="form-control" required>
					<option value="">Seleccione</option>
					<?php foreach($concesionarios as $concesionario): ?>
					<option value="<?php echo e($concesionario->id); ?>" <?php echo e($concesionario->id == $sala->id_concesionario ? 'selected' : ''); ?>><?php echo e($concesionario->nombre); ?></option>
					<?php endforeach; ?>
				</select>
				<div class="help-block with-errors"></div>
			</div>
			
			<div class="form-group">
				<input type="submit" class="btn btn-primary" value="Guardar" />
				<a href="/admin/salas" class="btn btn-default">Cancelar</a>
			</div>
		</form>

	</div>

</div>

<?php $__env->startSection('scripts'); ?>
	<script type="text/javascript">

		$('#form-sala').bootstrapValidator({
			exclude: false,
			fields: {
				nombre: {
	                validators: {
	                    notEmpty: {
	                        message: 'Por favor, introduzca un nombre.'
	                    }
	                }
	            },
	            hora_ini: {
	                validators: {
	                    notEmpty: {
	                        message: 'Por favor, seleccione una hora de apertura.'
	                    }
	                }
	            },
				hora_fin: {
	                validators: {
	                    notEmpty: {
	                        message: 'Por favor, seleccione una hora de cierre.'
	                    }
	                }
	            },
	            concesionario: {
	                validators: {
	                    notEmpty: {
	                        message: 'Por favor, seleccione un concesionario.'
	                    }
	                }
	            }
			},

		});

        $(function () {

			$('#picker_ini').datetimepicker({
				format: 'HH:mm'
			});

			$('#picker_fin').datetimepicker({
				format: 'HH:mm'
			});

			$("#picker_ini").on("changeDate", function(e){
				$("#form-sala").bootstrapValidator('revalidateField', 'hora_ini');
			});

			$("#picker_fin").on("changeDate", function(e){
				$("#form-sala").bootstrapValidator('revalidateField', 'hora_fin');
			});
        });
    </script>
<?php $__env->stopSection(); ?>