<style>
	.text-fidelitas { color: var(--bs-fidelitas); } /* azul oscuro */
	.pepheader {
		background-color: var(--bs-fidelitas);
		color: #FFFFFF;
	} 
	.pepdata {
		text-align: center;
		color: var(--bs-dark);
		font-size: 16px;
		padding-bottom: 8px;
	}
	.pepbox-neg {
		width: 100%;
		font-size: 20px;
		font-weight: bold;
		color: #FFFFFF;
		background-color: #63b68c;
		text-align: center;
		padding-top: 2px; padding-bottom: 2px;
	}
	.pepbox-rel {
		width: 100%;
		font-size: 20px;
		font-weight: bold;
		color: #FFFFFF;
		background-color: #FFB81C;
		text-align: center;
		padding-top: 2px; padding-bottom: 2px;
	}
	.pepbox-pos {
		width: 100%;
		font-size: 20px;
		font-weight: bold;
		color: #FFFFFF;
		background-color: #A72B2A;
		text-align: center;
		padding-top: 2px; padding-bottom: 2px;
	}
	.pepbox-pep {
		width: 100%;
		font-size: 20px;
		font-weight: bold;
		color: #FFFFFF;
		background-color: #FF5C1C;
		text-align: center;
		padding-top: 2px; padding-bottom: 2px;
	}
	.pepbox-so {
		width: 100%;
		font-size: 20px;
		font-weight: bold;
		color: #FFFFFF;
		background-color: #4A8AF0; 
		text-align: center;
		padding-top: 2px; padding-bottom: 2px;
	}
	.table-striped4 > tbody > tr:nth-of-type(4n+1){
		background-color:#eeeeee;
	}
	.btnaddnuevo{
		box-shadow: 3px 0px 9px 0px rgba(0,0,0,0.75);
		-webkit-box-shadow: 3px 0px 9px 0px rgba(0,0,0,0.75);
		-moz-box-shadow: 3px 0px 9px 0px rgba(0,0,0,0.75);
	}
</style>
<!-- -->
<div class="row justify-content-center my-3">
    <div class="col-xl-9 col-lg-10 col-md-11">  
        <section>
            <h3 class="text-fidelitas"><i class="bi bi-card-list"></i> Fidecheck Completo</h3>           
            <ul>
                <li>Paso 1: Hacer click en el boton "Recargar Fidecheck" para generar la tabla de fidecheck</li>               
				<li>Paso 2: Si obtuvo más de un resultado, va a aparecer un tercer botón con el icono <i class="bi bi-list-task"></i>, este boton va a tener los multiples resultados devueltos para que lo elijan. Hay que abrir todos los modales de duplicación para revisarlos sino <span class="text-danger fw-bold">no se permite finalizar la tarea </span> </li>
				<li>Paso 3: Luego, seleccione y guarde según corresponda. </li>
		 	</ul>
        </section>
    </div>
</div>
<hr>
<div class="row justify-content-start seccion_recarga_fidecheck" style="margin-left:4%;">
	<div class="col-xl-3 text-center">
		<button type="button" class="btn btn-primary recarga_fide">
			<i class="bi bi-arrow-clockwise"></i> <b>Recarga-Fidecheck</b>
		</button>
		<div class="spinner-border d-none" id="load_fide_auto" role="status" style="margin-left:10%;">
		</div>
	</div>
</div>


