<?php $__env->startSection('CSS'); ?>
<?php echo HTML::style('DataTables/dataTables.bootstrap.min.css'); ?>

<?php echo HTML::style('DataTables/responsive.dataTables.min.css'); ?>

<?php echo HTML::style('bootstrap-daterangepicker/daterangepicker.css'); ?>

<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/morris.js/0.5.1/morris.css">
<?php echo HTML::style('Prettify/prettify.min.css'); ?>

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

<?php $__env->startSection('Contenido'); ?>
<div class="row">
	<div class="col-md-12">
		<h2> <i class="fa fa-envelope"></i> Correos electrónicos institucionales </h2>
	</div><!--/col-md-12--> 
</div><!--/row-->
<div class="row">
	<div class="col-md-12">
		<div class="block-web">
			<div class="header">
				<h3 class="content-header"> Listado de correos electrónicos institucionales de clientes </h3>
			</div>
			<div class="porlets-content">
				<div class="table-responsive">
					<table class="table table-striped table-bordered table-hover display" id="tblCorreos" width="100%" cellspacing="0">
						<thead>
							<tr>
								<th class="all"> Correo electrónico institucional </th>
								<th class="all"> Correo de Redireccionamiento </th>
								<th class="min-tablet-l"> Cliente </th>
								<th class="min-tablet-l"> Estado </th>
								<th class="min-tablet-l"> Tipo </th>
								<th class="all"> Contraseña </th>
								<th class="all"> Acciones </th>
							</tr>
						</thead>
					</table>
				</div>
			</div>
		</div>
	</div>
</div>
<?php $__env->stopSection(); ?>

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

<?php echo HTML::script('DataTables/dataTables.bootstrap.min.js'); ?>

<?php echo HTML::script('DataTables/dataTables.responsive.min.js'); ?>

<?php echo HTML::script('bootstrap-daterangepicker/moment.min.js'); ?>

<?php echo HTML::script('bootstrap-daterangepicker/daterangepicker.js'); ?>

<script src="https://cdnjs.cloudflare.com/ajax/libs/raphael/2.1.0/raphael-min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/morris.js/0.5.1/morris.min.js"></script>
<?php echo HTML::script('SysWeb/SumeClientes/Fechas.js'); ?>

<?php echo HTML::script('bootstrap-daterangepicker/moment.min.js'); ?>

<?php echo HTML::script('Prettify/prettify.min.js'); ?>

<?php echo HTML::script('Prettify/run_prettify.min.js'); ?>

<?php echo HTML::script('ClipboardJS/clipboard.min.js'); ?>

<script type="text/javascript">
	function Actualizar(){
		var table = $("#tblCorreos").DataTable();
		table.ajax.reload(null, false);
	}
	function cambiarEstado(id){
		var id = id;
		var mensaje = '<form action="#" id="frmCambiarEstado"> \
			<div class="form-group"> \
				<label> ¿Seguro que deseas cambiar el estado? </label> \
				<input type="hidden" value="cambiarEstado" name="accion"> \
				<input type="hidden" value="'+id+'" name="idCE"> \
		</form>';
		BootstrapDialog.show({
			cssClass: "mdAvatar",
			title: "Cambiar estado del correo electrónico",
			message: mensaje,
			draggable: true,
			type: BootstrapDialog.TYPE_SUCCESS,
			buttons: [{
				id: "btnCambiarEstado",
				label: "Si, Cambiar el estado",
				cssClass: "btn-success btn-lg btn-block",
				action: function(dialogItself){
					$("#btnCambiarEstado").prop("disabled", true).html('<i class="fa fa-spinner fa-spin"></i> Procesando...');
					$.isLoading({ text: "Cargando..." }); NProgress.start();
					$.post(
						"<?php echo URL::route('SysWebSWebSolicitudesDeCorreos', array()); ?>",
						$("#frmCambiarEstado").serialize(),
						function(data){
							$.isLoading("hide"); NProgress.done();
							$("#btnCambiarEstado").prop("disabled", false).html("Si, Cambiar el estado");
							if(data.success){
								new PNotify({ title: "Realizado", text: data.mensaje, type: "success" });
								dialogItself.close();
								setTimeout( function(){ Actualizar(); }, 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"
					);
				}
			}]
		});
	}
	function eliminarCorreo(id){
		var id = id;
		var mensaje = '<form action="#" id="frmEliminar"> \
			<div class="form-group"> \
				<label> ¿Seguro que deseas eliminar el correo electrónico? </label> \
				<input type="hidden" value="eliminar" name="accion"> \
				<input type="hidden" value="'+id+'" name="idCE"> \
		</form>';
		BootstrapDialog.show({
			cssClass: "mdAvatar",
			title: "Eliminar correo electrónico",
			message: mensaje,
			draggable: true,
			type: BootstrapDialog.TYPE_DANGER,
			buttons: [{
				id: "btnEliminar",
				label: "Si, Cambiar el estado",
				cssClass: "btn-danger btn-lg btn-block",
				action: function(dialogItself){
					$("#btnEliminar").prop("disabled", true).html('<i class="fa fa-spinner fa-spin"></i> Procesando...');
					$.isLoading({ text: "Cargando..." }); NProgress.start();
					$.post(
						"<?php echo URL::route('SysWebSWebSolicitudesDeCorreos', array()); ?>",
						$("#frmEliminar").serialize(),
						function(data){
							$.isLoading("hide"); NProgress.done();
							$("#btnEliminar").prop("disabled", false).html("Si, Cambiar el estado");
							if(data.success){
								new PNotify({ title: "Realizado", text: data.mensaje, type: "success" });
								dialogItself.close();
								setTimeout( function(){ Actualizar(); }, 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"
					);
				}
			}]
		});
	}
</script>
<?php $__env->stopSection(); ?>

<?php $__env->startSection('JSOr'); ?>
$("#tblCorreos").DataTable({
	"processing": true,
	"serverSide": true,
	"ajax": {
		url: "<?php echo URL::route('SysWebSWebSolicitudesDeCorreos', array()); ?>",
		data: function(d){
			d.filtrofechas = $("#FiltroFechas").val();
		}
	},
	columns: [
		{data: "correo_electronico", name: "cexc.correo_electronico"},
		{data: "redireccionamiento", name: "cexc.redireccionamiento"},
		{data: "correoCliente", name: "c.correo_electronico"},
		{data: "procesado", name: "cexc.procesado", "searchable": false, "orderable": false},
		{data: "tipo", name: "cexc.tipo", "searchable": false, "orderable": false},
		{data: "contrasenha", name: "cexc.contrasenha"},
		{data: "acciones", name: "acciones", "searchable": false, "orderable": false, "class": "text-center"}
	],
	"language": {
		"url": "<?php echo asset('DataTables/Spanish.json'); ?>"
	},
	"fnDrawCallback": function( oSettings ) {
		$(".tooltips").tooltip();
	},
	"paging":   false,
	"ordering": false,
	"info":     false,
	"searching": true
});
<?php $__env->stopSection(); ?>
<?php echo $__env->make('BaseSistemaWeb', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>