<?php
include('includes/config/config.php');
include('includes/functions.php');
include('log_entry.php');
error_log("Start Printing Request Attributes");
$requestStr = "";
foreach ($_REQUEST as $key => $value) {
    $requestStr .= $key . " : " . $value . "\n";
    error_log($key . " : " . $value . "<br />\r\n");
}
error_log("End Printing Request Attributes");
$status_code = 200;
$checkup_ids = $_REQUEST['checkupIds'];

$currentDateTime = date('Y-m-d H:i:s');



for ($i = 0; $i < count($checkup_ids); $i++) {


    $query = "update checkup_form set current_status='DRA',doc_attend='" . $_SESSION['logged_user_empid'] . "',approve_date ='" . $currentDateTime . "',fit_unfit_status='fit'  where checkup_id='" . $checkup_ids[$i] . "'; ";

    error_log("approval  query " . $query);

    if (!$result = mysqli_query($conn, $query)) {
        error_log("error in final approval " . mysqli_error($conn) . "  query is " . $query);
        $status_code = 400;
        rollback();
    }
}

echo json_encode($status_code);