
<?php $__env->startSection('content'); ?>
<div class="main-header">
    <div class="admin-header">
        <div class="uk-grid">
            <div class="uk-width-1-2@m uk-text-center uk-text-left@l">
                <h1 class="uk-margin-small-top main-heading"><?php echo e($title); ?></h1>
            </div>
            <div class="uk-width-1-2@m uk-text-center uk-text-right@l">
                <a class="uk-button uk-button-primary" href="<?php echo e(url('admin/regions/'.$provinceId.'/create')); ?>"> Add Region</a>
                <a class="uk-button uk-button-default" href="<?php echo e(url('admin/provinces')); ?>">Back</a>
            </div>
        </div>
    </div>
</div>
<div class="uk-overflow-auto">
    <?php echo $__env->make('partials.messages', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?>
    <table class="uk-table uk-table-divider" id="regions">
        <thead>
            <tr>  
                <th>Actions</th>
                <th>Ordering</th>
                <th>City</th>
                <th>Name</th>
            </tr>
        </thead>
    </table>
</div>    
<?php $__env->stopSection(); ?>
<?php $__env->startSection('footer-script'); ?>
<script>
    $('#regions').DataTable({
        processing: true,
        pageLength: 100,
        responsive: true,
        serverSide: true,
        ordering: true,
        bPaginate: true,
        bLengthChange: false,
        bFilter: true,
        bInfo: false,
        bAutoWidth: false,
        language: {
            search: '',
            searchPlaceholder: 'Search'
        },
        // aaSorting: [[1, 'desc']],
        ajax: window.location.href, 
        columns: [
            { data: 'actions',orderable: false, name: 'actions',searchable: false, width: "1%" },
            { data: 'ordering',orderable: true, name: 'ordering',searchable: true, width: "1%" },
            { data: 'city',orderable: true, name: 'city',searchable: true, width: "1%" },
            { data: 'name',orderable: true, name: 'name',searchable: true, width: "5%" },
        ],
        order: [[ 1, "asc" ]]
    });
    
    $(document).on('click','.delete-region',function(){
        var id   = $(this).data('id');
        var clst = $(this).closest('tr');
        UIkit.modal.confirm('Are you sure you want to delete this Region?').then(function() {
            $.ajax(
            {
                url: url +  "/admin/delete-regions",
                type: 'POST',
                dataType: "JSON",
                data : {
                    'id':id
                },
                success: function (res)
                {
                    if(res.success == 1){
                        clst.remove();
                        UIkit.modal.alert('Region successfully deleted.');
                    }
                }
            });
        }, function () {
        });
    });
    

</script>
<?php $__env->stopSection(); ?>
<?php echo $__env->make('layouts.app', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH /home/kelowna/public_html/listingllama.kelowna.website/resources/views/admin/regions/index.blade.php ENDPATH**/ ?>