<div class="row">
	<div class="col-sm-4">
		<div class="ibox">
			<div class="ibox-content">
				<!--Tools-->
				<div class="input-group">
					<div class="col-sm-8">
						<!--<button type="button" id="ctsxcobrar-autorizar-btn"class="btn btn btn-primary"> <i class="fa fa-plus"></i> Nuevo cr&eacute;dito</button>-->						
						<div class="btn-group">
							<button id="ctsxcobrar-autorizar-btn" class="btn btn btn-primary" type="button">
								<i class="fa fa-plus"></i>
								Nuevo cr&eacute;dito
							</button>
						</div>
						<div class="btn-group">
							<button class="btn btn-default dropdown-toggle" data-toggle="dropdown">
								<i class="fa fa-file-text-o"></i>
								<span class="caret"></span>
							</button>
							<ul class="dropdown-menu">
								<li>
									<a href="<?php echo base_url("reportes/reporte_creditos");?>" target="_blank">Reporte de Cuentas por Cobrar</a>
								</li>
							</ul>
						</div>
					</div>
					<div class="col-sm-4">
						<input type="text" id="creditos-search-str" placeholder="Buscar cr&eacute;dito" class="input form-control">
					</div>
				</div>
				<!--Table-->
				<div class="clients-list" id="creditos-lista-wrapper">
					<div class="table-responsive">
						<table class="table table-striped table-hover" id="creditos-lista-table">
							<tbody>
								<tr class="tr-loader">
									<td colspan="3"></td>
								</tr>
								<!--<tr>
									<td>
										<h4>Ronald Sifredo Amaya</h4>
										<small>Xypnos</small>
									</td>
								</tr>-->
							</tbody>
						</table>
					</div>
				</div>
			</div>
		</div>
	</div>
	
	<div class="col-sm-8">
		<div class="ibox">
			<div class="ibox-content">
				<div id="creditos-detalles-wrapper" class="p-sm">
					<div id="creditos-detalles-info-wrapper" class="lista-detalles-info-wrapper">
						<i class="fa fa-chevron-circle-left fa-5x"></i>
						<small>Seleccione un cliente de la lista para ver detalles de creditos.</small>
					</div>
					
					<div id="creditos-detalles-ajax-wrapper">
					</div>
					
				</div>
			</div>
		</div>
	</div>
</div>
<script>
 $(document).ready(function() {
	 $("#ctsxcobrar-autorizar-btn").click(function(){
		Custombox.open({
			target:'<?php echo base_url("clientes/nuevocredito");?>?mode=create', 
			effect: 'fadein',
			overlayClose:false,
			complete:function(){
				$(".modal-body input:text").first().focus();
			}
		});
	});
	
	creditos.setUrl('<?php echo base_url();?>');
	creditos.cargar(true,0);
	$('#creditos-lista-wrapper').slimScroll({
        height: '500px'
	});
	$('#creditos-detalles-wrapper').slimScroll({
        height: '530px'
	});
	/*Load more*/
	$("#creditos-lista-wrapper").slimScroll().bind('slimscroll', function(e, position){
		if(position==='bottom'){
			creditos.cargar(false,$("#creditos-lista-table tbody tr").size()-1);
		}
	});
	/*Search*/
	$("#creditos-search-str").keyup(function(){
		creditos.cargar(true,0);
	}); 
	/*load details*/
	$("#creditos-lista-table").on("click","tbody tr:not(.tr-loader)",function(){
		creditos.detalles(($(this).attr('id').split('-')[1]));
	});
 })
</script>