

<?php $__env->startSection('title'); ?>
    Map Inventory
<?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">All Map File Inventory</li>
    </ol>
<?php $__env->stopSection(); ?>
<?php $__env->startSection('css'); ?>
    <style type="text/css">
        .bg-color {
            background-color: #1c3752;
        }
    </style>
<?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">

                        




                    </div>
                    <h3 class="box-title">File Detail</h3>
                    <?php if (\Illuminate\Support\Facades\Blade::check('permission', 'edit-balloting')): ?>
                    <?php endif; ?>
                    <div class="table-responsive">


                        <table id="myTable" class="table table-bordered table-hover">
                            <thead>
                                <tr>
                                    <th>#</th>
                                    <th>
                                        Sr No</th>
                                    <th> Plot No </th>
                                    <th>Category(Area)</th>


                                    <th>Feature</th>
                                    <th>
                                        Exact/Odd</th>
                                    <th> Sector </th>
                                    <th>Road Category</th>
                                    <th>Street</th>
                                    <th>Type</th>
                                    <th>Cnic</th>
                                    <th>MemberShip No</th>

                                    <th>Inventory</th>
                                    <th>Action</th>
                                </tr>
                            </thead>
                            <tbody>
                                <?php $count = 1; ?>
                                <?php $__currentLoopData = $balloting_file->mapDetail; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $file): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                    <tr>
                                        <td><?php echo e($count++); ?></td>
                                        <td><?php echo e($file->sr_no); ?> </td>
                                        <td><?php echo e($file->plot_no); ?> </td>
                                        <td><?php echo e($file->area); ?> Marla </td>
                                        <td><?php echo e($file->feature); ?> </td>
                                        <td><?php echo e($file->exact_odd); ?> </td>
                                        <td><?php echo e($file->sector); ?> </td>
                                        <td><?php echo e($file->road_category); ?> </td>

                                        <td><?php echo e($file->street); ?> </td>
                                        <td><?php echo e($file->type); ?> </td>
                                        <td><?php echo e($file->cnic); ?> </td>
                                        <td><?php echo e($file->membershipno); ?> </td>
                                        <?php if($file->Inventory): ?>
                                            <td><a href="<?php echo e(route('inventory.detail', $file->Inventory->id)); ?>"><?php echo e($file->Inventory->unit_number); ?>

                                                </a></td>
                                        <?php else: ?>
                                            <td>NIL</td>
                                        <?php endif; ?>

                                        <td>
                                            <?php if(!$file->Inventory): ?>
                                                <?php if (\Illuminate\Support\Facades\Blade::check('permission', 'edit-balloting')): ?>
                                                    <a href="<?php echo e(route('balloting.direct.map.inventory.edit', $file->id)); ?>"
                                                        data-toggle="tooltip" datza-original-title="Edit"> <i
                                                            class="fa fa-pencil text-inverse m-r-10"></i>&nbsp;&nbsp;</a>
                                                <?php endif; ?>
                                            <?php endif; ?>
                                            <?php if($file->Inventory): ?>
                                                <?php if($file->balloting_status == \App\BallotingMapDetail::balloting_pending): ?>
                                                    <?php if (\Illuminate\Support\Facades\Blade::check('permission', 'edit-balloting')): ?>
                                                        <a href="<?php echo e(route('balloting.direct.approve', $file->id)); ?>"
                                                            data-toggle="tooltip" datza-original-title="approve"> <i
                                                                class="fa fa-check-circle text-inverse m-r-10"></i>&nbsp;&nbsp;</a>
                                                    <?php endif; ?>

                                                    <?php if (\Illuminate\Support\Facades\Blade::check('permission', 'delete-balloting')): ?>
                                                        <button class="btn  btn-primary" id='postbutton'
                                                            onclick='callFunc(<?php echo e($file->id); ?>)' type='button'>
                                                            <i class="fa fa-trash-o"></i>&nbsp;Remove
                                                        </button>
                                                    <?php endif; ?>
                                                <?php else: ?>
                                                    <span class='label label-success'>Approved</span>
                                                <?php endif; ?>
                                            <?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>
        $(function() {
            // $('#myTable').DataTable({

            //     "displayLength": 25000,
            // });

            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'
            ]
        });


        var CSRF_TOKEN = $('meta[name="csrf-token"]').attr('content');
        // $("#postbutton").click(function() {
        function callFunc(val) {
            Swal.fire({
                    title: "Are you sure?",
                    text: "you want to remove inventory from map !",
                    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('balloting.direct.map.inventory.remove')); ?>',
                            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) {
                                $('.preloader').fadeOut();
                                if (data.success) {
                                    Swal.fire({
                                            icon: 'success',
                                            title: 'Your Data has been removed',
                                            confirmButtonText: 'ok!'
                                        })
                                        .then((result) => {
                                            if (result.isConfirmed) {
                                                location.reload();

                                            }
                                        })

                                }



                            },
                            error: function(xhr, status, error) {
                                $('.preloader').fadeOut();
                                Swal.fire({
                                    icon: 'error',
                                    title: 'Oops...',
                                    text: 'Something went wrong!',

                                })
                            }

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

        }

        function callApproveFunc(val) {
            Swal.fire({
                    title: "Are you sure?",
                    text: "you want to remove approve map inventory !",
                    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('balloting.direct.approve.all')); ?>',
                            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) {
                                $('.preloader').fadeOut();
                                if (data.success) {
                                    Swal.fire({
                                            icon: 'success',
                                            title: 'Balloting Approved Successfully',
                                            confirmButtonText: 'ok!'
                                        })
                                        .then((result) => {
                                            if (result.isConfirmed) {
                                                location.reload();

                                            }
                                        })

                                }



                            },
                            error: function(xhr, status, error) {
                                $('.preloader').fadeOut();
                                Swal.fire({
                                    icon: 'error',
                                    title: 'Oops...',
                                    text: 'Something went wrong!',

                                })
                            }

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

        }

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

<?php echo $__env->make('layouts.app', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH C:\xampp\htdocs\erpv7\resources\views/balloting/direct/view.blade.php ENDPATH**/ ?>