<!-- Modal -->
<div class="modal fade" id="addUserModal" tabindex="-1" aria-labelledby="addUserModalLabel">
    <div class="modal-dialog modal-lg">
      <div class="modal-content">
        <div class="modal-header">
          <h5 class="modal-title" id="addUserModalLabel">New User Form 001</h5>
          <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
        </div>
        <div class="modal-body">
            <div class="alert alert-success d-none" id="newUserSuccessArea"></div>
            <p class="alert alert-danger d-none" id="newUserErrorArea"></p>
            <div class="container-fluid">
            <div class="row">  
            <form class="row g-3" action="" method="POST" id="newUserForm">
              @csrf
              <input type="hidden" name="action" value="newuser">
              <div class="col-md-12">
                  <div class="form-check">
                  <input class="form-check-input" type="radio" name="user_type" value="district_user" id="userTypeDistrict" checked>
                  <label class="form-check-label" for="userTypeDistrict">District User</label>
                </div>
                <div class="form-check">
                  <input class="form-check-input" type="radio" name="user_type" value="regional_luspa" id="userTypeLuspaRegion">
                  <label class="form-check-label" for="userTypeLuspaRegion">Regional LUSPA</label>
                </div>
                <div class="form-check">
                  <input class="form-check-input" type="radio" name="user_type" value="national_luspa" id="userTypeLuspaNational">
                  <label class="form-check-label" for="userTypeLuspaNational">National LUSPA</label>
                </div>
                @if(session('current_user.user_type') == 'admin_user')
                <div class="form-check">
                  <input class="form-check-input" type="radio" name="user_type" value="admin_user" id="userTypeAdminUser">
                  <label class="form-check-label" for="userTypeAdminUser">Admin User</label>
                </div>
                @endif
              </div>
              <div class="col-md-2">
                <label for="titleSelecton" class="form-label">Title</label>
                <select id="titleSelecton" name="title" class="form-select" required>
                  <option selected disabled>Choose...</option>
                  <option value="Mr">Mr</option>
                  <option value="Mr">Miss</option>
                  <option value="Mrs">Mrs</option>
                  <option value="Dr">Dr</option>
                  <option value="Proff">Proff</option>
                </select>
              </div>
              
              <div class="col-md-5">
                <label for="addUserFullname" class="form-label">Fullname*</label>
                <input type="text" name="full_name" class="form-control" id="addUserFullname" required>
              </div>
              <div class="col-md-5">
                <label for="addUserEmail" class="form-label">Email*</label>
                <input type="email" name="email" class="form-control" id="addUserEmail" required>
              </div>

              <div class="col-md-4">
                <label for="addUserUsername" class="form-label">Username*</label>
                <input type="username" name="username" class="form-control" id="addUserUsername" required>
              </div>
              <div class="col-md-4">
                <label for="addUserGender" class="form-label">Gender*</label>
                <select id="addUserGender" name="gender" class="form-select" required>
                  <option selected disabled>Choose...</option>
                  <option value="female">Female</option>
                  <option value="male">Male</option>
                </select>
              </div>
                <div class="col-md-4">
                <label for="phone" class="form-label">Phone*</label>
                <input type="tel" name="phone" class="form-control" id="addUserphone" required>
                </div>
                <div class="col-md-<?php echo (session('current_user.user_type')) == 'district_user' ? '12' : '4';  ?>">
                  <label for="uaPostionAdd" class="form-label">Position</label>
                  <select id="uaPostionAdd" name="ua_position" class="form-select" required>
                    <option selected disabled>Choose...</option>
                    
                  </select>
                </div>
                @if (session('current_user.user_type') == 'district_user' )           
                <input type="hidden" name="district_id" value="{{ session('current_user.district_id') }}">
                @elseif(session('current_user.user_type') == 'regional_user')
                <div class="col-md-4">
                  <label for="regionID" class="form-label">Region</label>
                  <select name="region_id" id="regionID" class="form-select">
                    <option selected disabled>Choose...</option>
                    <?php foreach ($regions_arr as $row): ?>
                      <option value="<?php echo $row['regionid']; ?>" <?php //echo ($user_details[0]['regionid'] == $row['regionid'] ) ? "selected" : ""; ?>  ><?php echo $row['region_name']; ?></option>
                    <?php endforeach; ?>
                  </select>
                </div>
                
                @else
                <div class="col-md-4">
                  <label for="regionID" class="form-label">Region*</label>
                  <select name="region_id" id="regionID" class="form-select regionIDD">
                    <option selected disabled>Choose...</option>
                    <?php foreach ($regions_arr as $row): ?>
                      <option value="<?php echo $row['regionid']; ?>"><?php echo $row['region_name']; ?></option>
                    <?php endforeach; ?>
                  </select>
                </div>
                <div class="col-md-4">
                  <label for="districtID" class="form-label">District*</label>
                  <select id="districtID" name="district_id" class="form-select  districtIDD">
                    <option selected disabled>Choose...</option>
                  </select>
                </div>
                @endif
                <div class="col-md-6">
                  <label for="addUserUserStatus" class="form-label">Status *</label>
                  <select id="addUserUserStatus" name="user_status" class="form-select"required style="width:100%">
                    <option value="active">Active</option>
                    <option value="inactive">Inactive</option>
                  </select>
                </div>
                <!-- <div class="col-md-12">
                    <label for="allowedApps" class="form-label">Allowed Apps*</label>
                    <select id="allowedApps" name="allowed_apps[]"class="form-select" multiple required style="width:100%">
                      <option value="drawing-tools">Drawing Tools</option>
                      <option value="permit-tools">Permit Tools</option>
                      <option value="admin-gui">Admin GUI</option>
                    </select>
                </div> -->
                    <div class="col-md-12" style="padding-top: 10px;">
                    <div class="d-grid gap-2">
                      <button type="submit" class="btn btn-primary">Submit</button>
                    </div>
                  </div>

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





