

<?php $__env->startSection('title', 'Data User'); ?>

<?php $__env->startSection('content'); ?>
    <div class="page-content">
        <nav class="page-breadcrumb">
            <ol class="breadcrumb">
                <li class="breadcrumb-item"><a href="<?php echo e(route('dashboard')); ?>">Dashboard</a></li>
                <li class="breadcrumb-item active" aria-current="page">Data User</li>
            </ol>
        </nav>
        <div class="row">
            <div class="col-md-12 grid-margin stretch-card">
                <div class="card">
                    <div class="card-body">
                        <h1 class="card-title">Data User</h1>
                        <a href="<?php echo e(route('user.create')); ?>" class="btn btn-primary mb-3">
                            <i class="fa fa-plus"></i> Tambah User
                        </a>

                        <?php if(session('message')): ?>
                            <div class="alert alert-<?php echo e(session('alert-type')); ?> alert-dismissible fade show" role="alert">
                                <?php echo e(session('message')); ?>

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

                        <div class="table-responsive">
                            <table class="table table-bordered table-striped table-sm">
                                <thead>
                                    <tr>
                                        <th>No</th>
                                        <th>Email</th>
                                        <th>Nama</th>
                                        <th>Nama Kampus</th>
                                        <th>Gambar</th>
                                        <th>Masa Aktif</th>
                                        <th>Status</th>
                                        <th>Aksi</th>
                                    </tr>
                                </thead>
                                <tbody>
                                    <?php $__empty_1 = true; $__currentLoopData = $user; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $users => $index): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                                        <tr>
                                            <td><?php echo e(($user->currentPage() - 1) * $user->perPage() + $users + 1); ?></td>
                                            <td><?php echo e($index->email); ?></td>
                                            <td><?php echo e($index->name); ?></td>
                                            <td><?php echo e($index->kampus ?? '-'); ?></td>
                                            <td>
                                                <?php if($index->gambar): ?>
                                                    <img src="<?php echo e(asset('storage/userImage/' . $index->gambar)); ?>"
                                                        alt="gambar"
                                                        style="width: 50px; height: 50px; object-fit: cover; border-radius: 5px;">
                                                <?php else: ?>
                                                    <span class="text-muted">Tidak Ada</span>
                                                <?php endif; ?>
                                            </td>
                                            <td>
                                                <?php if($index->masa_aktif): ?>
                                                    <?php echo e(\Carbon\Carbon::parse($index->masa_aktif)->format('d/m/Y')); ?>

                                                    <?php if($index->getSisaHariAktif() !== null): ?>
                                                        <br>
                                                        <small class="text-muted">Sisa: <?php echo e($index->getSisaHariAktif()); ?> hari</small>
                                                    <?php endif; ?>
                                                <?php else: ?>
                                                    <span class="badge bg-info">Tidak Terbatas</span>
                                                <?php endif; ?>
                                            </td>
                                            <td>
                                                <?php if($index->isActive()): ?>
                                                    <span class="badge bg-success">Aktif</span>
                                                <?php else: ?>
                                                    <span class="badge bg-danger">Kadaluarsa</span>
                                                <?php endif; ?>
                                            </td>
                                            <td>
                                                <?php if(Auth::id() !== $index->id && $index->id !== 1): ?>
                                                    <form action="<?php echo e(route('user.delete', $index->id)); ?>" method="POST"
                                                        style="display:inline-block;">
                                                        <?php echo csrf_field(); ?>
                                                        <?php echo method_field('DELETE'); ?>
                                                        <button class="btn btn-danger btn-sm"
                                                            onclick="return confirm('Apakah Anda yakin ingin menghapus user ini?')">
                                                            <i class="fa fa-trash"></i> Hapus
                                                        </button>
                                                    </form>
                                                    
                                                    <!-- Tombol Perpanjang 6 Bulan -->
                                                    <form action="<?php echo e(route('user.extend.masa_aktif', $index->id)); ?>" method="POST"
                                                        style="display:inline-block;">
                                                        <?php echo csrf_field(); ?>
                                                        <?php echo method_field('PUT'); ?>
                                                        <button type="submit" class="btn btn-success btn-sm mt-1"
                                                            onclick="return confirm('Perpanjang masa aktif user ini 6 bulan?')">
                                                            <i class="fa fa-clock-o"></i> Perpanjang
                                                        </button>
                                                    </form>
                                                <?php elseif($index->id === 1): ?>
                                                    <span class="badge bg-warning">Admin Utama</span>
                                                <?php else: ?>
                                                    <span class="badge bg-secondary">Akun Sendiri</span>
                                                <?php endif; ?>
                                            </td>
                                        </tr>
                                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                                        <tr>
                                            <td colspan="8" class="text-center">Tidak ada data user</td>
                                        </tr>
                                    <?php endif; ?>
                                </tbody>
                            </table>
                        </div>
                    </div>
                    <div class="mt-3 px-3">
                        <?php echo e($user->links('vendor.pagination.simple-bootstrap-5')); ?>

                    </div>
                </div>
            </div>
        </div>
    </div>
<?php $__env->stopSection(); ?>
<?php echo $__env->make('dashboard.app', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH /home/edunesiaserver/public_html/K2/WEB_KAMPUS/JAKARTA/ISTA-ALKAMAL/WEB/resources/views/admin/user/index.blade.php ENDPATH**/ ?>