<!-- Main content -->
<?php if (isset($component)) { $__componentOriginal566f40242755341fef381206827a6570 = $component; } ?>
<?php if (isset($attributes)) { $__attributesOriginal566f40242755341fef381206827a6570 = $attributes; } ?>
<?php $component = Illuminate\View\AnonymousComponent::resolve(['view' => 'components.admin.contents','data' => []] + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? (array) $attributes->getIterator() : [])); ?>
<?php $component->withName('admin.contents'); ?>
<?php if ($component->shouldRender()): ?>
<?php $__env->startComponent($component->resolveView(), $component->data()); ?>
<?php if (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag && $constructor = (new ReflectionClass(Illuminate\View\AnonymousComponent::class))->getConstructor()): ?>
<?php $attributes = $attributes->except(collect($constructor->getParameters())->map->getName()->all()); ?>
<?php endif; ?>
<?php $component->withAttributes([]); ?>
     <?php $__env->slot('title', null, []); ?> <?php echo e($data['title']); ?> <?php $__env->endSlot(); ?>
     <?php $__env->slot('menuOpen', null, []); ?> <?php echo e($data['menuOpen']); ?>  <?php $__env->endSlot(); ?>
     <?php $__env->slot('menuActive', null, []); ?> <?php echo e($data['menuActive']); ?>  <?php $__env->endSlot(); ?>
     <?php $__env->slot('page', null, []); ?> <?php echo e($data['page']); ?> <?php $__env->endSlot(); ?>
     <?php $__env->slot('head', null, []); ?> 
        <link rel="stylesheet" href="<?php echo e(asset('')); ?>assets/admin/plugins/icheck-bootstrap/icheck-bootstrap.min.css">
        <link rel="stylesheet" href="<?php echo e(asset('assets/')); ?>/admin/plugins/sweetalert2/sweetalert2.min.css">
     <?php $__env->endSlot(); ?>


    <section class="content">

        <!-- Default box -->
        <div class="row">
            <div class="col-lg-12">
                <?php if (isset($component)) { $__componentOriginal88b0e6813f5b80100a19437aa80e29ba = $component; } ?>
