<div class="hpanel">

	<div class="panel-body">

		<?php if($action == 'create'): ?>
		<h3>Agregar nueva tecnología</h3>
		<?php else: ?>
		<h3>Editar tecnología</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-tecnologia" method="post" enctype="multipart/form-data" role="form" data-toggle="validator">

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

			<input type="hidden" name="id" value="<?php echo e($tecnologia->id); ?>" />
			
			<div class="form-group">
				<label for="nombre">Nombre</label>
				<input type="text" id="nombre" name="nombre" value="<?php echo e($tecnologia->nombre); ?>" class="form-control"/>
				<div class="help-block with-errors"></div>
			</div>
			
			<div class="form-group">
				<label for="descripcion">Descripcion</label>
				<textarea id="descripcion" name="descripcion" class="form-control" required><?php echo e($tecnologia->descripcion); ?></textarea>
				<div class="help-block with-errors"></div>
			</div>
			
			<div class="form-group">
				<label for="video">Video</label>
				<input type="text" id="video" name="video" value="<?php echo e($tecnologia->video); ?>" class="form-control"/>
				<div class="help-block with-errors"></div>
			</div>

			<div class="form-group">
				<label for="duracion">Duración estimada (min.)</label>
				<input id="duracion" name="duracion" type="number" class="form-control" value="<?php echo e($tecnologia->duracion); ?>" required />
				<div class="help-block with-errors"></div>
			</div>
	
			<div class="form-group">
				<label for="imagen">Imagen <small>(Tamaño: 250 x 220, Peso: < 300 kb sugerido)</small></label>
				<input type="file" id="photo" name="photo" data-ext='{"extp": ["image/png", "image/jpg", "image/jpeg", "image/gif"]}' accept="image/*" />
				<div class="help-block with-errors"></div>
			</div>

			<div class="form-group">
				<label for="imagen_2">Imagen 2 <small>(Tamaño: 250 x 220, Peso: < 300 kb sugerido)</small></label>
				<input type="file" id="imagen_2" name="imagen_2" data-ext='{"extp": ["image/png", "image/jpg", "image/jpeg", "image/gif"]}' accept="image/*" />
				<div class="help-block with-errors"></div>
			</div>
			
			<div class="form-group">
				<label for="categoria">Categoría</label>
				<select id="categoria" name="categoria" class="form-control" required >
					<option value="">Seleccione</option>
					<?php foreach($categorias as $categoria): ?>
					<option value="<?php echo e($categoria->id); ?>" <?php echo e($categoria->id == $tecnologia->id_categoria ? 'selected' : ''); ?>><?php echo e($categoria->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/tecnologias" class="btn btn-default">Cancelar</a>
			</div>
			
		</form>

	</div>

</div>
<?php $__env->startSection('scripts'); ?>
<script type="text/javascript">
	
	$('#form-tecnologia').bootstrapValidator({
		fields: {
			nombre: {
                validators: {
                    notEmpty: {
                        message: 'Por favor, introduzca un nombre.'
                    },
                    stringLength: {
                        //max: 60,
                        message: 'El nombre no debe exceder 60 caracteres.'
                    },
                }
            },
            descripcion: {
                validators: {
                    notEmpty: {
                        message: 'Por favor, introduzca una descripción.'
                    },
                    stringLength: {
                        //max: 400,
                        message: 'La descripción no debe exceder 400 caracteres.'
                    },
                }
            },
            duracion: {
                validators: {
                    notEmpty: {
                        message: 'Por favor, introduzca una duración estimada.'
                    },
                    integer: {
                        message: 'Por favor, introduzca un valor entero.'
                    },
                }
            },
			photo: {
				validators: {
					file: {
						extension: 'jpeg,jpg,png,JPG,PNG',
						type: 'image/jpeg,image/png',
						message: 'El formato de imagen debe ser .png o .jpg'
					}
				}
			},
			categoria: {
                validators: {
                    notEmpty: {
                        message: 'Por favor, selecciones una categoría.'
                    }
                }
            },
            video: {
            	validators: {
            		regexp: {
            			regexp: /^(?:https?:\/\/)?(?:www\.)?(?:youtu\.be\/|youtube\.com\/(?:embed\/|v\/|watch\?v=|watch\?.+&v=))((\w|-){11})(?:\S+)?$/,
            			message: 'Introduzca una dirección de YouTube válida.'
            		}
            	}
            }
		},

	});

</script>
<?php $__env->stopSection(); ?>