<div class="container-fluid">
    <div>
        <h3>Fake User Generator</h3>
        <nav aria-label="breadcrumb">
            <ol class="breadcrumb">
                <li class="breadcrumb-item">
                    <a href="#">Home</a>
                </li>
                <li class="breadcrumb-item">
                    <a href="#">Tools</a>
                </li>
                <li class="breadcrumb-item active" aria-current="page">Fake User Generator</li>
            </ol>
        </nav>
    </div>
    <div class="row">
        <div class="col-lg-6 col-md-6">
            <div class="card">
                <div class="card-body">
                    <h6 class="card-title">Fake User Generator</h6>
                    <div class="alert alert-info">Generate unlimited amount of fake users.</div>
                <form action="" method="POST" class="generate-form">
                	
                	 <div class="form-group form-float">
                            <div class="form-line">
                                <label class="form-label">How many users you want to generate?</label>
                                <input type="number" id="count_users" name="count_users" class="form-control" value="10">
                                <small class="admin-info">Minumum users required are 10</small>
                            </div>
                        </div>
                         <div class="form-group form-float">
                            <div class="form-line">
                                <label class="form-label">Password</label>
                                <input type="text" id="password" name="password" class="form-control">
                                <small class="admin-info">Choose the password that will be used for all users, default: 123456789</small>
                            </div>
                        </div>
                        <label for="avatar">Create Random Avatar?</label>
                        <div class="form-group">
                            <div class="form-check form-check-inline">
                                <input class="form-check-input" type="radio" name="avatar" id="avatar-enabled" value="1">
                                <label class="form-check-label" for="avatar-enabled">Yes</label>
                            </div>
                            <div class="form-check form-check-inline">
                                <input class="form-check-input" type="radio" name="avatar" id="avatar-disabled" value="0" checked>
                                <label class="form-check-label" for="avatar-disabled" class="m-l-20">No</label>
                            </div>
                        </div>
                        <div class="clearfix"></div>
                        <small>If avatar is enabled, you might see dublicated avatars, avatars are generated randomly.</small><br>
                        <small>This process might take some time, you can check for your site changes after few minutes.</small><br><div class="clearfix"></div>
                        <br>
                        <button type="submit" class="btn btn-primary waves-effect waves-light m-t-20" id="delete-btn">Generate Fake Data</button>
                        <button type="button" class="btn btn-success waves-effect waves-light m-t-20" onclick="DeleteAllFake('hide')" id="delete_all_btn">Delete All Fake Users</button>
                
                </form>
                </div>
            </div>
        </div>
        <div class="clearfix"></div>
    </div>
    </div>
<div class="modal fade" id="DeleteModal" tabindex="-1" role="dialog" aria-labelledby="exampleModal1Label" aria-hidden="true">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <h5 class="modal-title" id="exampleModal1Label">Delete Fake Users?</h5>
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                </button>
            </div>
            <div class="modal-body">
                Are you sure you want to delete All Fake Users?
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
                <button type="button" class="btn btn-primary" data-dismiss="modal">Delete</button>
            </div>
        </div>
    </div>
</div>
<script>
function DeleteAllFake(type = 'show') {
    if (type == 'hide') {
      $('#DeleteModal').find('.btn-primary').attr('onclick', "DeleteAllFake()");
      $('#DeleteModal').modal('show');
      return false;
    }
    $('#delete_all_btn').text('Please wait..');
    $.post(Wo_Ajax_Requests_File() + '?f=admin_setting&s=delete_fake_users', function(data, textStatus, xhr) {
        $('#delete_all_btn').text('User are being deleted, check your site after few mins.');
        setTimeout(function () {
            $('#delete_all_btn').text('Delete All Fake Users');
        }, 4000);
    });
}
$(function() {
    var generate_form = $('form.generate-form');
    generate_form.ajaxForm({
        url: Wo_Ajax_Requests_File() + '?f=admin_setting&s=generate_fake_users',
        beforeSend: function() {
            $('#delete-btn').text('Please wait..');
        },
        success: function(data) {
            if (data.status == 200) {
            	$('#delete-btn').text('User are being generated, check your site after few mins.');
            	setTimeout(function () {
					$('#delete-btn').text('Generate Fake Data');
				}, 4000);
            }
        }
    });

});
</script>