<div class="row">
	<div class="col-md-12">
		<div class="ibox">
			<div class="ibox-content">
				<div class="row m-t-md">
					<div id="cortes-table-wrapper" style="height:380px;">
						<div class="table-responsive" style="overflow-x:hidden;">
							<table id="cortes-table" class="display table" style="width: 100%; cellspacing: 0;">
								<thead>
									<tr>
										<th>No</th>
										<th>Fecha</th>
										<th>Usuario</th>
										<th>Desde</th>
										<th>Hasta</th>
										<th></th>
										<th></th>
									</tr>
								</thead>
									<!--<tr>
										<td>30-08-2015 11:42</td>
										<td>Ronald Sifredo Amaya</td>
										<td>Carlos Ulises Portillo</td>
										<td>$450.00</td>
										<td>
											<a class="btn btn-info btn-xs" target="_blank" href="<?php echo base_url('reportes/reporte_cotizacion?id=');?>3">Exportar</a>
											<button class="btn btn-warning btn-xs">Modificar</button>
											<button class="btn btn-danger btn-xs">Eliminar</button>
										</td>
									</tr>-->
								</tbody>
							</table>
						</div>
					</div>
				</div>
			</div>
		</div>
	 </div>
</div>
<!--Botones-->
<div class="row m-t-sm text-center">
	<button type="button" class="btn btn-danger" onclick="Custombox.close();">Salir</button>
</div>

<!--Detalles del exportar imprimir-->
<div class="modal inmodal fade" id="cortes-appmodal-exportar-opciones" tabindex="-1" role="dialog"  aria-hidden="true">
	<div class="modal-dialog modal-sm">
		<div class="modal-content">
			<div class="modal-header">
				<h4 class="">Opciones de cortes</h4>
			</div>
			<div class="modal-body">
				<label class="control-label">Incluir</label>
				<div>
					<label class="cursor-pointer"><input type="checkbox" class="i-checks" id="cortemodal-gastos" checked> Gastos</label>
				</div>
				<div>
					<label class="cursor-pointer"><input type="checkbox" class="i-checks" id="cortemodal-ingresos" checked> Ingresos</label>
				</div>
				<div>
					<label class="cursor-pointer"><input type="checkbox" class="i-checks" id="cortemodal-ingresos-resumen"> Mostrar resumido</label>
				</div>
				<div class="hr-line-dashed"></div>
				<label class="control-label">Por documento</label>
				<div>
					<label class="cursor-pointer"><input type="checkbox" class="i-checks" id="cortemodal-ingresos-doc-sd" checked> Ingresos sin Documento</label>
				</div>
				<div>
					<label class="cursor-pointer"><input type="checkbox" class="i-checks" id="cortemodal-ingresos-doc-factura" checked> Ingresos con Factura</label>
				</div>
				<div>
					<label class="cursor-pointer"><input type="checkbox" class="i-checks" id="cortemodal-ingresos-doc-ticket" checked> Ingresos con Tickets</label>
				</div>
				<div>
					<label class="cursor-pointer"><input type="checkbox" class="i-checks" id="cortemodal-ingresos-doc-ccf" checked> Ingresos con CCF</label>
				</div>
				<div>
					<label class="cursor-pointer"><input type="checkbox" class="i-checks" id="cortemodal-ingresos-doc-resumen"> Mostrar resumido</label>
				</div>
			</div>
			<div class="modal-footer">
				<button type="button" class="btn btn-white" data-dismiss="modal">Cancelar</button>
				<button type="button" id="cortes-appmodal-exportar-continuar-btn" class="btn btn-primary">Continuar</button>
				<input type="hidden" id="id_corte" value="">
			</div>
		</div>
	</div>