@if (!empty($socios) || !empty($relac) || !empty($direct) || !empty($propio))
<div class="row" >
	<div class="col-md-10 col-md-offset-1" style="margin-left:10%;">
        <div class="row g-3 align-items-center">
            <div class="col-auto">
                <label for="abrir_todos" class="col-form-label"><b>Abrir todos:</b></label>
            </div>
            <div class="col-auto">
                <div class="fcaretMasive" style="cursor:pointer;" id="abrir_todos">  
                    <svg height="20" width="20"><circle id="abre_certificados" cx="10" cy="10" r="9" stroke="black" fill="rgb(99, 182, 140)"  stroke-width="0" /></svg>
                    <i class="fa fa-caret-right text-fidelitas" id="caretP1"></i>
                </div>
            </div>
        </div>
		<div id="ocultar_tablas">
			<h3>@traducir('Reputation Risk','Reputation Risk')</h3>
			@if (!empty($propio))
				<div class="row">
					<div class="col-md-8 h4">
						&nbsp;
					</div>
					<div class="col-md-4 text-right fcaret" id="collapseP" data-target="#pepP{{$propio->tax_id}}" data-caret="#caretP{{$propio->tax_id}}" style="cursor:pointer;">
						@traducir('ver certificado', 'Ver certificado Propio')
						<i class="fa fa-caret-right text-fidelitas" id="caretP{{$propio->tax_id}}"></i>
					</div>
				</div>
				<table 
					class="table table-condensed table-striped4 table-hover" 
					style="box-shadow: 3px 0px 9px 0px rgba(0,0,0,0.75);-webkit-box-shadow: 3px 0px 9px 0px rgba(0,0,0,0.75);-moz-box-shadow: 3px 0px 9px 0px rgba(0,0,0,0.75);">
					<thead class="table-header-fidelitas">
						<tr class="pepheader">
							<th class="text-center">@traducir('nombre', 'Nombre y apellido') / @traducir('razon social', 'Razón social')</th>
							<th class="text-center">@traducir('tax id', 'Tax ID')</th>
							<th class="text-right">@traducir('estado', 'Estado')&nbsp;</th>
							<th class="text-center">@traducir('acción','acción')</th>
						</tr>
					</thead>
					<tbody>
						<tr style="border: 0;">
							<td>{{$propio->nombre}}</td>
							<td class="text-center">{{$propio->tax_id}}</td>
							<td class="text-right">
								<div class="fcaret" id="collapseP{{$propio->tax_id}}" data-target="#pepP{{$propio->tax_id}}" data-caret="#caretP{{$propio->tax_id}}" style="cursor:pointer;">  
									<svg height="20" width="20"><circle cx="10" cy="10" r="9" stroke="black" stroke-width="0" @if ($propio->fidecheck == 'N'  /*|| $propio->fidecheck == 'S'*/) fill="#63b68c" @elseif ($propio->fidecheck == 'S') fill="#4A8AF0" @elseif ($propio->fidecheck == 'E') fill="#FF5C1C" @elseif ($propio->fidecheck == 'R') fill="#FFB81C" @elseif ($propio->fidecheck == 'P') fill="#A72B2A" @endif /></svg>
									<i class="fa fa-caret-right text-fidelitas" id="caretP1"></i>
								</div>
							</td>	

							<td class="text-center">
								<button type="button" class="btn btn-success btnedit_soc " 
									data-bs-target="#modalFidecheck_nuevo" 
									data-id="{{$propio->id_fidecheck}}" 
									data-seccion="{{$propio->nombre_seccion}}" 
									data-contraparte="{{$contrap->contraparte}}">
									<i class="bi bi-pencil-square"></i>
								</button>
								<button type="button" class="btn btn-success btndelete_soc" 
									data-id="{{$propio->id_fidecheck}}" 
									data-seccion="{{$propio->nombre_seccion}}" 
									onclick="eliminar($(this))">
									<i class="bi bi-trash"></i>
								</button>
								@if(!empty($datos_finales_array))
										@foreach($datos_finales_array as $cuit => $registros)
											@php
												[$tax_id, $seccion] = explode('-', $cuit);
											@endphp
												@if($tax_id == $propio->tax_id)  <!-- Condición para mostrar el botón si el tax_id coincide -->
													<div class="text-center botonesModalFide">
														<button type="button" class="btn btn-primary abrirmodalfidecheck" 
															id="boton-fidecheck-multiple-{{ trim($tax_id) }}-{{ $propio->seccion }}"
															data-bs-target="#modal-{{ trim($tax_id) }}-{{ $propio->seccion }}"
															value="{{ trim($tax_id) }}-{{ $propio->seccion }}"
															style="margin-top:3px;"
															data-revision="0">
															<i class="bi bi-list-task"></i>
														</button>
													</div>
													@break
												@endif
										@endforeach
								@endif
							</td>
						</tr>
						<tr style="border: 0;">
							<td colspan="4" style="padding: 0px;">
								<div id="pepP{{$propio->tax_id}}" style="display: none;">
									<div style="width:100%; border: 10px #0f335a solid; padding: 4px 4px 4px 4px; ">
										<div style="width:100%; border: 4px #0f335a solid; padding: 10px 10px 10px 10px; ">
											<div class="text-center h4">@traducir('criteria', 'SEARCH CRITERIA')</div>
											<div class="pepdata ">@traducir('datos consultados', 'Datos consultados'): {{$propio->nombre}} @if (NULL != $propio->tax_id) ({{$propio->tax_id}}) @endif
												@if (NULL != $propio->fecha) <br>@traducir('Fecha', 'Fecha'): {{$propio->fecha}} @endif
											</div>
											@if (null != $propio->detalle) <div class="pepdata">{!! $propio->detalle !!}</div> @endif
											@if ($propio->fidecheck == 'N')<div class="pepbox-neg">@traducir('negative', 'Negative')</div>
											@elseif ($propio->fidecheck == 'R')<div class="pepbox-rel">@traducir('related', 'Related')</div>
											@elseif ($propio->fidecheck == 'E')<div class="pepbox-pep">@traducir('PEP', 'PEP')</div>
											@elseif ($propio->fidecheck == 'S')<div class="pepbox-so">@traducir('Sujeto obligado', 'Sujeto obligado')</div>
											@elseif ($propio->fidecheck == 'P')<div class="pepbox-pos">@traducir('positive', 'Positive')</div>
											@endif
											<div class="text-center">Sources checked: List of worldwide politicians and government controlled entities (also known as PEPs, for politically exposed persons); profiles
											of persons who hold political office, their immediate family members, close associates, and companies under their control; Crime - Global Enforcement List, Profiles of entities
											listed worldwide; Reputation - Global Foreign Officials List, SDN and Financial Intelligence Units, following the FATF (Financial Action Task Force) recommendations.</div>
										</div>
									</div>
								</div>
							</td>
						</tr>
					</tbody>
					<tfoot>
					</tfoot>
				</table>		

			@endif
			@if (!empty($socios))
				<div class="row">
					<div class="col-md-8 h4">
						@traducir('socios', 'Socios') / @traducir('accionistas', 'Accionistas')
					</div>
					<div class="col-md-4 text-right fcaret" id="collapseS" data-target="#pepS" data-caret="#caretS" style="cursor:pointer;">
						@traducir('ver certificados todos', 'Ver certificados de todos los Socios / Accionistas')
						<i class="fa fa-caret-right text-fidelitas" id="caretS"></i>
					</div>
				</div>
				<div id="pepS" style="display: none;">
				@foreach ($socios as $socio)
					<div style="width:100%; border: 10px #0f335a solid; padding: 4px 4px 4px 4px; ">
						<div style="width:100%; border: 4px #0f335a solid; padding: 10px 10px 10px 10px;">
							<div class="text-center h4">@traducir('criteria', 'SEARCH CRITERIA')</div>
							<div class="pepdata ">@traducir('datos consultados', 'Datos consultados'): {{$socio->nombre}} @if (NULL != $socio->tax_id) ({{$socio->tax_id}}) @endif
								@if (NULL != $socio->fecha) <br>@traducir('Fecha', 'Fecha'): {{$socio->fecha}} @endif
							</div>
							@if (null != $socio->detalle) <div class="pepdata ">{!! $socio->detalle !!}</div> @endif
							@if ($socio->fidecheck == 'N')<div class="pepbox-neg">@traducir('negative', 'Negative')</div>
							@elseif ($socio->fidecheck == 'R')<div class="pepbox-rel">@traducir('related', 'Related')</div>
							@elseif ($socio->fidecheck == 'E')<div class="pepbox-pep">@traducir('PEP', 'PEP')</div>
							@elseif ($socio->fidecheck == 'S')<div class="pepbox-so">@traducir('Sujeto obligado', 'Sujeto obligado')</div>
							@elseif ($socio->fidecheck == 'P')<div class="pepbox-pos">@traducir('positive', 'Positive')</div>
							@endif
							<div class="text-center">Sources checked: List of worldwide politicians and government controlled entities (also known as PEPs, for politically exposed persons); profiles
							of persons who hold political office, their immediate family members, close associates, and companies under their control; Crime - Global Enforcement List, Profiles of entities
							listed worldwide; Reputation - Global Foreign Officials List, SDN and Financial Intelligence Units, following the FATF (Financial Action Task Force) recommendations.</div>
						</div>
					</div>
					<br />
				@endforeach
				</div>
				<div class="float-end">
					<button type="button" class="btn btn-fidelitas btnaddnuevo btn-sm" 
							data-bs-target="#modalFidecheck_nuevo" 
							data-seccion="S" 
							data-contraparte="{{$contrap->contraparte}}" 
							style="margin-bottom:5px;">
							<i class="bi bi-plus-lg"></i> Agregar
					</button>	
				</div>
				<table 
					class="table table-condensed table-striped4 table-hover" 
					style="box-shadow: 3px 0px 9px 0px rgba(0,0,0,0.75);-webkit-box-shadow: 3px 0px 9px 0px rgba(0,0,0,0.75);-moz-box-shadow: 3px 0px 9px 0px rgba(0,0,0,0.75);">
					<thead class="table-header-fidelitas">
						<tr class="pepheader">
							<th class="text-center">@traducir('nombre', 'Nombre y apellido') / @traducir('razon social', 'Razón social')</th>
							<th class="text-center">@traducir('nacionalidad', 'Nacionalidad o país de origen')</th>
							<th class="text-center">@traducir('tax id', 'Tax ID')</th>
							<th class="text-center">%</th>
							<th class="text-right">@traducir('estado', 'Estado')&nbsp;</th>
							<th class="text-right">@traducir('acción','acción')</th>
						</tr>
					</thead>
					<tbody>
						@foreach ($socios as $socio)
							<tr style="border: 0;">
								<td>{{$socio->nombre}}</td>
								<td class="text-center">{{$socio->nacionalidad}}</td>
								<td class="text-center">{{$socio->tax_id}}</td>
								<td class="text-right">{{$socio->porcentaje}}&nbsp;&nbsp;&nbsp;</td>
								<td class="text-right">
									<div class="fcaret" id="collapseS{{$socio->tax_id}}" data-target="#pepS{{$socio->tax_id}}" data-caret="#caretS{{$socio->tax_id}}" @if ($socio->fidecheck == 'N')  style="cursor:pointer;" @else disabled  @endif>  
									<svg height="20" width="20"><circle cx="10" cy="10" r="9" stroke="black" stroke-width="0" @if ($socio->fidecheck == 'N' /*|| $socio->fidecheck == 'S'*/) fill="#63b68c" @elseif ($socio->fidecheck == 'S') fill="#4A8AF0" @elseif ($socio->fidecheck == 'E') fill="#FF5C1C" @elseif ($socio->fidecheck == 'R' || $socio->fidecheck == 'N') fill="#FFB81C" @elseif ($socio->fidecheck == 'P') fill="#A72B2A" @endif /></svg>
									<i class="fa fa-caret-right text-fidelitas" id="caretP1"></i>
									</div>
								</td>
								<td class="text-right">
									<button type="button" class="btn btn-success btnedit_soc" 
										data-bs-target="#modalFidecheck_nuevo" 
										data-id="{{$socio->id_fidecheck}}" 
										data-seccion="{{$socio->nombre_seccion}}" 
										data-contraparte="{{$contrap->contraparte}}">
										<i class="bi bi-pencil-square"></i>
									</button>
									<button type="button" class="btn btn-success btndelete_soc" 
										data-id="{{$socio->id_fidecheck}}" 
										data-seccion="{{$socio->nombre_seccion}}" 
										onclick="eliminar($(this))">
										<i class="bi bi-trash"></i>
									</button>
									@if(!empty($datos_finales_array))
										@foreach($datos_finales_array as $cuit => $registros)
											@php
												[$tax_id, $seccion] = explode('-', $cuit);
											@endphp
												@if($tax_id == $socio->tax_id)  <!-- Condición para mostrar el botón si el tax_id coincide -->
													<div class="text-center botonesModalFide">
														<button type="button" class="btn btn-primary abrirmodalfidecheck" 
															id="boton-fidecheck-multiple-{{ trim($tax_id) }}-{{ $socio->seccion }}"
															data-bs-target="#modal-{{ trim($tax_id) }}-{{ $socio->seccion }}"
															value="{{ trim($tax_id) }}-{{ $socio->seccion }}"
															style="margin-top:3px;"
															data-revision="0">
															<i class="bi bi-list-task"></i>
														</button>
													</div>
													@break
												@endif
										@endforeach
									@endif
								</td>
							</tr>
							<tr style="border: 0;">
								<td colspan="6" style="padding: 0px;">
									<div id="pepS{{$socio->tax_id}}" style="display: none;">
										<div style="width:100%; border: 10px #0f335a solid; padding: 4px 4px 4px 4px; ">
											<div style="width:100%; border: 4px #0f335a solid; padding: 10px 10px 10px 10px; ">
												<div class="text-center h4">@traducir('criteria', 'SEARCH CRITERIA')</div>
												<div class="pepdata ">Datos consultados: {{$socio->nombre}} @if (NULL != $socio->tax_id) ({{$socio->tax_id}}) @endif
													@if (NULL != $socio->fecha) <br>@traducir('Fecha', 'Fecha'): {{$socio->fecha}} @endif
												</div>
													@if (null != $socio->detalle) <div class="pepdata">{!! $socio->detalle !!}</div> @endif
													@if ($socio->fidecheck == 'N')<div class="pepbox-neg">@traducir('negative', 'Negative')</div>
													@elseif ($socio->fidecheck == 'R')<div class="pepbox-rel">@traducir('related', 'Related')</div>
													@elseif ($socio->fidecheck == 'E')<div class="pepbox-pep">@traducir('PEP', 'PEP')</div>
													@elseif ($socio->fidecheck == 'S')<div class="pepbox-so">@traducir('Sujeto obligado', 'Sujeto obligado')</div>
													@elseif ($socio->fidecheck == 'P')<div class="pepbox-pos">@traducir('positive', 'Positive')</div>
													@endif
												<div class="text-center">Sources checked: List of worldwide politicians and government controlled entities (also known as PEPs, for politically exposed persons); profiles
													of persons who hold political office, their immediate family members, close associates, and companies under their control; Crime - Global Enforcement List, Profiles of entities
													listed worldwide; Reputation - Global Foreign Officials List, SDN and Financial Intelligence Units, following the FATF (Financial Action Task Force) recommendations.
												</div>
											</div>
										</div>
									</div>
								</td>
							</tr>
						@endforeach
					</tbody>
					<tfoot></tfoot>
				</table>
			@endif
			@if (!empty($relac))
				<div class="row">
					<div class="col-md-8 h4">
						@traducir('vinculaciones', 'Vinculaciones') / @traducir('empresas relacionadas', 'Empresas relacionadas')
					</div>
					<div class="col-md-4 text-right fcaret" id="collapseR" data-target="#pepR" data-caret="#caretR" style="cursor:pointer;">
						@traducir('ver certificados vinculaciones', 'Ver certificados de todas las Vinculaciones / Empresas relacionadas')
						<i class="fa fa-caret-right text-fidelitas" id="caretR"></i>
					</div>
				</div>
				<div id="pepR" style="display: none;">
				@foreach ($relac as $relacionada)
					<div style="width:100%; border: 10px #0f335a solid; padding: 4px 4px 4px 4px; ">
						<div style="width:100%; border: 4px #0f335a solid; padding: 10px 10px 10px 10px; ">
							<div class="text-center h4">@traducir('criteria', 'SEARCH CRITERIA')</div>
							<div class="pepdata ">@traducir('datos consultados', 'Datos consultados'): {{$relacionada->nombre}} @if (NULL != $relacionada->tax_id) ({{$relacionada->tax_id}}) @endif
								@if (NULL != $relacionada->fecha) <br>@traducir('Fecha', 'Fecha'): {{$relacionada->fecha}} @endif
							</div>
							@if (null != $relacionada->detalle) <div class="pepdata">{!! $relacionada->detalle !!}</div> @endif
							@if ($relacionada->fidecheck == 'N')<div class="pepbox-neg">@traducir('negative', 'Negative')</div>
							@elseif ($relacionada->fidecheck == 'R')<div class="pepbox-rel">@traducir('related', 'Related')</div>
							@elseif ($relacionada->fidecheck == 'E')<div class="pepbox-pep">@traducir('PEP', 'PEP')</div>
							@elseif ($relacionada->fidecheck == 'S')<div class="pepbox-so">@traducir('Sujeto obligado', 'Sujeto obligado')</div>
							@elseif ($relacionada->fidecheck == 'P')<div class="pepbox-pos">@traducir('positive', 'Positive')</div>
							@endif
							<div class="text-center">Sources checked: List of worldwide politicians and government controlled entities (also known as PEPs, for politically exposed persons); profiles
								of persons who hold political office, their immediate family members, close associates, and companies under their control; Crime - Global Enforcement List, Profiles of entities
								listed worldwide; Reputation - Global Foreign Officials List, SDN and Financial Intelligence Units, following the FATF (Financial Action Task Force) recommendations.
							</div>
						</div>
					</div>
					<br />
				@endforeach
				</div>
				<div class="float-end">
					<button type="button" class="btn btn-fidelitas btnaddnuevo btn-sm" 
							data-bs-target="#modalFidecheck_nuevo" 
							data-seccion="R" 
							data-contraparte="{{$contrap->contraparte}}" 
							style="margin-bottom:5px">
							<i class="bi bi-plus-lg"></i> Agregar
					</button>
				</div>
				<table 
				class="table table-condensed table-striped4 table-hover"
				style="box-shadow: 3px 0px 9px 0px rgba(0,0,0,0.75);-webkit-box-shadow: 3px 0px 9px 0px rgba(0,0,0,0.75);-moz-box-shadow: 3px 0px 9px 0px rgba(0,0,0,0.75);">
					<thead class="table-header-fidelitas">
						<tr class="pepheader">
							<th class="text-center">N&deg;</th>
							<th class="text-center">@traducir('razon social', 'Razón social')</th>
							<th class="text-center">@traducir('nacionalidad', 'Nacionalidad o país de origen')</th>
							<th class="text-center">@traducir('tax id', 'Tax ID')</th>
							<th class="text-center">@traducir('tipo relacion', 'Tipo de relación')</th>
							<th class="text-right">@traducir('estado', 'Estado')&nbsp;</th>
							<th class="text-right">@traducir('acción', 'acción')&nbsp;</th>
						</tr>
					</thead>
					<tbody>
						@foreach ($relac as $relacionada)
							<tr style="border: 0;">
								<td class="text-center">{{$relacionada->orden}}</td>
								<td>{{$relacionada->nombre}}</td>
								<td class="text-center">{{$relacionada->nacionalidad}}</td>
								<td class="text-center">{{$relacionada->tax_id}}</td>
								<td class="text-center">{{$relacionada->tipo_relacion}}</td>
								<td class="text-right">
									<div class="fcaret" id="collapseR{{$relacionada->tax_id}}" data-target="#pepR{{$relacionada->tax_id}}" data-caret="#caretR{{$relacionada->tax_id}}" style="cursor:pointer;">  
									<svg height="20" width="20"><circle cx="10" cy="10" r="9" stroke="black" stroke-width="0" @if ($relacionada->fidecheck == 'N'/* || $relacionada->fidecheck == 'S'*/) fill="#63b68c" @elseif ($relacionada->fidecheck == 'S') fill="#4A8AF0"  @elseif ($relacionada->fidecheck == 'E') fill="#FF5C1C" @elseif ($relacionada->fidecheck == 'R') fill="#FFB81C" @elseif ($relacionada->fidecheck == 'P') fill="#A72B2A" @endif /></svg>
									<i class="fa fa-caret-right text-fidelitas" id="caretP1"></i>
									</div>
								</td>
								<td>
									<button type="button" class="btn btn-success btnedit_vin" 
										data-bs-target="#modalFidecheck_nuevo" 
										data-id="{{$relacionada->id_fidecheck}}" 
										data-seccion="{{$relacionada->nombre_seccion}}" 
										data-contraparte="{{$contrap->contraparte}}">
										<i class="bi bi-pencil-square"></i>
									</button>
									<button type="button" class="btn btn-success btndelete_vin" 
										data-id="{{$relacionada->id_fidecheck}}" 
										data-seccion="{{$relacionada->nombre_seccion}}" 
										onclick="eliminar($(this))">
										<i class="bi bi-trash"></i>
									</button>
									@if(!empty($datos_finales_array))
										@foreach($datos_finales_array as $cuit => $registros)
											@php
												[$tax_id, $seccion] = explode('-', $cuit);
											@endphp
												@if($tax_id== $relacionada->tax_id)  
													<div class="text-center botonesModalFide">
														<button type="button" class="btn btn-primary abrirmodalfidecheck" 
															id="boton-fidecheck-multiple-{{ trim($tax_id) }}-{{ $relacionada->seccion }}"
															data-bs-target="#modal-{{ trim($tax_id) }}-{{ $relacionada->seccion }}"
															value="{{ trim($tax_id) }}-{{ $relacionada->seccion }}"
															style="margin-top:3px;"
															data-revision="0">
															<i class="bi bi-list-task"></i>
														</button>
													</div>
													@break
												@endif
										@endforeach
									@endif
								</td>
							</tr>
							<tr style="border: 0;">
								<td colspan="7" style="padding: 0px;">
									<div id="pepR{{$relacionada->tax_id}}" style="display: none;">
										<div style="width:100%; border: 10px #0f335a solid; padding: 4px 4px 4px 4px; ">
											<div style="width:100%; border: 4px #0f335a solid; padding: 10px 10px 10px 10px; ">
												<div class="text-center h4">@traducir('criteria', 'SEARCH CRITERIA')</div>
												<div class="pepdata ">@traducir('datos consultados', 'Datos consultados'): {{$relacionada->nombre}} @if (NULL != $relacionada->tax_id) ({{$relacionada->tax_id}}) @endif
													@if (NULL != $relacionada->fecha) <br>@traducir('Fecha', 'Fecha'): {{$relacionada->fecha}} @endif
												</div>
												@if (null != $relacionada->detalle) <div class="pepdata">{!! $relacionada->detalle !!}</div> @endif
												@if ($relacionada->fidecheck == 'N')<div class="pepbox-neg">@traducir('negative', 'Negative')</div>
												@elseif ($relacionada->fidecheck == 'R')<div class="pepbox-rel">@traducir('related', 'Related')</div>
												@elseif ($relacionada->fidecheck == 'E')<div class="pepbox-pep">@traducir('PEP', 'PEP')</div>
												@elseif ($relacionada->fidecheck == 'S')<div class="pepbox-so">@traducir('Sujeto obligado', 'Sujeto obligado')</div>
												@elseif ($relacionada->fidecheck == 'P')<div class="pepbox-pos">@traducir('positive', 'Positive')</div>
												@endif

												<div class="text-center">Sources checked: List of worldwide politicians and government controlled entities (also known as PEPs, for politically exposed persons); profiles
													of persons who hold political office, their immediate family members, close associates, and companies under their control; Crime - Global Enforcement List, Profiles of entities
													listed worldwide; Reputation - Global Foreign Officials List, SDN and Financial Intelligence Units, following the FATF (Financial Action Task Force) recommendations.
												</div>

											</div>
										</div>
									</div>
								</td>
							</tr>
			
						@endforeach
					</tbody>
					<tfoot>
					</tfoot>
				</table>
			@endif
			@if (!empty($direct))
				<div class="row">
					<div class="col-md-8 h4">
						@traducir('directivos', 'Directivos')
					</div>
					<div class="col-md-4 text-right fcaret" id="collapseD" data-target="#pepD" data-caret="#caretD" style="cursor:pointer;">
						@traducir('ver certificados directivos', 'Ver certificados de todos los Directivos')
						<i class="fa fa-caret-right text-fidelitas" id="caretD"></i>
					</div>
				</div>
				<div id="pepD" style="display: none;">
				@foreach ($direct as $directivo)
					<div style="width:100%; border: 10px #0f335a solid; padding: 4px 4px 4px 4px; ">
						<div style="width:100%; border: 4px #0f335a solid; padding: 10px 10px 10px 10px; ">
							<div class="text-center h4">@traducir('criteria', 'SEARCH CRITERIA')</div>
							<div class="pepdata ">@traducir('datos consultados', 'Datos consultados'): {{$directivo->nombre}} @if (NULL != $directivo->tax_id) ({{$directivo->tax_id}}) @endif
								@if (NULL != $directivo->fecha) <br>@traducir('Fecha', 'Fecha'): {{$directivo->fecha}} @endif
							</div>
							@if (null != $directivo->detalle) <div class="pepdata">{!! $directivo->detalle !!}</div> @endif
							@if ($directivo->fidecheck == 'N')<div class="pepbox-neg">@traducir('negative', 'Negative')</div>
							@elseif ($directivo->fidecheck == 'R')<div class="pepbox-rel">@traducir('related', 'Related')</div>
							@elseif ($directivo->fidecheck == 'E')<div class="pepbox-pep">@traducir('PEP', 'PEP')</div>
							@elseif ($directivo->fidecheck == 'S')<div class="pepbox-so">@traducir('Sujeto obligado', 'Sujeto obligado')</div>
							@elseif ($directivo->fidecheck == 'P')<div class="pepbox-pos">@traducir('positive', 'Positive')</div>
							@endif
							<div class="text-center">Sources checked: List of worldwide politicians and government controlled entities (also known as PEPs, for politically exposed persons); profiles
							of persons who hold political office, their immediate family members, close associates, and companies under their control; Crime - Global Enforcement List, Profiles of entities
							listed worldwide; Reputation - Global Foreign Officials List, SDN and Financial Intelligence Units, following the FATF (Financial Action Task Force) recommendations.</div>
						</div>
					</div>
					<br />
				@endforeach
				</div>
				<div class="float-end">
					<button type="button" class="btn btn-fidelitas btnaddnuevo btn-sm" 
							data-bs-target="#modalFidecheck_nuevo" 
							data-seccion="D" 
							data-contraparte="{{$contrap->contraparte}}" 
							style="margin-bottom:5px">
							<i class="bi bi-plus-lg"></i> Agregar
					</button>
				</div>
				<table class="table table-condensed table-striped4 table-hover" style="border:0;box-shadow: 3px 0px 9px 0px rgba(0,0,0,0.75);-webkit-box-shadow: 3px 0px 9px 0px rgba(0,0,0,0.75);-moz-box-shadow: 3px 0px 9px 0px rgba(0,0,0,0.75);">
					<thead class="table-header-fidelitas">
						<tr class="pepheader">
							<th class="text-center">@traducir('nombre', 'Nombre y apellido')</th>
							<th class="text-center">@traducir('nacionalidad', 'Nacionalidad o país de origen')</th>
							<th class="text-center">@traducir('tax id', 'Tax ID')</th>
							<th class="text-center">@traducir('cargo', 'Cargo')</th>
							<th class="text-right">@traducir('estado', 'Estado')&nbsp;</th>
							<th class="text-right">@traducir('acción', 'acción')</th>
						</tr>
					</thead>
					<tbody>
						@foreach ($direct as $directivo)
							<tr style="border: 0;">
								<td>{{$directivo->nombre}}</td>
								<td class="text-center">{{$directivo->nacionalidad}}</td>
								<td class="text-center">{{$directivo->tax_id}}</td>
								<td class="text-center">{{$directivo->cargo}}</td>
								<td class="text-right">
									<div class="fcaret" id="collapseD{{$directivo->tax_id}}" data-target="#pepD{{$directivo->tax_id}}" data-caret="#caretD{{$directivo->tax_id}}" @if($directivo->fidecheck != 'N' ) pointer-events: none; @else style="cursor:pointer;" @endif >  
										<svg height="20" width="20"><circle cx="10" cy="10" r="9" stroke="black" stroke-width="0" @if ($directivo->fidecheck == 'N' /* || $directivo->fidecheck == 'S'*/) fill="#63b68c" @elseif ($directivo->fidecheck == 'S') fill="#4A8AF0"  @elseif ($directivo->fidecheck == 'E') fill="#FF5C1C" @elseif ($directivo->fidecheck == 'R') fill="#FFB81C" @elseif ($directivo->fidecheck == 'P') fill="#A72B2A" @endif /></svg>
										<i class="fa fa-caret-right text-fidelitas" id="caretD{{$directivo->tax_id}}"></i>
									</div>
								</td>
								<td class="text-center">
									<button class="btn btn-success btnedit_nuevo" data-bs-target="#modalFidecheck_nuevo"  data-id="{{$directivo->id_fidecheck}}" data-seccion="{{$directivo->nombre_seccion}}" data-contraparte="{{$contrap->contraparte}}">
										<i class="bi bi-pencil-square"></i>
									</button>
									<button type="button" class="btn btn-success btndelete" data-id="{{$directivo->id_fidecheck}}" data-seccion="{{$directivo->nombre_seccion}}" onclick="eliminar($(this))"><i class="bi bi-trash"></i></button>
									@if(!empty($datos_finales_array))
										@foreach($datos_finales_array as $cuit => $registros)
											@php
												[$tax_id, $seccion] = explode('-', $cuit);
											@endphp
												@if($tax_id == $directivo->tax_id)  <!-- Condición para mostrar el botón si el tax_id coincide -->
													<div class="text-center botonesModalFide">
														<button type="button" class="btn btn-primary abrirmodalfidecheck" 
															id="boton-fidecheck-multiple-{{ trim($tax_id) }}-{{ $directivo->seccion }}"
															data-bs-target="#modal-{{ trim($tax_id) }}-{{ $directivo->seccion }}"
															value="{{ trim($tax_id) }}-{{ $directivo->seccion }}"
															style="margin-top:3px;"
															data-revision="0">
															<i class="bi bi-list-task"></i>
														</button>
													</div>
													@break
												@endif
										@endforeach
									@endif
								</td>
							</tr>
							<tr style="border: 0;">
								<td colspan="6" style="padding: 0px;">
									<div id="pepD{{$directivo->tax_id}}" style="display: none;">
										<div style="width:100%; border: 10px #0f335a solid; padding: 4px 4px 4px 4px;">
											<div style="width:100%; border: 4px #0f335a solid; padding: 10px 10px 10px 10px; ">
												<div class="text-center h4">@traducir('criteria', 'SEARCH CRITERIA')</div>
												<div class="pepdata ">@traducir('datos consultados', 'Datos consultados'): {{$directivo->nombre}} @if (NULL != $directivo->tax_id) ({{$directivo->tax_id}}) @endif
													@if (NULL != $directivo->fecha) <br>@traducir('Fecha', 'Fecha'): {{$directivo->fecha}} @endif
												</div>
												@if (null != $directivo->detalle) <div class="pepdata">{!! $directivo->detalle !!}</div> @endif
												@if ($directivo->fidecheck == 'N')<div class="pepbox-neg">@traducir('negative', 'Negative')</div>
												@elseif ($directivo->fidecheck == 'R')<div class="pepbox-rel">@traducir('related', 'Related')</div>
												@elseif ($directivo->fidecheck == 'E')<div class="pepbox-pep">@traducir('PEP', 'PEP')</div>
												@elseif ($directivo->fidecheck == 'S')<div class="pepbox-so">@traducir('Sujeto obligado', 'Sujeto obligado')</div>
												@elseif ($directivo->fidecheck == 'P')<div class="pepbox-pos">@traducir('positive', 'Positive')</div>
												@endif
												<div class="text-center">Sources checked: List of worldwide politicians and government controlled entities (also known as PEPs, for politically exposed persons); profiles
													of persons who hold political office, their immediate family members, close associates, and companies under their control; Crime - Global Enforcement List, Profiles of entities
													listed worldwide; Reputation - Global Foreign Officials List, SDN and Financial Intelligence Units, following the FATF (Financial Action Task Force) recommendations.
												</div>
											</div>
										</div>
									</div>
								</td>
							</tr>
						@endforeach
					</tbody>
					<tfoot>
					</tfoot>
				</table>
			@endif
			<div id="modalFidecheck_nuevo" class="modal fade show" aria-modal="true" role="dialog" >
				<div class="modal-dialog modal-xl">
					<div class="modal-content">
						<div class="modal-header">
							<h3 class="modal-title" id="fidecheck_title"></h3>
							<h4 class="modal-title" id="fidecheck_title2"></h4>
							<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
						</div>
						<div class="modal-body" id="fidecheck_body"></div>
					</div>
				</div>
			</div>
		</div>
	</div>
		@if(!empty($datos_finales_array))
			@foreach($datos_finales_array as $cuit => $registros)
			@php
			 [$tax_id, $seccion] = explode('-', $cuit);
			@endphp
				<!-- Modal Dinámico -->
				<div class="modal fade" id="modal-{{ trim($tax_id) }}-{{ $seccion }}" tabindex="-1" aria-labelledby="modalLabel-{{ $cuit }}" aria-hidden="true">
					<div class="modal-dialog modal-xl" style="max-width:1550px;">
						<div class="modal-content">
							<div class="modal-header">
								<h5 class="modal-title" id="modalLabel-{{ $tax_id }}">Detalles de {{ $registros[0]['nombre'] ?? 'Sin Nombre' }} - {{ $tax_id }}</h5>
								<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
							</div>
							<div class="modal-body">
								<table class="table table-striped">
									<thead>
										<tr>
											<th>Seleccion</th>
											<th class='d-none'>ID</th>
											<th>Seccion</th>
											<th class="">Detalle</th>
											<th>Fidecheck</th>
											<th>Fuente</th>
											<th>Tipo Fuente</th>
											<th>Nombre Encontrado</th>
											<th>Documento Encontrado</th>
											<th>Residencia</th>
											<th>Descripcion Pais</th>
											<th>Fecha Novedad</th>
											<th>Porcentaje Similitud</th>
											<th>Cargo</th>
											<th>Institucion</th>
											<th>Domicilio </th>
											<th>Relacion</th>
											<th>URL</th>
											
										</tr>
									</thead>
									<tbody>
										@foreach($registros as $dato)
											<tr>
												<td>
													<input type="radio" name="seleccion[]" value="{{ is_array($dato) ? $dato['id'] : $dato->id }}">
												</td>
												<td class='d-none'>{{ $dato['id'] ?? '-' }}</td>
												<td>{{ $dato['seccion'] ?? '-' }}</td>
												<td class="fs-7 w-75">{{ $dato['detalle'] ?? '-' }}</td>
												<td>{{ $dato['fidecheck'] ?? '-' }}</td>
												<td>{{ $dato['fuente'] ?? '-' }}</td>
												<td>{{ $dato['tipo_fuente'] ?? '-' }}</td>
												<td>{{ $dato['nombre'] ?? '-' }}</td>
												<td>{{ $dato['documento_e'] ?? '-' }}</td>
												<td>{{ $dato['residencia'] ?? '-' }}</td>
												<td>{{ $dato['descripcion_p'] ?? '-' }}</td>
												<td>{{ $dato['fecha_novedad'] ?? '-' }}</td>
												<td>{{ $dato['score'] ?? '-' }}</td>
												<td>{{ $dato['cargo'] ?? '-' }}</td>
												<td>{{ $dato['institucion'] ?? '-' }}</td>
												<td>{{ $dato['domicilio'] ?? '-' }}</td>
												<td>{{ $dato['relacion'] ?? '-' }}</td>
												<td><a href="{{ $dato['url'] ?? '-' }}" target="_blank">ir a info.pld.global</a></td>
											</tr>
										@endforeach
									</tbody>
								</table>
								<div id="message" class="text-center" style="display: none; "></div>
							</div>
							<div class="modal-footer  justify-content-center">
								<button type="button" class="btn btn-fidelitas btn-secundary guardarSeleccionNegativa" data-cuit="{{ trim($tax_id) }}" data-seccion="{{ $seccion }}" data-contraparte="{{ $registros[0]['id'] }}">Guardar Fidecheck Como Negativo</button>
								<button type="button" class="btn btn-secondary cerrar_modalfide" data-bs-dismiss="modal" value="{{ trim($cuit) }}" >Cerrar</button>
								<button type="button" class="btn btn-primary guardarSeleccion" data-cuit="{{ trim($tax_id) }}" data-seccion="{{ $seccion }}" data-contraparte="{{ $registros[0]['id'] }}">Guardar selección</button>
							</div>
						</div>
					</div>
				</div>
			@endforeach
		@endif
	@else
		<div class="col-md-12 font15 text-center">-- @traducir('nodata', 'No se encuentra información') --</div>
	@endif
