@extends('layouts.admin.main')

@section('content')
<div class="col-md-12">
    <div class="card">
        <div class="card-header">
            Cours a venir
        </div>
        <div class="card-body">
                @if(count($userClasse) == 0)
                <div class="col-sm-12">
                        <div class="alert alert-info alert-with-icon">
                            <span data-notify="icon" class="ti-alert"></span>
                            <span data-notify="message">Aucun cours a venir</span>
                        </div>
                    </div>
                @endif
                @foreach ($userClasse as $classe)
                <div class="col-sm-6">
                    @if ($classe['plan_done'] == "on")
                    <div class="alert alert-success alert-with-icon">
                        <span data-notify="icon" class="ti-crown"></span>
                        <span data-notify="message">Le cours {{$classe['ocom']}} - {{$classe['name']}} du {{$classe['date']}} est remis.<br>
                        @if ($classe['material'] != "")
                            - Vous avez réservé 
                            @foreach (\App\Item::explodeItems($classe['material']) as $item)
                                @if (\App\Item::explodeItems($classe['material'])->last() == $item && \App\Item::explodeItems($classe['material'])->first() != $item)
                                    et
                                @endif
                                {{$item->name}}
                            @endforeach
                        @else
                            - Aucun matériel réservé
                        @endif
                        </span>
                    </div>
                    @else
                    <div class="alert alert-warning alert-with-icon">
                        <span data-notify="icon" class="ti-alert"></span>
                        <span data-notify="message">Le cours {{$classe['ocom']}} - {{$classe['name']}} du {{$classe['date']}} n'est pas remis.<br>
                        @if ($classe['material'] != "")
                            - Vous avez réservé 
                            @foreach (\App\Item::explodeItems($classe['material']) as $item)
                                @if (\App\Item::explodeItems($classe['material'])->last() == $item && \App\Item::explodeItems($classe['material'])->first() != $item)
                                    et
                                @endif
                                {{$item->name}}
                            @endforeach
                        @else
                            - Aucun matériel réservé
                        @endif
                        </span>
                    </div>
                    @endif
                </div>
            @endforeach
        </div>
    </div>
</div>
<div class="col-sm-6 col-lg-6">
    <div class="card">
        <div class="card-header">
            <div class="float-right">Activité a venir</div>
        </div>
        <div class="card-body">
            <div class="row">
                @if(count($futureEvent) == 0)
                <div class="col-sm-12">
                    <div class="alert alert-infi alert-with-icon">
                        <span data-notify="icon" class="ti-alert"></span>
                        <span data-notify="message">Aucune activité a venir</span>
                    </div>
                </div>
                @endif
            @foreach ($futureEvent as $event)
                <div class="col-md-6 col-sm-12"><i class="fa fa-star" aria-hidden="true" style="color:gold"></i> {{$event->data['event_name']}}</div>
            @endforeach
            </div>
            <br>
            <a href="/admin/calendar" type="button" class="btn btn-primary btn-lg btn-block">Afficher plus</a>
        </div>
    </div>
</div>
<div class="col-sm-6 col-lg-6">
        <div class="card">
            <div class="card-header">
                <span class="count">{{count(\App\Log::all())}}</span>
                <div class="float-right">Activité sur le site</div>
            </div>
            <div class="card-body">
                @foreach (\App\Log::all()->forPage(1,3); as $event)
                    <i class="fa fa-arrow-right" aria-hidden="true"></i> {{$event->action}}<br>
                @endforeach
                <br>
                <a href="/admin/stats/log" type="button" class="btn btn-primary btn-lg btn-block text-white">Afficher plus</a>
            </div>
        </div>
    </div>
<div class="col-lg-8 col-md-12">
    <div class="card">
        <div class="card-header">
                <span class="count">{{count(\App\Message::all())}}</span>
                <div class="float-right">Message publié</div>
        </div>
        <div class="card-body">
            <div class="row">
            @foreach (\App\Message::all()->forPage(1,4); as $msg)
                <div class="col-lg-6 text-center">
                    <div style="height:2rem;">{{$msg->title}}</div>
                    <br>
                    <div class="msg-body" style="height:12rem;overflow:hidden">
                        {!!$msg->body!!}
                    </div>
                    <br>
                </div>
            @endforeach
            </div>
            <br>
            <a href="/admin/admin/message" type="button" class="btn btn-primary btn-lg btn-block text-white">Afficher plus</a>
        </div>
    </div>
</div>
<div class="col-sm-4 col-lg-4">
    <div class="card">
        <div class="card-body">
            <div class="mx-auto d-block">
                <img class="rounded-circle mx-auto d-block" src="/assets/admin/images/avatar/user-{{\Auth::User()->avatar}}.jpg" alt="Card image cap" style="height:12rem">
                <h5 class="text-sm-center mt-2 mb-1">{{\Auth::User()->fullname()}}</h5>
                <div class="location text-sm-center"><i class="fa fa-id-card-o" aria-hidden="true"></i> {{\App\Rank::find(\Auth::User()->rank)->name}}</div>
            </div>
            <hr>
            <div class="card-text text-sm-center">
                <a href="/admin/profil">Profil</a>
            </div>
        </div>
    </div>
</div>
@endsection

@section('breadcrumb')
    <div class="breadcrumbs">
        <div class="col-sm-4">
            <div class="page-header float-left">
                <div class="page-title">
                    <h1>{{ trans('admin/dashboard.page_title')}}</h1>
                </div>
            </div>
        </div>
        <div class="col-sm-8">
            <div class="page-header float-right">
                <div class="page-title">
                    <ol class="breadcrumb text-right">
                        <li class="active">{{ trans('admin/dashboard.breadcrumb')}}</li>
                    </ol>
                </div>
            </div>
        </div>
    </div>
@endsection

@section('scripts')
    <script>
        ( function ( $ ) {
            "use strict";

            jQuery( '#vmap' ).vectorMap( {
                map: 'world_en',
                backgroundColor: null,
                color: '#ffffff',
                hoverOpacity: 0.7,
                selectedColor: '#1de9b6',
                enableZoom: true,
                showTooltip: true,
                values: sample_data,
                scaleColors: [ '#1de9b6', '#03a9f5' ],
                normalizeFunction: 'polynomial'
            } );
        } )( jQuery );
    </script>
@endsection
