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

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

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

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

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

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

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

<?php $__env->startSection('Contenido'); ?>
<div class="row">
	<div class="col-md-12">
		<h2><i class="fa fa-server"></i> Gestión de registros de servidor cPanel </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">
					Listado de registros de servidor cPanel
					<div data-toggle="buttons" class="button-group pull-right">
						<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="table-responsive">
					<table class="table table-striped-old table-bordered table-hover display" id="tblSrvsCpanel">
						<thead>
							<tr>
								<th class="all"> ID </th>
								<th class="all"> Nombre </th>
								<th class="all"> IP </th>
								<th class="all"> Dominio </th>
								<th class="all"> NSs </th>
								<th class="all"> Puertos </th>
								<th class="all"> Usuario W</th>
								<th class="all"> Contraseña W </th>
								<th class="all"> Usuario C</th>
								<th class="all"> Contraseña C </th>
								<th class="all"> Estado </th>
								<th class="all"> Tipo </th>
								<th class="min-tablet-l col-md-2"> Acciones </th>
							</tr>
						</thead>
					</table>
				</div>
			</div>
			<div class="bottom">
				<?php echo HTML::linkRoute('SysWebSWebSrvCPanelAgregar', 'Agregar', array(), array('class' => 'btn btn-primary')); ?>

				<button id="btnAsignacionInicial" class="btn btn-success" type="button">Asignación inicial SW</button>
			</div>
		</div>
	</div>
</div><!--/row end-->
<?php $__env->stopSection(); ?>

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

<?php echo HTML::script('bootstrap-select/js/i18n/defaults-es_CL.min.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('DataTables/dataTables.select.min.js'); ?>

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

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

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

<script type="text/javascript">
	function Actualizar(){
		$("#tblSrvsCpanel").DataTable().ajax.reload(null, false);
	}
	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='idCA' value='"+id+"'> \
				</form> \
			</div> \
		</div>";
		BootstrapDialog.show({
			title: "Eliminar registro",
			type: BootstrapDialog.TYPE_DANGER,
			message: mensaje,
			draggable: true,
			cssClass: "ModalEliminar",
			buttons: [{
				id: "btnEliminar",
				label: "Eliminar",
				cssClass: "btn-danger",
				action: function(dialogItself){
					$.isLoading({ text: "Cargando..." }); NProgress.start();
					$("#btnEliminar").prop("disabled", true).html('<i class="fa fa-spinner fa-spin"></i> Eliminando');
					$.post(
						"<?php echo URL::route('SysWebSWebSrvCPanelEliminar'); ?>",
						{idCA: id},
						function(data){
							$.isLoading("hide"); NProgress.done();
							$("#btnEliminar").prop("disabled", false).html("Eliminar");
							if(data.success){
								new PNotify({ title: "Felicidades!", text: data.mensaje, type: "success" });
								dialogItself.close();
								var table = $("#tblSrvsCpanel").DataTable();
								table.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"
					);
				}
			}]
		});
	}
</script>
<?php $__env->stopSection(); ?>

<?php $__env->startSection('JSOr'); ?>
var tabla = $("#tblSrvsCpanel").DataTable({
	"processing": true,
	"serverSide": true,
	"pageLength": 10,
	"ordering": false,
	"searching": false,
	"ajax": "<?php echo URL::route('SysWebSWebSrvCPanel'); ?>",
	columns: [
		{data: "id", name: "scp.id", "searchable": true},
		{data: "nombre", name: "scp.nombre", "searchable": true},
		{data: "ip", name: "scp.ip", "searchable": true},
		{data: "dominio", name: "scp.dominio", "searchable": true},
		{data: "NSs", name: "scp.NSs", "searchable": true},
		{data: "puertos", name: "scp.puertos", "searchable": true},
		{data: "usuarioW", name: "scp.usuarioW", "searchable": true},
		{data: "contrasenhaW", "visible": false, name: "scp.contrasenhaW", "searchable": true},
		{data: "usuarioC", name: "scp.usuarioC", "searchable": true},
		{data: "contrasenhaC", "visible": false, name: "scp.contrasenhaC", "searchable": true},
		{data: "estado", name: "scp.estado", "searchable": true},
		{data: "tipo", name: "scp.tipo", "searchable": true},
		{data: "acciones", name: "acciones", "searchable": false, "orderable": false, "class": "text-center"}
	],
	"language": {
		"url": "<?php echo asset('DataTables/Spanish.json'); ?>"
	},
	"fnDrawCallback": function( oSettings ) {
		$(".tooltips").tooltip();
		//$(".table-responsive").find("[title]").tooltip();
	},
	autoWidth: false,
	columnDefs: [{
		"data": null,
		"defaultContent": "",
		"className": "control",
		"orderable": false,
		"width": "9%",
		"targets": 0
	}],
});
$("#btnAsignacionInicial").click(function(e){
	$("#btnAsignacionInicial").html('<i class="fa fa-spinner fa-spin"></i> Cargando').prop("disabled", true);
	$.post(
		"<?php echo URL::route('SysWebSWebSrvCPanelAsignacionInicial'); ?>",
		{asignacionInicial: true},
		function(data){
			$.isLoading("hide"); NProgress.done();
			$("#btnAsignacionInicial").prop("disabled", false).html("Asignacion inicial");
			if(data.success){
				new PNotify({ title: "Realizado", text: data.mensaje, type: "success" });
				setTimeout( function(){ window.location.reload(); }, 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(Session::has('MensajeS')): ?>
new PNotify({ title: "Realizado", text: "<?php echo Session::get('MensajeS'); ?>", type: "success" });
<?php endif; ?>
<?php if(Session::has('MensajeE')): ?>
new PNotify({ title: "Realizado", text: "<?php echo Session::get('MensajeE'); ?>", type: "error" });
<?php endif; ?>
<?php $__env->stopSection(); ?>
<?php echo $__env->make('BaseSistemaWeb', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>