<?php $__env->startSection('content'); ?>
<div class="card">
     <div class="card-header">
            <div class="row align-items-center">
                <div class="col">
                    <h5 class="mb-0">Attendance Settings</h5>
                </div>
                <div class="col-auto">
                    <a href="<?php echo e(route('attendance.settings.create')); ?>" class="btn btn-primary btn-sm">
                        Add Settings Profile
                    </a>
                </div>
            </div>       
        </div>
    <div class="card-body">
        <table class="table table-bordered yajra-datatable w-100">
            <thead>
                <tr>
                    <th>#</th>
                    <th>Name</th>
                    <th>Device ID</th>
                    <th>Branch</th>
                    <th>Source</th>
                    <th>Punch Mode</th>
                    <th>Default</th>
                    <th>Status</th>
                    <th width="150">Action</th>
                </tr>
            </thead>
        </table>
    </div>
</div>
<?php $__env->stopSection(); ?>

<?php $__env->startSection('scripts'); ?>
<script>
$(function () {

    let table = $('.yajra-datatable').DataTable({
        processing: true,
        serverSide: true,
        ajax: "<?php echo e(route('attendance.settings.index')); ?>",
        order: [[1, 'asc']],
        dom:
            "<'row mb-3 align-items-center'<'col-md-6'l><'col-md-6 d-flex justify-content-end'f>>" +
            "<'table-responsive'tr>" +
            "<'row mt-3 align-items-center'<'col-md-6'i><'col-md-6 d-flex justify-content-end'p>>",
        language: {
            search: "",
            searchPlaceholder: "Search settings...",
            lengthMenu: "Show _MENU_ entries",
            info: "Showing _START_-_END_ of _TOTAL_ settings"
        },
        columns: [
            { data: 'DT_RowIndex', orderable: false, searchable: false },
            { data: 'name', name: 'name' },
            { data: 'device_id', name: 'device_id' },
            { data: 'branch', orderable: false },
            { data: 'source_type', orderable: false, searchable: false },
            { data: 'punch_mode', orderable: false, searchable: false },
            { data: 'is_default', orderable: false, searchable: false },
            { data: 'status', orderable: false, searchable: false },
            { data: 'action', orderable: false, searchable: false }
        ]
    });

    // Delete handler
    $(document).on('click', '.btn-delete', function () {
        let id = $(this).data('id');

        Swal.fire({
            title: 'Delete this settings profile?',
            text: 'This will also delete all associated import logs.',
            icon: 'warning',
            showCancelButton: true,
            confirmButtonColor: '#d33',
            confirmButtonText: 'Yes, delete it!'
        }).then((result) => {
            if (result.isConfirmed) {
                $.ajax({
                    url: "<?php echo e(url('attendance/settings')); ?>/" + id,
                    type: 'DELETE',
                    data: { _token: "<?php echo e(csrf_token()); ?>" },
                    success: function (res) {
                        Swal.fire('Deleted', res.message, 'success');
                        table.ajax.reload();
                    }
                });
            }
        });
    });

    // Set Default handler
    $(document).on('click', '.btn-set-default', function () {
        let id = $(this).data('id');
        $.post("<?php echo e(url('attendance/settings')); ?>/" + id + "/set-default", {
            _token: "<?php echo e(csrf_token()); ?>"
        }).done(function(res) {
            Swal.fire('Success', res.message, 'success');
            table.ajax.reload();
        });
    });

    // Toggle Status handler
    $(document).on('click', '.btn-status', function () {
        let id = $(this).data('id');
        $.post("<?php echo e(url('attendance/settings')); ?>/" + id + "/status", {
            _token: "<?php echo e(csrf_token()); ?>"
        }).done(function(res) {
            Swal.fire('Success', res.message, 'success');
            table.ajax.reload();
        });
    });

});
</script>
<?php $__env->stopSection(); ?>

<?php echo $__env->make('layouts.app', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH /home/codeproh/demo.laraoffice.com/app/Modules/HR/Attendance/Providers/../Views/settings/index.blade.php ENDPATH**/ ?>