Anons79 Mini Shell

Directory : /home/aplikasiposinfo/public_html/demo-absensi.aplikasipos.info/resources/views/
Upload File :
Current File : /home/aplikasiposinfo/public_html/demo-absensi.aplikasipos.info/resources/views/dashboard.blade.php

@extends('layouts.app')
@push('styles')
    <style>
        .lds-ripple {
            display: inline-block;
            position: relative;
            width: 80px;
            height: 80px;
        }

        .lds-ripple div {
            position: absolute;
            border: 4px solid #696cff;
            opacity: 1;
            border-radius: 50%;
            animation: lds-ripple 1s cubic-bezier(0, 0.2, 0.8, 1) infinite;
        }

        .lds-ripple div:nth-child(2) {
            animation-delay: -0.5s;
        }

        @keyframes lds-ripple {
            0% {
                top: 36px;
                left: 36px;
                width: 0;
                height: 0;
                opacity: 0;
            }

            4.9% {
                top: 36px;
                left: 36px;
                width: 0;
                height: 0;
                opacity: 0;
            }

            5% {
                top: 36px;
                left: 36px;
                width: 0;
                height: 0;
                opacity: 1;
            }

            100% {
                top: 0px;
                left: 0px;
                width: 72px;
                height: 72px;
                opacity: 0;
            }
        }
    </style>
