<!-- 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">
        <style>
            .demo {
                background-color: rgb(11, 156, 11);
                margin-left: 10px;
                margin-right: 10px;
                padding: 10px;
                font-size: 20px;
                font-weight: bold;
                color: white;
                border-radius: 5px;
            }
        </style>
     <?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">
                        <button class="btn btn-success float-right mb-3" data-toggle="modal" data-target="#tambah"><i
                                class="fa fa-plus-circle mr-2"></i> Diskon
                            Baru</button>
                        <h3 class="card-title"><i class="fa fa-server text-primary"></i> <?php echo e($data['page']); ?></h3>
                    </div>
                    <div class="card-body">
                        <table class="table table-bordered table-hover myTable tab">
                            <thead>
                                <tr>
                                    <th width="5%">No</th>
                                    <th>Judul</th>
                                    <th>Disc</th>
                                    <th>Mulai Tanggal</th>
                                    <th>Sampai Tanggal</th>
                                    <th>Timer</th>
                                    <th>Status</th>
                                    <th width="15%">Opsi</th>
                                </tr>
                            </thead>
                            <tbody id="view">
                                <?php $__empty_1 = true; $__currentLoopData = $modul; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $d): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                                    <tr>
                                        <td class="text-center"><?php echo e($no++); ?></td>
                                        <td><?php echo e($d->judul); ?></td>
                                        <td class="text-center"><?php echo e($d->isi); ?>%</td>
                                        <td><?php echo e(tgl_time($d->tgl1)); ?></td>
                                        <td><?php echo e(tgl_time($d->tgl2)); ?></td>
                                        <td class="text-center">
                                            <?php if($d->status == 'Y'): ?>
                                                <input type="hidden" name="" id="tgl"
                                                    value="<?php echo e($d->tgl2); ?>">
                                                <div class="demo" id="demo"></div>
                                            <?php else: ?>
                                                EXPIRED
                                            <?php endif; ?>
                                        </td>
                                        <td>
                                            <div class="custom-control custom-switch   custom-switch-on-success">
                                                <input type="checkbox" class="custom-control-input check"
                                                    data-id="<?php echo e($d->id); ?>" data-v="<?php echo e($d->status); ?>"
                                                    <?php echo e($d->status == 'Y' ? 'checked' : ''); ?>

                                                    id="status<?php echo e($d->id); ?>">
                                                <label class="custom-control-label" for="status<?php echo e($d->id); ?>">
                                                    <?php echo e($d->status == 'Y' ? 'Aktif' : 'Tidak Aktif'); ?></label>
                                            </div>

                                        </td>
                                        <td class="text-center">
                                            <button class="btn btn-primary btn-sm" data-toggle="modal"
                                                data-target="#edit<?php echo e($d->id); ?>"><i class="fa fa-edit mr-2"></i>
                                                Edit</button>
                                            <button class="btn btn-danger btn-sm hapus" data-id="<?php echo e($d->id); ?>"
                                                data-nm="<?php echo e($d->judul); ?>"><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="12" class="text-center">Data masih kosong</td>
                                    </tr>
                                <?php endif; ?>
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
            

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

    </section>


    
    <div class="modal fade" id="tambah">
        <div class="modal-dialog ">
            <div class="modal-content">
                <div class="modal-header bg-primary ">
                    Tambah Diskon
                </div>
                <form action="<?php echo e(route('diskon.tambah')); ?>" method="post">
                    <?php echo csrf_field(); ?>
                    <div class="modal-body">
                        <div class="form-group">
                            <label>Judul Diskon</label>
                            <input type="text" name="judul_diskon" class="form-control" placeholder="Judul Diskon"
                                autofocus required value="<?php echo e(old('judul_diskon')); ?>">
                        </div>
                        <div class="form-group">
                            <label>Jumlah Diskon</label>
                            <input type="text" name="diskon" class="form-control numbers" placeholder="0%" required
                                value="<?php echo e(old('diskon')); ?>">
                        </div>
                        <div class="form-group">
                            <label>Mulai Tanggal</label>
                            <input type="date" name="tgl1" class="form-control" required
                                value="<?php echo e(date('Y-m-d')); ?>">
                        </div>
                        <div class="form-group">
                            <label>Sampai Tanggal</label>
                            <input type="date" name="tgl2" class="form-control" required
                                value="<?php echo e(date('Y-m-d')); ?>">
                        </div>
                    </div>
                    <div class="modal-footer justify-content-between">
                        <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
                        <button type="submit" class="btn btn-primary satuan"><i class="fa fa-save mr-2"></i>
                            Simpan</button>
                    </div>
                </form>
            </div>
            <!-- /.modal-content -->
        </div>
        <!-- /.modal-dialog -->
    </div>

    <?php $__currentLoopData = $modul; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $d): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
        <div class="modal fade" id="edit<?php echo e($d->id); ?>">
            <div class="modal-dialog ">
                <div class="modal-content">
                    <div class="modal-header bg-primary ">
                        Tambah Diskon
                    </div>
                    <form action="<?php echo e(route('diskon.edit')); ?>" method="post">
                        <?php echo csrf_field(); ?>
                        <input type="hidden" name="id" id="" value="<?php echo e($d->id); ?>">
                        <div class="modal-body">
                            <div class="form-group">
                                <label>Judul Diskon</label>
                                <input type="text" name="judul_diskon" class="form-control"
                                    placeholder="Judul Diskon" autofocus required value="<?php echo e($d->judul); ?>">
                            </div>
                            <div class="form-group">
                                <label>Jumlah Diskon</label>
                                <input type="text" name="diskon" class="form-control numbers" placeholder="0%"
                                    required value="<?php echo e($d->isi); ?>">
                            </div>
                            <div class="form-group">
                                <label>Mulai Tanggal</label>
                                <input type="date" name="tgl1" class="form-control" required
                                    value="<?php echo e(date('Y-m-d', strtotime($d->tgl1))); ?>">
                            </div>
                            <div class="form-group">
                                <label>Sampai Tanggal</label>
                                <input type="date" name="tgl2" class="form-control" required
                                    value="<?php echo e(date('Y-m-d', strtotime($d->tgl2))); ?>">
                            </div>
                        </div>
                        <div class="modal-footer justify-content-between">
                            <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
                            <button type="submit" class="btn btn-primary satuan"><i class="fa fa-save mr-2"></i>
                                Simpan</button>
                        </div>
                    </form>
                </div>
                <!-- /.modal-content -->
            </div>
            <!-- /.modal-dialog -->
        </div>
    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>


     <?php $__env->slot('foot', null, []); ?> 
        <script src="<?php echo e(asset('')); ?>assets/admin/plugins/sweetalert2/sweetalert2.all.min.js"></script>
        <script>
            $(function() {
                $('.myTable').DataTable();
            });


            $('#view').on('click', '.check', function() {
                var token = $("meta[name='csrf-token']").attr("content");
                var id = $(this).attr('data-id');
                var value = $(this).attr('data-v');
                if (value == "Y") {
                    var isi = "N";
                } else {
                    var isi = "Y";
                }
                $.ajax({
                    type: 'POST',
                    url: 'status-diskon',
                    data: {
                        id: id,
                        isi: isi,
                        _token: token,
                    },
                    success: function(data) {
                        document.location.href = "";
                    }
                });
            });

            $('#view').on('click', '.hapus', function() {
                var id = $(this).attr('data-id');
                var nama = $(this).attr('data-nm');

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

            });
        </script>
        <script>
            // Set the date we're counting down to
            // var id = <?php echo e($d->id); ?>;
            var tgl = $('#tgl').val();
            var countDownDate = new Date(tgl).getTime();

            // Update the count down every 1 second
            var x = setInterval(function() {

                // Get today's date and time
                var now = new Date().getTime();

                // Find the distance between now and the count down date
                var distance = countDownDate - now;

                // Time calculations for days, hours, minutes and seconds
                var days = Math.floor(distance / (1000 * 60 * 60 * 24));
                var hours = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
                var minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60));
                var seconds = Math.floor((distance % (1000 * 60)) / 1000);

                // Output the result in an element with id="demo"
                document.getElementById("demo").innerHTML = days + " Hari " + hours + " : " +
                    minutes + " : " + seconds + "  ";

                // If the count down is over, write some text 
                if (distance < 0) {
                    clearInterval(x);
                    document.getElementById("demo").innerHTML = "EXPIRED";
                }
            }, 1000);
        </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/setting/diskon.blade.php ENDPATH**/ ?>