@include('header')
@include('navigator_menu_principal') 
<div class="container">
 
	<div class="row">
		<div class="col-md-3 h3">Documentos LED a verificar <i class="fa fa-exclamation text-warning"></i></div>
		<div class="col-md-9 form-group text-right">
			<!-- <form name="frmBalances" method="get" id="frmBalances" class="form form-inline">
				<label for="estado_balance">Estado del balance</label>
				<select name="estado_balance" class="form-control" id="estado_balance">
					<option value="P">Pendientes de verificar</option>
					<option value="E">En verificación</option>
					<option value="V">Verificado</option> 
					<option value="D">Descartado</option>
				</select>
			</form> -->

			<button type="button" class="btn btn-primary valoraciones"><i class="fa fa-file"></i> Valoración/Análisis</button>
			<button type="button" class="btn btn-danger rechazados"><i class="fa fa-times"></i> Documentos rechazados</button>
			<button type="button" class="btn btn-success verificados"><i class="fa fa-check"></i> Documentos verificados</button>
			<button type="button" class="btn btn-warning valoracion_pendiente"><i class="fa fa-pen"></i> Valoración BBVA Pendiente</button>
		</div>
	</div>

	<table class="table table-condensed table-striped" id="tablaDocumentos">
		<thead>
			<tr>
				<th class="text-left">Cliente</th>
				<th class="text-left">Contraparte</th>
				<th class="text-center">País</th>
				<th class="text-center">Identificación</th>
				<th class="text-left">Documento</th>

				<th class="text-center">Vigencia</th>
				<th class="hidden">&nbsp;</th>

				<th class="text-center">Ejercicio</th>
				<th class="text-center">Moneda</th>

				<th class="text-center">Cargado</th>
				<th class="hidden">&nbsp;</th>

				<th class="text-center">Acción</th>
				<th class="text-center">Revisados</th>
			</tr>
		</thead>

		<tbody>
			@foreach ($docs as $documento)
			<tr>
				<td>{{$documento->nombre_cliente}}</td>
				<td>{{$documento->nombre_persona}} @if (null != $documento->id_padre) <br>(Subcontratista de {{$documento->nombre_persona_padre}}) @endif</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
				</td>
				<td class="hidden">
					@if ($documento->es_balance > 0)
						@if ($documento->inicio_ejercicio != '') {{$documento->inicio_ejercicio_ymd}} @endif
						@if ($documento->fin_ejercicio != '') @if ($documento->inicio_ejercicio != '') <br /> @endif {{$documento->fin_ejercicio_ymd}} @endif
					@else
						@if ($documento->fecha_vigencia != '') {{$documento->fecha_vigencia_ymd}} @endif
					@endif
				</td>

				<td class="text-center">
					@if ($documento->es_balance > 0) {{$documento->ejercicio}} @endif
				</td>
				<td class="text-center">
					@if ($documento->es_balance > 0 && $documento->moneda != '') {{$documento->nombre_moneda}} ({{$documento->moneda}}) @endif
				</td>

				<td class="text-center">{{$documento->ingresado}}</td>
				<td class="hidden">{{$documento->ingresado_ymd}}</td>

				<td class="text-center">
					@if ( (strpos($documento->identificacion, 'LED') === FALSE && strpos($documento->identificacion, 'VLD') === FALSE) || in_array($documento->tipo_doc , explode(',', env('LED_DOCUMENTO_TAX_ID')) ) )
						@if ($documento->es_balance > 0)
							<button type="button" class="btn btn-fidelitas btn-primary verifybal" data-doc-id="{{$documento->doc_id}}">Verificar</button>
						@else
							<button type="button" class="btn btn-fidelitas btn-primary verifydoc" data-doc-id="{{$documento->doc_id}}" data-es-revisado="{{$documento->revisado}}">Verificar</button>
						@endif
					@else
						<button type="button" class="btn btn-fidelitas btn-primary tempid" data-doc-id="{{$documento->doc_id}}" data-toggle="modal" data-target="#modalDocumentos">Verificar</button>
					@endif
				</td>
				<td class="text-center">
					@if ($documento->revisado == 0)
					<span class="glyphicon glyphicon-remove" aria-hidden="true" style="color:red;"></span>
					@else
					<span class="glyphicon glyphicon-ok" aria-hidden="true" style="color:green;"></span>
					@endif
				</td>

			</tr>

			@endforeach
		</tbody>

		<tfoot></tfoot>
	</table>

</div>

<form id="frmDocumento" name="frmDocumento" method="post" action="/led/led-documento-verificar">
	{{csrf_field()}}
	<input type="hidden" name="doc_id" id="doc_id_doc" value="">
	<input type="hidden" name="es_revisado">
</form>
<form id="frmBalance" name="frmBalance" method="post" action="/led/led-balances-verificar">
{{csrf_field()}}
<input type="Hidden" name="doc_id" id="doc_id_bal" value="">
</form>


<div id="modalDocumentos" class="modal fade">
    <div class="modal-dialog" style="width:750px">
        <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" id="modal_title"></h3>
            </div>
            <div class="modal-body" id="modal_body">
				<br />
				<br />
				<div class="row">
					<div class="col-md-10 col-md-offset-1 h4 text-center" id="modal_text"></div>
				</div>
				<br />
				<br />
				<br />
			</div>
        </div>
    </div>
</div>


<script type="text/javascript">
	$(document).ready(function() {
		$('#tablaDocumentos').DataTable({

							"pagingType": "full_numbers",
							"dom" : "p<'row'>f<t>lp",
							"ordering": true,
							"columns": [ null, null, null, null, null, null, null, null, null, null, null, { "orderable": false } , null],

							"columnDefs": [ { 'orderData':[6], 'targets': [5] } , { 'orderData':[10], 'targets': [9] }],

							"searching": true,
							"order": [[ 9, "asc" ]],
							"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"
								},
							},
							stateSave: true


		});
	});

</script>


<script type="text/javascript" src="{{ URL::asset('js/led_documentos.js') }}?v={{time()}}"> </script>

@include('footer')