{{--@include('header')
@include('navigator_menu_principal')--}}

<form method="post" name="frmDocumento" id="frmDocumento" action="/led/led-detalle-documento">
<input type="hidden" name="_token" value="{{csrf_token()}}">
<input type="hidden" name="doc_id" value="" id="doc_id">
<input type="hidden" name="user_id" value="{{$user_id}}" id="user_id">
</form>
@if (isset($docs))

<div class="container">

	<table id="tablaDocumentos" class="table table-condensed table-striped table-hover">
		<thead>
			<tr>
				<th>Cliente</th>
				<th>Contraparte</th>
				<th>Pais</th>
				<th>Identificacion</th>
				<th>Documento</th>
				<th>Vigencia</th>
				<th>Cargado</th>
				<th class="hidden"></th>
				<th>Rechazado</th>
				<th class="hidden"></th>
				<th>Acción</th>
			</tr>
		</thead>
		<tbody>
			@foreach($docs as $documento)
			<tr>
				<td>{{$documento->nombre_cliente}}</td>
				<td>{{$documento->nombre_persona}}</td>
				<td class="text-center">{{$documento->country_name}} ({{$documento->country_code}})</td>
				<td class="text-center">{{$documento->abreviatura}} {{$documento->identificacion}}</td>
				<td class="text-left">
					{{$documento->nombre_tipo_doc}}
					@if ($documento->es_balance > 0)
						<br><span style="font-weight: bold; color: @if ($documento->estado == 'CARGA LED') #b042f4 @elseif ($documento->estado == 'ELIMINADO') #FF0000 @elseif ($documento->estado == 'PUBLICADO') #066b27 @elseif ($documento->estado == 'GRABADO PARCIAL') #0000FF @elseif ($documento->estado == 'A VERIFICAR') #d38d13 @endif "><?php ($documento->estado == 'CARGA LED') ? print_r('PENDIENTE DE CARGA') : print_r($documento->estado) ?></span>
					@endif
				</td>

				<td class="text-center">
					@if ($documento->es_balance > 0)
						@if ($documento->inicio_ejercicio != '') {{$documento->inicio_ejercicio}} @endif
						@if ($documento->fin_ejercicio != '') @if ($documento->inicio_ejercicio != '') <br /> @endif {{$documento->fin_ejercicio}} @endif
					@else
						@if ($documento->fecha_vigencia != '') {{$documento->fecha_vigencia}} @endif
					@endif
					@if ($documento->es_balance > 0 && $documento->ejercicio > 0) <br /> Ej. {{$documento->ejercicio}} @endif

				<td class="text-center">{{$documento->ingresado}}</td>
				<td class="hidden">{{$documento->ingresado_ymd}}</td>
				<td class="text-center">{{$documento->rechazado}} @if ($documento->rechazado_por > 0) ({{$documento->rechazado_por_usuario}}) @endif</td>
				<td class="hidden">{{$documento->rechazado_ymd}}</td>
				<td class="text-center">
					<button type="button" class="btn btn-fidelitas btn-primary detalle" data-doc-id="{{$documento->doc_id}}" data-toggle="modal" data-target="#modalDocumento">Detalle</button>
				</td>
			</tr>
			@endforeach
		</tbody>
	</table>

</div>
@endif

<div id="modalDocumento" class="modal fade">
    <div class="modal-dialog" style="width:950px">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                <h3 class="modal-title">Detalle del documento</h3>
            </div>
            <div class="modal-body" id="documento_edit"></div>
        </div>
    </div>
</div>


<script type="text/javascript" language="javascript">

	$(document).ready(function() {

		$(document).on('click', '.btnback', function() {
			@if (Session::get('es_bbva') == '1')
			location.href = '/led/led-documentos-bbva';
			@else
				location.href = '/led/led-documentos';
			@endif
		});


		$(document).on('click', '.verificados', function() {
			location.href = '/led/led-verificados-cliente';
		});


		$(document).on('click', '.detalle', function() {
			var id = $(this).data('docId');
			$('#doc_id').val(id);
			$.ajax({
						method : 'post',
						url : '/led/led-detalle-documento',
						data : $('#frmDocumento').serialize(),
						beforeSend: function() {
							$('#documento_edit').html('');
						},
						success : function(data) {
							$('#documento_edit').html(data);
						},



			});
		});



		$('#tablaDocumentos').DataTable({

							"pagingType": "full_numbers",
							"dom" : "p<'row'>f<t>lp",
							"ordering": true,
							"columns": [ null, null, null, null, null, null, null, null, null, null, { "orderable": false } ],
							"columnDefs": [ { 'orderData':[7], 'targets': [6] } , { 'orderData':[9], 'targets': [8] }],
							"searching": true,
							"order": [[ 8, "desc" ]],
							"info":  true,
							"lengthMenu": [ [10, 25, 50, 100, -1], [10, 25, 50, 100,"Todos"] ],
							"pageLength": 10,
							"language": {
								"lengthMenu": "Mostrar _MENU_ registros por página",
								"zeroRecords": "No se encontraron resultados",
								//"info": "Mostrando página _PAGE_ de _PAGES_",
								//"info": "Total de Registros: _MAX_", 
								"info": "Mostrando  _START_  de  _END_ - <b>Total:</b> _TOTAL_ registros",
								"infoEmpty": "No hay registros disponibles",
								"infoFiltered": "(filtered from _MAX_ total records)",
								"sSearch": "Buscar",
								"oPaginate": {
									"sFirst": "Primera",
									"sPrevious": "Anterior",
									"sNext": "Siguiente",
									"sLast": "Última"
								},
							}


		});

	});
</script>

{{--@include('footer')--}}