<?php $__env->startSection('title','Surat Keterangan Domisili Usaha'); ?>

<?php $__env->startSection('vendor-styles'); ?>
    <link rel="stylesheet" type="text/css" href="<?php echo e(asset('vendors/css/tables/datatable/datatables.min.css')); ?>">
    <link rel="stylesheet" type="text/css" href="<?php echo e(asset('css/pages/data-list-view.css')); ?>">

<?php $__env->stopSection(); ?>

<?php $__env->startSection('content'); ?>

<!-- Column selectors with Export Options and print table -->
<section id="data-list-view" class="data-list-view-header">   
    <div class="table-responsive">
        <table class="table data-list-view" id="skdu-table">
            <thead>
                <tr>
                    <th>Id</th>
                    <th>Tanggal Request</th>
                    <th>NIK</th>
                    <th>Nama</th>
                    <th>Scan KTP</th>
                    <th>Scan KK</th>
                    <th>Bidang Usaha</th>
                    <th>Alamat Usaha</th>
                    <th>Foto Tempat Usaha</th>
                    <th>Status</th>
                    <th>Keterangan</th>
                    <th>Aksi</th>
                </tr>
            </thead>
            <tbody>
            <?php $i = 1 ?>
            <?php $__currentLoopData = $skdu; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $s): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                <?php if($s->status === 'BELUM DI ACC'): ?>
                <?php $color1 = "danger" ?>
                <?php elseif($s->status === 'SUDAH ACC STAFF'): ?>
                <?php $color1 = "warning" ?>
                <?php elseif($s->status === 'SUDAH ACC LURAH'): ?>
                <?php $color1 = "primary" ?>
                <?php elseif($s->status === 'SURAT SUDAH DICETAK'): ?>
                <?php $color1 = "success" ?>
                <?php endif; ?>
        
                <tr>
                <td class="user-id"><?php echo e($i++); ?></td>
                <td class="user-tanggal"><?php echo e($s->created_at->isoFormat('D MMMM Y')); ?></td>
                <td class="user-nik"><?php echo e($s->user->nik); ?></td>
                <td class="user-nama"><?php echo e($s->user->name); ?></td>
                <td class="user-ktp"> 
                    <a type="button" href="#" name="ktp" id="<?php echo e($s->id); ?>" class="ktp" title="Lihat KTP"><span><img src="<?php echo e(asset('storage/'.$s->scan_ktp)); ?>" alt="avatar" height="40" width="60"></span></a>
                </td>
                <td class="user-kk">
                    <a type="button" href="#" name="kk" id="<?php echo e($s->id); ?>" class="kk" title="Lihat KK"><span><img src="<?php echo e(asset('storage/'.$s->scan_kk)); ?>" alt="avatar" height="40" width="60"></span></a>
                </td>
                <td class="user-bidang_usaha"><?php echo e($s->bidang_usaha); ?></td>
                <td class="user-alamat_usaha"><?php echo e($s->alamat_usaha); ?></td>
                <td class="user-fotousaha">
                    <a type="button" href="#" name="kk" id="<?php echo e($s->id); ?>" class="fotousaha" title="Lihat Foto Tempat Usaha"><span><img src="<?php echo e(asset('storage/'.$s->foto_usaha)); ?>" alt="avatar" height="40" width="60"></span></a>
                </td>
                <td class="user-status">
                    <div class="badge badge-pill badge-light-<?php echo e($color1); ?>">
                        <?php echo e($s->status); ?>

                    </div>
                </td>
                <td class="user-keterangan">
                    <?php if($s->keterangan === NULL): ?>
                        Data sedang diperiksa staff
                    <?php else: ?> 
                        <?php echo e($s->keterangan); ?>

                    <?php endif; ?>
                </td>
                <td class="user-action">
                    <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('acc pengajuan surat')): ?>
                        <?php if($s->status === 'BELUM DI ACC'): ?>
                            <a type="button" href="#" name="accstaff" id="<?php echo e($s->id); ?>" class="accstaff btn btn-icon rounded-circle btn-light-success" title="ACC"><i class="bx bx-check"></i></a>    
                        <?php endif; ?>
                        <a type="button" href="<?php echo e(route('skdu.edit', [$s->id])); ?>" class="btn btn-icon rounded-circle btn-light-primary" title="Edit"><i class="bx bx-edit-alt"></i></a>
                    <?php endif; ?>
                    <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('print surat')): ?>  
                        <?php if(auth()->check() && auth()->user()->hasRole('admin|lurah|staff')): ?>
                        <?php if($s->status === 'SUDAH ACC STAFF'): ?>
                            <a type="button" href="<?php echo e(route('skdu.surat', [$s->id])); ?>" class="btn btn-icon rounded-circle btn-light-info" title="Lihat"><i class="bx bx-show"></i></a>   
                        <?php endif; ?>
                        <?php if($s->status === 'SUDAH ACC LURAH'): ?>
                            <a type="button" href="<?php echo e(route('skdu.surat', [$s->id])); ?>" class="btn btn-icon rounded-circle btn-light-info" title="Lihat"><i class="bx bx-show"></i></a>   
                        <?php endif; ?>
                        <?php endif; ?>
                        <?php if(auth()->check() && auth()->user()->hasRole('admin|lurah|staff|warga')): ?>
                        <?php if($s->status === 'SURAT SUDAH DICETAK'): ?>
                            <a type="button" href="<?php echo e(route('skdu.surat', [$s->id])); ?>" class="btn btn-icon rounded-circle btn-light-info" title="Lihat"><i class="bx bx-show"></i></a>   
                        <?php endif; ?>
                        <?php endif; ?>
                    <?php endif; ?>
                    <?php if(auth()->check() && auth()->user()->hasRole('admin|lurah|staff')): ?>
                        <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('hapus surat')): ?>   
                            <a type="button" href="#" name="delete" id="<?php echo e($s->id); ?>" class="delete btn btn-icon rounded-circle btn-light-danger" title="Hapus"><i class="bx bx-trash"></i></a>
                        <?php endif; ?> 
                    <?php endif; ?>
                    <?php if(auth()->check() && auth()->user()->hasRole('warga')): ?>
                    <?php if($s->status === 'BELUM DI ACC'): ?>
                        <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('hapus surat')): ?>   
                            <a type="button" href="#" name="delete" id="<?php echo e($s->id); ?>" class="delete btn btn-icon rounded-circle btn-light-danger" title="Hapus"><i class="bx bx-trash"></i></a>
                        <?php endif; ?>    
                    <?php endif; ?>
                    <?php endif; ?>    
                </td>
                </tr>
            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
            </tbody>

        </table>
    </div>
