@extends("admin.layout.base")
@extends("admin.layout.header")

@section("title")
    Home - Admin Panel
@endsection

@section("content")
    <style>
        .card {
            min-width: 200px;
            width: calc(25% - 16px);
            margin: 0 8px 0 8px;
        }
        .content {
            display: flex;
            flex-wrap: wrap;
            flex-direction: row;
        }
        .card > .head {
            padding: 0 8px;
            display: flex;
            justify-content: center;
            align-items: center;
            width: calc(100% - 16px);
            min-height: 170px;
        }
        .mr-2 {
            margin-right: 1rem;
        }

        h3 {
            margin-top: 0;
        }

        .event_card > .header {
            padding-top: 1rem;
        }

        .ql-align-center {
            text-align: center;
        }

        .ql-align-center > strong {
            color: lightseagreen;
            margin: auto;
        }
    </style>

    <div class="card">
        <div class="head" style="background-color: orange;">
            <div>
                <img style="width: 4rem;" src="{{ asset("/images/icons/users-hvid.svg") }}" alt="">
                <h1 class="text-white">Brugere</h1>
            </div>
            <h1 class="text-white ml-auto mr-2" style="font-size: 3.5rem;">{{ count(\App\User::all()) }}</h1>
        </div>
        <table class="tbl mt-1">
            <tr>
                <th class="text-white text-center" style="background-color: orange;">Nyeste brugere</th>
            </tr>
            @for($i = 0; $i < 10 && $i < count(\App\User::query()->orderByDesc("id")->get()); $i++)
                <tr>
                    <td>{{ ucfirst(strtolower(\App\User::query()->orderByDesc("id")->get()[$i]->name_first)) . ' ' . ucfirst(strtolower(\App\User::query()->orderByDesc("id")->get()[$i]->name_last)) }}</td>
                </tr>
            @endfor
        </table>
    </div>

    <div class="card">
        <div class="head" style="background-color: red;">
            <div>
                <img style="margin-top: 8px;width: 3rem;" src="{{ asset("/images/icons/Aktiviteter.svg") }}" alt="">
                <h1 class="text-white">Aktiviteter</h1>
            </div>
            <h1 class="text-white ml-auto mr-2" style="font-size: 3.5rem;">{{ count(\App\Event::all()) }}</h1>
        </div>
        <table class="tbl mt-1">
            <tr>
                <th class="text-white text-center" style="background-color: red;">Næste aktivitet</th>
            </tr>
            @if(\App\Event::query()->orderByDesc("date")->first() == null)
                <tr>
                    <td class="text-center">Der er ingen aktiviteter</td>
                </tr>
            @endif
        </table>
        @if(\App\Event::query()->orderByDesc("date")->first() !== null)
            <div class="event_card">
                <div class="header" style="padding-top: 0">
                    <table class="tbl mt-0">
                        <tr>
                            <td><label>Aktivitet navn</label></td>
                            <td>{{ \App\Event::query()->orderByDesc("date")->first()->name }}</td>
                        </tr>
                        <tr>
                            <td><label>Aktivitet ansvarlig</label></td>
                            <td>Af:  {{ \App\Event::query()->orderByDesc("date")->first()->accountable }}</td>
                        </tr>
                        <tr>
                            <td><label>Tidspunkt</label></td>
                            <td>{{ \Illuminate\Support\Facades\Date::createFromTimeStamp(strtotime(\App\Event::query()->orderByDesc("date")->first()->date))->format('d/m/Y \k\l\. H:i') }}</td>
                        </tr>
                    </table>
                </div>
                <div class="container" style="margin-top: 8px;">
                     <table style="border: 1px solid lightgrey; width: 100%;">
                         <tr>
                             <td> {!! \App\Helpers::closetags(substr(\App\Event::query()->orderByDesc("date")->first()->description, 0, 300) )!!}</td>
                         </tr>
                     </table>
                    <input type="hidden" name="event_id" value="{{ \App\Event::query()->orderByDesc("date")->first()->id }}">
                    <div class="row" style="justify-content: space-between; margin-top: 16px;">
                        <a style="margin: 0; padding: 0; font-weight: 700;" class="sde-blue text-center" href="{{route("events.signups", ["event" => \App\Event::query()->orderByDesc("date")->first()->id ])}}">{{__('msg.sedeltagere')}}</a>
                    </div>
                </div>
            </div>
        @endif
    </div>

    <div class="card">
        <div class="head" style="background-color: deepskyblue;">
            <div>
                <img style="width: 4rem;" src="{{ asset("/images/icons/Vejledninger.svg") }}" alt="">
                <h1 class="text-white">Vejledninger</h1>
            </div>
            <h1 class="text-white ml-auto mr-2" style="font-size: 3.5rem;">{{ count(\App\Guide::all()) }}</h1>
        </div>
        <table class="tbl mt-1">
            <tr>
                <th class="text-white text-center" style="background-color: deepskyblue;">Seneste Vejledninger</th>
            </tr>
            @if(count(\App\Guide::all()) > 0)
                @for($i = 0; $i < 10 && $i < count(\App\Guide::query()->orderByDesc("id")->get()); $i++)
                    <tr>
                        <td>{{ ucfirst(strtolower(\App\Guide::query()->orderByDesc("id")->get()[$i]->name)) }}</td>
                    </tr>
                @endfor
            @else
                <tr>
                    <td class="text-center">Der er ingen vejledninger</td>
                </tr>
            @endif
        </table>
    </div>

    <div class="card">
        <div class="head" style="background-color: lightseagreen;">
            <div>
                <img style="width: 4rem;" src="{{ asset("/images/icons/Menuplan.svg") }}" alt="">
                <h1 class="text-white">Menuplan</h1>
            </div>
            <h1 class="text-white ml-auto mr-2" style="font-size: 3.5rem;">{{ count(\App\MenuPlan::all()) }}</h1>
        </div>
        <table class="tbl mt-1">
            <tr>
                <th class="text-white text-center" colspan="2" style="background-color: lightseagreen;">Ugens Menuplan</th>
            </tr>
            @if(\App\MenuPlan::query()->where("week", "=", date('W'))->first() !== null)
                {{-- \App\MenuPlan::query()->where("week", "=", date('W'))->first() --}}
                <tr>
                    <td><label>Mandag </label></td>
                    <td>{{ \App\MenuPlan::query()->where("week", "=", date('W'))->first()->monday }}</td>
                </tr>
                    <td><label>Tirsdag</label></td>
                    <td>{{ \App\MenuPlan::query()->where("week", "=", date('W'))->first()->tuesday }}</td>
                </tr>
                    <td><label>Onsdag</label></td>
                    <td>{{ \App\MenuPlan::query()->where("week", "=", date('W'))->first()->wednesday }}</td>
                </tr>
                    <td><label>Torsdag</label></td>
                    <td>{{ \App\MenuPlan::query()->where("week", "=", date('W'))->first()->thursday }}</td>
                </tr>
            @else
                <tr>
                    <td colspan="2" class="text-center">Der er ingen menuplan for denne uge</td>
                </tr>
            @endif
        </table>
    </div>
@endsection
