@extends('layouts.backend.masterapp')
@section('title', 'Dashboard')
@section('content')
<section class="row">
        <div class="col-12 col-lg-12">
            <div class="row">
                <div class="col-6 col-lg-3 col-md-6">
                    {{-- <div class="card">
                        <div class="card-body px-3 py-4-5"> --}}
                            <form action="{{ route('dashboard.index') }}" method="GET" id="form-filter">
                                <div class="form-group">
                                    <label for="basicInput">Periode</label>
                                    <select onchange="filterPeriode()" class="form-control" name="periode" id="select-periode">
                                        <option value="">Semua</option>
                                        @foreach ($ms_periode as $item)
                                            <option value="{{ encrypt($item->id) }}" {{ $item->id == $periode ? 'selected' : '' }}>{{ $item->nama }}</option>
                                        @endforeach
                                    </select>
                                </div>
                            </form>
                        {{-- </div>
                    </div> --}}
                </div>
            </div>
            <br>
            <div class="row">
                <div class="col-6 col-lg-3 col-md-6">
                    <div class="card">
                        <div class="card-body px-3 py-4-5">
                            <div class="row">
                                {{-- <div class="col-md-4">
                                    <div class="stats-icon purple">
                                        <span class="fa-fw select-all fas"></span>
                                    </div>
                                </div> --}}
                                <div class="col-md-8">
                                    <h6 class="text-muted font-semibold">Jumlah Semua Pendaftar </h6>
                                    <h6 class="font-extrabold mb-0">{{ $semua_pendaftar }}</h6>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="col-6 col-lg-3 col-md-6">
                    <div class="card">
                        <div class="card-body px-3 py-4-5">
                            <div class="row">
                                <div class="col-md-8">
                                    <h6 class="text-muted font-semibold">Jumlah Pendaftar Konfirmasi</h6>
                                    <h6 class="font-extrabold mb-0">{{ $pendaftar_konfirmasi }}</h6>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="col-6 col-lg-2 col-md-6">
                    <div class="card">
                        <div class="card-body px-3 py-4-5">
                            <div class="row">
                                <div class="col-md-12">
                                    <h6 class="text-muted font-semibold">Jumlah Pendaftar Diterima</h6>
                                    <h6 class="font-extrabold mb-0">{{ $pendaftar_validasi }}</h6>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="col-6 col-lg-2 col-md-6">
                    <div class="card">
                        <div class="card-body px-3 py-4-5">
                            <div class="row">
                                <div class="col-md-12">
                                    <h6 class="text-muted font-semibold">Jumlah Pendaftar Ditolak</h6>
                                    <h6 class="font-extrabold mb-0">{{ $pendaftar_tolak }}</h6>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="col-6 col-lg-2 col-md-6">
                    <div class="card">
                        <div class="card-body px-3 py-4-5">
                            <div class="row">
                                <div class="col-md-12">
                                    <h6 class="text-muted font-semibold">Jumlah Pendaftar Belum Divalidasi</h6>
                                    <h6 class="font-extrabold mb-0">{{ $pendaftar_belum_validasi }}</h6>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="col-6 col-lg-6 col-md-6">
                    <div class="card">
                        <div class="card-header">
                            <h4>Jumlah Pendaftar Berdasarkan Formasi</h4>
                        </div>
                        <div class="card-body px-3 py-4-5">
                            <div id="chart-formasi">

                            </div>
                        </div>
                    </div>
                </div>
                <div class="col-6 col-lg-6 col-md-6">
                    <div class="card">
                        <div class="card-header">
                            <h4>Jumlah Pendaftar Berdasarkan Jenis Formasi</h4>
                        </div>
                        <div class="card-body px-3 py-4-5">
                            <div id="chart-jenis-formasi">

                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
</section>
@endsection
@push('js')
    <script>
        function filterPeriode(){
            $('#form-filter').submit();
        }
    </script>
    <script>
        let jenisFormasiOptions  = {
            series: [
                @foreach ($jenis_formasi as $key => $item)
                    {{ $item->count() }}
                    @if(!$loop->last)
                    ,
                    @endif
                @endforeach
            ],
            labels: [
                @foreach ($jenis_formasi as $key => $item)
                    "{{ $key }}"
                    @if(!$loop->last)
                    ,
                    @endif
                @endforeach
            ],
            colors: ['#435ebe','#55c6e8'],
            chart: {
                type: 'donut',
                width: '100%',
                height:'350px'
            },
            legend: {
                position: 'bottom'
            },
            plotOptions: {
                pie: {
                    donut: {
                        size: '30%'
                    }
                }
            }
        }
        var formasiOptions = {
            annotations: {
                position: 'back'
            },
            dataLabels: {
                enabled:false
            },
            chart: {
                type: 'bar',
                height: 300
            },
            fill: {
                opacity:1
            },
            plotOptions: {
            },
            series: [{
                name: 'Jumlah',
                data: [
                    @foreach ($formasi as $key => $item)
                        {{ $item->count() }}
                        @if(!$loop->last)
                        ,
                        @endif
                    @endforeach
                ]
            }],
            colors: '#435ebe',
            xaxis: {
                categories: [
                    @foreach ($formasi as $key => $item)
                        "{{ $key }}"
                        @if(!$loop->last)
                        ,
                        @endif
                    @endforeach
                ],
            },
        }
        var formasiChart = new ApexCharts(document.querySelector("#chart-formasi"), formasiOptions);
        var jenisFormasiChart = new ApexCharts(document.querySelector("#chart-jenis-formasi"), jenisFormasiOptions);
        formasiChart.render();
        jenisFormasiChart.render();
    </script>
@endpush
