<?php $__env->startSection('content'); ?>
<div class="row">
    <div class="col-12">
        <div class="card mt-2">
            <div class="card-header">
                <h3 class="card-title">
                 Customer List
                </h3>
              
            </div>
            <div class="card-body table-responsive">
          


<?php echo csrf_field(); ?>
<div class="row ">

<div class="col-lg-2 form-group">
                <label class="required">Finances</label>
                <select class="form-control <?php echo e($errors->has('level') ? 'is-invalid' : ''); ?>" name="finances" id="finances">
                    <option value >
                        <?php echo e(trans('global.pleaseSelect')); ?></option>
                        <?php $__currentLoopData = $finances; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $orgCode => $finances): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                        <option value="<?php echo e($orgCode); ?>" <?php echo e((in_array($orgCode, old('finances', [])) || isset($customer) && $customer->finances->contains($orgCode)) ? 'selected' : ''); ?>>
                            <?php echo e($finances); ?>

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

                <input type="hidden" name="_token" id="token" value="<?php echo e(csrf_token()); ?>">
                
           
            
            <div class="form-group col-lg-1">
            <label class="required">&nbsp</label>
                <button class="btn btn-primary btn-block float-right" name="btnload" id="btnload" type="submit">
                   Load
               </button>
             
              </div>
              <div class="col-lg-1 form-group">
                <label class="required">&nbsp</label>
                <a href="<?php echo e(route('admin.get_registered_customer')); ?>" class="btn btn-secondary btn-block float-right">Reset</a>
                
              </div>
              </div>
              
</div>
<div class="table-responsive">
                <table class="table table-head-fixed table-bordered text-nowrap" id="data-table">
                    <thead>
                        <tr>
                            <th width="30px"><input type="checkbox" class="check" id="check_all"></th>
                            <th>Finance</th>
                            <th>Acc Code</th>
                            <th>Name</th>
                            <th>Address</th>
                            <th>Mobile</th>
                            <th>Balance</th>
                            <th>Account Type</th>
                            <th>Interest Amount</th>
                            <th>Fine Amount</th>                            
                             <th>Action</th>
                            
                        </tr>
                    </thead>
                    <tbody class="text-nowrap">
                       
                       
                    </tbody>
                </table>
                </div>
            </div>
        </div>
    </div>
</div>

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

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

<script>
function approveform(id){
  if(confirm("Are you sure you want to approve the form?") == false) {
              return false;
          }
    var url = "<?php echo e(url('approve-form')); ?>/"+id;
      $.ajax({
        url: url,
        method: 'get',
        success: function(result){
              alert(result);
              $("#btnload").click()

              //window.location.reload(false); 
          }});
}
function rejectform(id){
  
    $('#rejectid').val(id);
  $('.modal').modal();
}


 
    $(document).ready(function() {


     
    $("#btnload").button().click(function(){
      
        var datas = {
        "_token": $('#token').val(),
        "finances": $('#finances').val(),
    };
        var t = $('.table').DataTable({
            dom: 'Blfrtip',
            "lengthMenu": [[10, 100, 500, 1000], [10, 100, 500, 1000]],
            searchable:false,
          processing: true,
        serverSide: true,
        responsive: true,
        destroy: true,
        "buttons": [
                          
                          {
                              "extend": 'excel',
                              "text": 'Excel',
                              "titleAttr": 'Excel',                               
                              "action": newexportaction,
                              className: 'btn btn-warning',
                   exportOptions: {
                   columns: ':not(:last-child)',
               
               }
                          },
               
],
        
        "ajax": {
    "url": '<?php echo e(route('admin.get_registered_customer')); ?>',
    "type": "POST",
    "data":datas,
},

       
        columns: [
               {  data : 'DT_RowIndex',
                orderable: false, 
                    searchable: false,
         render : function(data, type, row) {
             datasss = data+'<input type="checkbox" class="approve_class" name="sel_app[]" value="submission_no" >'
           return datasss;
                                        }},
                   
                { "data": "finance" },
                {"data": "acCode"},
                {"data": "name"},
                {"data": "address"},
                {"data": "mobile"},
                {"data": "balance"},
                {"data": "acType"},
                {"data": "interest"},
                {"data": "fine"},
                {  data : 'action',
         render : function(data, type, row) {
            
           return data;
  
       },
       },    
            ]    
           
        });

        var buttons = new $.fn.dataTable.Buttons(t, {
            buttons: [
                {
                    extend: 'excel',
                    className: 'btn btn-warning',
                    exportOptions: {
                    columns: ':not(:last-child)',
                
                }
                },
               
            ],
}).container().appendTo($('#buttons'));
      
    });
    
    
    $('#check_all').on('click',function(){
        if(this.checked){
            $('.approve_class').each(function(){
                this.checked = true;
            });
        }else{
             $('.approve_class').each(function(){
                this.checked = false;
            });
        }
    });
    
  
});   


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

<?php echo $__env->make('layouts.admin', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH /var/www/html/finance/resources/views/admin/customers/index.blade.php ENDPATH**/ ?>