    @extends('superadmin.include.master')
@section('page_title','Admin User')
@section('content')

		
<!--start page wrapper -->
<div class="page-wrapper">
     <div class="page-breadcrumb  mt-3 main_header card p-1">
         <div class="row">
         <div class="col-md-9">
                        <div class="breadcrumb-title d-flex align-items-center ms-3">
                            <i class="bx bx-user me-1 mb-1"></i>
                            <span>Admin User</span>
                        </div>
                        </div>
                            <div  class="col-md-3 text-end" >
                                      @if(permission(session('SUPERADMIN_ID'), '4', 'action_add'))
  <a href="{{asset('superadmin/adminuseradd')}}" class="btn py-1 px-3 btn-primary">Add </a>
@endif
                    </div>
                    </div>
    </div>
	<div class="page-content">
	     <div class="row">
					<div class="col-xl-12">
                
					<div class="card">
					 <!--   <div class="card-header  text-capitalize">-->
      <!--                      <h6 class="mb-0">Admin User </h6>-->
						<!--</div>-->
					 <div class="card-body">
						<div class="table-responsive">
							<table id="adminusertable" class="table table-striped  dataTable border table-bordered no-footer" style="width:100%">
								<thead>
									<tr class="hello1" >
    								<th>ID</th>
										<th>Image</th>
										<th>Role</th>
										<th>Name</th>
										<th>Number</th>
										<th>Email</th>
										<th>Status</th>
										<th>Action</th>
									</tr>
								</thead>
								<tbody>
								</tbody>
							</table>
						</div>
					</div>
				</div>
					</div>
					
				</div>
  
	    	</div>

	 
</div>		
@endsection


@push('scripts')
 <script>
        $(document).ready(function () {
         
            $.ajaxSetup({
                headers: {
                    "X-CSRF-TOKEN": $('meta[name="csrf-token"]').attr("content"),
                },
            });

            $("#adminusertable").DataTable({
                 @include('superadmin.include.datatableajax.datatablefilter')
                
                processing: true,
                serverSide: true,
                serverMethod: "POST",
               ajax: {
                        url: "{{ route('superadmin.houseajexadminuser') }}",
                       data: function (d) {
    d.role = $('#role').val();
    d.emailmobile = $('#emailmobile').val();
},
 beforeSend: function () {
                    $('#loader').show(); 
                    },
                    complete: function () {
                    $('#loader').hide(); 
                   
                     }
                  
                    },
                    
                columns: [
                    { data: "id" },
                    { data: "image", title: "Image" },
                    { data: "role", title: " Role" },
                    { data: "name", title: " Name" },
                    { data: "number", title: " Number" },
                   
                    { data: "email", title: "Email" },
                    { data: "status", title: " Status" },
                    { data: "action", title: "Action" }
                ],
            });
        });
    </script>

	

	<script>
	    	$(document).on('change', '.toggle-flip input[type="checkbox"]', function () {
    let status = $(this).prop('checked') ? 1 : 0;
    let userId = $(this).data('id');

    $.ajax({
        type: "POST",
        url: "{{ asset('superadmin/adminuserstatus') }}",
        data: {
            status: status,
            id: userId,
            _token: '{{ csrf_token() }}',
        },
        success: function (response) {
            console.log("Status updated", response);
        },
        error: function (xhr) {
            console.log("AJAX Error:", xhr);
            alert("Something went wrong");
        }
    });
});
	</script>
@endpush	