</section>
<div id="confirmModal" class="modal fade text-left" id="danger" tabindex="-1" role="dialog"
    aria-labelledby="myModalLabel120" aria-hidden="true">
    <div class="modal-dialog modal-dialog-centered">
        <div class="modal-content">
            <div class="modal-header bg-danger">              
                <h5 class="modal-title white">Konfirmasi</h5>
                <button type="button" class="close btn btn-sm" data-dismiss="modal" aria-label="Close">
                    <i class="bx bx-x"></i>
                </button>
            </div>
            <div class="modal-body">
                <h5 align="center" style="margin:0;">Apakah Anda yakin akan <span class="text-danger"> menghapus </span> data ini?</h5>
            </div>
            <div class="modal-footer">
                <button type="button" name="ok_button" id="ok_button" class="btn btn-sm btn-danger">OK</button>
                <button type="button" class="btn btn-sm btn-light-secondary" data-dismiss="modal">Batal</button>
            </div>
        </div>
    </div>
</div>
<div id="modalWait" class="modal fade text-left" id="danger" tabindex="-1" role="dialog"
    aria-labelledby="myModalLabel120" aria-hidden="true">
    <div class="modal-dialog modal-dialog-centered">
        <div class="modal-content">
            <div class="modal-header bg-warning">              
                <h5 class="modal-title white">Konfirmasi</h5>
                <button type="button" class="close btn btn-sm" data-dismiss="modal" aria-label="Close">
                    <i class="bx bx-x"></i>
                </button>
            </div>
            <div class="modal-body">
                <h5 align="center" style="margin:0;">Apakah Anda yakin akan <span class="text-warning"> menonaktifkan </span> data ini?</h5>
            </div>
            <div class="modal-footer">
                <button type="button" name="ok_wait" id="ok_wait" class="btn btn-sm btn-warning">OK</button>
                <button type="button" class="btn btn-sm btn-light-secondary" data-dismiss="modal">Batal</button>
            </div>
        </div>
    </div>