@endpush
@section('content')
    <div class="row">
        @if (auth()->user()->roles[0]->id == 1)
            <div class="col-lg-8 mb-4 order-0">
                <div class="card">
                    <div class="card-body">
                        <div style="display: flex; column-gap: 6px;">
                            <h5 class="card-title text-primary">Informasi Server</h5> <small>(ter-update tiap 60 menit)</small>
                        </div>
                        <div class="row">
                            <div class="col-md-4">
                                
                                <ul>
                                    <li>
                                        Waktu Server : {{ date('d F Y H:i:s') }}
                                    </li>
                                    <li>
                                        CPU Usage : <span id="cpu_usage">Loading...</span>
                                    </li>
                                    <li>
                                        Total Foto : <span id="total_foto">Loading...</span>
                                    </li>
                                    <li>
                                        Jumlah Foto : <span id="jumlah_foto">Loading...</span>
                                    </li>
                                    <li>
                                        Total Database : <span id="total_db">Loading...</span>
                                    </li>
                                </ul>
                            </div>
                            <div class="col-md-4" style="position: relative;height: 260px;">
                               
                                <canvas id="memoryChart"></canvas>
                            </div>
                            <div class="col-md-4" style="position: relative;height: 260px;">
                               
                                <canvas id="diskChart"></canvas>
                            </div>
                        </div>


                    </div>
                </div>
            </div>
        @else
            <div class="col-lg-8 mb-4 order-0">
                <div class="card">
                    <div class="d-flex align-items-end row">
                        <div class="col-sm-7">
                            <div class="card-body">
                                <h5 class="card-title text-primary">Welcome {{ auth()->user()->nama }}! 🎉</h5>

                            </div>
                        </div>
                        <div class="col-sm-5 text-center text-sm-left">
                            <div class="card-body pb-0 px-0 px-md-4">
                                <img src="{{ asset('/') }}/assets/img/illustrations/man-with-laptop-light.png"
                                    height="140" alt="View Badge User"
                                    data-app-dark-img="illustrations/man-with-laptop-dark.png"
                                    data-app-light-img="illustrations/man-with-laptop-light.png" />
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        @endif

        <div class="col-lg-4 col-md-4 order-1">
            <div class="row">
                <div class="col-lg-6 col-md-12 col-6 mb-4">
                    <div class="card">
                        <div class="card-body">
                            <div class="card-title d-flex align-items-start justify-content-between">
                                <div class="avatar flex-shrink-0">
                                    <i class="bx bx-building-house"></i>
                                </div>
                                <div class="dropdown">
                                    <button class="btn p-0" type="button" id="cardOpt3" data-bs-toggle="dropdown"
                                        aria-haspopup="true" aria-expanded="false">
                                        <i class="bx bx-dots-vertical-rounded"></i>
                                    </button>
                                    <div class="dropdown-menu dropdown-menu-end" aria-labelledby="cardOpt3">
                                        <a class="dropdown-item" href="{{route('perusahaan.index')}}">View
                                            More</a>
                                       
                                    </div>
                                </div>
                            </div>
                            <span class="fw-semibold d-block mb-1">Perusahaan</span>
                            <h3 class="card-title mb-2">{{ $jumlahPerusahaan }}</h3>

                        </div>
                    </div>
                </div>
                <div class="col-lg-6 col-md-12 col-6 mb-4">
                    <div class="card">
                        <div class="card-body">
                            <div class="card-title d-flex align-items-start justify-content-between">
                                <div class="avatar flex-shrink-0">
                                    <i class="bx bx-user"></i>
                                </div>
                                <div class="dropdown">
                                    <button class="btn p-0" type="button" id="cardOpt6" data-bs-toggle="dropdown"
                                        aria-haspopup="true" aria-expanded="false">
                                        <i class="bx bx-dots-vertical-rounded"></i>
                                    </button>
                                    <div class="dropdown-menu dropdown-menu-end" aria-labelledby="cardOpt6">
                                        <a class="dropdown-item" href="{{route('karyawan.index')}}">View
                                            More</a>
                                       
                                    </div>
                                </div>
                            </div>
                            <span>Karyawan</span>
                            <h3 class="card-title text-nowrap mb-1">{{ $jumlahKaryawan }}</h3>

                        </div>
                    </div>
                </div>
                <div class="col-lg-6 col-md-12 col-6 mb-4">
                    <div class="card">
                        <div class="card-body">
                            <div class="card-title d-flex align-items-start justify-content-between">
                                <div class="avatar flex-shrink-0">
                                    <i class="bx bx-user"></i>
                                </div>
                                <div class="dropdown">
                                    <button class="btn p-0" type="button" id="cardOpt6" data-bs-toggle="dropdown"
                                        aria-haspopup="true" aria-expanded="false">
                                        <i class="bx bx-dots-vertical-rounded"></i>
                                    </button>
                                    <div class="dropdown-menu dropdown-menu-end" aria-labelledby="cardOpt6">
                                        <a class="dropdown-item" href="{{route('departemen.index')}}">View
                                            More</a>
                                    </div>
                                </div>
                            </div>
                            <span>Departemen</span>
                            <h3 class="card-title text-nowrap mb-1">{{ $jumlahDepartemen }}</h3>

                        </div>
                    </div>
                </div>
            </div>
        </div>


    </div>
    <div class="row">
        <div class="col-lg mb-4 order-0">
            <div class="card">
                <div class="d-flex align-items-end row">
                    <div class="col-sm-12">
                        <div class="card-body">
                            <h5 class="card-title text-primary">Absensi Terbaru</h5>
                            <form class="form row" action="">
                                <div class="col-md-10">
                                    <input type="text" class="form-control" placeholder="Search..."
                                        aria-label="Search" name="search" value="{{ request()->search }}">
                                </div>
                                <div class="col-md-2">
                                    <button class="btn btn-secondary">Search</button>
                                </div>
                            </form>
                            <div class="table-responsive text-nowrap">

                                <table class="table" id="table">
                                    <thead>
                                        <tr>
                                            <th>NIK</th>
                                            <th>Karyawan</th>
                                            <th>Departemen</th>
                                            <th>Jabatan</th>
                                            <th>Perusahaan</th>
                                            <th>Jenis</th>
                                            <th>Jam</th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                        @foreach ($riwayatAbsensis as $riwayatAbsensi)
                                            <tr>
                                                <td>{{ $riwayatAbsensi->absensi->karyawan->nik }}</td>
                                                <td>{{ $riwayatAbsensi->absensi->karyawan->nama }}</td>
                                                <td>{{ @$riwayatAbsensi->absensi->karyawan->departemen->nama_departemen }}
                                                </td>
                                                <td>{{ @$riwayatAbsensi->absensi->karyawan->jabatan }}</td>
                                                {{-- <td>
                                                    {{ @$riwayatAbsensi->absensi->karyawan->perusahaan->nama_perusahaan }}
                                                </td> --}}
                                                <td>
                                                    {{($riwayatAbsensi->absensi->karyawan->perusahaans->count() > 0)?implode(", ",$riwayatAbsensi->absensi->karyawan->perusahaans->pluck('nama_perusahaan')->toArray()):""}}
                                                </td>
                                                <td>{{ $riwayatAbsensi->jenis_absen }}</td>
                                                <td>{{ $riwayatAbsensi->waktu_absen }}</td>
                                            </tr>
                                        @endforeach
                                    </tbody>
                                    <tfoot>
                                        <tr>
                                            <td colspan="{{ 7 }}">
                                                {{ $riwayatAbsensis->appends(request()->query())->links() }}
                                            </td>
                                        </tr>
                                    </tfoot>
                                </table>

                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>

    </div>

    <div class="row">
        <div class="col-md-12 py-4" id="error-result">

        </div>
    </div>
    <div class="row">
        <div class="col-lg mb-4 order-0">
            <div class="card">
                <div class="card-body">
                    <div class="row">
                        <div class="col-sm-12">
                            <div class="card-body">
                                <h5 class="card-title text-primary">Jumlah Absensi Per Departemen</h5>
                                <div class="table-responsive text-nowrap">
                                    <center>
                                        <div class="lds-ripple">
                                            <div></div>
                                            <div></div>
                                        </div>
                                    </center>
                                    <canvas id="myChart" height="300" style="width: 100%"></canvas>

                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="row">
                        <div class="col-sm-12">
                            <div class="card-body">
                                <h5 class="card-title text-primary">Jumlah Absensi Hari Ini (<span
                                        id="jumlahAbsenHariIni">0</span>)
                                </h5>
                                <div class="table-responsive text-nowrap">
                                    <center>
                                        <div class="lds-ripple">
                                            <div></div>
                                            <div></div>
                                        </div>
                                    </center>
                                    <canvas id="jumlahAbsenChart" height="300" style="width: 100%"></canvas>

                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>

    </div>



    {{-- <div class="row">
        <div class="col-lg mb-4 order-0"">
            <div class="card">
                <div class="d-flex align-items-end row">
                    <div class="col-sm-12">
                        <div class="card-body">
                            <h5 class="card-title text-primary">Jumlah Absensi</h5>
                            <div class="table-responsive text-nowrap">
                                <canvas id="myChart" height="300" style="width: 100%"></canvas>

                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>

    </div> --}}
