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

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

<style type="text/css">
	@media (max-width: 450px) { .ModalEliminar .modal-dialog { width: auto; } }
	@media (min-width: 451px) { .ModalEliminar .modal-dialog { width: 450px; } }
	.mdAvatar .modal-dialog .modal-content .modal-header {
		background-color: #363B3F;
	}
	.mdAvatar .modal-dialog .modal-content .bootstrap-dialog-title{
		display: block;
	}
	.btnRadius{
  		border-radius: 4px !important;
	}
	.modal-header{
		margin-bottom: -1px;
	}
	.modal-footer{
		margin-top: 0px;
	}
	@media (max-width: 800px) { 
		.block-web ul.divSW > li.active > a, .block-web ul.divSW > li.active > a:hover, .block-web ul.divSW > li.active > a:focus{
			background-color: transparent !important;
			box-shadow: unset;
			content: '';
		}
		ul.divSW li.final{
			display: none;
		}
		ul.divSW li.paginas span {
			display: none;
		}
		ul.divSW li:first-child span::before{
			content: "\e913";
		}
		ul.divSW li.paginas a:not(.stepOne) {
			display: inline-block;
			font: normal normal normal 14px/1 FontAwesome;
			font-size: inherit;
			text-rendering: auto;
			-webkit-font-smoothing: antialiased;
			-moz-osx-font-smoothing: grayscale;
			box-shadow: unset !important;
		}
		ul.divSW li.paginas {
			font-family: 'icomoon' !important;
			display: flex;
			justify-content: center;
			align-items: center;
			overflow: hidden;
			padding: 10px 0px;
		}
		ul.divSW li.active{
			background-color: #fff !important;
		}
		ul.divSW li.active a,
		.modal .nav-tabs > li.active a:hover{
			background-color: transparent !important;
		}
		ul.divSW {
			width: 100%;
			display: flex;
			justify-content: center;
			text-align: center;
		}
		ul.divSW li:first-child a::before{
			content: "\f0c0";
			font-size: 25px;
		}
		ul.divSW li:nth-child(2) a::before{
			content: "\f02c";
			font-size: 25px;
		}
		ul.divSW  li>a{
			padding: unset !important;
		}
		.dvVer{
			width: 36% !important;
		}
	}
</style>
<?php $__env->stopSection(); ?>

<?php $__env->startSection('Contenido'); ?>
<div class="row">
	<div class="col-md-12">
		<h2><i class="fa fa-envelope-o"></i> E-Mail Marketing </h2>
	</div><!--/col-md-12-->
</div><!--/row-->

