
<?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(route('admin.heating-fuels.create')); ?>"> Add Heating and Cooling</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="heating_fuels">
        <thead>
            <tr>  
                <th>Actions</th>
                <th>Status</th>
                <th>Ordering</th>
                <th>Name</th>
            </tr>
        </thead>
    </table>
</div>    
<?php $__env->stopSection(); ?>
<?php $__env->startSection('footer-script'); ?>
<script>
    $('#heating_fuels').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: 'status',orderable: false, name: 'status',searchable: false, width: "1%" },
            { data: 'ordering',orderable: true, name: 'ordering',searchable: true, width: "1%" },
            { data: 'name',orderable: true, name: 'name',searchable: true, width: "10%" },
        ],
        order: [[ 2, "asc" ]]
    });
    
    $(document).on('click','.delete-heating-fuel',function(){
        var id   = $(this).data('id');
        var clst = $(this).closest('tr');
        UIkit.modal.confirm('Are you sure you want to delete this heating and cooling?').then(function() {
            $.ajax(
            {
                url: url + "/admin/heating-fuels/"+id,
                type: 'DELETE',
                dataType: "JSON",
                success: function (res)
                {
                    if(res.success == 1){
                        clst.remove();
                        UIkit.modal.alert('Heating and cooling successfully deleted.');
                    }
                }
            });
        }, function () {
        });
    });
    
     $(document).on('click','.active',function(){
        var id   = $(this).data('id');
        var clst = $(this).closest('td');
        UIkit.modal.confirm('Are you sure you want to inactive this heating and cooling?').then(function() {
            $.ajax(
            {
                url: url +  "/admin/heating-fuel-status",
                type: 'POST',
                dataType: "JSON",
                data : {
                    type : 'inactive',
                    'id':id
                },
                success: function (res)
                {
                    if(res.success == 1){
                        clst.html("<a href='javascript:void(0)' data-id='"+id+"' class='uk-label uk-label-danger inactive'>Inactive</a>");
                    }
                }
            });
        }, function () {
        });
    });
    
    $(document).on('click','.inactive',function(){
        var id   = $(this).data('id');
        var clst = $(this).closest('td');
        UIkit.modal.confirm('Are you sure you want to active this heating and cooling?').then(function() {
            $.ajax(
            {
                url: url +  "/admin/heating-fuel-status",
                type: 'POST',
                dataType: "JSON",
                data : {
                    type : 'active',
                    'id':id
                },
                success: function (res)
                {
                    if(res.success == 1){
                        clst.html("<a href='javascript:void(0)' data-id='"+id+"' class='uk-label uk-label-success active'>Active</a>");
                    }
                }
            });
        }, 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/heating_fuels/index.blade.php ENDPATH**/ ?>