<!-- Modal -->
<div class="modal fade" id="user_types" tabindex="-1" role="dialog" aria-labelledby="exampleModalCenterTitle" aria-hidden="true">
  <div class="modal-dialog modal-dialog-centered" role="document">
    <div class="modal-content">
      <div class="modal-header">
        <h5 class="modal-title" id="exampleModalLongTitle">Update User Types</h5>
        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
        </button>
      </div>
      <?php echo Form::open(array('route' => 'usertypes.store')); ?>

      <div class="modal-body">

        <!--- Form -->


            <div class="form-group row">
              <label for="inputPassword" class="col-sm-12 col-form-label">Enter User Cnic</label>
              <div class="col-sm-12">
                <input type="text" onchange="getUserTypes(event,this)" class="form-control form-control-sm cls_cnic"  id="cnic" placeholder="00000-0000000-0" data-mask="00000-0000000-0" data-mask-clearifnotmatch="true">
              </div>
            </div>

            <div class="form-group user_types_dropdown" style="display:none">
                <label>List of User Types</label>
                <select multiple class="form-control user_types_options form-control-sm" name="types[]" >
                </select>
            </div>

        <!--- End Form -->
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
        <button type="submit" class="btn btn-primary">Update</button>
        <input type="hidden" name="user"/>
      </div>
    </form>
    </div>
  </div>
</div>

<script type="text/javascript">
    function getUserTypes(event,obj){
        event.preventDefault();

			 var valid =  validate_cnic($(obj));

			        if(valid == true)
			        {
			        	showLoader();
			        	 var route = '/getusertypes/'+$(obj).val();

			        	 $.get(route, function(data)
						 {

                            console.log(data);
							if(data.user)
							{
                                $(".user_types_options").html(data.html);
                                $('input[name=user]').val(data.user);
                                $(".user_types_dropdown").show();

			        			messageToaster('success','User Found','Success');

							}
							else
							{
                                $(".user_types_options").html(data);
                                $('input[name=user]').val();
                                $(".user_types_dropdown").hide();
                                messageToaster('error','User Not Found','Error');

							}

			        	removeLoader();


			        });
			        }
			        else
			        {
			        	messageToaster('error','Cnic' ,'Format not correct','Invalid Cnic');

			        }
    }
</script>
<?php /**PATH /var/www/skylite/resources/views/user/modals/update_user_types.blade.php ENDPATH**/ ?>