<?php $__env->startSection('CSS'); ?>
<?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>
</div>

<div class="row">
	<div class="col-md-7">
		<div class="block-web">
			<div class="header"> <h3 class="content-header"> Amazon Web Services (SES) </h3> </div>
			<div class="porlets-content">
				<?php echo Form::open(array('route' => 'SysWebEmailMarketingConfApiAmazon', 'method' => 'post', 'class' => 'form-horizontal row-border', 'id' => 'frmEditar', 'files' => true, 'target' => 'upload_iframe')); ?>

					<div class="form-group">
						<label class="col-sm-3 control-label"> Key </label>
						<div class="col-sm-9">
							<?php if(count($ConfiguracionAmazon)==0): ?>
							<?php echo Form::text('key', '', array('class' => 'form-control', 'placeholder' => '')); ?>

							<?php else: ?>
							<?php echo Form::text('key', $ConfiguracionAmazon->key, array('class' => 'form-control', 'placeholder' => '')); ?>

							<?php endif; ?>
							<span class="text-danger" id="errkey"> </span>
						</div>
					</div>
					<div class="form-group">
						<label class="col-sm-3 control-label"> Secret </label>
						<div class="col-sm-9">
							<?php if(count($ConfiguracionAmazon)==0): ?>
							<?php echo Form::text('secret', '', array('class' => 'form-control', 'placeholder' => '')); ?>

							<?php else: ?>
							<?php echo Form::text('secret', $ConfiguracionAmazon->secret, array('class' => 'form-control', 'placeholder' => '')); ?>

							<?php endif; ?>
							<span class="text-danger" id="errsecret"> </span>
						</div>
					</div>
					<div class="form-group">
						<label class="col-sm-3 control-label"> Region </label>
						<div class="col-sm-9">
							<?php if(count($ConfiguracionAmazon)==0): ?>
							<?php echo Form::text('region', '', array('class' => 'form-control', 'placeholder' => '')); ?>

							<?php else: ?>
							<?php echo Form::text('region', $ConfiguracionAmazon->region, array('class' => 'form-control', 'placeholder' => '')); ?>

							<?php endif; ?>
							<span class="text-danger" id="errregion"> </span>
						</div>
					</div>
					<?php if(count($ConfiguracionAmazon)>0): ?>
					<?php echo Form::hidden('id', $ConfiguracionAmazon->id, array('id' => 'id')); ?>

					<?php endif; ?>
					<div class="bottom">
						<?php echo Form::button('Editar', array('class' => 'btn btn-primary', 'id' => 'btnAgregar', 'type' => 'submit')); ?>

					</div>
				<?php echo Form::close(); ?>

			</div>
		</div>
	</div>
	<div class="col-md-5"> </div>
	<div class="col-md-7">
		<div class="block-web">
			<div class="header"> <h3 class="content-header"> NeverBounce </h3> </div>
			<div class="porlets-content">
				<?php echo Form::open(array('route' => 'SysWebEmailMarketingConfApiNeverBounce', 'method' => 'post', 'class' => 'form-horizontal row-border', 'id' => 'frmEditarNB', 'files' => true, 'target' => 'upload_iframe')); ?>

					<div class="form-group">
						<label class="col-sm-3 control-label"> API Username </label>
						<div class="col-sm-9">
							<?php if(count($ConfNeverBounce)==0): ?>
							<?php echo Form::text('api_username', '', array('class' => 'form-control', 'placeholder' => '')); ?>

							<?php else: ?>
							<?php echo Form::text('api_username', $ConfNeverBounce->api_username, array('class' => 'form-control', 'placeholder' => '')); ?>

							<?php endif; ?>
							<span class="text-danger" id="errapi_username"> </span>
						</div>
					</div>
					<div class="form-group">
						<label class="col-sm-3 control-label"> API Secret Key </label>
						<div class="col-sm-9">
							<?php if(count($ConfNeverBounce)==0): ?>
							<?php echo Form::text('api_secret_key', '', array('class' => 'form-control', 'placeholder' => '')); ?>

							<?php else: ?>
							<?php echo Form::text('api_secret_key', $ConfNeverBounce->api_secret_key, array('class' => 'form-control', 'placeholder' => '')); ?>

							<?php endif; ?>
							<span class="text-danger" id="errapi_secret_key"> </span>
						</div>
					</div>
					<?php if(count($ConfNeverBounce)>0): ?>
					<?php echo Form::hidden('id', $ConfNeverBounce->id, array('id' => 'idNB')); ?>

					<?php endif; ?>
				<div class="bottom">
					<?php echo Form::button('Editar', array('class' => 'btn btn-primary', 'id' => 'btnEditarNB', 'type' => 'submit')); ?>

					<?php if( count($ConfNeverBounce)>0 && $ConfNeverBounce->activo == 1 ): ?>
					<?php echo Form::button('Desactivar', array('class' => 'btn btn-warning', 'id' => 'btnDesactivarNB', 'type' => 'button')); ?>

					<?php elseif( count($ConfNeverBounce)>0 && $ConfNeverBounce->activo == 0 ): ?>
					<?php echo Form::button('Activar', array('class' => 'btn btn-success', 'id' => 'btnActivarNB', 'type' => 'button')); ?>

					<?php endif; ?>
				</div>
				<?php echo Form::close(); ?>

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