</div>	
<form id="frmDelete_nuevo" method="post" action="/blue/servicios-contratados-contrapartes/fidecheck/acciones">
	{{csrf_field()}}	
	<input type="hidden" name="id_fidecheck" value="" id="_fidecheck2">
	<input type="hidden" name="accion" value="borrar">
</form>
<!-- -->
<input type="hidden" name="_token" value="{{csrf_token()}}" id="token0">
<input type="hidden" value="{{$contrap->contraparte}}" id="contraparte_fidecheck">
<input type="hidden" value="{{$contrap->cliente}}" id="cliente_fidecheck">
<!-- -->
<script src="{{ asset('/Libreria_CA/Js/funciones_fidecheckuevo.js') }}?v={{ time() }}"></script>
<script type="text/javascript">
	$(document).ready(function(){
		hablitarImagenesFideCheck();
		edicionFidecheck_nuevo('.btnedit_nuevo');
		edicionFidecheck_nuevo('.btnedit_vin');
		edicionFidecheck_nuevo('.btnedit_soc');
		agregarFidecheck_nuevo('.btnaddnuevo');
		recargaFide();
		botonAbreCertificados();
		modalFidecheck('.abrirmodalfidecheck');
		cerrarFidecheck('.cerrar_modalfide');
		//guardarDatosModalFide();
		//guardarDatosModalFideNegativo();
		

		guardarDatosModalFideGeneral('.guardarSeleccion');
		// Para el botón que siempre guarda fidecheck = 'N'
		guardarDatosModalFideGeneral('.guardarSeleccionNegativa', 'N');

		verificarRevisiones();
	});
	//función para evento del boton que abre los certificados
	function botonAbreCertificados() {
		$('#abrir_todos').on('click', function () {
			if($(this).hasClass("girado")){
				$(this).removeClass('girado')
				$(this).css("rotate","none")
				$('#abre_certificados').css('fill','rgb(99, 182, 140)')
			}else{
				$(this).addClass('girado')
				$(this).css("rotate","90deg")
				$('#abre_certificados').css('fill','black')
			}
		})
	}
	$('#guardarSeleccion').on('click', function () {
        let seleccionados = [];
        document.querySelectorAll('input[name="seleccion[]"]:checked').forEach((checkbox) => {
            seleccionados.push(checkbox.value);
        });
        console.log('Seleccionados:', seleccionados);
        $('#fidecheckModal').modal('hide');
    });

	if ($('td .botonesModalFide').is(':visible')) {
		$('td .btnedit_soc').addClass('d-none');
		$('td .btndelete_soc').addClass('d-none');
		$('td .btndelete').addClass('d-none');
		$('td .btnedit_nuevo').addClass('d-none');
		$('td .btnedit_vin').addClass('d-none');
		$('td .btndelete_vin').addClass('d-none');
		$('.float-end .btnaddnuevo').addClass('d-none');

	}else{
		$('td .btnedit_soc').removeClass('d-none');
		$('td .btndelete_soc').removeClass('d-none');
		$('td .btnedit_vin').removeClass('d-none');
		$('td .btndelete_vin').removeClass('d-none');
		$('.float-end  .btnaddnuevo').removeClass('d-none');
        $('td .btndelete').removeClass('d-none');
		$('td .btnedit_nuevo').removeClass('d-none');

	}


</script>