@endsection

@push('scripts')
    <script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/3.8.0/chart.min.js"></script>
    <script>
        const url = "{{ url('chart') }}";

        //ajax url as html
        $.ajax({
            url: url,
            type: "GET",

            success: function(response) {
                try {
                    const data = response;

                    // sum value in array data[0][0] to #jumlahAbsenHariIni
                    $('#jumlahAbsenHariIni').html(data[0][0].reduce((a, b) => a + b, 0));
                    const ctx = document.getElementById('myChart').getContext('2d');
                    const myChart = new Chart(ctx, {
                        type: 'bar',
                        data: {
                            datasets: [{
                                    label: 'Absensi hari ini',
                                    data: data[0][0],
                                    backgroundColor: [
                                        'rgba(140,202,50, 0.5)',

                                    ],
                                    borderColor: [
                                        'rgb(53,194,0)',

                                    ],
                                    borderWidth: 1
                                },
                                {
                                    label: 'Absensi bulan ini',
                                    data: data[0][1],
                                    backgroundColor: [
                                        'rgba(255, 159, 64, 0.2)',

                                    ],
                                    borderColor: [
                                        'rgb(255, 159, 64)',

                                    ],
                                    borderWidth: 1
                                },
                                {
                                    label: 'Tidak absen hari ini',
                                    data: data[0][2],
                                    backgroundColor: [
                                        'rgba(220,53,69, 0.5)',

                                    ],
                                    borderColor: [
                                        'rgb(196,16,72)',

                                    ],
                                    borderWidth: 1
                                }
                            ],

                            labels: data[1],

                        },
                        options: {
                            scales: {
                                y: {
                                    beginAtZero: true
                                }
                            }
                        },

                    });

                    const ctx2 = document.getElementById('jumlahAbsenChart').getContext('2d');
                    const myChart2 = new Chart(ctx2, {
                        type: 'bar',
                        data: {
                            labels: data[1],
                            datasets: [{
                                label: 'Absensi hari ini',
                                data: data[0][0],
                                backgroundColor: [
                                    'rgba(140,202,50, 0.5)',

                                ],
                                borderColor: [
                                    'rgb(53,194,0)',

                                ],
                                borderWidth: 1
                            }]
                        }
                    });
                } catch (e) {
                    $('#error-result').html(`Error: ${e}`);
                }

                //hide all loading
                $('.lds-ripple').hide();
            },
            error: function(e) {
                $('#error-result').html("Error " + e.status + ": " + e.statusText);
            }
        });

        $.ajax({
            url: "{{ url('disk-info') }}",
            type: "GET",

            success: function(response) {
                const data = response.data;
                document.getElementById('jumlah_foto').innerHTML = data.jumlahFoto;
                document.getElementById('total_foto').innerHTML = data.totalFoto+" GB";
                document.getElementById('total_db').innerHTML = data.totalDB+" MB";
                document.getElementById('cpu_usage').innerHTML = data.cpuUsage+" %";
                const ctx = document.getElementById('diskChart').getContext('2d');
                new Chart(ctx, {
                    type: 'pie',
                    data: {
                        labels: ['Used Space', 'Free Space'],
                        datasets: [{
                            data: [data.used, data.free],
                            backgroundColor: ['#FF6384', '#36A2EB']
                        }]
                    },
                    options: {
                        responsive: true,
                        plugins: {
                            title: {
                                display: true,
                                text: `Total Disk Space: ${data.total} GB`
                            },
                            tooltip: {
                                callbacks: {
                                    
                                    label: function(context) {
                                        let label = context.dataset.label || '';
                                        if (label) {
                                            label += ': ';
                                        }
                                        label += context.dataset.data[context.dataIndex] + ' GB';
                                        return label;
                                    }
                                }
                            }
                        }
                    }
                });

                const ctx2 = document.getElementById('memoryChart').getContext('2d');
                new Chart(ctx2, {
                    type: 'pie',
                    data: {
                        labels: ['Used Memory', 'Free Memory'],
                        datasets: [{
                            data: [data.usedMemory, data.freelMemory],
                            backgroundColor: ['#FF6384', '#36A2EB']
                        }]
                    },
                    options: {
                        responsive: true,
                        plugins: {
                            title: {
                                display: true,
                                text: `Total Memory: ${data.totalMemory} GB`
                            },
                            tooltip: {
                                callbacks: {
                                    
                                    label: function(context) {
                                        let label = context.dataset.label || '';
                                        if (label) {
                                            label += ': ';
                                        }
                                        label += context.dataset.data[context.dataIndex] + ' GB';
                                        return label;
                                    }
                                }
                            }
                        }
                    }
                });
            },
            error: function(e) {
                document.getElementById('jumlah_foto').innerHTML = "Error";
                document.getElementById('total_foto').innerHTML = "Error";
                document.getElementById('total_db').innerHTML = "Error";
                document.getElementById('cpu_usage').innerHTML = "Error";
            }
        });
    </script>
@endpush

Anons79 File Manager Version 1.0, Coded By Anons79
Email: [email protected]