<?php if (isset($attributes)) { $__attributesOriginal88b0e6813f5b80100a19437aa80e29ba = $attributes; } ?>
<?php $component = Illuminate\View\AnonymousComponent::resolve(['view' => 'components.message','data' => []] + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? (array) $attributes->getIterator() : [])); ?>
<?php $component->withName('message'); ?>
<?php if ($component->shouldRender()): ?>
<?php $__env->startComponent($component->resolveView(), $component->data()); ?>
<?php if (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag && $constructor = (new ReflectionClass(Illuminate\View\AnonymousComponent::class))->getConstructor()): ?>
<?php $attributes = $attributes->except(collect($constructor->getParameters())->map->getName()->all()); ?>
<?php endif; ?>
<?php $component->withAttributes([]); ?> <?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__attributesOriginal88b0e6813f5b80100a19437aa80e29ba)): ?>
<?php $attributes = $__attributesOriginal88b0e6813f5b80100a19437aa80e29ba; ?>
<?php unset($__attributesOriginal88b0e6813f5b80100a19437aa80e29ba); ?>
<?php endif; ?>
<?php if (isset($__componentOriginal88b0e6813f5b80100a19437aa80e29ba)): ?>
<?php $component = $__componentOriginal88b0e6813f5b80100a19437aa80e29ba; ?>
<?php unset($__componentOriginal88b0e6813f5b80100a19437aa80e29ba); ?>
<?php endif; ?>
                <div class="card card-primary card-outline">
                    <div class="card-header">
                        <h3 class="card-title"><i class="fa fa-server text-primary"></i> <?php echo e($data['page']); ?></h3>
                    </div>
                    <div class="card-body">
                        <form class="form-inline float-right">
                            <input class="form-control mr-sm-2" type="search" placeholder="Search" aria-label="Search"
                                name="cari">
                            <button class="btn btn-primary " type="submit"> <i class="fa fa-search mr-2"></i>
                                Cari!</button>
                        </form>

                        <button class="btn btn-default shadow-sm">
                            <div class="icheck-blue d-inline " style="margin-right: -7px">
                                <input type="checkbox" id="cekall">
                                <label for="cekall">
                                </label>
                            </div>
                        </button>
                        <button class="btn btn-danger" id="pilih_hapus"><i class="fa fa-trash"></i> Hapus</button>
                        <table class="table table-bordered table-hover myTable tab mt-2">
                            <thead>
                                <tr>
                                    <th width="3%">No</th>
                                    <th>#</th>
                                    <th>Nama Lengkap</th>
                                    <th>Email</th>
                                    <th>Subjek</th>
                                    <th>Status</th>
                                    <th>Tgl. Kirim</th>
                                    <th width="20%">Opsi</th>
                                </tr>
                            </thead>
                            <tbody id="view">
                                <?php $__empty_1 = true; $__currentLoopData = $pesan; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $p): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                                    <tr>
                                        <td class="text-center"><?php echo e($no++); ?></td>
                                        <td class="text-center">
                                            <div class="icheck-blue d-inline " style="margin-right: -7px">
                                                <input type="checkbox" name="id[]" id="cek<?php echo e($p->id); ?>"
                                                    class="ceklis" value="<?php echo e($p->id); ?>">
                                                <label for="cek<?php echo e($p->id); ?>">
                                                </label>
                                            </div>
                                        </td>
                                        <td><?php echo e($p->nama); ?></td>
                                        <td><?php echo e($p->email); ?></td>
                                        <td><?php echo e($p->subjek); ?></td>
                                        <td><?php echo $p->sts_pesan == 'B' ? '<span class="badge badge-danger">Pesan Baru</span>' : 'Dilihat'; ?>

                                        </td>
                                        <td><?php echo e(tgl_inf($p->created_at)); ?> </td>
                                        <td class="text-center">
                                            <button class="btn btn-info btn-sm lihat" data-id="<?php echo e($p->id); ?>"><i
                                                    class="fa fa-eye mr-2"></i>
                                                Lihat</button>
                                            <button class="btn btn-danger btn-sm hapus" data-id="<?php echo e($p->id); ?>"
                                                data-nm="<?php echo e($p->nama); ?>"><i class="fa fa-trash mr-2"></i>
                                                Hapus</button>
                                        </td>
                                    </tr>
                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                                    <tr>
                                        <td colspan="10" class="text-center">Data masih kosong</td>
                                    </tr>
                                <?php endif; ?>
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>

        </div>
        <!-- /.card -->

    </section>

    
    <div class="modal fade" id="detail">
        <div class="modal-dialog ">
            <div class="modal-content">
                <div class="modal-header bg-danger ">
                    Detail Pesan
                </div>
                <div class="modal-body" id="vdetail">

                </div>
                <div class="modal-footer justify-content-between">
                    <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
                </div>
            </div>
            <!-- /.modal-content -->
        </div>
        <!-- /.modal-dialog -->
    </div>


     <?php $__env->slot('foot', null, []); ?> 
        <script src="<?php echo e(asset('assets/')); ?>/admin/plugins/sweetalert2/sweetalert2.all.min.js"></script>
        <script>
            $('#view').on('click', '.lihat', function() {
                var token = $("meta[name='csrf-token']").attr("content");
                var id = $(this).attr('data-id');

                $.ajax({
                    type: 'post',
                    url: 'lihat-pesan',
                    data: {
                        id: id,
                        _token: token,
                    },
                    success: function(data) {
                        $('#detail').modal('show');
                        $('#vdetail').html(data);
                    }
                });
            });
            $('#view').on('click', '.hapus', function() {
                var id = $(this).attr('data-id');
                var nama = $(this).attr('data-nm');

                Swal.fire({
                    title: "Apa anda yakin?",
                    text: "Pesan  dari ( " + nama + " ) akan di hapus!",
                    icon: "warning",
                    showCancelButton: true,
                    confirmButtonColor: "#3085d6",
                    cancelButtonColor: "#d33",
                    confirmButtonText: "Ya, Hapus!"
                }).then((result) => {
                    if (result.isConfirmed) {
                        document.location.href = "delete-pesan/" + id;
                    }
                });

            });

            // ceklis
            $("#cekall").change(function() {
                if ($(this).prop("checked")) {
                    $(".ceklis").prop("checked", true);
                } else {
                    $(".ceklis").prop("checked", false);
                }
            });

            $("#pilih_hapus").click(function() {
                var allVals = [];
                $(".ceklis:checked").each(function() {
                    allVals.push($(this).val());
                });
                var token = $("meta[name='csrf-token']").attr("content");

                if (allVals.length <= 0) {
                    Toast.fire({
                        icon: "error",
                        title: "Ceklis data yang akan dihapus!!!.",
                    });
                } else {
                    Swal.fire({
                        title: "Pastikan dengan benar!",
                        text: "Data yang anda pilih akan dihapus!",
                        icon: "warning",
                        showCancelButton: true,
                        confirmButtonColor: "#3085d6",
                        cancelButtonColor: "#d33",
                        confirmButtonText: "Ya, Hapus!",
                    }).then((result) => {
                        if (result.isConfirmed) {
                            $.ajax({
                                type: "DELETE",
                                url: "deleteall-pesan",
                                data: {
                                    allVals: allVals,
                                    _token: token,
                                },
                                beforeSend: function() {
                                    $("#pilih_hapus").html(
                                        '<i class="fas fa-spinner fa-spin"></i> Tunggu..'
                                    );
                                    $("#pilih_hapus").attr("disabled", true);
                                },
                                success: function(data) {
                                    // alert(data)
                                    $("#pilih_hapus").html(
                                        '<i class="fa fa-trash"></i>'
                                    );
                                    $("#pilih_hapus").attr("disabled", true);
                                    Swal.fire({
                                        icon: "success",
                                        title: "Berhasil",
                                        text: "Data berhasil dihapus!",
                                    }).then((result) => {
                                        if (result.isConfirmed) {
                                            document.location.href = "";
                                        }
                                    });
                                },
                            });
                        }
                    });
                }
            });
        </script>
     <?php $__env->endSlot(); ?>
 <?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__attributesOriginal566f40242755341fef381206827a6570)): ?>
<?php $attributes = $__attributesOriginal566f40242755341fef381206827a6570; ?>
<?php unset($__attributesOriginal566f40242755341fef381206827a6570); ?>
<?php endif; ?>
<?php if (isset($__componentOriginal566f40242755341fef381206827a6570)): ?>
<?php $component = $__componentOriginal566f40242755341fef381206827a6570; ?>
<?php unset($__componentOriginal566f40242755341fef381206827a6570); ?>
<?php endif; ?>
<?php /**PATH /Applications/XAMPP/xamppfiles/htdocs/e-CommerceLv11/resources/views/admin/data/pesan.blade.php ENDPATH**/ ?>