</div>
<div id="modalAccStaff" class="modal fade text-left" id="danger" tabindex="-1" role="dialog"
    aria-labelledby="myModalLabel120" aria-hidden="true">
    <div class="modal-dialog modal-dialog-centered">
        <div class="modal-content">
            <div class="modal-header bg-success">              
                <h5 class="modal-title white">Konfirmasi</h5>
                <button type="button" class="close btn btn-sm" data-dismiss="modal" aria-label="Close">
                    <i class="bx bx-x"></i>
                </button>
            </div>
            <div class="modal-body">
                <h5 align="center" style="margin:0;">Apakah Anda yakin akan <span class="text-success"> ACC </span> data ini?</h5>
            </div>
            <div class="modal-footer">
                <button type="button" name="ok_aktif" id="ok_aktif" class="btn btn-sm btn-success">OK</button>
                <button type="button" class="btn btn-sm btn-light-secondary" data-dismiss="modal">Batal</button>
            </div>
        </div>
    </div>
</div>
<div id="modalKTP" class="modal fade text-left" id="danger" tabindex="-1" role="dialog"
    aria-labelledby="myModalLabel120" aria-hidden="true">
    <div class="modal-dialog modal-dialog-centered">
        <div class="modal-content">
            <div class="modal-header">              
                <button type="button" class="close btn btn-sm" data-dismiss="modal" aria-label="Close">
                    <i class="bx bx-x"></i>
                </button>
            </div>
            <div class="modal-body">
                <span id="resultktp"></span>
            </div>
        </div>
    </div>
</div>
<div id="modalKK" class="modal fade text-left" id="danger" tabindex="-1" role="dialog"
    aria-labelledby="myModalLabel120" aria-hidden="true">
    <div class="modal-dialog modal-dialog-centered">
        <div class="modal-content">
            <div class="modal-header">              
                <button type="button" class="close btn btn-sm" data-dismiss="modal" aria-label="Close">
                    <i class="bx bx-x"></i>
                </button>
            </div>
            <div class="modal-body">
                <span id="resultkk"></span>
            </div>
        </div>
    </div>
</div>
<div id="modalfotousaha" class="modal fade text-left" id="danger" tabindex="-1" role="dialog"
    aria-labelledby="myModalLabel120" aria-hidden="true">
    <div class="modal-dialog modal-dialog-centered">
        <div class="modal-content">
            <div class="modal-header">              
                <button type="button" class="close btn btn-sm" data-dismiss="modal" aria-label="Close">
                    <i class="bx bx-x"></i>
                </button>
            </div>
            <div class="modal-body">
                <span id="resultfotousaha"></span>
            </div>
        </div>
    </div>
</div>
<!-- Column selectors with Export Options and print table -->

<?php $__env->stopSection(); ?>

<?php $__env->startSection('vendor-scripts'); ?>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.1.3/jszip.min.js"></script>
<script src="<?php echo e(asset('vendors/js/tables/datatable/datatables.min.js')); ?>"></script>
<script src="<?php echo e(asset('vendors/js/tables/datatable/dataTables.bootstrap4.min.js')); ?>"></script>
<script src="<?php echo e(asset('vendors/js/tables/datatable/dataTables.buttons.min.js')); ?>"></script>
<script src="<?php echo e(asset('vendors/js/tables/datatable/buttons.html5.min.js')); ?>"></script>
<script src="<?php echo e(asset('vendors/js/tables/datatable/buttons.print.min.js')); ?>"></script>
<script src="<?php echo e(asset('vendors/js/tables/datatable/buttons.bootstrap.min.js')); ?>"></script>
<script src="<?php echo e(asset('vendors/js/tables/datatable/pdfmake.min.js')); ?>"></script>
<script src="<?php echo e(asset('vendors/js/tables/datatable/vfs_fonts.js')); ?>"></script>
<?php $__env->stopSection(); ?>

