<?php $__env->startSection('CSS'); ?>
<link media="all" type="text/css" rel="stylesheet" href="<?php echo asset ('bootstrap-wysihtml5-0.4.4/src/bootstrap-wysihtml5.css'); ?>">
<link media="all" type="text/css" rel="stylesheet" href="<?php echo asset ('bootstrap-wysihtml5-0.4.4/lib/css/wysiwyg-color.css'); ?>">
<style>
	input[type="radio"], input[type="checkbox"] {
        cursor: pointer;
        height: 18px;
        opacity: unset !important;
        position: absolute;
        width: 18px;
        z-index: 2;
    }
    .alert-success{
        border: none;
    }
</style>
<?php $__env->stopSection(); ?>


<?php $__env->startSection('Contenido'); ?>
<div class="row">
	<div class="col-md-12">
		<h2><i class="fa fa-bell"></i> Agregar notificaciones</h2>
	</div>
</div>
<div class="row">
	<div class="col-md-6">
		<div class="block-web">
			<div class="header"> <h3 class="content-header"> Agregar notificación </h3> </div>
			<div class="porlets-content">
				<form class="form-horizontal row-border" id="frmAgregarNotificacion">
					<div class="form-group">
						<label class="col-sm-3 control-label"> Título </label>
						<div class="col-sm-9">
							<textarea type="text" name="titulo" id="titulo" class="form-control" rows="1" placeholder="" required></textarea>
						</div>
					</div>
					<div class="form-group">
						<label class="col-sm-3 control-label"> Descripción </label>
						<div class="col-sm-9">
							<textarea name="descripcion" id="descripcion" class="form-control" rows="10" placeholder="" required></textarea> <br>
						</div>
					</div>
					<div class="form-group">
						<label class="col-sm-3 control-label"> Estado </label>
						<div class="col-sm-9">
							<td>
								<select class="" name="estado" id="estado" required>
									<option value="1" selected>ACTIVA</option>
                                    <option value="0">INACTIVA</option>
								</select>
							</td>
						</div>
					</div>
					<div class="form-group">
						<label class="col-sm-3 control-label"> Fijar notificacion </label>
						<div class="col-sm-9">
							<td>
								<select class="" name="fijar" id="fijar" required>
									<option value="0" selected>No fijar</option>
                                    <option value="1">Fijar</option>
								</select>
							</td>
						</div>
					</div>
					<div class="form-group">
						<label class="col-sm-3 control-label"> Configuraciones adicionales </label>
						<div class="col-sm-9">
							<textarea name="configuraciones" id="configuraciones" class="form-control" rows="5" placeholder="{&quot;background-color&quot;: &quot;#d2d2d2&quot;}" required></textarea> <br>
						</div>
					</div>
					<div class="bottom">
                        <input class="btn btn-primary" id="btnAgregar" type="submit" value="Agregar">
						<a class="btn btn-default" href="<?php echo route('SysWebNotificacionesListar'); ?>">Cancelar</a>
						<button class="btn btn-warning" id="btnPrevisualizar">Previsualizar</button>
					</div>
				</form>
				
			</div>
		</div>
	</div>
	<div class="col-md-6">
		<div class="block-web g-emerketing-r notiLlamadaInicial-r notisLLI block-notifications">
			<div class="header">
				<div class="content-header">
					<h4 class="text-skyblue fw-bold">Previsualizar</h4>
				</div>
			</div>
			<div class="alert alert-success notificacion" id="noti-container">
				<h4 style="text-align: center;" id="titulo-prev"><strong></strong></h4>
				<div id="content-prev"></div>
			</div>
		</div>
	</div>
</div>
<?php $__env->stopSection(); ?>

<?php $__env->startSection('JS'); ?>
<script src="<?php echo asset ('bootstrap-wysihtml5-0.4.4/bootstrap3-wysihtml5.all.min.js'); ?>"></script>
<script src="<?php echo asset ('bootstrap-wysihtml5-0.4.4/src/locales/bootstrap-wysihtml5.es-ES.js'); ?>"></script>
<script>
	let titulo = "";
	let descripcion = "";
	let configuraciones = {};
	$("#btnPrevisualizar").click(function(){
		event.preventDefault();
		titulo = $("#titulo").val();
		descripcion = $("#descripcion").val();
		$("#titulo-prev").html("");
		$("#titulo-prev").html("<strong>"+titulo+"</strong>");
		$("#content-prev").html("");
		$("#content-prev").html(descripcion);
		configuraciones = JSON.parse($("#configuraciones").val());
		if(configuraciones.hasOwnProperty("background-color")){
			console.log(configuraciones);
			$("#noti-container").css(Object.keys(configuraciones)[0], Object.values(configuraciones)[0]);
		}
		if(configuraciones.hasOwnProperty("class")){
			$("#noti-container").removeClass("alert-success").addClass(configuraciones.class);
		}
	});
</script>
<?php $__env->stopSection(); ?>

<?php $__env->startSection('JSOr'); ?>
$("#frmAgregarNotificacion").submit(function(e){
	e.preventDefault();
	var frmAgregarNotificacion = new FormData(document.getElementById("frmAgregarNotificacion"));
	$.ajax({
		type: "POST",
		url: "<?php echo route('SysWebNotificacionesAgregar'); ?>",
		data: frmAgregarNotificacion,
		cache: false,
		contentType: false,
		processData: false,
		dataType: "json",
		success: function(data){
            if(data.success){
                new PNotify({ title: "Realizado", text: data.mensaje, type: "success" });
				setTimeout( function(){ window.location.href = "<?php echo route('SysWebNotificacionesListar'); ?>"; }, 2000 );
            }
			else{
                new PNotify({ title: "Realizado", text: data.mensaje, type: "error" });
            }
		},
		error: function(jqXHR, textStatus, errorThrown){
            new PNotify({ title: "Error", text: textStatus + " " + errorThrown, type: "error" });
		}
	});
});

$("#descripcion").wysihtml5({
	locale: "es-ES",
	toolbar: {
		"font-styles": true,
		"emphasis": true,
		"lists": true,
		"html": true,
		"link": true,
		"image": false,
		"color": true,
		"blockquote": false
	}
});
$("#titulo").wysihtml5({
	locale: "es-ES",
	toolbar: {
		"font-styles": false,
		"emphasis": true,
		"lists": false,
		"html": false,
		"link": false,
		"image": false,
		"color": true,
		"blockquote": false
	}
});
<?php $__env->stopSection(); ?>
<?php echo $__env->make('BaseSistemaWeb', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>