<div class="row">
	<div class="col-md-11">
		<h2><?php echo $cliente->nombre_cliente;?></h2>
		<span class=""><?php echo $cliente->razonsocial_cliente;?></span>
		<p>
			<small><?php echo $cliente->giro_cliente;?></small>
		</p>
	</div>
	<div class="col-md-1">
		<div class="input-group">
			<button class="btn btn-link dropdown-toggle" data-toggle="dropdown"><i class="fa fa-ellipsis-v fa-2x"></i></button>
			<ul class="dropdown-menu">
				<li><a href="javascript:void(0)" <?php if($permiso_modificarxcobrar):?>id="ctzxcobrar-modificar-btn"<?php else:?>onclick="error_noacces()"<?php endif;?> data-id="<?php echo $cliente->id_cliente;?>" data-saldo="<?php echo $saldo;?>"><i class="fa fa-pencil"></i> Editar</a></li>
				<li><a href="javascript:void(0)" <?php if($permiso_eliminarctaxcobrar):?>onclick="creditos.eliminar(<?php echo $cliente->id_cliente;?>,'<?php echo $cliente->nombre_cliente;?>','<?php echo $saldo;?>')"<?php else:?>onclick="error_noacces()"<?php endif;?>><i class="fa fa-times"></i> Eliminar</a></li>
				<li class="divider"></li>
				<li><a <?php if($permiso_exportarxcobrar):?>href="<?php echo base_url("reportes/reporte_creditos_cliente");?>?idcliente=<?php echo $cliente->id_cliente;?>" target="_blank"<?php else:?>onclick="error_noacces()"<?php endif;?>><i class="fa fa-file-pdf-o"></i> Exportar creditos</a></li>
			</ul>
		</div>
	</div>
</div>
<div class="hr-line-dashed"></div>
<div class="row">
	<div class="col-sm-6">
		<label class="control-label">Monto Autorizado:</label>
		<span class=""> $ <?php echo $cliente->limite_credito_cliente;?></span>
	</div>
	<div class="col-sm-6">
		<label class="control-label">Saldo Total:</label>
		<span class="">$ <?php echo $saldo;?></span>
	</div>
</div>
<div class="hr-line-dashed"></div>
<!--tabla-->
<h3>Cr&eacute;ditos activos</h3>
<div id="cxc-creditos-tabla">
	<?php if(count($creditos)>0):?>
	<div class="table-responsive">
		 <table id="table-cxc-creditos" class="table table-striped table-hover">
			<thead>
				<tr>
					<th>ID</th>
					<th>Activo</th>
					<th>Final</th>
					<th>Monto</th>
					<th>Saldo</th>
					<th>Estado</th>
					<th>Acciones</th>
				</tr>
			</thead>
			<tbody>
				<?php foreach($creditos as $credito):?>
				<tr>
					<td><?php echo $credito->id_credito;?></td>
					<td><?php echo $credito->autorizacion_credito;?></td>
					<td><?php echo $credito->finalizacion_credito;?></td>
					<td><?php echo $credito->monto_credito;?></td>
					<td><?php echo $credito->saldo_credito;?></td>
					<td>
						<?php switch($credito->estado_credito):
						case 0:?>
						<span class="label label-info">Activo</span>
						<?php break; case 1:?>
						<span class="label">Liquidado</span>
						<?php break; endswitch;?>
					</td>
					<td>
						<button class="btn btn-primary btn-xs modal-trigger" data-target="<?php echo base_url("clientes/creditosdetalles");?>?id=<?php echo $credito->id_credito;?>&saldototal=<?php echo $saldo;?>">Ver</button>
					</td>
				</tr>
				<?php endforeach;?>
			</tbody>
		</table>
	</div>
	<?php else:?>
	<span>No hay creditos para este cliente</span>
	<?php endif;?>
</div>
<script>
	$("#ctzxcobrar-modificar-btn").click(function(){
		var id=$(this).attr('data-id');
		var saldo=$(this).attr('data-saldo');
		Custombox.open({
			target:'<?php echo base_url("clientes/nuevocredito");?>?mode=edit&id='+id+'&saldo='+saldo, 
			effect: 'fadein',
			overlayClose:false,
			complete:function(){
				$(".modal-body input:text").first().focus();
			}
		});
	});
</script>