@extends('header_nuevo_generico')
@section('main')	
	<div class="container mt-5 mb-5">
		<div class="row justify-content-center my-2 mb-4 mt-5">
			<div class="col-md-12 mt-5">
				<h2 class="text-fidelitas text-center">Tabla de Valores de Score</h2>
			</div>
		</div>	
		@foreach ($tabla_score_separada as $grupo => $tabla_score)
			<h4 class="text-center">Grupo {{ $grupo }}</h4>
			<table id="tabla_valores_score_{{ $grupo }}" class="tabla_valores_score table table-bordered text-right table-hover">
				<thead>
					<tr>
						<th class="hidden"></th>
						<th class="text-center">Grupo</th>
						<th class="text-center">Codigo</th>
						<th class="text-center">Cant desde</th>
						<th class="text-center">Cant hasta</th>
						<th class="text-center">Dias desde</th>
						<th class="text-center">Dias hasta</th>
						<th class="text-center">Valor</th>
						<th class="text-center">Afecta Score</th>
						<th class="text-center">Acciones</th>
					</tr>
				</thead>
				<tbody>
					@foreach($tabla_score as $valores)
					<tr>
						<td class="id_score text-center hidden">{{ $valores['id_score'] }}</td>
						<td class="id_grupo text-center">{{ $valores['id_grupo'] }}</td>
						<td  class="codigo text-center"> {{ $valores['codigo'] }}</td>
						<td  class="cant_desde text-right">{{ $valores['cant_desde'] }}</td>
						<td  class="cant_hasta text-right">{{ $valores['cant_hasta'] }}</td>
						<td  class="dias_desde text-right">{{ $valores['dias_desde'] }}</td>
						<td  class="dias_hasta text-right">{{ $valores['dias_hasta'] }}</td>
						<td  class="valor text-right">{{ $valores['valor'] }}</td>
						<td  class="afecta_directo text-right">{{ $valores['afecta_directo'] }}</td>
						<td class="text-center"><button  id="modificar_{{ $valores['id_score'] }}" class="btn btn-fidelitas" data-bs-toggle="modal" data-bs-target="#modal_tabla_valores_score" data-backdrop="static">Editar</button></td>
					</tr>
				@endforeach
				</tbody>
				<tfoot>
					<tr>
						<th class="hidden"></th>
						<th class="text-center">Grupo</th>
						<th class="text-center">Codigo</th>
						<th class="text-center">Cant desde</th>
						<th class="text-center">Cant hasta</th>
						<th class="text-center">Dias desde</th>
						<th class="text-center">Dias hasta</th>
						<th class="text-center">Valor</th>
						<th class="text-center">Afecta Score directamente</th>
						<th class="text-center">Acciones</th>
					</tr>
				</tfoot>
			</table>
			<br><br>
		@endforeach
		<!--  -->		
		<h4 class="text-center">Balances (aplica al final del score)</h4>
		<table id="tabla_valores_score_{{ $grupo }}" class="tabla_valores_score table table-bordered text-right table-hover">
			<thead>
				<tr>
					<th class="hidden"></th>
					<th class="text-center">Score desde</th>
					<th class="text-center">Score hasta</th>
					<th class="text-center">Afecta (%)</th>
					<th class="text-center">Acciones</th>
				</tr>
			</thead>
			<tbody>
				@foreach($tablaNueva as $i => $valores)
				<tr>
					<td class="id_score text-center hidden">{{ $valores->id_score }}</td>
					<td  class="desde text-right">{{ $valores->desde }}</td>
					<td  class="hasta text-right">{{ $valores->hasta }}</td>
					<td  class="valor text-right">{{ $valores->valor }}</td>
					<td class="text-center"><button  id="modificar_score_{{ $valores->id_score }}" class="btn btn-fidelitas" data-bs-toggle="modal" data-bs-target="#modal_tabla_valores_score_chico" data-backdrop="static">Editar</button></td>
				</tr>
			@endforeach
			</tbody>
			<tfoot>
				<tr>							
					<th class="hidden"></th>
					<th class="text-center">Score desde</th>
					<th class="text-center">Score hasta</th>					
					<th class="text-center">Afecta (%)</th>
					<th class="text-center">Acciones</th>
				</tr>
			</tfoot>
		</table>
		<br><br>		
		<!--  -->

		<!--  -->		
		<h4 class="text-center">Aportes como empleador (aplica al final del score)</h4>
		<table id="tabla_valores_aportes_{{ $grupo }}" class="tabla_valores_score table table-bordered text-right table-hover">
			<thead>
				<tr>
					<th class="hidden"></th>
					<th class="text-center">Item</th>
					<th class="text-center">Meses para atras</th>
					<th class="text-center">Resultado</th>
					<th class="text-center">Afecta (%)</th>
					<th class="text-center">Acciones</th>
				</tr>
			</thead>
			<tbody>
				@foreach($tablaAportes as $i => $valores)
				<tr>
					<td class="id_aportes text-center hidden">{{ $valores->id_score }}</td>
					<td class="campo text-center hidden">{{ $valores->campo }}</td>
					<td class="mes_para_atras text-center hidden">{{ $valores->mes_para_atras }}</td>
					<td class="resultado text-center" style="background-color:@if($valores->resultado=='PAGO'||$valores->resultado=='SI') #2e7d32 @endif @if($valores->resultado=='IMPAGO' || $valores->resultado=='NO' ) #A72B2A @endif  @if($valores->resultado=='PAGO PARCIAL') #FFB81C @endif">{{ $valores->resultado }}</td>
					<td class="valor_aportes text-center">{{ $valores->valor }}</td>
					<td class="text-center"><button  id="modificar_aportes_{{ $valores->id_score }}" class="btn btn-fidelitas" data-bs-toggle="modal" data-bs-target="#modal_tabla_valores_aportes_chico" data-backdrop="static">Editar</button></td>
				</tr>
			@endforeach
			</tbody>
			<tfoot>
				<tr>							
					<th class="hidden"></th>
					<th class="text-center">Item</th>
					<th class="text-center">Meses para atras</th>
					<th class="text-center">Resultado</th>
					<th class="text-center">Afecta (%)</th>
					<th class="text-center">Acciones</th>
			</tfoot>
		</table>
		<br><br>		
		<!--  -->


		<div class="separador" style="margin-top: 20px;">
			<h3 class="text-center">Indices de Combinación General de Score</h3>
				<form id="indices_combinacion">
				{{csrf_field()}}
				<table id="tabla_indices_combinacion" class="table table-bordered text-right ">
					<thead>
						<tr>
							<th>Contable</th>
							<th>Judicial</th>
							<th>Cendeu</th>
							<th>Cheques</th>
							<th>Fiscal</th>
							<th>Formal</th>
						</tr>
					</thead>
					<tbody>
						<tr>

							<td><input type="text" class="form-control" name="contable" value="{{$tabla_porcentajes_indice_combinacion_general->contable}}"></td>
							<td><input type="text" class="form-control" name="judicial" value="{{$tabla_porcentajes_indice_combinacion_general->judicial}}"></td>
							<td><input type="text" class="form-control" name="cendeu" value="{{$tabla_porcentajes_indice_combinacion_general->cendeu}}"></td>
							<td><input type="text" class="form-control" name="cheques" value="{{$tabla_porcentajes_indice_combinacion_general->cheques}}"></td>
							<td><input type="text" class="form-control" name="fiscal" value="{{$tabla_porcentajes_indice_combinacion_general->fiscal}}"></td>
							<td><input type="text" class="form-control" name="formal" value="{{$tabla_porcentajes_indice_combinacion_general->formal}}"></td>
						</tr>
						<tr>
							<td class="text-left" colspan="6"><button type="submit" class="btn btn-fidelitas">Grabar</button></td>
						</tr>
					</tbody>
				</table>
				</form>
		</div>
		<div class="separador" style="margin-top: 20px;">
				<h3 class="text-center">Porcentajes por afectación de Score</h3>
				<form id="form_porcentajes_score">
				{{csrf_field()}}
				<table id="tabla_porcentajes_score" class="table table-bordered text-right ">
					<thead>
						<tr>
							<th>Porcentaje</th>
							<th>Afecta directamente</th>
						</tr>
					</thead>
					<tbody>
						<tr>
							<td><input type="text" class="form-control" name="porcentaje_0" value="{{$tabla_porcentajes_score[0]->porcentaje}}"> </td>
							<td><input type="text" class="form-control" readonly="readonly" name="afecta_directo_0" value="{{$tabla_porcentajes_score[0]->afecta_directo}}"</td>
						</tr>
						<tr>
							<td><input type="text" class="form-control"  name="porcentaje_1" value="{{$tabla_porcentajes_score[1]->porcentaje}}"> </td>
							<td><input type="text" class="form-control" readonly="readonly" name="afecta_directo_1" value="{{$tabla_porcentajes_score[1]->afecta_directo}}"</td>
						</tr>
						<tr>
							<td class="text-left" colspan="2"><button type="submit" class="btn btn-fidelitas">Grabar</button></td>
						</tr>
					</tbody>
				</table>
				</form>
		</div>
	</div>
	<div class="modal" tabindex="-1" id="modal_tabla_valores_score" data-bs-backdrop="static">
		<div class="modal-dialog" style="max-width: 100%;" role="document">
			<div class="modal-content">
				@include('modals/modal_tabla_valores_score')
			</div>
		</div>
	</div>	
	<div class="modal" tabindex="-1" id="modal_tabla_valores_score_chico" data-bs-backdrop="static">
		<div class="modal-dialog" style="max-width: 100%;" role="document">
			<div class="modal-content">
				@include('modals/modal_tabla_valores_score_chico')
			</div>
		</div>
	</div>
	<div class="modal" tabindex="-1" id="modal_tabla_valores_aportes_chico" data-bs-backdrop="static">
		<div class="modal-dialog" style="max-width: 100%;" role="document">
			<div class="modal-content">
				@include('modals/modal_tabla_valores_aportes_chico')
			</div>
		</div>
	</div>
@endsection
@section('funcionesJS')
	<script type="text/javascript" src="{{ URL::asset('js/utilitarios/score.js') }}"> </script>	
	<script>
		$(document).ready(function(){
			crearDataTable(".tabla_valores_score");
			function crearDataTable(tabla){
				return $(tabla).DataTable( {
					"pagingType": "full_numbers",
					"ordering": true,
					"info":     true,
					"lengthMenu": [ [12, 25, 50, 100, -1], [12, 25, 50, 100, "Todos"] ],
					"language": {
					"lengthMenu": "Mostrar _MENU_ registros por página",
					"zeroRecords": "No se encontraron  resultados para ésa búsqueda",
					//"info": "Mostrando página _PAGE_ de _PAGES_",
					"info": "Mostrando  _START_  de  _END_ - <b>Total:</b> _TOTAL_ registros",
					"infoEmpty": "No hay registros disponibles",
					"infoFiltered": "(filtrados de _MAX_ total de registros)",
					"sSearch":        "Buscar",
					"oPaginate": {
						"sFirst":     "Primera",
						"sPrevious":  "Anterior",
						"sNext":      "Siguiente",
						"sLast":      "Última"
					},
					}
				});
			}
		})
	    
	</script>
@endsection