<?php
include($_SERVER['DOCUMENT_ROOT'] . "/COMPONENTS/root/path.php");
echo "<h5 class='userId' style='display:none;'>" . $_GET['userId'] . "</h5>";
?>


<form action="#" class="pl-3 pr-3" id="form_revertStaff" enctype="multipart/form-data" autocomplete='off' validate>

<h1 style='font-size:15px; text-align:center;'>Are you sure you want to revert staff back to the active list?</h1>
<?php 
    echo '<input class="form-control userId" type="text" required="" name="unique_user_id" value=' . $_GET['userId'] . ' id="name" placeholder="Enter description" style="display:none;">';
    ?>

<div class="form-group text-center" style='margin-top:20px;'>
    <button type="button" class="btn btn-rounded btn-secondary closeModal" style='width:80px;'>No</button>
    <button type="submit" class="btn btn-rounded btn-danger" id="submit_revertStaff" ><span class='submitLoader'><i class="fa fa-check"></i> Yes</span></button> 
   
</div>

</form>



<script>
    $("#submit_revertStaff").on("click", function() {
        $("#form_revertStaff").submit(function(e) {
            $.ajax({
                url: domain_api + "/staff/revert-staff.php?reverted_by="+token,
                type: "POST",
                data: new FormData(this),
                contentType: false,
                processData: false,
                beforeSend: function() {
                    $("#submit_revertStaff").attr("disabled", "disabled");
                    $(".submitLoader").html("<i class='fa fa-spinner fa-spin'></i>")
                },
                success: function(data) {
                    var ActivePage = sessionStorage.getItem("ActivePage");
                    if (data.code == 200) {
                        $("#myModal_actions").modal("hide");
                        $(".container-fluid").load(ActivePage, function(data) {});
                        swal("Succes!", data.message, "success");
                    } else {
                        swal("Oops!", data.message, "error");
                    }
                    $("#submit_revertStaff").attr("disabled", false);
                },
                error: function(request, error) {
                    swal("Oops!", "Saving was not successful, you should try again!", "error");
                },
            });
            e.preventDefault();
        });
        $(this).off();
    });

</script>