<?php $__env->startSection('title', 'Pelanggan'); ?>
<?php $__env->startSection('active7', 'active'); ?>
<?php $__env->startSection('menu1', 'open'); ?>
<?php $__env->startSection('content'); ?>
    <div class="content-wrapper">
        <div class="container-xxl flex-grow-1 container-p-y">
            <!-- Invoice List Table -->
            <div class="card">
                <div class="header-menu d-flex justify-content-between align-items-center">
                    <h3 class="card-header">Data Pelanggan</h3>
                    <button type="button" class="btn btn-primary me-2" data-bs-toggle="modal"
                        data-bs-target="#staticBackdrop"><i class="bx bx-plus bx-sm"></i> Add</button>
                </div>


                <div class="table-responsive">
                    <table class="table table-hover" id="Mytable">
                        <thead class="table-primary text-center">
                            <tr>
                                <th scope="col">Foto</th>
                                <th scope="col">Laundry</th>
                                <th scope="col">Username</th>
                                <th scope="col">Email</th>
                                <th scope="col">No Telp</th>
                                <th scope="col">nama</th>
                                <th scope="col">Alamat</th>
                                <th scope="col">Status</th>
                                <th scope="col">Action</th>
                            </tr>
                        </thead>
                        <tbody>
                            <?php $__currentLoopData = $pelanggan; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $pelanggan): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                <tr>
                                    <td>
                                        <img src="<?php echo e($pelanggan->foto ? asset('storage/img/' . $pelanggan->foto) : asset('default-avatar.png')); ?>"
                                            alt="Foto Pegawai" width="50px" height="50px">
                                    </td>

                                    <td><?php echo e($pelanggan->laundry->nama_laundry); ?></td>
                                    <td><?php echo e($pelanggan->user->username); ?></td>
                                    <td><?php echo e($pelanggan->user->email); ?></td>
                                    <td><?php echo e($pelanggan->no_telp); ?></td>
                                    <td><?php echo e($pelanggan->nama); ?></td>
                                    <td><?php echo e($pelanggan->alamat); ?></td>
                                    <td>
                                        <?php if(Auth::user()->role == 'admin'): ?>
                                            <?php if($pelanggan->pegawai_status == 'aktif'): ?>
                                                <span class="badge bg-label-success me-1">Aktif</span>
                                            <?php elseif($pelanggan->status == 'tidak aktif'): ?>
                                                <span class="badge bg-label-danger me-1">Tidak Aktif</span>
                                            <?php endif; ?>
                                        <?php else: ?>
                                            <?php if($pelanggan->status == 'aktif'): ?>
                                                <span class="badge bg-label-success me-1">Aktif</span>
                                            <?php elseif($pelanggan->status == 'tidak aktif'): ?>
                                                <span class="badge bg-label-danger me-1">Tidak Aktif</span>
                                            <?php endif; ?>
                                        <?php endif; ?>
                                    </td>
                                    <td>
                                        <a href="<?php echo e(route('pelanggan.edit', $pelanggan->user->id)); ?>"
                                            class="btn btn-sm btn-label-secondary"> <i class="bx bx-edit-alt"></i></a>

                                        <form action="<?php echo e(route('pelanggan.aktifasi', $pelanggan->id)); ?>" method="POST">
                                            <?php echo csrf_field(); ?>

                                            <?php if($pelanggan->status == 'aktif'): ?>
                                                <button type="submit" class="btn btn-sm btn-label-danger"
                                                    onclick="return confirm('Apakah anda yakin ingin menonaktifkan akun ini?')">
                                                    <i class="bx bx-user-x bx-sm"></i>
                                                </button>
                                            <?php elseif($pelanggan->status == 'tidak aktif'): ?>
                                                <button type="submit" class="btn btn-sm btn-label-success"
                                                    onclick="return confirm('Apakah anda yakin ingin mengaktifkan akun ini?')">
                                                    <i class="bx bx-user-check bx-sm"></i>
                                                </button>
                                            <?php endif; ?>
                                        </form>
                                    </td>
                                </tr>
                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                        </tbody>
                    </table>
                </div>

            </div>
            <!-- Modal -->
            <div class="modal fade" id="staticBackdrop" data-bs-backdrop="static" data-bs-keyboard="false" tabindex="-1"
                aria-labelledby="staticBackdropLabel" aria-hidden="true">
                <div class="modal-dialog modal-lg">
                    <div class="modal-content ">
                        <div class="modal-header">
                            <h5 class="modal-title" id="staticBackdropLabel">Tambah Data Pelanggan</h5>
                            <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
                        </div>
                        <div class="modal-body">
                            <form action="<?php echo e(route('pelanggan.store')); ?>" method="POST" enctype="multipart/form-data">
                                <?php echo csrf_field(); ?>
                                <div class="row">
                                    <!-- Kolom Kiri -->
                                    <div class="col-md-6">
                                        <!-- Laundry -->
                                        <div class="mb-3">
                                            <label for="laundry_id" class="form-label">Pilih Laundry</label>

                                            <?php if(Auth::user()->role != 'pegawai' && Auth::user()->role != 'kepala_toko'): ?>
                                                <select id="laundry_id" name="laundry_id" class="form-select" required>
                                                    <option value="">Pilih Laundry</option>
                                                    <?php $__currentLoopData = $laundry; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $laundry): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                                        <option value="<?php echo e($laundry->id); ?>"><?php echo e($laundry->nama_laundry); ?>

                                                        </option>
                                                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                                </select>
                                            <?php else: ?>
                                                <input type="text" class="form-control"
                                                    value="<?php echo e($laundry->nama_laundry); ?>">
                                                <input type="hidden" value="<?php echo e($laundry->id); ?>" name="laundry_id">
                                            <?php endif; ?>
                                        </div>
                                        <!-- Username -->
                                        <div class="mb-3">
                                            <label for="username" class="form-label">Username</label>
                                            <input type="text" class="form-control" id="username" name="username"
                                                placeholder="Masukkan Username" required>
                                        </div>

                                        <!-- Email -->
                                        <div class="mb-3">
                                            <label for="email" class="form-label">Email</label>
                                            <input type="email" class="form-control" id="email" name="email"
                                                placeholder="Masukkan Email" required>
                                        </div>

                                        <!-- Password -->
                                        <div class="mb-3">
                                            <label for="password" class="form-label">Password</label>
                                            <input type="password" class="form-control" id="password" name="password"
                                                placeholder="Masukkan Password" required>
                                        </div>

                                        <!-- Phone -->
                                        <div class="mb-3">
                                            <label for="phone" class="form-label">No. Telp</label>
                                            <input type="text" class="form-control" id="no_telp" name="no_telp"
                                                placeholder="Masukkan No. Telp" required>
                                        </div>

                                        <!-- Role -->
                                        
                                    </div>

                                    <!-- Kolom Kanan -->
                                    <div class="col-md-6">
                                        <!-- Nama -->
                                        <div class="mb-3">
                                            <label for="nama" class="form-label">Nama</label>
                                            <input type="text" class="form-control" id="nama" name="nama"
                                                placeholder="Masukkan Nama" required>
                                        </div>

                                        <!-- Alamat -->
                                        <div class="mb-3">
                                            <label for="alamat" class="form-label">Alamat</label>
                                            <textarea class="form-control" id="alamat" name="alamat" placeholder="Masukkan Alamat" rows="3" required></textarea>
                                        </div>

                                        <!-- Foto -->
                                        <div class="mb-3">
                                            <label for="foto" class="form-label">Foto</label>
                                            <input type="file" class="form-control" id="foto" name="foto">
                                        </div>



                                        
                                    </div>
                                </div>

                        </div>

                        <div class="modal-footer">
                            
                            <button type="submit" class="btn btn-primary">Simpan</button>
                        </div>
                        </form>
                    </div>
                </div>
            </div>
        <?php $__env->stopSection(); ?>

<?php echo $__env->make('component.app', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH C:\xampp_2\htdocs\Laundry\resources\views/pelanggan/index.blade.php ENDPATH**/ ?>