<?php

include $_SERVER['DOCUMENT_ROOT'] . "/WebBuilder/WebApp.class.php";
$db = new DBMain();
$asses_res = $db->exec_query('asseses', ['*'], '', '', '', '', "record_id = {$_GET['record_id']}");
$asses = $asses_res->fetch_assoc();

$assesor_res = $db->exec_query('safesure_users', ['*'], '', '', '', '', "record_id = {$asses['safesure_users_id']}");
$assesor = $assesor_res->fetch_assoc();

$time_res = $db->exec_query('asseses_timeline', ['*'], '', '', '', '', "record_id = {$asses['asseses_timeline']}");
$t_delta = $time_res->fetch_assoc();

$candidate_res = $db->exec_query('client_employees', ['*'], '', '', '', '', "record_id = {$asses['client_employees_id']}");
$candidate = $candidate_res->fetch_assoc();

$client_res = $db->exec_query('clients', ['*'], '', '', '', '', "record_id = {$asses['clients_id']}", 'ORDER BY clients_name ASC');
$client = $client_res->fetch_assoc();

if ($asses['results'] == "C") {
    $WebApp->pageHeading("ASSESMENT RESULT: <span style='color:green;'>COMPETENT</span>");
} else {
    $WebApp->pageHeading("ASSESMENT RESULT: <span style='color:red;'>NOT COMPETENT</span>");
}
?>

<div class='form_container' style='width:100%'>
    <table style="width: 100%">
        <tr>
            <td style="width:25%">
                BOOKING NO.
            </td>
            <td style="width:25%">
                ASSESOR NAME.
            </td>
            <td style="width:25%">
                DATE.
            </td>
            <td style="width:25%">
                TIME TO COMPLETION.
            </td>
        </tr>
        <tr>
            <td style="width:25%">
                <button onclick="window.location.href='open_booking.php?record_id=<?php echo $asses['booking']; ?>';" class='button'><?php echo $asses['booking']; ?></button>
                <button onclick="window.location.href='reports/attendance_registar.php?record_id=<?php echo $asses['booking']; ?>';" class='button'>PDF</button>
            </td>
            <td style=" width:25%">
                <button onclick="window.location.href='edit_user.php?record_id=<?php echo $assesor['record_id']; ?>';" class='button'><?php echo $assesor['safesure_users_name']; ?></button>
            </td>
            <td style="width:25%">
                <input type='text' class='input' value='<?php echo $asses['date']; ?>' readonly />
            </td>
            <td style="width:25%">
                <input type='text' class='input' value='<?php echo $t_delta['t_delta']; ?>' readonly />

            </td>
        </tr>
    </table>
</div>


<div class='form_container' style='width:100%'>
    <table style="width: 100%">
        <tr>
            <td style="width:25%">
                CANDIDATE.
            </td>
            <td style="width:25%">
                CLIENT.
            </td>
            <td style="width:25%" colspan='2'>
                PDF
            </td>
        </tr>
        <tr>
            <td style="width:25%">
                <button onclick="window.location.href='edit_employee.php?record_id=<?php echo $candidate['record_id']; ?>';" class='button'><?php echo $candidate['client_employees_name']; ?></button>
            </td>
            <td style="width:25%">
                <button onclick="window.location.href='edit_client.php?record_id=<?php echo $client['record_id']; ?>';" class='button'><?php echo $client['clients_name']; ?></button>
            </td>
            <td style="width:25%" colspan='2'>
                <button onclick="window.location.href='assesor/assesment_pdf.php?id=<?php echo $asses['record_id']; ?>';" class='button'><?php echo $asses['asseses_name']; ?></button>
            </td>
        </tr>
    </table>
</div>
