@extends('layouts.dashboard')



@section('title', 'Dashboard')

    

@section('content')

@auth

<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH" crossorigin="anonymous">

<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-YvpcrYf0tY3lHB60NNkmXc5s9fDVZLESaAA55NDzOxhy9GkcIdslK1eN7N6jIeHz" crossorigin="anonymous"></script>



<br>



<div class="row g-3">    

    <div class="col">

        <?php

        $user = config('services.labsmobile.user');
        $pass = config('services.labsmobile.pass');
        $endpoint = config('services.labsmobile.endpoint');

        $auth_basic = base64_encode("{$user}:{$pass}");



        $curl = curl_init();

        

        $telefono1 = "56972177378";

        $telefono2 = "56965095650";

         //$telefono3 = "56962497598"; 

        

         $telefono4 = "56992820117";

         $telefono5 = "56956906947";

         $telefono6 = "56998703494";

         $telefono7 = "56941701966";

        

         $telefono1 = "56934477175";

         $telefono2 = "56962497598";

         $telefono3 = "56978994637";

         $telefono4 = "56984847283";

         $telefono5 = "56965095650";

         $telefono6 = "56991589465";

         $telefono7 = "56934477175";

         $telefono8 = "56972177378";

         $telefono9 = "569942866025";

     //   for($i=0;$i<count($contacts);$i++){


        curl_setopt_array($curl, array(

          CURLOPT_URL => "https://api.labsmobile.com/json/send",

          CURLOPT_RETURNTRANSFER => true,

          CURLOPT_ENCODING => "",

          CURLOPT_MAXREDIRS => 10,

          CURLOPT_TIMEOUT => 30,

          CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,

          CURLOPT_CUSTOMREQUEST => "POST",

          //CURLOPT_POSTFIELDS => '{"message":"¡ADVERTENCIA! \n \nVulneración de Seguridad en FAENA TRÁNSITO! \nPersonal de Seguridad en Peligro!", "tpoa":"Sender","recipient":[{"msisdn":"'.$contactos[0][4].'"},{"msisdn":"'.$contactos[1][4].'"}]}',

          //CURLOPT_POSTFIELDS => '{"message":"¡ADVERTENCIA DE EMERGENCIA! \n \nGUARDIA DE SEGURIDAD EN PELIGRO! \nRecinto Vulnerado!", "tpoa":"Sender","recipient":[{"msisdn":"'.$telefono8.'"}]}', 

      CURLOPT_POSTFIELDS => '{"message":"¡ADVERTENCIA DE EMERGENCIA! \n \nGUARDIA DE SEGURIDAD EN PELIGRO! \nRecinto Vulnerado!", "tpoa":"Sender","recipient":[{"msisdn":"'.$telefono1.'"},{"msisdn":"'.$telefono2.'"},{"msisdn":"'.$telefono4.'"},{"msisdn":"'.$telefono5.'"},{"msisdn":"'.$telefono3.'"},{"msisdn":"'.$telefono6.'"},{"msisdn":"'.$telefono7.'"},{"msisdn":"'.$telefono8.'"},{"msisdn":"'.$telefono9.'"}]}', 

          CURLOPT_HTTPHEADER => array(

            "Authorization: Basic ".$auth_basic,

            "Cache-Control: no-cache",

            "Content-Type: application/json"

          ),

        ));

        

        $response = curl_exec($curl);

        $err = curl_error($curl);

        

        curl_close($curl);

        

        if ($err) {

          echo "cURL Error #:" . $err;

        } else {

          //echo "Enviadas";

         ?>
            <form action="{{ route('empleado.dashboard') }}" method="GET" id="autoForm">
            @csrf
        </form>

      <script>
          window.addEventListener('DOMContentLoaded', () => {
              document.getElementById('autoForm').submit();
          });
      </script>
              <?php

   //     }

      }

        ?>

    </div>

</div>

@else
    @php
        header("Location: " . route('login'));
        exit;
    @endphp
@endauth

@endsection