

<?php $__env->startSection('title'); ?>
    All Cancel Units
<?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 Blocked Units</li>
    </ol>
<?php $__env->stopSection(); ?>
<?php $__env->startSection('css'); ?>

    <link href="https://cdn.datatables.net/1.10.24/css/jquery.dataTables.min.css" rel="stylesheet">
    <link href="https://cdn.datatables.net/buttons/1.7.0/css/buttons.dataTables.min.css" rel="stylesheet">

    <style>
        table.dataTable thead .sorting_asc {
            background-image: none !important;
        }

        .table.dataTable,
        table.dataTable {
            width: 99.8% !important;
        }
    </style>

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

<?php $__env->startSection('content'); ?>


    <div class="container-fluid">
        <!-- /row -->



        <div class="row" id="update-table">
            <div class="col-sm-12">
                <div class="white-box">
                    <div class="pull-right">
                        

                        <a href="<?php echo e(route('property.block.history')); ?>" class="btn  btn-primary">
                            <i class="fa fa-plus-square"></i>&nbsp; View History
                        </a>
                    </div>

                    <h3 class="box-title">Blocked Units (<?php echo e(number_format($statementCount)); ?>)</h3>

                    <div class="table-responsive">
                        <table id="myTable" class="table table-striped">
                            <thead>
                                <tr>
                                    <th>#</th>


                                    <th>Unit #</th>
                                    
                                    <th>Member Name</th>
                                    <th>Net Amount</th>

                                    <th>Received Amount</th>

                                    <th>Block Date</th>
                                   
                                  
                                    <th>Unit Status</th>
                                    <th>Action</th>
                                    
                                </tr>
                            </thead>
                            <tbody>
                                <?php $count = 1; ?>


                             

                                <?php if (\Illuminate\Support\Facades\Blade::check('permission', 'view-block')): ?>
                                    <?php $view_membership = true; ?>
                                <?php else: ?>
                                    <?php $view_membership = false; ?>
                                <?php endif; ?>

                                <?php if (\Illuminate\Support\Facades\Blade::check('permission', 'edit-block')): ?>
                                <?php $edit_membership = true; ?>
                                <?php else: ?>
                                <?php $edit_membership = false; ?>
                               <?php endif; ?>

                               <?php if (\Illuminate\Support\Facades\Blade::check('permission', 'delete-block')): ?>
                               <?php $delete_membership = true; ?>
                               <?php else: ?>
                               <?php $delete_membership = false; ?>
                              <?php endif; ?>



                                <?php $__currentLoopData = $allStatements; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $statement): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                    <tr>
                                        <td><?php echo e($count++); ?></td>


                                        <td><?php echo e($statement->inventory->unit_number); ?></td>
                                      
                                        <td><?php echo e($statement->customer ? $statement->customer->name : ''); ?><br><b>Dealer:
                                            </b><?php echo e($statement->dealer ? $statement->dealer->name : ''); ?></td>

                                        <td><b><?php echo e(number_format($statement->net_pay)); ?></b></td>


                                        <td><b><?php echo e(number_format($receivedAmt[$statement->id])); ?></b></td>
                                        <td><b><?php echo e($statement->block_date); ?></b></td>



                                                                               
                                      

                                      


                                        <?php if($statement->status == \App\CustomerProperty::pending): ?>
                                            <td><span class="label label-primary"
                                                    style="background-color:#cd703d;">Pending</span></td>
                                        <?php elseif($statement->status == \App\CustomerProperty::approved): ?>
                                            <td><span class="label label-success">Approved</span></td>
                                        <?php elseif($statement->status == \App\CustomerProperty::cancel): ?>
                                            <td><span class="label label-danger">Canceled</span></td>
                                        <?php elseif($statement->status == \App\CustomerProperty::block): ?>
                                            <td><span class="label label-danger" style="background-color:red;">Blocked</span></td>
                                        <?php else: ?>
                                            <td></td>
                                        <?php endif; ?>
                                     
                                         

                                        


                                        <td class="text-nowrap">
                                            <center>
                                                <?php if($view_membership): ?>
                                                    <a href="<?php echo e(route('statement.detail', ['id' => $statement->id])); ?>"
                                                        data-toggle="tooltip" data-original-title="View"> <i
                                                            class="fa fa-eye text-inverse m-r-10"></i>&nbsp;&nbsp;</a>
                                                <?php endif; ?>
                                                <?php if($edit_membership): ?>
                                                  
                                                <a  type='button'
                                                data-toggle="tooltip" data-original-title="Reopen"
                                                    onclick="confirmReopen('<?php echo e($statement->id); ?>')"> <i
                                                        class="fa fa fa-repeat text-inverse m-r-10"></i>&nbsp;&nbsp;</a>
                                           
                                                 <?php endif; ?>
                                            </center>
                                        </td>

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

                            </tbody>
                        </table>
                        <div style="float: right;"><?php echo e($allStatements->links()); ?></div>
                    </div>
                </div>
            </div>
        </div>
        <!-- /.row -->
    </div>
    <!-- /.container-fluid -->


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

<?php $__env->startSection('js'); ?>

    <script src="https://cdn.datatables.net/1.10.24/js/jquery.dataTables.min.js"></script>
    <script src="https://cdn.datatables.net/buttons/1.7.0/js/dataTables.buttons.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.1.3/jszip.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.53/pdfmake.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.53/vfs_fonts.js"></script>
    <script src="https://cdn.datatables.net/buttons/1.7.0/js/buttons.html5.min.js"></script>
    <script src="https://cdn.datatables.net/buttons/1.7.0/js/buttons.print.min.js"></script>

    <script>
        function confirmReopen(val) {
        
            var CSRF_TOKEN = $('meta[name="csrf-token"]').attr('content');
           


            Swal.fire({
                        title: "Are you sure?",
                        text: "You want to reopen the Unit!",
                        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('property.block.update')); ?>',
                                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();
                                            Swal.fire("Poof! Unit Reopened Successfully!", {
                                                
                confirmButtonColor: '#3085d6',
                cancelButtonColor: '#d33',
                confirmButtonText: 'Yes, Sure!'
                                            }) .then((result) => {location.reload();});
                                }
                            });
                        } else {
                            $('.preloader').fadeOut();
                            Swal.fire("OK! Action Revert");
                        }
                    });



        
            // return false;
            // if (confirm('Are you sure you want to reopen this property.')) 
            // {
            //    return true; 
            // }
            // else
            // {
            //     return false;
            // }
            $('.preloader').fadeOut();
        }
        $(function() {
            $('#myTable').DataTable({
                'pageLength': 25,
                'paging': false,
                'searching': false,
                'info': false,
                'dom': 'Bfrtip',
                'buttons': [
                    'copy', 'csv', 'excel', 'pdf', 'print'
                ]
            });
        });
    </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/statement/block/index.blade.php ENDPATH**/ ?>