@extends('admin')
@section('contentData')
    @if (session()->has('message'))
        <div class="alert alert-success">
            {{ session('message') }}
        </div>
    @endif
    <h2 style="color: #0095fe; font-family: Calibri,serif;">Nastavení čidel/stanic</h2>
    <div style=' width: 900px; 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;'>
        <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="p-2">
                <th scope="col" class="p-2" style="padding-left: 10px; width: 30px;">ID</th>
                <th scope="col" class="p-2" style="width: 100px;">Název stanice</th>
                <th scope="col" class="p-2">Adresa</th>
                <th scope="col" class="p-2" style="width: 80px;">Externi ID</th>
                <th scope="col" class="p-2" style="width: 70px;">Aktivni</th>
                <th scope="col" class="p-2">Vloženo</th>
                <th scope="col" class="p-2 nosort" style="width: 20px;"> </th>
                <th scope="col" class="p-2 nosort"  style="width: 20px;"> </th>
                <th scope="col" class="p-2 nosort" style="width: 20px;"> </th>
            </tr>
            </thead>
            @foreach($stanice as $id => $data)
                @php
                    if ($id%2 == 1)
                    {
                      $rowColor = "#e5e5e5";
                    }
                    else
                    {
                        $rowColor = "whitesmoke";
                    }

                    if($data->registrovano ===1)
                    {
                        $routa = 'stanice-vypnout';
                        $img = '/resources/images/btn-delete.png';
                    }
                    else
                    {
                        $routa = 'stanice-zapnout';
                        $img = '/resources/images/btn-view.png';
                    }
                    if($data->ban === 1)
                    {
                        $routaBan = 'stanice-unban';
                        $img1 = '/resources/images/btn-activate.png';
                    }
                    else
                    {
                        $routaBan = 'stanice-ban';
                        $img1 = '/resources/images/btn-deactivate.png';
                    }

                @endphp
                <tr style="background-color: {{$rowColor}};">
                    <th scope="row" style="padding-left: 10px;">{{$data->appId}}</th>
                    <td>{{$data->nazev}}</td>
                    <td>{{$data->adresa}}</td>
                    <td>{{$data->idStanice}}</td>
                    <td>@if($data->registrovano===1)Ano @else Ne @endif</td>
                    <td>{{ \Carbon\Carbon::parse($data->vlozeny)->format('d.m.Y H:i:s')}}</td>
                    <td> <a href="{{ route('stanice-edit',$data->appId) }}"><img src="{{URL::asset('/resources/images/btn-edit.png')}}" alt="Edit"/></a></td>
                    <td> <a href="{{ route($routa,$data->appId) }}"><img src="{{URL::asset($img)}}" alt="Vypnout"/></a></td>
                    <td> <a href="{{ route($routaBan,$data->appId) }}" ><img src="{{URL::asset($img1)}}" width="25px" height="25px" alt="BAN"/></a></td>
                </tr>
                @endforeach
        </table>
    </div>
@endsection

