<?php include($_SERVER['DOCUMENT_ROOT'] . "/COMPONENTS/root/path.php"); ?>


<style>
    table {
        border: 1px solid #ccc;
        border-collapse: collapse;
        table-layout: fixed;
        width: 100%;
    }



    table tr {
        border: 1px solid #ddd;
        padding: .35em;
    }

    table tr:nth-child(even) {
        background: #f8f8f8;
    }

    table th,
    table td {
        padding: .625em;
        text-align: center;

    }

    table th {
        /* background: #999; */
        color: #fff;
        font-size: .85em;
        letter-spacing: .1em;
        text-transform: uppercase;
    }

    table td {
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .btnn {
        /* width:50px !important;
        height:30px !important; */
        border-radius: 8px;
        cursor: pointer;

    }

    .ii {
        font-size: 13px;
        width: 100%;
        float: right;
        text-align: right;
    }

   
</style>

<div class="row">
    <div class="col-md-12">
        <div class="card">
            <div class="card-body">
                <h4 class="card-title">Terminated Appointment List</h4>
                <h6 class="card-subtitle"></h6>
                <div class="table-responsive">
                    <table id="example" style='Width:100%'>
                        <thead class="bg-info">
                            <tr>
                                <!-- <th scope="col" style="width:50px;"></th> -->
                                <th scope="col">Name</th>
                                <th scope="col">Gender</th>
                                <th scope="col">Date Of Birth</th>
                                <th scope="col">Nationality</th>
                                <th scope="col">Phone</th>
                                <th scope="col">Appointment Date</th>
                                <th scope="col">Termination Date</th>
                                <th scope="col">Reason</th>
                                <th scope="col">Revert</th>
                            </tr>
                        </thead>
                    </table>
                </div>
            </div>
        </div>
    </div>
</div>


<div class="modals"></div>

<script>
    $(".modals").load(domain + "/COMPONENTS/sub-pages/modals.php");
    var table = $('#example').DataTable({
        responsive: true,
        "ajax": {
            "url": domain_api + "/staff/terminated-appoitments.php?role="+encodeURIComponent(role)+"",
            "dataSrc": "staff_information"
        },
        "columns": [
            {
                "data": null,
                render: function(data, type, row) {
                    return data.title + ' ' + data.first_name + ' ' + data.middle_name + ' ' + data.last_name;
                }
            },
            {
                "data": "gender"
            },

            {
                "data": "dob"
            },
            {
                "data": "nationality"
            },
            {
                "data": "phone"
            },
            {
                "data": "date_of_application"
            },

            {
                "data": "date_of_termination"
            },
            {
                "data": "reasonfortermination"
            },
            {
                "data": null,
                render: function(data, type, row) {
                    return '<div class="btn btnn btn-success action" data-id="' + data.unique_user_id + '"  data-url="/COMPONENTS/sub-pages/revert-staff.php" title="Profile"><i class="ii far fa-user"></i></div>'
                }
            }
           
        ]
    });

    new $.fn.dataTable.FixedHeader(table);

    $(document).unbind().on("click", ".profile", function() {
        var id = $(this).attr("data-id");
        $(".profileView").load(domain + "/COMPONENTS/sub-pages/staff-profile.php?userId=" + encodeURIComponent(id) + "", function() {
            $("#myModal_profile").modal("show");
        });
      $(this).off();  
    });

    $(document).on("click", ".action", function() {
        var id = $(this).attr("data-id");
        var url = $(this).attr("data-url");
        var url = url + "?userId=" + encodeURIComponent(id) + "";
        $(".actionBody").load(domain + url, function() {
            $("#myModal_actions").modal("show");
            $(".closeModal").on("click", function() {
                $("#myModal_actions").modal("hide");
            });
        })
    });
</script>

<script src="<?php echo $website_name; ?>/dist/js/pages/dashboards/dashboard1.min.js"></script>