
<?php $__env->startSection('content'); ?>
<main id="main" class="main">

    <div class="pagetitle">
      <h1>Absensi</h1>
      <nav>
        <ol class="breadcrumb">
          <li class="breadcrumb-item"><a>Dashboard</a></li>
          <li class="breadcrumb-item"><a>Presensi</a></li>
          <li class="breadcrumb-item active">Absensi</li>
        </ol>
      </nav>
    </div><!-- End Page Title -->

    <section class="section dashboard">
      <?php if(Session::get('msg')): ?>
      <div class="alert alert-success alert-dismissible fade show" role="alert">
          <i class="bi bi-check-circle me-1"></i>
                <?php echo e(Session::get('msg')); ?>

          <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
      </div>
      <?php endif; ?>


      <div class="row">
        <div class="col-lg-12">
          <div class="card">
            <div class="card-body">
                <h5 class="card-title">Data Absensi</h5>
                  <Button class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#addModal">
                    <i class="bi bi-plus"></i>
                      Tambah Data  
                  </Button>
                 <br>
                
                <form method="GET" action="<?php echo e(url('dashboard/absensi/trainer')); ?>" class="row g-3 mt-1">
                <?php echo csrf_field(); ?>
                <div class="col-auto">
                  <select name="month" id="month" class="form-select" required>
                    <?php
                      $currentMonth = $month ?? now()->format('m');
                      $months = [
                        '01' => 'Januari',
                        '02' => 'Februari',
                        '03' => 'Maret',
                        '04' => 'April',
                        '05' => 'Mei',
                        '06' => 'Juni',
                        '07' => 'Juli',
                        '08' => 'Agustus',
                        '09' => 'September',
                        '10' => 'Oktober',
                        '11' => 'November',
                        '12' => 'Desember'
                      ];
                    ?>
                    <?php $__currentLoopData = $months; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $key => $month): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                      <option value="<?php echo e($key); ?>" <?php echo e($currentMonth == $key ? 'selected' : ''); ?>><?php echo e($month); ?></option>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                  </select>
                </div>
                <div class="col-auto">
                  <select name="year" id="year" class="form-select" required>
                    <?php
                      $currentYear = $year ?? now()->format('Y');
                      $startYear = 2020; // Change as per your requirement
                      $endYear = $currentYear + 5; // Future years range
                    ?>
                    <?php for($year = $startYear; $year <= $endYear; $year++): ?>
                      <option value="<?php echo e($year); ?>" <?php echo e($currentYear == $year ? 'selected' : ''); ?>><?php echo e($year); ?></option>
                    <?php endfor; ?>
                  </select>
                </div>
                <div class="col-auto">
                  <button type="submit" class="btn btn-primary">Filter</button>
                </div>
              </form>
                
              
              <br>
              <br>
              <!-- Default Table -->
              <table class="table" id="table">
                <thead>
                  <tr>
                    <th scope="col">#</th>
                    <th scope="col">Waktu Latihan</th>
                    <th scope="col">Venue</th>
                    <th scope="col">Peserta</th>
                    <!-- <th scope="col">Foto</th> -->
                    <th scope="col">Status</th>
                    <th scope="col">Action</th>
                  </tr>
                </thead>
                <tbody>
                  <?php 
                    $i = 1;
                  ?>
                  <?php $__currentLoopData = $data; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $datas): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                  <tr>
                    <th scope="row"><?php echo e($i++); ?></th>
                    <td><?php echo e($datas->date); ?> <?php echo e($datas->time); ?> </td>
                    <td><?php echo e($datas->Venue ? $datas->Venue->name : ''); ?></td>
                    <?php if($datas->student_come == 0): ?>
                    <td><?php echo e($datas->student_name); ?><span class="badge bg-danger">tidak hadir</span></td>
                    <?php endif; ?>
                    <?php if($datas->student_come == 1): ?>
                    <td><?php echo e($datas->student_name); ?><span class="badge bg-success">hadir</span></td>
                    <?php endif; ?>
                    <!-- <td><img src="/<?php echo e($datas->image); ?>" alt="" title="" style="width:50px" /></td> -->
                    <?php if($datas->status == 0): ?>
                    <td><span class="badge bg-warning">menunggu verifikasi</span></td>
                    <?php endif; ?>
                    <?php if($datas->status == 1): ?>
                    <td><span class="badge bg-success">terverifikasi</span></td>
                    <?php endif; ?>
                    <?php if($datas->status == 2): ?>
                    <td><span class="badge bg-danger">ditolak</span></td>
                    <?php endif; ?>
                    <td>
                      <a href="/dashboard/absensi/detail/<?php echo e($datas->id); ?>" class="btn btn-secondary btn-sm" 
                        data-bs-toggle="tooltip" data-bs-placement="top" title="Detail">
                        <i class="bi bi-info-square"></i>
                      </a>
                      <?php if($datas->status == 0): ?>
                      <a href="" class="btn btn-warning btn-sm" data-bs-toggle="modal" data-bs-target="#editModal<?php echo e($datas->id); ?>" >
                        <i class="bi bi-pencil-square"></i>
                      </a>
                      
                      <a href="/dashboard/absensi/trainer/delete/<?php echo e($datas->id); ?>" class="btn btn-danger btn-sm" 
                        onclick="return confirm('Anda yakin ingin menghapus data?')" 
                        data-bs-toggle="tooltip" data-bs-placement="top" title="Hapus">
                        <i class="bi bi-trash"></i>
                      </a>
                      <?php endif; ?>
                    </td>
                  </tr>
                  <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>  
                </tbody>
              </table>
              <!-- End Default Table Example -->
            </div>
          </div>
        </div>
      </div>
    </section>

    <!-- Modal -->
    <div class="modal fade" id="addModal" tabindex="-1">
      <div class="modal-dialog">
        <div class="modal-content">
           <div class="card">
            <div class="card-body">
              <h5 class="card-title">Tambah Data</h5>

              <!-- Floating Labels Form -->
              <form class="row g-3" method="POST" action="/dashboard/absensi/trainer/add" enctype="multipart/form-data">
              <?php echo csrf_field(); ?>

                <div class="col-md-6">
                  <select name="venue_id" style="width: 100%" class="form-select select2" required="">
                    <option value="">-- Pilih Venue --</option>
                    <?php $__currentLoopData = $venue; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $venues): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                    <option value="<?php echo e($venues->id); ?>"><?php echo e($venues->name); ?></option>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                  </select>
                </div>
                <div class="col-md-6">
                  <select class="js-ortu-select2" class="form-select select2"name="group_type" style="width: 100%" required="">
                    <option value="">-- Kategori Latihan --</option>
                    <option value="0">Tunggal</option>
                    <option value="1">Grup</option>
                    <option value="2">Therapy</option>
                    <option value="3">Club</option>
                  </select>
                </div>
                <div class="col-md-12">
                  <div class="form-floating">
                    <input type="text" class="form-control" id="floatingName" placeholder="Nama Siswa" name="student_name" required="">
                    <label for="floatingName">Nama Peserta</label>
                  </div>
                </div>
                <div class="col-md-6">
                  <div class="form-floating">
                    <input type="date" class="form-control" id="floatingName" placeholder="Nama Siswa" name="date" required="">
                    <label for="floatingName">Tgl Latihan</label>
                  </div>
                </div>
                <div class="col-md-6">
                  <div class="form-floating">
                    <input type="time" class="form-control" id="floatingName" placeholder="Nama Siswa" name="time" required="">
                    <label for="floatingName">Jam Latihan</label>
                  </div>
                </div>
                 <div class="col-md-6">
                  <select class="js-ortu-select2" name="student_come" style="width: 100%" required="">
                    <option value="">-- Kehadiran Peserta --</option>
                    <option value="1">Hadir</option>
                    <option value="0">Tidak Hadir</option>
                  </select>
                </div>
                <!-- <div class="col-md-6">
                  <div class="form-floating">
                    <input type="file" class="form-control" id="floatingName" placeholder="Nama Siswa" name="image" required="">
                    <label for="floatingName">Foto Bukti Kehadiran</label>
                  </div>
                </div> -->
                <div>
                  <button type="submit" class="btn btn-primary" >Save</button>
                  <button type="reset" class="btn btn-secondary" data-bs-dismiss="modal">Cancel</button>
                </div>
              </form><!-- End floating Labels Form -->

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

    <?php $__currentLoopData = $data; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $datas): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
    <div class="modal fade" id="editModal<?php echo e($datas->id); ?>" tabindex="-1">
      <div class="modal-dialog">
        <div class="modal-content">
           <div class="card">
            <div class="card-body">
              <h5 class="card-title">Edit Data</h5>

              <!-- Floating Labels Form -->
              <form class="row g-3" method="POST" action="/dashboard/absensi/trainer/update" enctype="multipart/form-data">
              <?php echo csrf_field(); ?>

                <div class="col-md-6">
                  <input type="hidden" name="id" value="<?php echo e($datas->id); ?>">
                  <select name="venue_id" style="width: 100%">
                    <option value="">-- Pilih Venue --</option>
                    <?php $__currentLoopData = $venue; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $venues): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                      <?php if($datas->venue_id == $venues->id): ?>
                        <option value="<?php echo e($venues->id); ?>" selected=""><?php echo e($venues->name); ?></option>  
                      <?php endif; ?>
                      <?php if($datas->venue_id != $venues->id): ?>
                        <option value="<?php echo e($venues->id); ?>" ><?php echo e($venues->name); ?></option>  
                      <?php endif; ?>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                  </select>
                </div>
                <div class="col-md-6">
                  <select class="js-ortu-select2" name="group_type" style="width: 100%">
                    <?php if($datas->group_type == 0): ?>
                      <option value="0" selected="">Tunggal</option>
                      <option value="1">Grup</option>  
                      <option value="2">Therapy</option>
                      <option value="3">Club</option>
                    <?php endif; ?>
                    <?php if($datas->group_type == 1): ?>
                      <option value="1" selected="">Grup</option>  
                      <option value="0">Tunggal</option>
                        <option value="2">Therapy</option>
                      <option value="3">Club</option>
                    <?php endif; ?>
                    <?php if($datas->group_type == 2): ?>
                      <option value="1">Grup</option>  
                      <option value="0">Tunggal</option>
                        <option value="2" selected="">Therapy</option>
                      <option value="3">Club</option>
                    <?php endif; ?>
                    <?php if($datas->group_type == 3): ?>
                      <option value="1">Grup</option>  
                      <option value="0">Tunggal</option>
                        <option value="2">Therapy</option>
                      <option value="3" selected="">Club</option>
                    <?php endif; ?>
                  </select>
                </div>
                <div class="col-md-12">
                  <div class="form-floating">
                    <input type="text" class="form-control" id="floatingName" placeholder="Nama Siswa" name="student_name" value="<?php echo e($datas->student_name); ?>">
                    <label for="floatingName">Nama Peserta</label>
                  </div>
                </div>
                <div class="col-md-6">
                  <div class="form-floating">
                    <input type="date" class="form-control" id="floatingName" placeholder="Nama Siswa" name="date" value="<?php echo e($datas->date); ?>">
                    <label for="floatingName">Tgl Latihan</label>
                  </div>
                </div>
                <div class="col-md-6">
                  <div class="form-floating">
                    <input type="time" class="form-control" id="floatingName" placeholder="Nama Siswa" name="time" value="<?php echo e($datas->time); ?>">
                    <label for="floatingName">Jam Latihan</label>
                  </div>
                </div>
                <div class="col-md-6">
                  <select class="js-ortu-select2" name="student_come" style="width: 100%" required="">
                    <option value="">-- Kehadiran Peserta --</option>
                    <?php if($datas->student_come == 1): ?>
                    <option value="1" selected="">Hadir</option>
                    <option value="0">Tidak Hadir</option>
                    <?php endif; ?>
                    <?php if($datas->student_come == 0): ?>
                    <option value="1">Hadir</option>
                    <option value="0" selected="">Tidak Hadir</option>
                    <?php endif; ?>
                    
                  </select>
                </div>
                <div>
                  <button type="submit" class="btn btn-primary" >Update</button>
                  <button type="reset" class="btn btn-secondary" data-bs-dismiss="modal">Cancel</button>
                </div>
              </form><!-- End floating Labels Form -->

            </div>
          </div>
        </div>
      </div>
    </div>
    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>


  </main><!-- End #main -->
<?php $__env->stopSection(); ?>
<?php echo $__env->make('dashboard.layout', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH /home/tpsm5646/public_html/tpscmalang.com/tpscmalang/resources/views/dashboard/trainer/absensi.blade.php ENDPATH**/ ?>