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

<?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">Messages</li>
            </ol>
        </nav>

        <div class="row">
            <div class="col-md-12 grid-margin stretch-card">
                <div class="card">
                    <div class="card-body">
                        <h6 class="card-title">Messages</h6>
                        <div class="table-responsive">
                            <table class="table table-bordered table-striped">
                                <thead>
                                    <tr>
                                        <th>No</th>
                                        <th>Nama</th>
                                        <th>Email</th>
                                        <th>No Telpon</th>
                                        <th>Alamat</th>
                                        <th>Pesan</th>
                                        <th>Tanggal Pembuatan</th>
                                        <th>Action</th>
                                    </tr>
                                </thead>
                                <tbody>
                                    <?php $__currentLoopData = $messages; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $index => $message): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                        <tr>
                                            <td><?php echo e($index + 1); ?></td>
                                            <td><?php echo e($message->nama); ?></td>
                                            <td><?php echo e($message->email); ?></td>
                                            <td><?php echo e($message->no_telp); ?></td>
                                            <td><?php echo e($message->alamat); ?></td>
                                            <td><?php echo e(Str::limit($message->pesan, 50)); ?>..</td>
                                            <td><?php echo e($message->created_at); ?></td>
                                            <td>
                                                <div class="d-flex flex-wrap gap-2">
                                                    <button class="btn btn-info btn-sm btn-detail"
                                                        data-nama="<?php echo e($message->nama); ?>"
                                                        data-no_telp="<?php echo e($message->no_telp); ?>"
                                                        data-alamat="<?php echo e($message->alamat); ?>"
                                                        data-email="<?php echo e($message->email); ?>"
                                                        data-pesan="<?php echo e($message->pesan); ?>"
                                                        data-date="<?php echo e($message->created_at); ?>">
                                                        <i class="fa fa-eye"></i> Detail
                                                    </button>
                                                    <form action="<?php echo e(route('kontak.destroy', $message->kontak_id)); ?>"
                                                        method="POST" style="display:inline;">
                                                        <?php echo csrf_field(); ?>
                                                        <?php echo method_field('DELETE'); ?>
                                                        <button type="submit" class="btn btn-danger btn-sm">
                                                            <i class="fa fa-trash"></i> Delete
                                                        </button>
                                                    </form>
                                                </div>
                                            </td>
                                        </tr>
                                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                </tbody>
                            </table>
                            <div class="d-flex justify-content-start mt-4">
                                <?php echo e($messages->links('vendor.pagination.simple-bootstrap-5')); ?>

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

        <!-- Message Detail Modal -->
        <div id="messageDetailModal" class="modal fade" tabindex="-1" role="dialog">
            <div class="modal-dialog modal-dialog-centered" role="document">
                <div class="modal-content">
                    <div class="modal-header">
                        <h5 class="modal-title">Message Detail</h5>
                        <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
                    </div>
                    <div class="modal-body">
                        <p><strong>From:</strong> <span id="fromName"></span></p>
                        <p><strong>Email:</strong> <span id="fromEmail"></span></p>
                        <p><strong>No Telpon:</strong> <span id="fromTelp"></span></p>
                        <p><strong>Alamat:</strong> <span id="fromAddress"></span></p>
                        <p><strong>Message:</strong></p>
                        <p id="detailMessage"></p>
                        <p>Terima kasih.</p>
                        <p>Salam hangat, <span id="warmRegards"></span></p>
                    </div>
                </div>
            </div>
        </div>
    </div>
<?php $__env->stopSection(); ?>

<?php $__env->startPush('script'); ?>
    <script>
        $(document).ready(function() {
            $('.btn-detail').on('click', function() {
                const nama = $(this).data('nama');
                const noTelp = $(this).data('no_telp');
                const alamat = $(this).data('alamat');
                const email = $(this).data('email');
                const message = $(this).data('pesan');

                $('#fromName').text(nama);
                $('#fromEmail').text(email);
                $('#fromTelp').text(noTelp);
                $('#fromAddress').text(alamat);
                $('#detailMessage').text(message);

                $('#messageDetailModal').modal('show');
            });
        });
    </script>
<?php $__env->stopPush(); ?>

<?php echo $__env->make('dashboard.app', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH /home/u4591423/public_html/PUBLIC_DOMAIN/2025-STISIP-IMAM-BONJOL/resources/views/admin/kontak/index.blade.php ENDPATH**/ ?>