@extends('layout.template')
@section('intitule')
    <h5 class="font-weight-medium text-uppercase mb-0">Statistiques : {{ $data['titre'] }}</h5>
@endsection

@section('breadcrumb')
    <li class="breadcrumb-item active" aria-current="page">Statistiques</li>
@endsection

@section('styles')
    <link href="{{ asset('assets/extra-libs/datatables.net-bs4/css/dataTables.bootstrap4.css') }}" rel="stylesheet">

    <link rel="stylesheet" type="text/css"
        href="{{ asset('assets/extra-libs/datatables.net-bs4/css/responsive.dataTables.min.css') }}">

    <link rel="stylesheet" href="{{ asset('assets/libs/apexcharts/dist/apexcharts.css') }}">

    <link href="{{ asset('assets/libs/morris.js/morris.css') }}" rel="stylesheet">
@endsection

@section('main')
    <div class="row justify-content-center mt-4" style="min-height: calc(85vh - 60px)">
        <div class="col-lg-12">
            <div class="" style=" background:#fff;">

                <div class="card-group py-5 mb-0 ">

                    <div class=" col-lg-3 col-sm-12 " style="border-right:1px solid rgba(120,130,140,.13);">
                        <div class="p-lg-3 p-2">
                            <div class="d-flex align-items-center">

                                <h3 class="mb-0 display-10"><i class="icon-people text-pulpe"></i></h3>

                                <div class="ms-2 container-sm ">
                                    <h2 class="fs-5 ">Effectif Total</h2>
                                    <div class="progress">
                                        <div class="progress-bar bg-cyan" role="progressbar" style="width: 100%"
                                            aria-valuenow="100" aria-valuemin="0" aria-valuemax="100"></div>
                                    </div>
                                </div>
                                <div class="ms-auto">
                                    <h2 class="display-7 mb-0">{{ $data['nb2'] }}</h2>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class=" col-lg-2 col-sm-12 " style="border-right:1px solid rgba(120,130,140,.13);">
                        <div class="p-lg-3 p-2">
                            <div class="d-flex align-items-center">

                                <h3 class="mb-0 display-10"><i class="icon-people text-pulpe"></i></h3>

                                <div class="ms-2 container-sm ">
                                    <h2 class="fs-5 ">Admis</h2>
                                    <div class="progress">
                                        <div class="progress-bar bg-success" role="progressbar"
                                            style="width: {{ $data['padmis'] }}%" aria-valuenow="0" aria-valuemin="0"
                                            aria-valuemax="100"></div>
                                    </div>
                                </div>
                                <div class="ms-auto">
                                    <h2 class="display-7 mb-0">{{ $data['nbadmis'] }}</h2>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class=" col-lg-2 col-sm-12 " style="border-right:1px solid rgba(120,130,140,.13);">
                        <div class="p-lg-3 p-2">
                            <div class="d-flex align-items-center">

                                <h3 class="mb-0 display-10"><i class="icon-people text-pulpe"></i></h3>

                                <div class="ms-2 container-sm ">
                                    <h2 class="fs-5">Enjambé</h2>
                                    <div class="progress">
                                        <div class="progress-bar bg-info" role="progressbar"
                                            style="width: {{ $data['penjambe'] }}%" aria-valuenow="0" aria-valuemin="0"
                                            aria-valuemax="100"></div>
                                    </div>
                                </div>
                                <div class="ms-auto">
                                    <h2 class="display-7 mb-0">{{ $data['nbenjambe'] }}</h2>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class=" col-lg-2 col-sm-12 " style="border-right:1px solid rgba(120,130,140,.13);">
                        <div class="p-lg-3 p-2">
                            <div class="d-flex align-items-center">

                                <h3 class="mb-0 display-10"><i class="icon-people text-pulpe"></i></h3>

                                <div class="ms-2 container-sm">
                                    <h2 class="fs-5">Redouble</h2>
                                    <div class="progress">
                                        <div class="progress-bar bg-warning" role="progressbar"
                                            style="width: {{ $data['predouble'] }}%" aria-valuenow="77.78"
                                            aria-valuemin="0" aria-valuemax="100"></div>
                                    </div>
                                </div>
                                <div class="ms-auto">
                                    <h2 class="display-7 mb-0">{{ $data['nbredouble'] }}</h2>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class=" col-lg-3 col-sm-12 " style="border-right:1px solid rgba(120,130,140,.13);">
                        <div class="p-lg-3 p-2">
                            <div class="d-flex align-items-center">

                                <h3 class="mb-0 display-10"><i class="icon-people text-pulpe"></i></h3>

                                <div class="ms-2 container-sm">
                                    <h2 class="fs-5">Exclu</h2>
                                    <div class="progress">
                                        <div class="progress-bar bg-danger" role="progressbar"
                                            style="width: {{ $data['pexclu'] }}%" aria-valuenow="22.22" aria-valuemin="0"
                                            aria-valuemax="100"></div>
                                    </div>
                                </div>
                                <div class="ms-auto">
                                    <h2 class="display-7 mb-0">{{ $data['nbexclu'] }}</h2>
                                </div>
                            </div>
                        </div>
                    </div>

                </div>
            </div>
            <div class="mt-5 ms-4">

                <h3>Statistiques Générales : {{ $data['nomUE'] }}</h3>
                <h4>Pourcentage de validation</h4>

                <div class="progress mt-2" style="height: 40px;">
                    <div class="progress-bar fs-6 bg-success" style="width: {{ $data['percentValide'] }}%;"
                        role="progressbar">
                        {{ $data['percentValide'] }}%[{{ $data['valide'] }}/{{ $data['valide'] + $data['invalide'] }}]
                    </div>
                </div>

                <div>
                    <h4>Pourcentage de non validation</h4>
                </div>

                <div class="progress mt-2" style="height: 40px;">
                    <div class="progress-bar fs-6 bg-danger" style="width: {{ $data['percentInvalide'] }}%;"
                        role="progressbar">
                        {{ $data['percentInvalide'] }}%[{{ $data['invalide'] }}/{{ $data['valide'] + $data['invalide'] }}]
                    </div>
                </div>

            </div>

            <div class="col-12 mt-5">

                <div class="container">
                    <div class="table-responsive">
                        <table
                            class="table table-striped table-bordered table-border table-hoverable table-white  no-footer"
                            id="datatable" cellpadding="10px">
                            <thead class="border-bottom">
                                <tr>
                                    <th>Num</th>
                                    <th>Matricule</th>
                                    <th>Nom &amp; Prénom</th>
                                    @foreach ($data['ecu'] as $ecu)
                                        <th align="center">{{ $ecu->intituleEcu }}</th>
                                    @endforeach
                                    <th>Moyenne</th>
                                    <th>Résultat</th>
                                </tr>
                            </thead>
                            <tbody>
                                @php
                                    $count = 0;
                                @endphp
                                @foreach ($data['selection'] as $student)
                                    @php
                                        $count++;
                                    @endphp
                                    <tr>
                                        <td>{{ $count }}</td>
                                        <td>{{ $student->matricule }}</td>
                                        <td>{{ $student->nomPrenom }}</td>
                                        @php
                                            $moyenne = 0;
                                            $Notes = App\Models\NoteEcu::selectRaw('code_ecu, noteEcu')
                                                ->where([['annee_acad', Session::get('RESULTAT_DATA')['RESULTAT_YEAR']->annee_acad], ['matricule', $student->matricule], ['idFiliere', $idFiliere], ['annee', $etudeYear], ['niveauFormation', $formation], ['code_unite', $code_unite]])
                                                ->orderBy('code_ecu')
                                                ->get();
                                        @endphp
                                        @foreach ($Notes as $note)
                                            @php
                                                $moyenne += $note->noteEcu;
                                            @endphp
                                            <td align="center">{{ $note->noteEcu }}</td>
                                        @endforeach
                                        <td>{{ App\Http\Helpers\AdditionalHelpers::myround($moyenne / $data['ecu']->count(), 2) }}
                                        </td>
                                        <td>{{ $student->resultat == 'A' ? 'Validé' : 'Non validé' }}</td>
                                    </tr>
                                @endforeach
                            </tbody>
                        </table>

                    </div>
                </div>
                <div class="col-sm-12">
                    <div class="">
                        <div class="card-body">
                            <div class="table-responsive">

                                {{-- <div class="ms-5 mb-4 mt-5">
                                    <h2>Option d'exportation :</h2>


                                </div> --}}
                            </div>

                        </div>

                    </div>
                </div>
            </div>
        </div>
    </div>