<div class="row">
	<?php /*
	<div class="col-md-12">
		<nav class="navbar navbar-inverse">
			<ul class="nav navbar-nav">
				<li><a href="<?php echo URL::to('templates'); ?>">Ver todos los Templates</a></li>
				<li><a href="<?php echo URL::to('templates/create'); ?>">Crear un Template</a>
			</ul>
		</nav>
	</div>
	*/ ?>
	<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">
					Listas
					&nbsp;&nbsp; <?php echo HTML::linkRoute('SysWebEmailMarketingListasSubscriptoresAgregar', 'Crear', array(), array('class' => 'btn btn-success btnAgregar btnRadius', 'id' => 'btnSuscriptoresAgregar2')); ?>

					 <button type="button" class="btn btn-success btn-global btnRadius" onclick="BuscarSuscriptor()"> <i class="fa fa-search"></i> Búsqueda global </button>
					<div data-toggle="buttons" class="button-group pull-right">
						<a class="tooltips" data-toggle="tooltip" data-original-title="Integración con Calendly" onclick="integracionCalendlyAPI()" href="javascript:integracionCalendlyAPI()" style="color: rgba(0, 0, 0, 0.3)">
							<i class="fa fa-calendar"> </i>
						</a>
						<a class="tooltips" data-toggle="tooltip" data-original-title="Historial de Importaciones" onclick="historialImportaciones()" href="javascript:historialImportaciones()" style="color: rgba(0, 0, 0, 0.3)">
							<i class="fa fa-file-excel-o"> </i>
						</a>
						<a class="tooltips" data-toggle="tooltip" data-original-title="Búsqueda global de suscriptor" onclick="BuscarSuscriptor()" href="javascript:BuscarSuscriptor()" style="color: rgba(0, 0, 0, 0.3)">
							<i class="fa fa-search"> </i>
						</a>
						<a class="refresh tooltips" data-toggle="tooltip" data-original-title="Actualizar registros" onclick="Actualizar()" href="javascript:Actualizar()" style="color: rgba(0, 0, 0, 0.3)">
							<i class="fa fa-repeat"> </i>
						</a>
					</div>
				</h3>
			</div>
			<div class="porlets-content">
				<div class="tab-container">
					<ul class="nav nav-tabs divSW">
						<li class="active paginas"><a href="#genericas" data-toggle="tab"> <span>De suscriptores </span></a></li>
						<li class="paginas"><a href="#segmentadas" data-toggle="tab"><span> Segmentadas </span></a></li>
					</ul>
					<div class="tab-content">
						<div class="tab-pane cont active" id="genericas">
							<div class="table-responsive">
								<table class="table table-striped table-bordered table-hover" id="tblListasSuscriptores">
									<thead>
										<tr>
											<th class="all"> Nombre de la lista </th>
											<th style="width: 10%;" class="min-tablet-l"> Suscriptores </th>
											<th style="width: 10%;" class="min-tablet-l"> Desuscritos </th>
											<th style="width: 38%;" class="min-tablet-l"> Acciones </th>
										</tr>
									</thead>
								</table>
							</div>
						</div>
						<div class="tab-pane" id="segmentadas">
							<div class="table-responsive">
								<table class="table table-striped table-bordered table-hover" id="tblListasSegmentados">
									<thead>
										<tr>
											<th class="all"> Nombre de la lista </th>
											<th style="width: 10%;" class="min-tablet-l"> Suscriptores </th>
											<th style="width: 10%;" class="min-tablet-l"> Desuscritos </th>
											<th style="width: 30%;" class="min-tablet-l"> Acciones </th>
										</tr>
									</thead>
								</table>
							</div>
						</div>
					</div>
				</div>
			</div>
			<div class="bottom">
				<?php echo HTML::linkRoute('SysWebEmailMarketingListasSubscriptoresAgregar', 'Crear', array(), array('class' => 'btn btn-success btnAgregar', 'id' => 'btnSuscriptoresAgregar')); ?>

				<?php if(strpos(public_path(), 'prospector') !== false): ?>
				<?php else: ?>
				<?php $fbLNuevo = false; ?>
				<?php if( $fbLNuevo ): ?>
				<button <?php echo $isdisable; ?>  onclick="myFacebookLogin()" id="btngetaccesstoken" class="btn btn-primary" >Inicio de sesión con Facebook</button>
				<?php else: ?>
				<button <?php echo $isdisable; ?>  onclick="getFaceBookAccessToken()" id="btngetaccesstoken" class="btn btn-primary" >Inicio de sesión con Facebook</button>
				<?php endif; ?>
				<button <?php if( $isdisable == '' ): ?> disabled <?php endif; ?>  onclick="cerrarSesionFB()" id="" class="btn btn-danger" >Cerrar sesión con Facebook</button>
				<input type="hidden" id="hfaccesskeyid" value="<?php echo $accesskey; ?>">
				<input type="hidden" id="hfexpirydate" value="<?php echo $expirydate; ?>">
				<?php endif; ?>
			</div>
		</div>
	</div>
</div><!--/row end-->
<?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('jQueryValidate/jquery.validate.min.js'); ?>

<?php echo HTML::script('jQueryValidate/additional-methods.min.js'); ?>

<?php echo HTML::script('jQueryValidate/jquery.validationEngine-es.js'); ?>

