@extends('layouts.admin.main')

@section('content')
<div class="row">
    <div class="col-md-12">
        <div class="card">
            <div class="card-header card-header-primary">
                <h4 class="card-title"> Cours à venir</h4>
            </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 à 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>
<div class="row">
    <div class="col-sm-6 col-lg-6">
        <div class="card">
            <div class="card-header card-header-primary">
                <h4 class="card-title">Activité à venir</h4>
            </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é à venir</span>
                        </div>
                    </div>
                    @endif
                @foreach ($futureEvent as $event)
                    <div class="col-md-12">
                        <div class="alert" style="background-color: {{\App\ComplementaryActivity::find($event->type)->calendar_color}}">
                            <div class="row text-white">
                                <div class="col-md-2 text-capitalize m-auto d-none d-md-flex">
                                    <h3 class="m-0 p-0" style="margin-top: -0.5rem !important;">{!! \App\ComplementaryActivity::find($event->type)->calendar_icon !!}</h3>
                                </div>
                                <div class="col-md">
                                    {{$event->name}}
                                </div>
                                <div class="col-md-4">
                                    {{$event->date_begin}}
                                </div>
                            </div>
                        </div>
                    </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 card-header-primary">
                <h4 class="card-title">Activité sur le site</h4>
            </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>
<div class="row">
    <div class="col-lg-8 col-md-12">
        <div class="card">
            <div class="card-header card-header-primary">
                    <h4 class="card-title">Message publié</h4>
            </div>
            <div class="card-body">
                <div class="row">
                @foreach (\App\Message::all()->forPage(1,4); as $msg)
                        <div class="col-lg-6 text-center">
                            <a href="/admin/message/{{$msg->id}}">
                                <div style="height:2rem;">{{$msg->title}}</div>
                                <br>
                                <div class="msg-body" style="height:12rem;overflow:hidden">
                                    {!!$msg->body!!}
                                </div>
                                <br>
                            </a>
                        </div>
                @endforeach
                </div>
                <br>
                <a href="/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 card-profile">
            <div class="card-avatar">
                <a>
                    <img class="img" src="/assets/admin/images/avatar/user-{{\Auth::User()->avatar}}.jpg">
                </a>
            </div>
            <div class="card-body">
                <div class="mx-auto d-block">
                    <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 class="btn btn-block btn-secondary" href="/admin/profil">Profil</a>
                </div>
            </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
