@extends('layout.app')

@section('title', 'Dashboard')

<script type="text/javascript" src="{{ asset('js/jquery.min.js') }}"></script>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script type="text/javascript">
    $(document).ready(function () {
        setInterval(function() {
            $.get("{{ url('bacamasuk') }}", function(data) {
                $('#masuk .h5').text(data.nilaivisitor); // Mengupdate data 'masuk'
            }).fail(function(jqXHR, textStatus, errorThrown) {
                console.error("Error in bacamasuk request:", textStatus, errorThrown);
            });

            $.get("{{ url('bacakeluar') }}", function(data) {
                $('#keluar .h5').text(data.nilaikeluar); // Mengupdate data 'keluar'
            }).fail(function(jqXHR, textStatus, errorThrown) {
                console.error("Error in bacakeluar request:", textStatus, errorThrown);
            });

            $.get("{{ url('bacatotal') }}", function(data) {
                $('#total .h5').text(data.nilaitotal); // Mengupdate data 'total'
            }).fail(function(jqXHR, textStatus, errorThrown) {
                console.error("Error in bacatotal request:", textStatus, errorThrown);
            });
        }, 1000);
    });
</script>


@section('content')

<!-- Content Row -->
<div class="row">

   <!-- Masuk Card -->
   <div class="col-xl-3 col-md-6 mb-4">
       <div class="card border-left-primary shadow h-100 py-2" style="height: 150px;">
           <div class="card-body">
               <div class="row no-gutters align-items-center">
                   <div class="col mr-2">
                       <span id="masuk">
                           <div class="text-xs font-weight-bold text-primary text-uppercase mb-1">
                               Pengunjung Masuk(in)
                           </div>
                           <div class="h5 mb-0 font-weight-bold text-gray-800">{{ $nilaivisitor }}</div>
                       </span>
                   </div>
                   <div class="col-auto">
                       <i class="fas fa-users fa-2x text-gray-300"></i>
                   </div>
               </div>
           </div>
       </div>
   </div>

   <!-- Keluar Card -->
   <div class="col-xl-3 col-md-6 mb-4">
       <div class="card border-left-primary shadow h-100 py-2" style="height: 150px;">
           <div class="card-body">
               <div class="row no-gutters align-items-center">
                   <div class="col mr-2">
                       <span id="keluar">
                           <div class="text-xs font-weight-bold text-primary text-uppercase mb-1">
                               Pengunjung Keluar(out)
                           </div>
                           <div class="h5 mb-0 font-weight-bold text-gray-800">{{ $nilaikeluar }}</div>
                       </span>
                   </div>
                   <div class="col-auto">
                       <i class="fas fa-users fa-2x text-gray-300"></i>
                   </div>
               </div>
           </div>
       </div>
   </div>

   <!-- Total Card -->
   <div class="col-xl-3 col-md-6 mb-4">
       <div class="card border-left-primary shadow h-100 py-2" style="height: 150px;">
           <div class="card-body">
               <div class="row no-gutters align-items-center">
                   <div class="col mr-2">
                       <span id="total">
                           <div class="text-xs font-weight-bold text-primary text-uppercase mb-1">
                               Total Pengunjung
                           </div>
                           <div class="h5 mb-0 font-weight-bold text-gray-800">{{ $nilaitotal }}</div>
                       </span>
                   </div>
                   <div class="col-auto">
                       <i class="fas fa-users fa-2x text-gray-300"></i>
                   </div>
               </div>
           </div>
       </div>
   </div>

</div>

@endsection