<script type="text/javascript">
	<?php
		//$appId = (App::environment() == 'local' || strpos(public_path(), 'desarrollo'))?'216664162092407':'1304262509596042';
		$appId = (App::environment() == 'local' || strpos(public_path(), 'desarrollo'))?'216664162092407':'844034313701236';
		//$fbAppV = (isset($_GET['fbAppV']))?$_GET['fbAppV']:'v3.2';
		$fbAppV = 'v19.0';
	?>
	/* -------- SDK JAVASCRIPT DE FACEBOOK ------- */
	window.fbAsyncInit = function(){
		FB.init({
			appId: "<?= $appId ?>",
			xfbml: true,
			version: "<?= $fbAppV ?>"
		});
	};
	(function(d, s, id) {
		var js, fjs = d.getElementsByTagName(s)[0];
		if (d.getElementById(id)) {
			return; }
		js = d.createElement(s);
		js.id = id;
		js.src = "//connect.facebook.net/en_US/sdk.js";
		fjs.parentNode.insertBefore(js, fjs);
	}(document, 'script', 'facebook-jssdk'));
	<?php if( $fbLNuevo ): ?>
	function subscribeApp(page_id, page_access_token){
		console.log("Subscribing page to app! "+ page_id);
		FB.api(
			"/"+page_id+"/subscribed_apps",
			"post",
			{access_token: page_access_token, subscribed_fields: ["leadgen"]},
			function(response){
				console.log("Successfully subscribed page", response);
			}
		);
	}
	function myFacebookLogin(){
		FB.login(function(response){
			console.log("Successfully logged in", response);
			FB.api("/me/accounts",
				function(response){
					console.log("Successfully retrieved pages", response);
					var pages = response.data;
					var ul = document.getElementById("list");
					for(var i = 0, len = pages.length; i < len; i++){
						var page = pages[i];
						var li = document.createElement("li");
						var a = document.createElement("a");
						a.href = "#";
						a.onclick = subscribeApp.bind(this, page.id, page.access_token);
						a.innerHTML = page.name;
						li.appendChild(a);
						ul.appendChild(li);
					}
				});
		}, {scope: "email, pages_show_list, pages_manage_ads, pages_manage_metadata, leads_retrieval, pages_read_engagement, ads_management, business_management"});
	}
	<?php endif; ?>
	/* --------------------------------------------- */
	function Eliminar(id){
		var id = id;
		var mensaje = "<div class='row'> \
							<div class='col-xs-12'> \
								<form id='frmEliminar'> \
									<h2> ¿Seguro que desea eliminar? </h2> \
									<input type='hidden' name='idL' value='"+id+"'> \
								</form> \
							</div> \
						</div>";
		BootstrapDialog.show({
			title: "Eliminar registro",
			type: BootstrapDialog.TYPE_DANGER,
			message: mensaje,
			draggable: true,
			closeByBackdrop: false,
			cssClass: "ModalEliminar mdAvatar",
			onshown: function(dialogItself){
				$("body").addClass("modal-open");
			},
			buttons: [{
				id: "btnEliminar",
				label: "Eliminar",
				cssClass: "btn-danger btn-block btn-lg",
				action: function(dialogItself){
					NProgress.start();
					$("#btnEliminar").prop("disabled", true).html('<i class="fa fa-spinner fa-spin"></i> Eliminando');
					$.post(
						"<?php echo URL::route('SysWebEmailMarketingListasSubscriptoresEliminar'); ?>",
						{idL:id},
						function(data){
							NProgress.done();
							$("#btnEnviar").prop("disabled", false).html("Eliminar");
							if(data.success){
								new PNotify({ title: "Felicidades!", text: data.mensaje, type: "success" });
								dialogItself.close();
								var table = $("#tblListasSuscriptores").DataTable();
								var table2 = $("#tblListasSegmentados").DataTable();
								table.ajax.reload(null, false);
								table2.ajax.reload(null, false);
							}
							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"
					);
				}
			}],
			onhidden: function(dialogItself){
				$("body").removeClass("modal-open");
			}
		});
	}
	/* ---- CREACIÓN DE TOKEN DE ACCESO A LA APLICACIÓN DE FACEBOOK --- */
	function getFaceBookAccessToken() {
		FB.login(function(response){
			console.log( response );
			$.post(
				"<?php echo URL::route('SysWebEmailMarketingAddUserAccessToken'); ?>",
				{accesstoken: response.authResponse.accessToken},
				function(data){
					if(data.success){
						new PNotify({ title: "Felicidades!", text: "La plataforma ya a sido vinculada con tu cuenta de FB", type: "success" });
						//dialogItself.close();
						setTimeout( function(){ window.location.reload(); }, 3000 );
						/*$("#hfaccesskeyid").val(data.accesstoken)
						$("#btngetaccesstoken").prop('disabled', true);*/
					}
					else{
						alert(data.message);
					}
				},
				"json"
			);
		}, {scope: "email, pages_show_list, pages_manage_ads, pages_manage_metadata, leads_retrieval, pages_read_engagement, ads_management, business_management"});
	}
	function cerrarSesionFB(){
		$.isLoading({ text: "Cargando..." }); NProgress.start();
		$.get(
			"<?php echo URL::route('SysWebEmailMarketingRevocarPermisosFB'); ?>",
			function(data){
				if(data.success){
					$.isLoading("hide"); NProgress.done();
					new PNotify({ title: "Felicidades!", text: "La plataforma a sido desvinculada con tu cuenta de FB", type: "success" });
					//dialogItself.close();
					setTimeout( function(){ window.location.reload(); }, 3000 );
					/*$("#hfaccesskeyid").val(data.accesstoken)
					$("#btngetaccesstoken").prop('disabled', true);*/
				}
				else{
					alert(data.message);
				}
			},
			"json"
		);
	}
	/* -------------------------------------------------------------- */
	function Actualizar(){
		var table1 = $("#tblListasSuscriptores").DataTable();
		table1.ajax.reload(null, false);
		var table2 = $("#tblListasSegmentados").DataTable();
		table2.ajax.reload(null, false);
	}

	function integracionCalendlyAPI(){
		var mensaje = '<div class="row"> \
			<div class="col-xs-12"> \
				<div class="alert alert-info" role="alert"> \
					La integración con la API de Calendly te permitirá vincular listas de suscriptores con Tipos de eventos que crees en Calendly para que las personas que se registren a un tipo de evento se registre automáticamente a la lista asociada, solamente debes tomar en cuenta que: \
					<ul> \
						<li> La API solo es compatible con la versión de pago de Calendly </li> \
						<li> Las listas deben tener los mismos campos que el tipo de evento de Calendly a vincular </li> \
					</ul> \
				</div> \
			</div> \
			<div class="col-xs-12"> \
				<form id="frmIntegracionCalendlyAPI"> \
					<div class="form-group"> \
						<label for="calendlyToken">Token de acceso personal</label> \
						<input type="text" class="form-control" id="calendlyToken" name="calendlyToken" placeholder=""> \
						<span id="errcalendlyToken" class="text-danger"></span> \
					</div> \
					<button type="button" class="btn btn-success btn-lg btn-block disabled" id="btnGuardarToken">Guardar Token</button> \
				</form> \
			</div> \
		</div>';
		BootstrapDialog.show({
			title: "Integración con API de Calendly",
			type: BootstrapDialog.TYPE_SUCCESS,
			size: BootstrapDialog.SIZE_WIDE,
			message: mensaje,
			draggable: true,
			closable: true,
			closeByBackdrop: false,
			cssClass: "mdAvatar",
			onshown: function(dialogItself){
				$.isLoading({ text: "Cargando..." }); NProgress.start();
				$("body").addClass("modal-open");
				var modalBody = dialogItself.getModalBody();
				$.post(
					"<?php echo URL::route('SysWebEmailMarketingListasSubscriptoresCalendlyAPI'); ?>",
					{accion: "verificarToken"},
					function(data){
						$.isLoading("hide"); NProgress.done();
						if(data.success){
							modalBody.find("#calendlyToken").val(data.token);
						}
						modalBody.find("#btnGuardarToken").removeClass("disabled");
					},
					"json"
				);
				modalBody.find("#btnGuardarToken").click(function(e){
					$.isLoading({ text: "Cargando..." }); NProgress.start();
					$(this).html('<i class="fa fa-spinner fa-spin"></i> Cargando').prop("disabled", true);
					$.post(
						"<?php echo URL::route('SysWebEmailMarketingListasSubscriptoresCalendlyAPI'); ?>",
						{accion: "guardarToken", calendlyToken: modalBody.find("#calendlyToken").val()},
						function(data){
							$.isLoading("hide"); NProgress.done();
							modalBody.find("#btnGuardarToken").html("Guardar Token").prop("disabled", false);
							if(data.success){
								new PNotify({ title: "Realizado", text: data.mensaje, type: "success" });
								dialogItself.close();
							}
							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(""); } });
								$("[id^='err']").html(""); $.each(data.errMensajes, function(key, value){ $("#err"+key).html(value); });
							}
						},
						"json"
					);
				});

			},
			onhidden: function(dialogItself){
				$("body").removeClass("modal-open");
			}
		});
	}

	function BuscarSuscriptor(){
		var mensaje = '<div class="row"> \
			<div class="col-xs-12"> \
				<form id="frmBuscarSuscriptor"> \
					<div class="form-group"> \
						<label for="correo_electronico">Correo electrónico del suscriptor</label> \
						<div class="input-group"> \
							<input type="text" class="form-control" id="correo_electronico" name="correo_electronico" placeholder="correo@electronico.com"> \
							<span class="input-group-btn"> \
								<button class="btn btn-success" type="button" id="btnBuscarSGlobal"><i class="fa fa-search"></i></button> \
							</span> \
						</div> \
						<span id="errcorreo_electronico" class="text-danger"></span> \
					</div> \
				</form> \
				<div class="table-responsive"> \
					<table class="table table-striped table-bordered table-hover" id="tblListasSuscriptoresGlobal"> \
						<thead> \
							<tr> \
								<th class="text-center" style="width: 45%;">Nombre de la lista</th> \
								<th class="text-center" style="width: 25%;">Tipo de lista</th> \
								<th class="text-center" style="width: 25%;">Estado del suscriptor</th> \
								<th class="text-center" style="width: 15%;">Acciones</th> \
							</tr> \
						</thead> \
					</table> \
				</div> \
			</div> \
		</div>';
		BootstrapDialog.show({
			title: "<p class='text-center' style='margin: 0px; color:#ccc; font-size: 20px; '> Buscador global de suscriptores </p>",
			type: BootstrapDialog.TYPE_SUCCESS,
			size: BootstrapDialog.SIZE_WIDE,
			message: mensaje,
			draggable: true,
			closable: true,
			closeByBackdrop: false,
			cssClass: "mdAvatar",
			onshown: function(dialogItself){
				$("body").addClass("modal-open");
				var modalBody = dialogItself.getModalBody();
				modalBody.find("#correo_electronico").blur(function(e){
					modalBody.find("#correo_electronico").val( modalBody.find("#correo_electronico").val().trim() );
				});
				var formulario = modalBody.find("#frmBuscarSuscriptor").validate({
					lang: "es",
					errorPlacement: function(error, element){
						var p = error.attr("id").indexOf("-error");
						var elemento = "err"+error.attr("id").substr(0, p);
						$("#"+elemento).html( error.html() );
					},
					success: function(error){
						var p = error.attr("id").indexOf("-error");
						var elemento = "err"+error.attr("id").substr(0, p);
						$("#"+elemento).html("");
					},
					rules: {
						correo_electronico: {
							required: true,
							email: true
						}
					},
					onfocusout: false,
					onkeyup: false,
					onclick: false
				});
				modalBody.find("#btnBuscarSGlobal").click(function(e){
					if(formulario.valid()){
						var table = $("#tblListasSuscriptoresGlobal").DataTable();
						table.ajax.reload(null, false);
					}
				});
				modalBody.find("#tblListasSuscriptoresGlobal").DataTable({
					"processing": true,
					"serverSide": true,
					"ordering": false,
					"paging":   true,
					"pageLength": 5,
					"searching": false,
					preDrawCallback: function (settings) { modalBody.isLoading("hide"); },
					"ajax": {
						url: "<?php echo URL::route('SysWebEmailMarketingListasSubscriptoresBusquedaGlobal'); ?>",
						data: function(d){
							d.correo_electronico = modalBody.find("#correo_electronico").val().trim();
						}
					},
					columns: [
						{data: "nombre", name: "nombre"},
						{data: "tipo", name: "tipo", "searchable": false, "orderable": false, "class": "text-center"},
						{data: "estado", name: "estado", "searchable": false, "orderable": false, "class": "text-center"},
						{data: "acciones", name: "acciones", "searchable": false, "orderable": false, "class": "text-center"}
					],
					"language": {
						"url": "<?php echo asset('DataTables/Spanish.json'); ?>"
					},
					"fnDrawCallback": function( oSettings ){
						$(".tooltips").tooltip();
					},
					autoWidth: false,
					"order": [[ 0, "desc" ]],
					responsive: true,
					initComplete: function(){}
				}).on("processing.dt", function(e, settings, processing) {
					if (processing) {
						modalBody.isLoading({position: "overlay"});
					}
					else{
						modalBody.isLoading("hide");
						window.scrollTo(0, 0);
					}
				});
			},
			onhidden: function(dialogItself){
				$("body").removeClass("modal-open");
			}
		});
	}
	function historialImportaciones(){
		window.location.href = "<?php echo URL::route('SysWebEmailMarketingHistorialImportacionSuscriptores'); ?>";
	}
	/*$("#"+tbl+" .minimize").each(function(e){
		var minimize = $(this);
		minimize.click(function(e){
			var h = $(this).parents(".header");
			var c = h.next(".porlets-content");
			var p = h.parent();
			c.slideToggle();
			p.toggleClass("closed");
			e.preventDefault();
		});
	});*/