<?php $__env->startSection('JS'); ?>
<?php /* HTML::script('WebPro/plugins/ckeditor-new/ckeditor.js') */ ?>
<?php $__env->stopSection(); ?>

<?php $__env->startSection('JSOr'); ?>
$("#frmEditar").submit(function(e){
	$("#btnAgregar").html('<i class="fa fa-spinner fa-spin"></i> Cargando').prop("disabled", true);
	e.preventDefault();
	var frmEditar = new FormData(document.getElementById("frmEditar"));
	$.ajax({
		type: "POST",
		url: "<?php echo URL::route('SysWebEmailMarketingConfApiAmazon', array()); ?>",
		data: frmEditar,
		cache: false,
		contentType: false,
		processData: false,
		dataType: "json",
		success: function(data){
			$("#btnAgregar").html("Editar").prop("disabled", false);
			if(data.success){
				new PNotify({ title: "Realizado", text: data.mensaje, type: "success" });
				setTimeout( function(){ window.location.href = "<?php echo URL::route('SysWebEmailMarketingConfApiAmazon'); ?>"; }, 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(""); } });
			}
		},
		error: function(jqXHR, textStatus, errorThrown){
			new PNotify({ title: "Error", text: textStatus + " " + errorThrown, type: "error" });
		}
	});
});
$("#frmEditarNB").submit(function(e){
	$("#btnEditarNB").html('<i class="fa fa-spinner fa-spin"></i> Cargando').prop("disabled", true);
	e.preventDefault();
	$.post(
		"<?php echo URL::route('SysWebEmailMarketingConfApiNeverBounce'); ?>",
		$("#frmEditarNB").serialize(),
		function(data){
			$("#btnEditarNB").html("Editar").prop("disabled", false);
			if(data.success){
				new PNotify({ title: "Realizado", text: data.mensaje, type: "success" });
				setTimeout( function(){ window.location.href = "<?php echo URL::route('SysWebEmailMarketingConfApiAmazon'); ?>"; }, 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 if( count($ConfNeverBounce)>0 && $ConfNeverBounce->activo ==1 ): ?>
$("#btnDesactivarNB").click(function(e){
	$("#btnDesactivarNB").html('<i class="fa fa-spinner fa-spin"></i> Cargando').prop("disabled", true);
	e.preventDefault();
	$.post(
		"<?php echo URL::route('SysWebEmailMarketingConfApiNeverBounceDesactivar'); ?>",
		{ id:<?php echo $ConfNeverBounce->id; ?> },
		function(data){
			$("#btnDesactivarNB").html("Desactivar").prop("disabled", false);
			if(data.success){
				new PNotify({ title: "Realizado", text: data.mensaje, type: "success" });
				setTimeout( function(){ window.location.href = "<?php echo URL::route('SysWebEmailMarketingConfApiAmazon'); ?>"; }, 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 elseif( count($ConfNeverBounce)>0 && $ConfNeverBounce->activo == 0 ): ?>
$("#btnActivarNB").click(function(e){
	$("#btnActivarNB").html('<i class="fa fa-spinner fa-spin"></i> Cargando').prop("disabled", true);
	e.preventDefault();
	$.post(
		"<?php echo URL::route('SysWebEmailMarketingConfApiNeverBounceActivar'); ?>",
		{ id:<?php echo $ConfNeverBounce->id; ?> },
		function(data){
			$("#btnActivarNB").html("Activar").prop("disabled", false);
			if(data.success){
				new PNotify({ title: "Realizado", text: data.mensaje, type: "success" });
				setTimeout( function(){ window.location.href = "<?php echo URL::route('SysWebEmailMarketingConfApiAmazon'); ?>"; }, 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 endif; ?>
<?php $__env->stopSection(); ?>
<?php echo $__env->make('BaseSistemaWeb', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>