@if ( $_SERVER['REMOTE_ADDR'] == substr(env('URL_BASE'),7) )
	@include('led/led_header_dossier')
@endif
<!-- page break para version impresa -->
<div class="page-break"></div>
<div id="imagen_fidelitas_comerciales" class="text-left hidden" style="padding-bottom: 10px;"></div>
<div id="nombre_cuit_seccion_comex" class="hidden" ></div>
<h4 id="titulo_seccion_comex" class="text-center titulo-fidelitas" style="background-color: #0f335a; color: #ffffff">@traducir('COMEX', 'COMERCIO EXTERIOR')</h4>  
@if (!$comex_impo && ( !$comex_totales || (!isset($comex_totales->total_impo) && (!$comex_totales->total_impo) && !isset($comex_totales->total_expo) && (!$comex_totales->total_expo))) && (!$comex_pais_impo))
  <div class="col-md-12 padding10">
    <h4 class="text-center titulo-fidelitas ">@traducir('IMPORTACIONES','IMPORTACIONES')</h4>
    <div class="text-center font15">  - @traducir('No se detectaron datos','No se detectaron datos') -</div>
  </div>
@else

  @if((isset($comex_totales->total_expo) && ($comex_totales->total_expo > 0)) || ((isset($comex_totales->total_impo) && ($comex_totales->total_impo > 0))))
    <div class="col-md-12 padding10 mt20">
      <div class="col-md-1"></div>
      <div class="col-md-4">
        <div class ="padding10 background-fidelitas text-center font15 ">
        @traducir('IMPORTACIONES','IMPORTACIONES')
          <div>(@traducir('últimos','últimos') {{$meses}} @traducir('meses','meses'))</div>
        </div>
        <div class =" padding10 text-center" style="border:1px solid #eee;">
          USD {{number_format($comex_totales->total_impo,0,'.',' ')}}
        </div>
      </div>
      <div class="col-md-2"></div>
      <div class="col-md-4">
        <div class ="padding10 background-fidelitas text-center font15 ">
          @traducir('EXPORTACIONES','EXPORTACIONES')
          <div>(@traducir('últimos','últimos') {{$meses}} @traducir('meses','meses'))</div>
        </div>
        <div class =" padding10 text-center "  style="border:1px solid #eee;">
          USD {{number_format($comex_totales->total_expo,0,'.',' ')}}
        </div>
      </div>
      <div class="col-md-1"></div>
    </div>
  @endif

  <div class="col-md-12 padding10">
    <h4 class="text-center titulo-fidelitas ">@traducir('IMPORTACIONES','IMPORTACIONES')</h4>
    @if($comex_impo && $esled=='')
      <h4 style="padding:10px;" class="text-left titulo-contables heading-block">@traducir('Importaciones (últimos 24 meses)','Importaciones (últimos 24 meses)')</h4>
    @endif
  </div>
  @if ($esled=='')
    <div class="col-md-12 col-sm-12 col-xs-12" >
      @if($grafico_impo_comex != '')
        <img src="{{$grafico_impo_comex}}" class="img-responsive center-block" style="width: 95%;" />
      @else
        <canvas   id="impo_comex" class="impo_comex chartjs-render-monitor"></canvas>
      @endif
    </div>
  @endif

  @if($comex_impo && $esled=='')
    <div class="col-md-12">
      <div class="col-md-12">
        <div class="col-md-12"  >
          <table  class="table table-striped" id="tabla_comex">
            <thead class="thead">
              <tr>
                <th>@traducir('Período','Período')<br><span style="color:white;">@traducir('Periodo','Periodo')</span></th>
                <th>@traducir('Consumo','Consumo')                  <br>
                  <span style="color: #369EAD;">@traducir('Total','Total'): @if(isset($total_consumo)) {{ number_format($total_consumo,0,","," ") }} @endif</span>
                </th>
                <th>(F.O.B. U$S)  @traducir('Temporal','Temporal')   <br>
                  <span style="color:#C24642;">@traducir('Total','Total'): @if(isset($total_temporal)) {{ number_format($total_temporal,0,","," ") }} @endif</span>
                </th>
                <th>(F.O.B. U$S)  @traducir('Depósito','Depósito')   <br>
                  <span style="color:#7F6084;">@traducir('Total','Total'): @if(isset($total_deposito)) {{ number_format($total_deposito,0,","," ") }} @endif</span>
                </th>
                <th>(F.O.B. U$S)  @traducir('Zona Franca','Zona Franca')<br>
                  <span style="color:#86B402;">@traducir('Total','Total'): @if(isset($total_zonafranca)){{ number_format($total_zonafranca,0,","," ") }} @endif</span>
                </th>
                <th>(F.O.B. U$S)<br>
                  <span>@traducir('Total','Total'): @if(isset($total_totales)){{ number_format($total_totales,0,","," ") }} @endif</span>
                </th>
              </tr>
            </thead>
            <tbody class="text-left">
          @foreach($comex_impo as $info)
          <tr>
            <td class="text-right">{{$info->mes}}/{{$info->anio}}</td>
            <td class="text-right">{{number_format($info->consumo,0,","," ")}}</td>
            <td class="text-right">{{number_format($info->temporal,0,","," ")}}</td>
            <td class="text-right">{{number_format($info->deposito,0,","," ")}}</td>
            <td class="text-right">{{number_format($info->zonafranca,0,","," ")}}</td>
            <td class="text-right">{{number_format($info->total,0,","," ")}}</td>
          </tr>
          @endforeach
            </tbody>
          </table>
        </div>
      </div>
    </div>
  @endif
  <!--inicio Importaciones por pais -->
 
  @if(isset($comex_pais_impo[0]) && $comex_pais_impo[0]->fob > 0)
    <div class="col-md-12">  <h4 style="padding:10px;" class="text-center  titulo-contables heading-block">@traducir('Importaciones por País (últimos 24 meses)','Importaciones por País (últimos 24 meses)')</h4></div>
    <div class="col-md-12" >  
      <div class="col-md-12 padding10"> 
        <div  @if(Session::get('html')) class="col-md-12 " @else class="col-md-7" @endif >
          <table class="table table-striped">
            <tr class="background-fidelitas">
              <th class="col-md-9">@traducir('País','País')</th>
              <th class="col-md-1 text-center">%</th>
              <th class="col-md-2 text-center">@traducir('Fob Total','Fob Total')</th>
            </tr>
            @foreach($comex_pais_impo as $key => $expo)          
              <tr class="@if($expo->nombre == 'Totales') destacar-registro @endif">
                <td class="text-left comex_td"  >{{$expo->nombre ?? ''}}</td>
                <td class="text-center" >
                  @if($expo->nombre!='Totales' && $expo->fob > 0)
                    {{number_format(($expo->fob * 100) / $total_pais_impo,2)}}
                  @endif
                </td>
                <td class="text-center"  >{{ number_format($expo->fob,0,',',' ')  }}</td>
              </tr>
            @endforeach
          </table>
          <div class="col-md-12 text-left">@traducir('Valores estadísticos aproximados','Valores estadísticos aproximados')</div>
        </div>
        @if(Session::get('html'))
          <div class="col-md-12 text-center" ><img src="{{$grafico_pais_impo_comex}}"   style="width: 50% " /></div>
        @elseif($grafico_pais_impo_comex != '')
          <div class="col-md-5"> <img src="{{$grafico_pais_impo_comex}}"  style="width: 250px;height: 250px" /></div>
        @else
          <div class="col-md-5" >
            <canvas  id="pais_impo" class=" chartjs-render-monitor" ></canvas>
          </div>
        @endif
      </div>
    </div>
  @else
    <div class="col-md-12">
      <div @if(Session::get('html')) class="text-center font15" @else class="text-center font15" @endif >- @traducir('No se detectaron datos','No se detectaron datos') -</div>
    </div> 
  @endif
  <!--fin Importaciones por pais -->
  <!--inicio RUBROS importaciones -->
  @if(isset($comex_rubro_impo[0]) && $comex_rubro_impo[0]->fob > 0)
    <div class="col-md-12"><h4 style="padding:10px;" class="text-center  titulo-contables heading-block">@traducir('Importaciones por Rubro (últimos 24 meses)','Importaciones por Rubro (últimos 24 meses)')</h4></div>
    <div class="col-md-12">
      <div class="col-md-12 padding10">
        <div @if(Session::get('html')) class="col-md-12" @else class="col-md-7" @endif  >
          <table class="table table-striped">
            <tr class="background-fidelitas">
              <th class="col-md-7">@traducir('Nombre','Nombre')</th>
              <th class="col-md-2 text-center">@traducir('Posicion','Posicion')</th>
              <th class="col-md-1 text-center">%</th>
              <th class="col-md-2 text-center">@traducir('Fob Total','Fob Total')</th>
            </tr>
            @foreach($comex_rubro_impo as $key => $impo)
              <tr class="@if($impo->descripcion == 'Totales') destacar-registro @endif">
                <td class="col-md-6 text-left">
                  <div class="truncate-ellipsis">
                    <span>
                      {{$impo->descripcion ?? ''}}
                    </span>
                  </div>
                </td>            
                <td class="col-md-2 text-center">{{$impo->posicion ?? ''}}</td>

                <td class="text-center ">
                  @if($impo->descripcion != 'Totales')
                    @if($impo->fob > 0)
                      {{number_format(($impo->fob * 100) / $total_rubro_impo,2)}}
                    @endif
                  @endif
                </td>
                <td class="col-md-4 text-center">{{ number_format($impo->fob,0,',',' ')  }}</td>
              </tr>
            @endforeach
          </table>
          <div class="col-md-12 text-left">@traducir('Valores estadísticos aproximados','Valores estadísticos aproximados')</div>
        </div>
        @if(Session::get('html'))
          <div class="col-md-12 text-center"> <img src="{{$grafico_rubro_impo_comex}}"  style="width: 50%"  /></div>
        @elseif($grafico_rubro_impo_comex != '')
          <div class="col-md-5"> <img src="{{$grafico_rubro_impo_comex}}"  style="width: 250px;height: 250px"  /></div>
        @else
          <div class="col-md-5">
            <canvas id="rubros_impo" class="chartjs-render-monitor"></canvas>
          </div>
        @endif

      
      @endif

    </div>
  </div>
  @endif
  <!--fin RUBROS importaciones -->

  @if (!$comex_expo)
    <div class="col-md-12 padding10">
      <h4 class="text-center titulo-fidelitas ">@traducir('EXPORTACIONES','EXPORTACIONES')</h4>
      <div class="text-center font15">  - @traducir('No se detectaron datos','No se detectaron datos') -</div>
    </div>
  @else

  <div class="col-md-12 padding10">
    <h4 class="text-center titulo-fidelitas ">@traducir('EXPORTACIONES','EXPORTACIONES')</h4>  
    <h4 style="padding:10px;" class="text-left titulo-contables heading-block ">@traducir('Exportaciones (últimos 24 meses)','Exportaciones (últimos 24 meses)')</h4> 
  </div>


 
    <div class="col-md-12">
     @if($grafico_expo_comex != '')
     {{dd($grafico_expo_comex)}}
       <img src="{{$grafico_expo_comex}}"  class="img-responsive center-block" style="width: 95%;"/>
     @else
        <!-- <div  id="grafico_exportaciones_comex" ></div> -->
        <canvas id="expo_comex" class="expo_comex chartjs-render-monitor"></canvas>
     @endif
    </div>



  <!--inicio Exportaciones por pais -->
  <div class="col-md-12">  <h4 style="padding:10px;" class="text-center  titulo-contables heading-block">@traducir('Exportaciones (últimos 24 meses)','Exportaciones (últimos 24 meses)')</h4></div>
  @if($comex_pais_expo)
  <div class="col-md-12" >
    <div  class="col-md-12">
      <div @if(Session::get('html')) class="col-md-12" @else class="col-md-7" @endif >
          <table class="table table-striped">
            <tr class="background-fidelitas">
              <th class="col-md-9">País</th>
              <th class="col-md-1 text-center" >%</th>
              <th class="col-md-2 text-center">Fob Total</th>
            </tr>
          @foreach($comex_pais_expo as $key => $expo)
            <tr class="@if($expo->nombre == 'Totales') destacar-registro @endif">
              <td class="text-left comex_td"  ><span>{{$expo->nombre ?? ''}}</span></td>
              <td class="text-center" >
                @if($expo->nombre!='Totales')
                  @if($expo->fob > 0)
                    {{number_format(($expo->fob * 100) / $total_pais_expo,0,',',' ')}}
                  @endif
                @endif
              </td>
              <td class="text-center">{{ number_format($expo->fob,0,',',' ')  }}</td>
            </tr>
          @endforeach
          </table>
      <div class="col-md-12 text-left">@traducir('Valores estadísticos aproximados','Valores estadísticos aproximados')</div>


      </div>
      @if(Session::get('html'))
        <div class="col-md-12 text-center"> <img src="{{$grafico_pais_expo_comex}}" style="width: 50%" /></div>

     @elseif($grafico_pais_expo_comex != '')
      <div class="col-md-5"> <img src="{{$grafico_pais_expo_comex}}" style="width: 250px;height: 250px" /></div>
     @else
     <div class="col-md-5">
        <canvas id="pais_expo" class="chartjs-render-monitor"></canvas>
      </div>
      <!-- <div class="col-md-4" id="pais_expo"></div> -->
     @endif
    </div>
  </div>  
  @else
  <div class="col-md-12">
    <div class="text-left font15">- @traducir('No se detectaron datos','No se detectaron datos') -</div>
  </div> 
  @endif

  <!--fin Exportaciones por pais -->

  <!--inicio RUBROS exportaciones-->
  <div class="col-md-12">  
    <h4 style="padding:8px;" class="text-center  titulo-contables heading-block">@traducir('Exportaciones por Rubro (últimos 24 meses)','Exportaciones por Rubro (últimos 24 meses)')</h4>
  </div>
  @if($comex_rubro_expo)
  <div class="col-md-12">
    <!--div class="col-md-12 padding10"-->
    <div class="col-md-12">

      <div @if(Session::get('html')) class="col-md-12" @else class="col-md-7" @endif >
          <table class="table table-striped">
            <tr class="background-fidelitas">
              <th class="col-md-7">@traducir('Nombre','Nombre')</th>
              <th class="col-md-2 text-center">@traducir('Posicion','Posicion')</th>
              <th class="col-md-1 text-center">%</th>
              <th class="col-md-2 text-center">@traducir('Fob Total','Fob Total')</th>
            </tr>
          @foreach($comex_rubro_expo as $key => $expo)
            <tr class="@if($expo->descripcion == 'Totales') destacar-registro @endif">
              <td class="col-md-6 text-left">
                <div class="truncate-ellipsis">
                  <span>
                    {{$expo->descripcion ?? ''}}
                  </span>
                </div>
              </td>            
              <td class="col-md-2 text-center">{{$expo->posicion ?? ''}}</td>

              <td class="text-center">
                @if($expo->descripcion != 'Totales')
                  @if($expo->fob > 0)
                    {{number_format(($expo->fob * 100) / $total_rubro_expo,2)}}
                  @endif
                @endif
              </td>
              
              <td class="col-md-4 text-center">{{ number_format($expo->fob,0,',',' ')  }}</td>

            </tr>
          @endforeach
          </table>
          <div class="col-md-12 text-left">@traducir('Valores estadísticos aproximados','Valores estadísticos aproximados')</div>
      </div>
      @if(Session::get('html'))
        <div class="col-md-12 text-center"> <img src="{{$grafico_rubro_expo_comex}}"  style="width: 50%"  /></div>
      @elseif($grafico_rubro_expo_comex != '')
        <div class="col-md-5"> <img src="{{$grafico_rubro_expo_comex}}"  style="width: 250px;height: 250px"  /></div>
       @else
       <div class="col-md-5">
        <canvas  id="rubros_expo" class=" chartjs-render-monitor"></canvas>
        <canvas  id="rubros_expo_led" class=" chartjs-render-monitor"></canvas>
      </div>
        <!-- <div class="col-md-4" id="rubros_expo"></div> -->
       @endif

      @else
       <div class="col-md-12">
          <div class="text-left font15">- @traducir('No se detectaron datos','No se detectaron datos') -</div>
      </div>
      @endif
     </div>
   </div>
  @endif

@if ( $_SERVER['REMOTE_ADDR'] == substr(env('URL_BASE'),7) )
	@include('led/led_footer_dossier')
@endif