<?php $__env->startSection('content'); ?>
<div class="card">
    <div class="card-body">
        <h4 class="card-title">Distributors</h4>
        <div class="table-responsive">
            <table class="table table-bordered" id="distributors-table">
                    <thead>
                        <tr>
                            <th>Id</th>
                            <th>Username</th>
                            <th>Name</th>
                            <th>Phone</th>
                            <th>City</th>
                            <th>State</th>
                            <th>Created At</th>
                            <th>Updated At</th>
                            <th>Action</th>
                        </tr>
                    </thead>
                </table>
        </div>
    </div>
</div>
<!-- The Modal -->
<div class="modal fade" id="loadModalAjax" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" style="display: none;" aria-hidden="true">
  <div class="modal-dialog modal-lg" role="document" style="max-width:1000px;">
    <div class="modal-content">

      <!-- Modal Header -->
      <div class="modal-header">
        <h4 class="modal-title">Distributors</h4>
        <button type="button" class="close" data-dismiss="modal">&times;</button>
      </div>

      <!-- Modal body -->
      <div class="modal-body">
          <span>Loading...Please Wait</span> 
          <div class="progress m-t-30">
              <div class="progress-bar bg-success active progress-bar-striped active" style="width:100%; height:20px;" role="progressbar"></div>
          </div>
      </div>

      <!-- Modal footer -->
      <div class="modal-footer">
        <button type="button" class="btn btn-danger" data-dismiss="modal">Close</button>
      </div>

    </div>
  </div>
</div>

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

<?php $__env->startSection('javascript'); ?>
    <script>
        $('#distributors-table').DataTable({
                processing: true,
                serverSide: true,
                ajax: '<?php echo url('/'); ?>/admin/distributors/anydata',
                dom: 'Blfrtip',
                'pageLength': 30,
                'lengthMenu': [ [10, 30, 50, -1], [10, 30, 50, "All"] ],
                'buttons': [
                            'copy', 'csv', 'excel', 'pdf', 'print'
                        ],
                'columns': [
                    { data: 'id', name: 'id' },
                    { data: 'username', name: 'username' },
                    { data: 'full_name', name: 'full_name' },
                    { data: 'mobileno', name: 'mobileno' },
                    { data: 'city', name: 'city' },
                    { data: 'state', name: 'state' },
                    { data: 'created_at', name: 'created_at' },
                    { data: 'updated_at', name: 'updated_at' },
                    { data: 'action', name: 'action' }
                ],
                'order': [[0, 'asc']],
                drawCallback: function( settings ) {
                    openModal();
                  },
                initComplete: function() {
                    
                }
            });

            function openModal(){
                $('.openModal').click(function(){
                  
                  if($(this).hasClass('loadDeals')){
                    var url ='<?php echo e(url('/')); ?>/admin/distributors/' + $(this).attr('data-id') + '/loadDeals';
                  }else{
                    var url ='<?php echo e(url('/')); ?>/admin/distributors/' + $(this).attr('data-id') + '/edit';
                  }
              	 
                 $('#loadModalAjax .modal-body').load(url,function(result){
            	    $('#loadModalAjax').modal({show:true});
                  //init_validation('#updateStudentForm', rules, messages);
            	   });
                });
                
                $('.activate').click(function(){
                    var ele = $(this);
                    $.ajax({
                       url: '<?php echo e(url('/')); ?>/admin/distributors/ajax_update/' + $(this).attr('data-id'),
                       type: 'PUT',
                       data: { "_token": "<?php echo e(csrf_token()); ?>", id : $(this).attr('data-id'), active : $(this).attr('data-active') },
                       success: function(response) {
                         if(response == true){
                            if(ele.attr('data-active') == 1){
                                ele.removeClass('btn-warning').addClass('btn-danger').attr('data-active','0').find('span.ladda-label').text('Deactivate');
                            }else{
                                ele.removeClass('btn-danger').addClass('btn-warning').attr('data-active','1').find('span.ladda-label').text('Activate');
                            }
                         }else{
                            alert('error'+ response);
                         }
                       }
                    });
                });              
                

                $('.openModalInvoices').click(function(){
              	 $('#loadModalAjax .modal-content').load('/student_invoices_modal.php?id=' + $(this).attr('data-id'),function(result){
            	    $('#loadModalAjax').modal({show:true});
                  //init_validation('#updateStudentForm', rules, messages);
            	   });
              });
            }

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

<?php echo $__env->make('layouts.app', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH G:\xampp\htdocs\yeselectricv.loc\resources\views/admin/distributors/index.blade.php ENDPATH**/ ?>