</div>
<script>
$(document).ready(function(){
	$("#cortes-table").DataTable({
		"processing": true,
		"iDisplayLength": 5,
		"aLengthMenu": [[5], [5]],
		"order": [ 0, 'desc' ],
		"serverSide": true,
		"ajax": {
			"url": "<?php echo base_url();?>transacciones/cargar_cortes_cajachica",
			"type": "POST"
		},
		"columnDefs": [
			{ "width": "10%", "targets": 0 },
			{ "width": "20%", "targets": 1 },
			{ "width": "20%", "targets": 2 },
			{ "width": "20%", "targets": 3 },
			{ "width": "20%", "targets": 4 },
			{ "width": "5%", "targets": 5, "className" : "myTableActionClass export-cut","orderable": false, "searchable": false },
			{ "width": "5%", "targets": 6, "className" : "myTableActionClass delete-cut","orderable": false, "searchable": false },
		],
		"language": {
			"emptyTable":     "",
			"lengthMenu": "Mostrar _MENU_ registros por pagina",
			"zeroRecords": "",
			"info": "Pagina _PAGE_ de _PAGES_",
			"infoEmpty": "No hay registros",
			"infoFiltered": "(Ningun resultado encontrado de _MAX_ registros)",
			"search":         "Buscar:",
			"processing":     '<div class="sk-circle"><div class="sk-circle1 sk-child"></div><div class="sk-circle2 sk-child"></div><div class="sk-circle3 sk-child"></div><div class="sk-circle4 sk-child"></div><div class="sk-circle5 sk-child"></div><div class="sk-circle6 sk-child"></div><div class="sk-circle7 sk-child"></div><div class="sk-circle8 sk-child"></div><div class="sk-circle9 sk-child"></div><div class="sk-circle10 sk-child"></div><div class="sk-circle11 sk-child"></div><div class="sk-circle12 sk-child"></div></div>',
			"loadingRecords": '<div class="sk-circle"><div class="sk-circle1 sk-child"></div><div class="sk-circle2 sk-child"></div><div class="sk-circle3 sk-child"></div><div class="sk-circle4 sk-child"></div><div class="sk-circle5 sk-child"></div><div class="sk-circle6 sk-child"></div><div class="sk-circle7 sk-child"></div><div class="sk-circle8 sk-child"></div><div class="sk-circle9 sk-child"></div><div class="sk-circle10 sk-child"></div><div class="sk-circle11 sk-child"></div><div class="sk-circle12 sk-child"></div></div>',
			"paginate": {
				"first":      "Primero",
				"last":       "Ultimo",
				"next":       "Siguiente",
				"previous":   "Anterior"
			}
		},
		"bAutoWidth": false
	});
	
	$("#cortes-table").on("click","td.export-cut",function(){
		var dataClick = $(this).parent();
		//alert("Exportar "+dataClick.find("button").data("id"));
		$("#id_corte").val(dataClick.find("button").data("id"));
		$("#cortes-appmodal-exportar-opciones").modal({backdrop: 'static', keyboard: false});
		$("#cortes-appmodal-exportar-opciones").modal("show");
	});
	
	$("#cortes-table").on("click","td.delete-cut",function(){
		var dataClick = $(this).parent();
		alert("Eliminar "+dataClick.find("button").data("id"));
	});
	
	$("#cortes-appmodal-exportar-continuar-btn").click(function(e){
		if(!$(this).is(':disabled')){
			var gastos=$("#cortemodal-gastos").is(":checked");
			var ingresos=$("#cortemodal-ingresos").is(":checked");
			var ingresos_resumen=$("#cortemodal-ingresos-resumen").is(":checked");
			var ingresos_doc_sd=$("#cortemodal-ingresos-doc-sd").is(":checked");
			var ingresos_doc_factura=$("#cortemodal-ingresos-doc-factura").is(":checked");
			var ingresos_doc_ticket=$("#cortemodal-ingresos-doc-ticket").is(":checked");
			var ingresos_doc_ccf=$("#cortemodal-ingresos-doc-ccf").is(":checked");
			var ingresos_doc_resumen=$("#cortemodal-ingresos-doc-resumen").is(":checked");
			var id=$("#id_corte").val();
		
			url="<?php echo base_url();?>transacciones/exportar_corte";
			window.open(url+"?by=corte&id="+id+"&gastos="+gastos+"&ingresos="+ingresos+"&ingresos_resumen="+ingresos_resumen+"&ingresos_doc_sd="+ingresos_doc_sd+"&ingresos_doc_factura="+ingresos_doc_factura+"&ingresos_doc_ticket="+ingresos_doc_ticket+"&ingresos_doc_ccf="+ingresos_doc_ccf+"&ingresos_doc_resumen="+ingresos_doc_resumen,"_blank");
			$("#cortes-appmodal-exportar-opciones").modal("hide");			
		}
	});
	
	$('.i-checks').iCheck({
		checkboxClass: 'icheckbox_square-green',
		radioClass: 'iradio_square-green',
	});
});
</script>