@endsection
@section('scripts')
    <script src="{{ asset('assets/extra-libs/datatables.net/js/jquery.dataTables.min.js') }}"></script>

    <script src="{{ asset('assets/extra-libs/datatables.net-bs4/js/dataTables.responsive.min.js') }}"></script>

    <script src="{{ asset('dist/js/pages/datatable/datatable-basic.init.js') }}"></script>

    <script>
        $(document).ready(function() {
            $('#datatable').DataTable();
        });
    </script>

    <script src="https://cdn.datatables.net/buttons/1.5.1/js/dataTables.buttons.min.js"></script>

    <script src="https://cdn.datatables.net/buttons/1.5.1/js/buttons.flash.min.js"></script>

    <script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.1.3/jszip.min.js"></script>

    <script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.32/pdfmake.min.js"></script>

    <script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.32/vfs_fonts.js"></script>

    <script src="https://cdn.datatables.net/buttons/1.5.1/js/buttons.html5.min.js"></script>

    <script src="https://cdn.datatables.net/buttons/1.5.1/js/buttons.print.min.js"></script>

    <script src="{{ asset('dist/js/pages/datatable/datatable-advanced.init.js') }}"></script>
    <script src="{{ asset('assets/libs/raphael/raphael.min.js') }}"></script>
@endsection
