<div class="row">
	<div class="panel blank-panel">
		<div class="panel-body">
			<div class="row">
				<div class="col-md-12">
					<p>
						<label>Cliente: </label><span> <?php echo $credito->nombre_cliente;?></span>
					</p>
				</div>
			</div>
			<div class="row">
				<div class="col-md-3">
					<p>
						<label>Activo: </label><span> <?php echo $credito->autorizacion_credito;?></span>
					</p>
				</div>
				<div class="col-md-3">
					<p>
						<label>Final: </label><span> <?php echo $credito->finalizacion_credito;?></span>
					</p>
				</div>
				<div class="col-md-3">
					<p>
						<label>Monto: </label><span id="monto-credito"> <?php echo $credito->monto_credito;?></span>
					</p>
				</div>
				<div class="col-md-3">
					<p>
						<label>Saldo: </label><span id="saldo-credito"> <?php echo $credito->saldo_credito;?></span>
					</p>
				</div>
			</div>
			
			<div class="row">
				<form autocomplete="off" class="form-horizontal" name='formSaveTrans' id='formSaveTrans' method='post' action='<?php echo base_url('clientes/guardar_transaccion');?>' onsubmit="creditos.guardarTrans(event);">
					<input type="hidden" id="id_cliente" name="id_cliente" value="<?php echo $credito->id_cliente;?>">
					<input type="hidden" id="nombre_cliente" name="nombre_cliente" value="<?php echo $credito->nombre_cliente;?>">
					<input type="hidden" id="id_credito" name="id_credito" value="<?php echo $credito->id_credito;?>">
					<input type="hidden" id="saldo_credito" name="saldo_credito" value="<?php echo $credito->saldo_credito;?>">
					<input type="hidden" id="monto_credito" name="monto_credito" value="<?php echo $credito->monto_credito;?>">
					<input type="hidden" id="nuevo_monto_credito" name="nuevo_monto_credito" value="<?php echo $credito->monto_credito;?>">
					<input type="hidden" id="limite_credito_cliente" name="limite_credito_cliente" value="<?php echo $credito->limite_credito_cliente;?>">
					<input type="hidden" id="saldototal" name="saldototal" value="<?php echo $saldototal;?>">
					<input type="hidden" id="estado_credito" name="estado_credito" value="<?php echo $credito->estado_credito;?>">
					<div class="form-group">
						<div class="col-md-3"><!--Transaccion-->
							<label class="control-label">Transaccion:</label>
							<select  name="tipo_transaccion" id="tipo_transaccion" class="form-control" required>
								<option value="" disabled selected>Seleccione una...</option>
								<option value="0">Cargo</option>
								<option value="1">Abono</option>
							</select>
						</div>
					
						<div class="col-md-5"><!--Concepto-->
							<label class="control-label">Concepto:</label>
							<input type="text" class="form-control" name="ref_transaccion" id="ref_transaccion" required>
						</div>

						<div class="col-md-2"><!--Cantidad-->
							<label class="control-label">Cantidad:</label>
							<input type="number" step="0.01" min="0.01" class="form-control" name="monto_transaccion" id="monto_transaccion" onkeydown='return isNumberDecimalKey(event);' required>
						</div>
						
						<div class="col-md-2">
							<button class="btn btn-info btn-sm m-t-md" id="guardar-transaccion" type="submit">Realizar cargo</button>
						</div>
					</div>
				</form>
			</div>
			
			<div class="hr-line-dashed"></div>
			<!--tabla-->
			<div id="detalles-credito-transacciones-wrapper" style="height:340px; overflow:hidden;">
				<div class="table-responsive">
					 <table id="detalles-credito-transacciones-table" class="table table-striped table-hover">
						<thead>
							<tr>
								<th>ID</th>
								<th>Fecha</th>
								<th>Tipo</th>
								<th>Transaccion</th>
								<th>Cargos</th>
								<th>Abonos</th>
								<th>Saldo</th>
							</tr>
						</thead>
						<tbody>
							<!--<tr>
								<td>129834920</td>
								<td>28/07/2015</td>
								<td>Venta al credito sin documento</td>
								<td>$ 659.00</td>
								<td>-</td>
								<td>$ 659.00</td>
							</tr>-->
						</tbody>
					 </table>
				</div>
			</div>			
		</div>
	</div>
</div>
<script>
 $(document).ready(function() {
	/*scroll*/
	if($("#estado_credito").val() == 1){
		$("#guardar-transaccion").attr('disabled','disabled');					
	}
	
	$('#detalles-credito-transacciones-wrapper').slimScroll({
        height: '340px'
	});
	$("#detalles-credito-transacciones-table").dataTable({
		"dom": '<"export">lftip',
		"columns": [
			{ "data": "id_transaccion"},
			{ "data": "fecha_transaccion","width":"30%"},
			{ "data": "tipo_transaccion","orderable":false},
			{ "data": "ref_transaccion","width":"25%","orderable":false},
			{ "data": "cargo_transaccion","width":"15%","orderable":false},
			{ "data": "abono_transaccion","width":"15%","orderable":false},
			{ "data": "saldo_transaccion","width":"15%","orderable":false},
		],
		"columnDefs": [
			{ "targets": 0, 'visible' : false, 'searchable' : false},
			{ "targets": 2, 'visible' : false, 'searchable' : false},
		],
		"iDisplayLength": 5,
		"aLengthMenu": [[5, 10, 25, -1], [5, 10, 25, "Todas"]],
		"bLengthChange": true,
		"processing": true,
		"order": [ 1, 'asc' ],
		"serverSide": true,
		"ajax": {
			"url": "<?php echo base_url();?>clientes/cargar_transacciones",
			"type": "POST",
			"data": function ( d ) {
				d.idCredito = "<?php echo $credito->id_credito;?>";
			}
		},
		"language": {
			"emptyTable":     "",
			"lengthMenu": "Mostrar _MENU_ registros por pagina",
			"zeroRecords": "",
			"info": "Pagina _PAGE_ de _PAGES_",
			"infoEmpty": "No hay registros",
			"infoFiltered": "",
			"search":         "Buscar:",
			"processing":     "<div class='overlay'><i class='fa fa-refresh fa-spin'></i></div>",
			"loadingRecords": "<div class='overlay'><i class='fa fa-refresh fa-spin'></i></div>",
			"paginate": {
				"first":      "Primero",
				"last":       "Ultimo",
				"next":       "Siguiente",
				"previous":   "Anterior"
			}
		},
		"bAutoWidth": false
	});
	 $("div.export").html("<a class='btn btn-white pull-right m-l-xs' title='Exportar estado de cuenta' style='padding:4px 12px;'   <?php if($permiso_exportarxcobrar):?> href='<?php echo base_url("reportes/reporte_credito_cliente");?>?idcredito=<?php echo $credito->id_credito;?>&idcliente=<?php echo $credito->id_cliente;?>' target='_blank'<?php else:?>  onclick='error_noacces()'<?php endif;?>><i class='fa fa-file-pdf-o'></i></a>");
 });
</script>