<?php $__env->startSection('CSS'); ?>
<?php echo HTML::style('image-picker/image-picker.css'); ?>

<style type="text/css">
	.image_picker_image {
		height: 260px !important; width: 200px !important;
	}
	.caption {
		text-align: center;
	}
	.caption h3 {
		font-weight: bold;
	}
	.caption button{
		display: inline-block;
		width: 135px;
		margin-bottom: 3px;
	}
	.caption a{
		display: inline-block;
		width: 135px;
		margin-bottom: 3px;
	}
	.activo{
		background-color: #efefef;
		border: 3px solid #5cb85c !important;
	}
	.modal-body {
		padding-bottom: 5px;
	}
	.mdAvatar .modal-dialog .modal-content .modal-header{ background-color: #363B3F; }
</style>
<?php $__env->stopSection(); ?>

<?php $__env->startSection('Contenido'); ?>
<div class="row">
	<div class="col-md-12">
		<h2><i class="fa fa-window-maximize"></i> Ventanas emergentes </h2>
	</div><!--/col-md-12-->
</div><!--/row-->

<div class="row">
	<div class="col-md-12">
		<?php if(Session::has('message')): ?>
		<div class="alert alert-info"><?php echo Session::get('message'); ?></div>
		<?php endif; ?>
	</div>
</div>

<div class="row">
	<div class="col-md-12">
		<div class="block-web">
			<div class="header"> <h3 class="content-header"> Crear nueva ventana emergente </h3> </div>
			<div class="porlets-content">
				<?php echo Form::open(array('route' => 'SysWebVEmergentesVentanasEmergentesAgregar', 'method' => 'post', 'class' => 'form-horizontal row-border', 'id' => 'frmAgregar', 'files' => true)); ?>

					<div class="margin-updown">
						<div class="row">
							<?php foreach($VentanasEmergentes as $VentanasEmergente): ?>
								<div class="col-sm-4 col-md-3">
									<div class="thumbnail" style="margin-bottom: 20px; border: 2px solid #363B3F; background-color: #f2f2f2;">
										<div class="caption">
											<h3 style="height: 70px;"> <?php echo $VentanasEmergente->nombre; ?> </h3>
										</div>
										<img src="<?php echo asset('SysWeb/PaginasAterrizaje/VentanasEmergentes/'.$VentanasEmergente->imagen); ?>" class="thumbnail" style="border: 3px solid #ddd;">
										<div class="caption">
											<button type="button" class="btn btn-success btnSelectionV tooltips" data-idV="<?php echo $VentanasEmergente->id; ?>" id="btnSelectionP" data-toggle="tooltip" data-original-title="Seleccionar" data-nombre="<?php echo $VentanasEmergente->nombre; ?>">
												<!--Seleccionar-->
												<i class="fa fa-check"></i>
											</button>
											<a href="<?php echo $VentanasEmergente->ruta; ?>" class="btn btn-primary tooltips <?php if($VentanasEmergente->ruta == ''): ?> disabled <?php endif; ?>" target="_blank" id="btnVisualP" data-toggle="tooltip" data-original-title="Previsualizar">
												<!--Previsualizar-->
												<i class="fa fa-eye"></i>
											</a>
										</div>
									</div>	
								</div>
							<?php endforeach; ?>
						</div>
					</div>
					<?php if( !isset($_GET['modulo']) ){ ?>
					<input type="hidden" name="modulo" value="PC">
					<?php }else{ ?>
					<input type="hidden" name="modulo" value="<?php echo $_GET['modulo']; ?>">
					<?php } ?>
				<?php echo Form::close(); ?>

		</div>
	</div>
</div><!--/row end-->
<?php $__env->stopSection(); ?>

<?php $__env->startSection('JS'); ?>
<?php echo HTML::script('image-picker/image-picker.min.js'); ?>

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

<?php $__env->startSection('JSOr'); ?>
$("select").imagepicker({ hide_select : true, show_label  : true });
$(".btnSelectionV").click(function(){
	var titulo = $(this).attr("data-nombre");
	var id = $(this).attr("data-idV");
	var modulo = $('[name="modulo"]').val();
	var mensaje = '<form action="#" id="frmVentanaEmergente"> \
		<div class="form-group"> \
			<label> ¿Qué nombre deseas asignarle a tu ventana emergente? </label> \
			<input type="text" class="form-control" placeholder="Nombre de la ventana emergente" name="nombre"></input> \
			<span class="text-danger" id="errnombre"> </span> \
		</div> \
		<input type="hidden" name="ventana_emergente" value="'+id+'"> \
		<input type="hidden" name="modulo" value="'+modulo+'"> \
	</form>';
	BootstrapDialog.show({
		cssClass: "mdAvatar",
		title: titulo,
		message: mensaje,
		draggable: true,
		closeByBackdrop: false,
		buttons: [{
			id: "btnAgregarV",
			label: "Agregar",
			cssClass: "btn-success btn-lg btn-block",
			action: function(dialogItself){
				$("#btnAgregarV").prop("disabled", true).html('<i class="fa fa-spinner fa-spin"></i> Procesando...');
				$.isLoading({ text: "Cargando..." }); NProgress.start();
				$.post(
					"<?php echo URL::route('SysWebVEmergentesVentanasEmergentesAgregar'); ?>",
					$("#frmVentanaEmergente").serialize(),
					function(data){
						$.isLoading("hide"); NProgress.done();
						$("#btnAgregarV").prop("disabled", false).html("Agregar");
						if(data.success){
							var urlEdicion = "<?php echo URL::route('SysWebVEmergentesVentanasEmergentesEditarV2', array(0)); ?>";
							urlEdicion = urlEdicion.replace("0", data.idVE);
							new PNotify({ title: "Realizado", text: data.mensaje, type: "success" });
							setTimeout( function(){ window.location.href = urlEdicion; }, 3000 );
						}
						else{
							if(data.mensaje != ''){ new PNotify({ title: "Error", text: data.mensaje, type: "error" }); }
							$.each(data.errMensajes, function(key, value){ if(value != ''){ $("#err"+key).html(value); } else{ $("#err"+key).html(""); } });
						}
					},
					"json"
				);
			}
		}]
	});
});
<?php $__env->stopSection(); ?>
<?php echo $__env->make('BaseSistemaWeb', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>