

<?php $__env->startSection('title'); ?>
    Unit Blockage Criteria
<?php $__env->stopSection(); ?>

<?php $__env->startSection('breadcrumb'); ?>
    <ol class="breadcrumb pull-right">
        <li><a href="<?php echo e(route('home')); ?>"><i class="fa fa-dashboard"></i> Home</a></li>

        <li class="active">Unit Blockage Criteria</li>
    </ol>
<?php $__env->stopSection(); ?>
<?php $__env->startSection('content'); ?>


    <div class="container-fluid">
        <!-- /row -->
        <div class="row">
            <div class="col-sm-12">
                <div class="white-box">
                    <div class="pull-right" style="margin-top: 10px;">
                        <?php if (\Illuminate\Support\Facades\Blade::check('permission', 'create-unit-block-criteria')): ?>
                            <a href="<?php echo e(route('unitblockage.create')); ?>" class="btn  btn-primary">
                                <i class="fa fa-plus-square"></i>&nbsp; Add New Criteria
                            </a>
                        <?php endif; ?>

                    </div>
                    <h3 class="box-title">Unit Block Criteria List</h3>

                    <div class="table-responsive">
                        <table id="myTable" class="table table-striped">
                            <thead>
                                <tr>
                                    <th>#</th>
                                    <th>Name</th>
                                    <th>Total Days</th>
                                    <th>Total Due Amounts</th>

                                    <th>Description</th>
                                    <th>Status</th>

                                    <th>Action</th>
                                </tr>
                            </thead>
                            <tbody>
                                <?php $count = 1; ?>
                                <?php $__currentLoopData = $unit_criteria; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $uc): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                    <tr>
                                        <td><?php echo e($count++); ?></td>
                                        <td><?php echo e($uc->criteria_no); ?></td>
                                        <td><?php echo e($uc->total_days); ?></td>
                                        <td><?php echo e(number_format($uc->total_amount)); ?></td>
                                        <td><?php echo e($uc->description); ?></td>
                                        <?php if($uc->status == true): ?>
                                            <td><span class="label label-success">Active</span></td>
                                        <?php else: ?>
                                            <td><span class="label label-danger">InActive</span></td>
                                        <?php endif; ?>

                                        <td class="text-nowrap">



                                            <?php if (\Illuminate\Support\Facades\Blade::check('permission', 'edit-unit-block-criteria')): ?>
                                                <a type='button' onclick="callCriteriaFunction('<?php echo e($uc->id); ?>')" data-toggle="tooltip" data-original-title="Active">
                                                    <i class="fa fa-wrench text-inverse m-r-10"></i>
                                                </a>

                                                <a href="<?php echo e(route('unitblockage.edit',['id'=>$uc->id])); ?>" data-toggle="tooltip" data-original-title="Edit"> <i class="fa fa-pencil text-inverse m-r-10"></i> </a>
                                               
                                            <?php endif; ?>



                                        </td>
                                    </tr>
                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>

                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
        </div>
        <!-- /.row -->
    </div>
    <!-- /.container-fluid -->

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

<?php $__env->startSection('js'); ?>
    <script>
        var CSRF_TOKEN = $('meta[name="csrf-token"]').attr('content');

        function callCriteriaFunction(val) {
           
 
            Swal.fire({
                    title: "Are you sure?",
                    text: "you want to active this criteria!",
                    icon: "warning",
                    buttons: true,
                    dangerMode: true,
                    showCancelButton: true,
                    confirmButtonColor: '#3085d6',
                    cancelButtonColor: '#d33',
                    confirmButtonText: 'Yes, Sure!'
                })
                .then((result) => {
                    if (result.isConfirmed) {
                        $('.preloader').fadeIn();
                        $.ajax({
                            /* the route pointing to the post function */
                            url: '<?php echo e(route('unitblockage.active')); ?>',
                            type: 'POST',
                            /* send the csrf-token and the input to the controller */
                            data: {
                                _token: CSRF_TOKEN,
                                id: val
                            },
                            dataType: 'JSON',
                            /* remind that 'data' is the response of the AjaxController */
                            success: function(data) {

                               if(data.msg){
                                Swal.fire("Criteria Active Successfully!");
                               }

                               $('.preloader').fadeOut();
                               location.reload();




                            }
                        });
                    } else {
                        Swal.fire("Data is safe!");
                        $('.preloader').fadeOut();
                    }
                });



        }
        $(function() {
            $('#myTable').DataTable();

            var table = $('#example').DataTable({
                "columnDefs": [{
                    "visible": false,
                    "targets": 2
                }],
                "order": [
                    [2, 'asc']
                ],
                "displayLength": 25,
                "drawCallback": function(settings) {
                    var api = this.api();
                    var rows = api.rows({
                        page: 'current'
                    }).nodes();
                    var last = null;
                    api.column(2, {
                        page: 'current'
                    }).data().each(function(group, i) {
                        if (last !== group) {
                            $(rows).eq(i).before('<tr class="group"><td colspan="5">' + group +
                                '</td></tr>');
                            last = group;
                        }
                    });
                }
            });
            // Order by the grouping
            $('#example tbody').on('click', 'tr.group', function() {
                var currentOrder = table.order()[0];
                if (currentOrder[0] === 2 && currentOrder[1] === 'asc') {
                    table.order([2, 'desc']).draw();
                } else {
                    table.order([2, 'asc']).draw();
                }
            });
        });
        $('#example23').DataTable({
            dom: 'Bfrtip',
            buttons: [
                'copy', 'csv', 'excel', 'pdf', 'print'
            ]
        });
    </script>
    <script></script>
<?php $__env->stopSection(); ?>

<?php echo $__env->make('layouts.app', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH /home/proje372/akram-city.projecterp.net/resources/views/Setting/unitblockage/index.blade.php ENDPATH**/ ?>