@extends('admin')
@section('contentData')
    @if (session()->has('message'))
        <div class="alert alert-success">
            {{ session('message') }}
        </div>
    @endif
    @if (session()->has('message-fail'))
        <div class="alert alert-warning">
            {{ session('message-fail') }}
        </div>
    @endif
    <h2 style="color: #0095fe; font-family: Calibri,serif;">Nastavení emailových služeb</h2>
    <div class="alert-info p-2 mb-3" style="width: 900px; border-radius: 5px; border: 1px rgba(142,194,236,0.65) solid; font-family: Calibri,serif; color: #1b1e21; font-size: 17px;">
        Pro správné nastavení je nutné zjistit z příslušného emailového portálu jakým způsobem nastavit server.<br>
        Příklad: Google - driver: smtp, host: smtp.google.com, port: 465, zabezpečení: ssl.<br> Dále je nutné povolit ve <b> Správa účtu google - Zabezpečení - Přístup méně zabezpečených aplikací</b>
     </div>
    <div style=' width: 950px; padding: 40px;background-image: url("{{URL::asset('/resources/images/bg-top1.png')}}"); background-repeat:no-repeat; background-size: 10px 100%; border-radius: 10px; background-color: whitesmoke;'>
        <a href="{{ route('emailSet-add')}}">
            <input type="button" style="width: 170px; height: 37px; background-color: darkorange; border: 0 darkorange; font-size: 20px; font-family: Calibri,serif; margin-bottom: 15px; color: whitesmoke; border-radius: 5px;" value="Přidat nastavení"/>
        </a>
        <form method="POST" action="{{ route('emailSet-update')}}">

            <table width="100%" id="table">
                <thead style='background-image: url("{{URL::asset('/resources/images/bg-top1.png')}}"); background-repeat:no-repeat; background-size: 100%; color: white;'>
                <tr class="text-center">
                    <th scope="col" class="p-2" style="padding-left: 10px; width: 20px;">ID</th>
                    <th scope="col" class="p-2" style="width: 70px;">Aktivní</th>
                    <th scope="col" class="p-2" style="width: 70px;">Driver</th>
                    <th scope="col" class="p-2">Host</th>
                    <th scope="col" class="p-2" style="width: 50px;">Port</th>
                    <th scope="col" class="p-2">Přihl. jméno</th>
                    <th scope="col" class="p-2" style="width: 75px;">Šifrování</th>
                    <th scope="col" class="p-2" style="width: 90px;">Vyzkoušet</th>
                    <th scope="col" style="width: 10px;" class="nosort"> </th>
                    <th scope="col" style="width: 10px;" class="nosort"> </th>
                </tr>
                </thead>
                @foreach($dataC as $id => $data)
                    @php
                        if ($id%2 == 1)
                        {
                          $rowColor = "#e5e5e5";
                        }
                        else
                        {
                            $rowColor = "whitesmoke";
                        }
                        if($data->aktivni == 1)
                        {
                            $checked = "checked";
                        }
                        else
                        {
                            $checked = "";
                        }
                    @endphp
                    <tr style="background-color: {{$rowColor}}; text-align: center">
                        <th scope="row" style="padding-left: 10px;">{{$data->idemail_sender_define}}</th>
                        <td><label>
                                <input type="radio" name="aktivni" value={{$data->idemail_sender_define}} id={{$data->idemail_sender_define}} {{$checked}}>
                            </label></td>
                        <td>{{$data->driver}}</td>
                        <td>{{$data->host}}</td>
                        <td>{{$data->port}}</td>
                        <td>{{$data->username_email}}</td>
                        <td>{{$data->encryption}}</td>
                        <td style="text-align: center">
                            @if($checked!=='')
                                <a href="{{ route('emailSet-testovaci',$data->idemail_sender_define)}}">Odeslat</a>
                            @else
                                ---
                            @endif
                        </td>
                        <td style="width: 20px;"><a href="{{ route('emailSet-edit',$data->idemail_sender_define)}}"> <img src="{{URL::asset('/resources/images/btn-edit.png')}}" alt="Edit"/></a></td>
                        <td style="width: 20px;"><a href="{{ route('emailSet-delete',$data->idemail_sender_define)}}"> <img src="{{URL::asset('/resources/images/btn-delete.png')}}" alt="Smazat"/></a></td>
                    </tr>
                @endforeach
            </table>


            <div class="form-group row mt-3">
                <div class="col-md-12 offset-md-5">
                    <button type="submit" class="btn btn-primary">
                        {{ __('Uložit') }}
                    </button>
                </div>
            </div>
        </form>
    </div>
@endsection
