<?php $__env->startSection('content'); ?>
<!-- start page title -->
<Style>
#summernote .note-editable {
  background-color: white !important;
}

</Style>
      <!-- start page title -->
<div class="container-xxl flex-grow-1 container-p-y">
    <div class="col-lg-12 mb-4 order-0">
    </div>

    <?php if(session('success')): ?>
    <div class="alert alert-success">
        <?php echo e(session('success')); ?>

    </div>
    <?php endif; ?>

    <?php if(session('info')): ?>
    <div class="alert alert-info">
        <?php echo e(session('info')); ?>

    </div>
    <?php endif; ?>
    <!-- end page title -->

<div class="card ">
    <div class="card-body">
        <h4 class="mb-3 header-title mt-0">Tambah Kategori</h4>
        <form action="<?php echo e(route('kategori.post')); ?>" method="POST" enctype="multipart/form-data">
            <?php echo csrf_field(); ?>
            <div class="mb-3 row">
                <label class="col-lg-2 col-form-label" for="example-fileinput">Nama</label>
                <div class="col-lg-10">
                    <input type="text" class="form-control <?php $__errorArgs = ['nama'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?> is-invalid <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>" value="<?php echo e(old('nama')); ?>" name="nama">
                    <?php $__errorArgs = ['nama'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
                    <div class="invalid-feedback">
                        <?php echo e($message); ?>

                    </div>
                    <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                </div>
            </div>
            <div class="mb-3 row">
                <label class="col-lg-2 col-form-label" for="example-fileinput">Sub Nama (brand)</label>
                <div class="col-lg-10">
                    <input type="text" class="form-control <?php $__errorArgs = ['sub_nama'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?> is-invalid <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>" value="<?php echo e(old('sub_nama')); ?>" name="sub_nama">
                    <?php $__errorArgs = ['sub_nama'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
                    <div class="invalid-feedback">
                        <?php echo e($message); ?>

                    </div>
                    <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                </div>
            </div>
            <div class="mb-3 row">
                <label class="col-lg-2 col-form-label" for="example-fileinput">Url</label>
                <div class="col-lg-10">
                    <input type="text" class="form-control <?php $__errorArgs = ['kode'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?> is-invalid <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>" value="<?php echo e(old('kode')); ?>" name="kode">
                    <?php $__errorArgs = ['kode'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
                    <div class="invalid-feedback">
                        <?php echo e($message); ?>

                    </div>
                    <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                </div>
            </div>
            <!--<div class="mb-3 row">-->
            <!--    <label class="col-lg-2 col-form-label" for="example-fileinput">Brand</label>-->
            <!--    <div class="col-lg-10">-->
            <!--        <input type="text" class="form-control <?php $__errorArgs = ['brand'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?> is-invalid <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>" value="<?php echo e(old('brand')); ?>" name="brand">-->
            <!--        <?php $__errorArgs = ['brand'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>-->
            <!--        <div class="invalid-feedback">-->
            <!--            <?php echo e($message); ?>-->
            <!--        </div>-->
            <!--        <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>-->
            <!--    </div>-->
            <!--</div>-->
            <div class="mb-3 row">
                <label class="col-lg-2 col-form-label" for="example-fileinput">Deskripsi Game</label>
                <div class="col-lg-10">
                    <textarea id="summernote" class="form-control <?php $__errorArgs = ['deskripsi_game'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?> is-invalid <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>" name="deskripsi_game"><?php echo e(old('deskripsi_game')); ?></textarea>
                    <?php $__errorArgs = ['deskripsi_game'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
                    <div class="invalid-feedback">
                        <?php echo e($message); ?>

                    </div>
                    <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                </div>
            </div>
            <div class="mb-3 row">
                <label class="col-lg-2 col-form-label" for="example-fileinput">Deskripsi field</label>
                <div class="col-lg-10">
                    <textarea class="form-control <?php $__errorArgs = ['deskripsi_field'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?> is-invalid <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>" name="deskripsi_field"><?php echo e(old('deskripsi_field')); ?></textarea>
                    <?php $__errorArgs = ['deskripsi_field'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
                    <div class="invalid-feedback">
                        <?php echo e($message); ?>

                    </div>
                    <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                </div>
            </div>
            <div id="fieldsContainer" class="flex flex-col gap-2 p-4 border border-secondary-400 rounded-lg rounded">
                <div class="field-group">
                    <div class="flex justify-between">
                        <div class="">Field 1</div>
                    </div>
                    <div class="mt-4">
                        <input class="form-control" placeholder="Title" name="inputs_1_title">
                    </div>
                    <div class="mt-4">
                        <input class="form-control" placeholder="Name" name="inputs_1_name">
                    </div>
                    <div class="mt-4 mb-4">
                        <select class="form-control" name="inputs_1_type">
                            <option>Select Input Type</option>
                            <option value="text">Text</option>
                            <option value="number">Number</option>
                            <option value="password">Password</option>
                            <option value="select">Select</option>
                        </select>
                    </div>
                </div>
            </div>
            <button id="addMoreBtn" class="btn btn-info mt-2" type="button">Add More</button>
            
            <div class="mb-3 row">
                <label class="col-lg-2 col-form-label" for="example-fileinput">Thumbnail</label>
                <div class="col-lg-10">
                    <input type="file" class="form-control" name="thumbnail">
                    <?php $__errorArgs = ['thumbnail'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
                    <div class="invalid-feedback">
                        <?php echo e($message); ?>

                    </div>
                    <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                </div>
            </div>
            <div class="mb-3 row">
                <label class="col-lg-2 col-form-label" for="example-fileinput">Banner</label>
                <div class="col-lg-10">
                    <input type="file" class="form-control" name="banner">
                    <?php $__errorArgs = ['banner'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
                    <div class="invalid-feedback">
                        <?php echo e($message); ?>

                    </div>
                    <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                </div>
            </div>
            <div class="mb-3 row">
                <label class="col-lg-2 col-form-label" for="example-fileinput">Tipe</label>
                <div class="col-lg-10">
                    <select class="form-select" name="tipe">                
                        <option value='populer'>Populer</option>
                        <option value='game'>Topup Game</option>
                        <option value='e-money'>E-Money</option>-->
                        <option value='app'>App Premium</option>
                        <option value='voucher'>Voucher</option>
                        <option value='joki'>JOKI MLBB</option>
                        <option value='jokigendong'>JOKI Gendong</option>
                        <option value='giftskin'>Gift Skins</option>
                        <option value='vilogml'>ML Vilog</option>
                        <option value='streamingapp'>Streaming APP</option>
                        <!--<option value="gift_skin">Gift Skin MLBB</option>-->

                    </select>
                    <?php $__errorArgs = ['tipe'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
                    <div class="invalid-feedback">
                        <?php echo e($message); ?>

                    </div>
                    <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                </div>
            </div>
            <button type="submit" class="btn btn-primary">Submit</button>
        </form>
    </div>
</div>
<div class="row">
    <div class="col-lg-12">
        <div class="card">
            <div class="card-body">
                <h4 class="header-title mt-0 mb-1">Semua Kategori</h4>
                <div id="loadingSpinnerKategori" class="text-center">
                    <div class="spinner-border text-primary" role="status">
                        <span class="visually-hidden">Loading...</span>
                    </div>
                </div>
                <div class="table-responsive d-none" id="kategoriTableContainer">
                    <table class="table table-dark table-bordered table-striped m-0" id="kategori-table">
                        <thead>
                            <tr>
                                <th>ID</th>
                                <th>Thumbnail</th>
                                <th>Nama</th>
                                <th>Sub Nama</th>
                                <th>Kode</th>
                                <!--<th>Brand</th>-->
                                <!--<th>Deskripsi Game</th>-->
                                <!--<th>Deskripsi Field User ID & Zone ID</th>-->
                                <th>Status</th>
                                <!--<th>Banner</th>-->
                                <th>Aksi</th>
                                <th>Tanggal</th>
                            </tr>
                        </thead>
                        <tbody>
                            <?php $__currentLoopData = $data; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $datas): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                            <?php
                            $label_pesanan = '';
                            if($datas->status == "active"){
                            $label_pesanan = 'info';
                            }else if($datas->status == "unactive"){
                            $label_pesanan = 'warning';
                            }
                            ?>
                            <tr>
                                <th scope="row"><?php echo e($datas->id); ?></th>
                                <td>
                                    <img src="<?php echo e(asset($datas->thumbnail)); ?>" width="50" height="50" style="border-radius: 10px;">
                                </td>
                                <td><?php echo e($datas->nama); ?></td>
                                <td><?php echo e($datas->sub_nama); ?></td>
                                <td><?php echo e($datas->kode); ?></td>
                                <!--<td><?php echo e($datas->brand); ?></td>-->
                                <!--<td><?php echo e($datas->deskripsi_game); ?></td>-->
                                <!--<td><?php echo e($datas->deskripsi_field); ?></td>-->
                                <td>
                                    <div class="btn-group-vertical">
                                        <button id="btnGroupDrop1" type="button" class="btn btn-<?php echo e($label_pesanan); ?> dropdown-toggle" data-bs-toggle="dropdown" aria-expanded="false"> <?php echo e($datas->status); ?> <i class="mdi mdi-chevron-down"></i> </button>
                                        <ul class="dropdown-menu" aria-labelledby="btnGroupDrop1">
                                            <li><a class="dropdown-item" href="/kategori-status/<?php echo e($datas->id); ?>/unactive">unactive</a></li>
                                            <li><a class="dropdown-item" href="/kategori-status/<?php echo e($datas->id); ?>/active">active</a></li>
                                    </div>
                                </td>
                                <!--<td>-->
                                <!--    <img src="<?php echo e(asset($datas->banner )); ?>"  width="100" height="50" style="border-radius: 10px;">-->
                                <!--</td>-->
                                <td>
                                    <a href="javascript:;" onclick="modal('<?php echo e($datas->nama); ?>', '<?php echo e(route('kategori.detail', [$datas->id])); ?>')" class="btn-sm btn-info mb-3">Edit</a>
                                    <br>
                                    <br>
                                    <a class="btn-sm btn-danger mt-2" href="/kategori/hapus/<?php echo e($datas->id); ?>">Hapus</a>
                                </td>
                                <td><?php echo e($datas->created_at); ?></td>
                            </tr>
                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
    </div>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/Sortable/1.14.0/Sortable.min.js"></script>
<script>
    var table = document.getElementById('kategori-table').getElementsByTagName('tbody')[0];
    new Sortable(table, {
        animation: 150,
        ghostClass: 'bg-light',
        handle: 'th',
        onEnd: function (evt) {
            // Callback ketika pengurutan selesai
            var item = evt.item; // Item yang diurutkan (baris tabel)
            // Lakukan pembaruan atau operasi lain setelah pengurutan selesai
        }
    });
</script>

<script>
$(document).ready(function() {
    setTimeout(function() {
        $('#loadingSpinnerKategori').addClass('d-none');
        $('#kategoriTableContainer').removeClass('d-none');
        $('#kategori-table').DataTable();
    }, 500); // Adjust the delay as needed
});
</script>

<script type="text/javascript">
    $(document).ready(function(){
        $('.table').DataTable({
        });
    });
    
    function modal(name, link) {
        var myModal = new bootstrap.Modal($('#modal-detail'))
        $.ajax({
            type: "GET",
            url: link,
            beforeSend: function() {
                $('#modal-detail-title').html(name);
                $('#modal-detail-body').html('Loading...');
            },
            success: function(result) {
                $('#modal-detail-title').html(name);
                $('#modal-detail-body').html(result);
                 $('#summernotee').summernote({
                    height: 200,
                    minHeight: null,
                    maxHeight: null,
                    focus: true
                });
            },
            error: function() {
                $('#modal-detail-title').html(name);
                $('#modal-detail-body').html('There is an error...');
            }
        });
        myModal.show();
    }
</script>

<script>
    let fieldCount = 1;
    const addMoreBtn = document.getElementById('addMoreBtn');
    const fieldsContainer = document.getElementById('fieldsContainer');

    addMoreBtn.addEventListener('click', () => {
        fieldCount++;

        const newFieldGroup = document.createElement('div');
        newFieldGroup.classList.add('field-group');

        newFieldGroup.innerHTML = `
            <div class="flex justify-between">
                <div class="">Field ${fieldCount}</div>
            </div>
            <div class="mt-4">
                <input class="form-control" placeholder="Title" name="inputs_${fieldCount}_title">
            </div>
            <div class="mt-4">
                <input class="form-control" placeholder="Name" name="inputs_${fieldCount}_name">
            </div>
            <div class="mt-4 mb-4">
                <select class="form-control" name="inputs_${fieldCount}_type">
                    <option>Select Input Type</option>
                    <option value="text">Text</option>
                    <option value="number">Number</option>
                    <option value="password">Password</option>
                    <option value="select">Select</option>
                </select>
            </div>
        `;

        fieldsContainer.appendChild(newFieldGroup);

        const newSelect = newFieldGroup.querySelector(`select[name="inputs_${fieldCount}_type"]`);
        newSelect.addEventListener('change', (event) => {
            if (event.target.value === 'select') {
                const labelInput = document.createElement('input');
                labelInput.classList.add('form-control');
                labelInput.placeholder = 'Label';
                labelInput.name = `inputs_${fieldCount}_label`;

                const valueInput = document.createElement('input');
                valueInput.classList.add('form-control');
                valueInput.classList.add('mt-4');
                valueInput.placeholder = 'Value';
                valueInput.name = `inputs_${fieldCount}_value`;

                newFieldGroup.appendChild(labelInput);
                newFieldGroup.appendChild(valueInput);
            } else {
                const labelInput = newFieldGroup.querySelector(`input[name="inputs_${fieldCount}_label"]`);
                const valueInput = newFieldGroup.querySelector(`input[name="inputs_${fieldCount}_value"]`);

                if (labelInput) {
                    labelInput.remove();
                }
                if (valueInput) {
                    valueInput.remove();
                }
            }
        });
    });
</script>

    

<div class="modal fade bs-example-modal-lg" tabindex="-1" role="dialog" id="modal-detail" style="border-radius:7%">
    <div class="modal-dialog modal-lg">
        <div class="modal-content">
            <div class="modal-header">
                <h4 class="modal-title" id="modal-detail-title"></h4>
                <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
            </div>
            <div class="modal-body" id="modal-detail-body"></div>
        </div>
    </div>
</div>
</div>

<?php $__env->stopSection(); ?>
<?php echo $__env->make('main-admin', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH /home/akstarsc/genztopup/resources/views/components/admin/kategori.blade.php ENDPATH**/ ?>