<?php $__env->startSection('page-scripts'); ?>
<script src="<?php echo e(asset('js/scripts/datatables/datatable.js')); ?>"></script>
<script>
    $(document).ready(function() {
    var user_id;

    $(document).on('click', '.delete', function(){
        user_id = $(this).attr('id');
        $('#confirmModal').modal('show');
    });

    $('#ok_button').click(function(){
        $.ajax({
        url:"skdu/destroy/"+user_id,
        beforeSend:function(){
        $('#ok_button').text('Menghapus data...');
        },
        success:function(data)
        {
            setTimeout(function(){
            $('#confirmModal').modal('hide');
            $('#ok_button').text('OK');
            Swal.fire('Berhasil','Data berhasil dihapus!', 'success');
            }, 1500);

            setTimeout(function(){
                window.location.href = "<?php echo e(URL::to('skdu')); ?>"
            } , 3000);   
        }
        })
    });
    });
</script>
<script>
    $(document).ready(function() {
    var user_id;

    $(document).on('click', '.wait', function(){
        user_id = $(this).attr('id');
        $('#modalWait').modal('show');
    });

    $('#ok_wait').click(function(){
        $.ajax({
        url:"user/deaktivasi/"+user_id,
        beforeSend:function(){
        $('#ok_wait').text('Menonaktifkan data...');
        },
        success:function(data)
        {
            setTimeout(function(){
            $('#modalWait').modal('hide');
            $('#ok_wait').text('OK');
            Swal.fire('Berhasil','Data berhasil dinonaktifkan!', 'success');
            }, 1500);

            setTimeout(function(){
                window.location.href = "<?php echo e(URL::to('user')); ?>"
            } , 3000);   
        }
        })
    });
    });
</script>
<script>
    $(document).ready(function() {
    var user_id;

    $(document).on('click', '.accstaff', function(){
        user_id = $(this).attr('id');
        $('#modalAccStaff').modal('show');
    });

    $('#ok_aktif').click(function(){
        $.ajax({
        url:"skdu/accstaff/"+user_id,
        beforeSend:function(){
        $('#ok_aktif').text('Mengaktifkan data...');
        },
        success:function(data)
        {
            setTimeout(function(){
            $('#modalAccStaff').modal('hide');
            $('#ok_aktif').text('OK');
            Swal.fire('Berhasil','Data berhasil di ACC!', 'success');
            }, 1500);

            setTimeout(function(){
                window.location.href = "<?php echo e(URL::to('skdu')); ?>"
            } , 3000);   
        }
        })
    });
    });
</script>
<script>
    $(document).on('click', '.ktp', function (event) {

    event.preventDefault();
    var id = $(this).attr('id');
    console.log(id)
    $.get('skdu/ktp/'+id, function (data) {
        $('#modalKTP').modal('show');
        $('#resultktp').html('<img src="storage/'+data.data.scan_ktp+'" alt="avatar" width="100%">');
    })
    });
</script>
<script>
    $(document).on('click', '.kk', function (event) {

    event.preventDefault();
    var id = $(this).attr('id');
    console.log(id)
    $.get('skdu/kk/'+id, function (data) {
        $('#modalKK').modal('show');
        $('#resultkk').html('<img src="storage/'+data.data.scan_kk+'" alt="avatar" width="100%">');
    })
    });
</script>
<script>
    $(document).on('click', '.fotousaha', function (event) {

    event.preventDefault();
    var id = $(this).attr('id');
    console.log(id)
    $.get('skdu/fotousaha/'+id, function (data) {
        $('#modalfotousaha').modal('show');
        $('#resultfotousaha').html('<img src="storage/'+data.data.foto_usaha+'" alt="avatar" width="100%">');
    })
    });
</script>
<?php $__env->stopSection(); ?>
<?php echo $__env->make('layouts.contentLayoutMaster', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH /Users/mac/laravel-projects/wagom/resources/views/skdu/index.blade.php ENDPATH**/ ?>