@include('/led/led_header')
<form id="frmRSEContrapartes" method="post" action="/led/led-excel-Sostenibilidad" class="form-signin">
{{csrf_field()}}
<input name="tipo_doc" type="hidden" value="{{$tipo_doc}}">
<input name="tipo" type="hidden" value="{{$tipo}}">

<div class="sidebar-excel-div">
	@if(isset($nombre_documento))
	    <button type="submit" class="btn btn-success text-right" id="btnReporte" title="Generar Reporte con las contrapartes seleccionadas">Generar<br>Excel<br><i class="fa fa-file-excel"></i></button>
	@endif
</div>
<div class="container" style="width:60%">
	@if(isset($nombre_documento))
	<br>
	<div class="row" style="height:50px;">
		<div class="col-md-12 text-left">
		<b>Contrapartes con Documento de {{$nombre_documento}} ingresado y verificado<br><br>Seleccione las que desea incluir en el reporte</b>
		</div>

	</div>
	@endif

	<table class="table table-striped table-condensed" id="tablaRSE">
		<thead>
			<tr>
				<th class="text-center"><input type="Checkbox" name="todas" id="todas" value="1"></th>
				<th class="text-center">@traducir('País','País')</th>
				<th class="text-left" style="white-space: nowrap;">@traducir('Familia','Familia')</th>
				<th class="text-left" style="white-space: nowrap;">@traducir('Razón Social','Razón Social')</th>
				<th class="text-left" style="white-space: nowrap;">@traducir('Identificación','Identificación')</th>
				<th style="display: none;">ID</th>
			</tr>
		</thead>
		<tbody>
		@foreach ($contrapartes as $prov)
			<tr style="cursor:pointer;">
				<td class="text-center">
          <input type="Checkbox" name="contraparte[]" class="chk" value="{{$prov->contraparte}}">
        </td>
				<td class="text-center celda-panel" data-id="{{$prov->contraparte}}"><span class="hidden">flag-icon-{{strtolower($prov->country_code)}}</span><span class="flag-icon flag-icon-background flag-icon-{{strtolower($prov->country_code)}}"></span></td>
				<td class="text-left celda-panel" style="white-space: nowrap;" data-id="{{$prov->contraparte}}">{{$prov->nombre_familia}}</td>
				<td class="text-left celda-panel" style="vertical-align: middle;white-space: nowrap;" title="{{$prov->nombre_persona}}" valign="middle" data-id="{{$prov->contraparte}}">{{$prov->nombre_persona}}</td>
				<td class="text-left celda-panel" style="white-space: nowrap;" data-id="{{$prov->contraparte}}">{{$prov->numero}}</td>
				<td style="display:none;">{{$prov->contraparte}}</td>
			</tr>
		@endforeach
		</tbody>
	</table>
</div>

</form>

<script language="javascript" type="text/javascript">
	
	$(document).ready(function() {
		
		$(document).on('click',"#todas",function(){
			$.each($('.chk'), function(i, el) {
				$(this).prop('checked', $('#todas').prop('checked'));
			});
		});

		$(document).on('click',"#btnReporte",function(e)
			{
			e.preventDefault(); 
			checked = $("input[type=checkbox]:checked").length;
      if(!checked) {
        alert("No ha seleccionado ninguna contraparte");
        return false;
      }
      $("#frmRSEContrapartes").submit(); 
      /*
      $('#todas').prop('checked', false);
      $.each($('.chk'), function(i, el) {				
								$(this).prop('checked', false);
							});*/
		});
	});

</script>

@include('footer')
