<?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'); ?>

<style type="text/css">
	@media (max-width: 450px) { .ModalEliminar .modal-dialog { width: auto; } }
	@media (min-width: 451px) { .ModalEliminar .modal-dialog { width: 450px; } }
</style>
<?php $__env->stopSection(); ?>


<?php $__env->startSection('Contenido'); ?>
<div class="row">
	<div class="col-md-12">
		<h2><i class="fa fa-file-pdf-o"></i> Reportes </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-8">
		<div class="block-web">
			<div class="header">
				<h3 class="content-header">
					Reporte de efectividad de vendedores
					<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">
				<form id="frmFiltroFechas" class="form-inline" style="padding-bottom: 15px;">
					<div class="form-group">
						<label for="FiltroFechas" style="padding-top: 10px;"> Suscritos en: </label>
						<input id="FiltroFechas" type="text" name="filtrofechas" value="" readonly>
					</div>
					<select name="slVendedores" class="form-control" id="slVendedores">
						<option>Seleccione un vendedor...</option>
						<option>Seleccione un vendedor...</option>
						<option>Seleccione un vendedor...</option>
					</select>
					<button type="submit" class="btn btn-primary"> Filtrar </button>
					<button id="btnLimpiar" type="button" class="btn btn-default"> Limpiar </button>
				</form>
				<div class="table-responsive">
					<table class="table table-striped table-bordered table-hover" id="tblReferencias">
						<thead>
							<tr>
								<th class="" style="width: 9%;"> Fecha </th>
								<th class=""> Prospecto </th>
								<th style=""> Acciones </th>
							</tr>
						</thead>
					</table>
				</div>
			</div>
			<?php if( Auth::user()->tipo == 'EC' ): ?>
			<?php
				//$Empleado = Empleado::find( Empleado::select('id')->where('users_id', '=', Auth::id())->first()->id );
				//$CargoEmpleado = Cargo::select('nombre')->where('id', '=', $Empleado->cargos_id)->first()->nombre;
			?>
				<?php /* <?php if( $CargoEmpleado == 'Recepción' || $CargoEmpleado == 'Gerente de ventas' ): ?> */ ?>
			<div class="bottom">
				<a href="<?php echo URL::route('SysWebGClientesProspectosAgregar'); ?>" class="btn btn-primary"> Agregar </a>
			</div>
				<?php /* <?php endif; ?> */ ?>
			<?php endif; ?>
		</div>
	</div>
	<div class="col-md-4">
		<div class="block-web">
			<div class="header">
				<h3 class="content-header">
					Desglose de efectividad
					<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>
		</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('bootstrap-daterangepicker/moment.min.js'); ?>

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

<script type="text/javascript">
	function Actualizar(){
		var table = $("#tblReferencias").DataTable();
		table.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='idR' 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('SysWebGClientesProspectosEliminar'); ?>",
						{idP: id},
						function(data){
							$.isLoading("hide"); NProgress.done();
							$("#btnAgregar").html("Guardar").prop("disabled", false);
							if(data.success){
								dialogItself.close();
								var table = $("#tblReferencias").DataTable();
								table.ajax.reload(null, false);
								new PNotify({ title: "Realizado", text: data.mensaje, type: "success" });
							}
							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'); ?>
$(".sidebar-toggle-box").trigger("click");
//$("a[data-toggle=\"tab\"]").on("shown.bs.tab", function (e) { $.fn.dataTable.tables( {visible: true, api: true} ).columns.adjust(); });

/*$('#tblReferencias tfoot th').each(function(){
	var title = $(this).text();
	$(this).html( '<input type="text" placeholder="Search '+title+'" />' );
});*/

/*$("#tblReferencias").DataTable({
	"processing": true,
	"serverSide": true,
	"ajax": {
		url: "<?php echo URL::route('SysWebGClientesProspectos'); ?>",
		data: function (d) {
			d.filtrofechas = $("#FiltroFechas").val();
			d.chEstadoP = $("#chEstadoP").is(":checked");
			d.chEstadoV = $("#chEstadoV").is(":checked");
			d.chEstadoC = $("#chEstadoC").is(":checked");
		}
	},
	columns: [
		{data: 'fecha_registrado', name: 'seguimientos_clientes.fecha_registrado'},
		{data: 'nombre', name: 'seguimientos_clientes.nombre'},
		{data: 'contacto', name: 'seguimientos_clientes.contacto'},
		{data: 'telefono', name: 'seguimientos_clientes.telefono'},
		{data: 'correo_electronico', name: 'seguimientos_clientes.correo_electronico'},
		{data: 'contestadoPor', name: 'cp.nombre_completo'},
		{data: 'asignadoA', name: 'aa.nombre_completo'},
		{data: 'producto', name: 'ps.nombre'},
		{data: 'referencia', name: 'r.nombre'},
		{data: 'comentario', name: 'seguimientos_clientes.comentario'},
		{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,
	responsive: true/*,
	initComplete: function(){
		this.api().columns().every(function(){
			var column = this;
			//console.log( column );
			var input = document.createElement("input");
			$(input).appendTo($(column.footer()).empty()).on("change", function(){
				//column.search($(this).val()).draw();
				//column.search($(this).val(), false, false, true).draw();
			});
		});
	}*/
});*/
/*$("#FiltroFechas").daterangepicker({
	"ranges": {
		"Hoy": [moment(), moment()],
		"Ayer": [moment().subtract(1, 'days'), moment().subtract(1, 'days')],
		"Últimos 7 días": [moment().subtract(6, 'days'), moment()],
		"Últimos 30 días": [moment().subtract(29, 'days'), moment()],
		"Este mes": [moment().startOf('month'), moment().endOf('month')],
		"Último mes": [moment().subtract(1, 'month').startOf('month'), moment().subtract(1, 'month').endOf('month')]
	},
	"alwaysShowCalendars": true,
	locale: {
		format: 'DD/MM/YYYY'
	},
	autoUpdateInput: false,
	"startDate": moment(),
	"endDate": moment()
}, function(start, end, label) {
	console.log("New date range selected: ' + start.format('YYYY-MM-DD') + ' to ' + end.format('YYYY-MM-DD') + ' (predefined range: ' + label + ')");
});
$("#FiltroFechas").on("apply.daterangepicker", function(ev, picker) { $(this).val(picker.startDate.format("DD/MM/YYYY") + " - " + picker.endDate.format("DD/MM/YYYY")); });
$("#FiltroFechas").on("cancel.daterangepicker", function(ev, picker) { $(this).val(""); });
$("#frmFiltroFechas").submit(function(e){
	e.preventDefault();
	var table = $("#tblReferencias").DataTable();
	table.ajax.reload(null, false);
});
$("#btnLimpiar").click(function(e){
	e.preventDefault();
	$("#FiltroFechas").val("");
	var table = $("#tblReferencias").DataTable();
	table.ajax.reload(null, false);
});*/
<?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(); ?>