</script>
<?php $__env->stopSection(); ?>

<?php $__env->startSection('JSOr'); ?>
$("a[data-toggle=\"tab\"]").on("shown.bs.tab", function(e){
	//$.fn.dataTable.tables({visible: true, api: true}).columns.adjust();
	var table = $("#tblListasSuscriptores").DataTable();
	var table2 = $("#tblListasSegmentados").DataTable();
	table.ajax.reload(null, false);
	table2.ajax.reload(null, false);
	table.draw();
	table2.draw();
});
$("#tblListasSuscriptores").DataTable({
	"processing": true,
	"serverSide": true,
	"ajax": "<?php echo URL::route('SysWebEmailMarketingListasSubscriptores'); ?>",
	preDrawCallback: function (settings) { $.isLoading("hide"); $.isLoading("hide"); },
	columns: [
		{data: 'nombre', name: 'nombre'},
		{data: 'suscriptores', name: 'suscriptores', "searchable": false},
		{data: 'desuscritos', name: 'desuscritos', "searchable": false},
		{data: 'acciones', name: 'acciones', "searchable": false, "orderable": false, "class": "text-center"}
	],
	//dom: "<'row'<'col-sm-3 col-mostrar'l><'col-sm-4 col-busqueda'f><'col-sm-5 col-paginacion'p>>" +
	//	"<'row'<'col-sm-12'tr>>" +
	//"<'row'<'col-sm-5'i><'col-sm-7'p>>",
	"language": {
		"url": "<?php echo asset('DataTables/Spanish.json'); ?>"
	},
	"fnDrawCallback": function( oSettings ) {
		$(".tooltips").tooltip();
		if(oSettings._iRecordsTotal == 0){
			$(".btnAgregar:not(.btnRadius)").webuiPopover({
				trigger: "manual",
				title: "Instrucciones de Plataforma Sume Clientes",
				content: '<div class="alert alert-info" role="alert"> \
					<p style="font-size: 16;">Aún no tienes ningúna lista de suscripción, empieza a crear tus listas de suscripción haciendo clic en el botón de crear</p> \
				<div>',
				closeable: true,
				backdrop: true,
				style: "",
				width: 500,
				multi: true,
				onShow: function($element){
					$(".webui-popover-backdrop").click(function(e){
						$(".btnAgregar:not(.btnRadius)").webuiPopover("hide");
					});
				}
			});
			$(".btnAgregar:not(.btnRadius)").webuiPopover("show");
		}
	},
	autoWidth: false,
	responsive: true,
	initComplete: function(){
		var input = $("#tblListasSuscriptores_filter input").unbind();
		$("#tblListasSuscriptores_filter").html('');
		var self = this.api(),
		self = this.api(),
		$searchButton = $('<button class="btn btn-primary tooltips" style="margin-left: 5px;" data-toggle="tooltip" data-original-title="Buscar" data-container="body">').html('<i class="fa fa-search"></i>').click(function(){
			self.search(input.val().trim()).draw();
		}),
		$clearButton = $('<button class="btn btn-default tooltips" style="margin-left: 5px;" data-toggle="tooltip" data-original-title="Limpiar" data-container="body">').html('<i class="fa fa-paint-brush"></i>').click(function(){
			input.val('');
			$searchButton.click(); 
		});
		divInputGroup = $('<div class="input-group div-groupinput dgiSuscriptores">'+
			'<div class="input-group-btn div-groupbutton dgbSuscriptores">'+
			'</div>'+
		'</div>');
		$("#tblListasSuscriptores_filter").append(divInputGroup);
		$(".dgiSuscriptores").prepend(input);
		$(".dgbSuscriptores").append($searchButton, $clearButton);
		$("body").tooltip({selector: "[data-toggle='tooltip']"});
		$("input[type=search]").attr("placeholder", "Buscar...");
		detectarPantalla();
	}
}).on("processing.dt", function(e, settings, processing) {
	if (processing) {
		$.isLoading();
	}
	else{
		$.isLoading("hide");
		window.scrollTo(0, 0);
	}
});
$("#tblListasSegmentados").DataTable({
	"processing": true,
	"serverSide": true,
	"ajax": "<?php echo URL::route('SysWebEmailMarketingListasSegmentadas'); ?>",
	preDrawCallback: function (settings) { $.isLoading("hide"); $.isLoading("hide"); },
	columns: [
		{data: 'nombre', name: 'nombre'},
		{data: 'suscriptores', name: 'suscriptores', "searchable": false},
		{data: 'desuscritos', name: 'desuscritos', "searchable": false},
		{data: 'acciones', name: 'acciones', "searchable": false, "orderable": false, "class": "text-center"}
	],
	//dom: "<'row'<'col-sm-3 col-mostrar'l><'col-sm-4 col-busqueda'f><'col-sm-5 col-paginacion'p>>" +
	//	"<'row'<'col-sm-12'tr>>" +
	//"<'row'<'col-sm-5'i><'col-sm-7'p>>",
	"language": {
		"url": "<?php echo asset('DataTables/Spanish.json'); ?>"
	},
	"fnDrawCallback": function( oSettings ) {
		$(".tooltips").tooltip();
	},
	autoWidth: false,
	scrollCollapse: true,
	responsive: true,
	initComplete: function(){
		var input = $("#tblListasSegmentados_filter input").unbind();
		$("#tblListasSegmentados_filter").html('');
		var self = this.api(),
		$searchButton = $('<button class="btn btn-primary tooltips" style="margin-left: 5px;" data-toggle="tooltip" data-original-title="Buscar" data-container="body">').html('<i class="fa fa-search"></i>').click(function(){
			self.search(input.val().trim()).draw();
		}),
		$clearButton = $('<button class="btn btn-default tooltips" style="margin-left: 5px;" data-toggle="tooltip" data-original-title="Limpiar" data-container="body">').html('<i class="fa fa-paint-brush"></i>').click(function(){
			input.val('');
			$searchButton.click(); 
		});
		divInputGroup = $('<div class="input-group div-groupinput dgiSegmentados">'+
			'<div class="input-group-btn div-groupbutton dgbSegmentados">'+
			'</div>'+
		'</div>');
		$("#tblListasSegmentados_filter").append(divInputGroup);
		$(".dgiSegmentados").prepend(input);
		$(".dgbSegmentados").append($searchButton, $clearButton);
		$("body").tooltip({selector: "[data-toggle='tooltip']"});
		$("input[type=search]").attr("placeholder", "Buscar...");
		detectarPantalla();
	}
}).on("processing.dt", function(e, settings, processing) {
	if (processing) {
		$.isLoading();
	}
	else{
		$.isLoading("hide");
		window.scrollTo(0, 0);
	}
});
$('a[href="#genericas"]').click(function(e){
	$("#btnSuscriptoresAgregar").show();
	$("#btnSuscriptoresAgregar2").show();
});
$('a[href="#segmentadas"]').click(function(e){
	$("#btnSuscriptoresAgregar").hide();
	$("#btnSuscriptoresAgregar2").hide();
});
<?php if(Session::has('EliminarMensajeS')): ?>
new PNotify({ title: "Realizado", text: "<?php echo Session::get('EliminarMensajeS'); ?>", type: "success" });
<?php endif; ?>
<?php if(Session::has('EliminarMensajeE')): ?>
new PNotify({ title: "Realizado", text: "<?php echo Session::get('EliminarMensajeE'); ?>", type: "error" });
<?php endif; ?>
<?php $__env->stopSection(); ?>
<?php echo $__env->make('BaseSistemaWeb', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>