<?php
include('includes/functions.php');
include('includes/config/config.php');

error_log("date " . $_POST['date']);
// $date = date("Y-m-d", strtotime($_POST['date']));
$date = DateTime::createFromFormat("d/m/Y", $date)->format("Y-m-d");
error_log("date " . $date);
$attendance_id = -1;
if (!empty($date)) {
    $check = "select * from attendance_master where attendance_date = '" . $date . "'";

    error_log("query " . $check);
    $result = mysqli_query($conn, $check);

    if (mysqli_num_rows($result) > 0) {
        $row = mysqli_fetch_assoc($result);

        $attendance_id = $row['attendance_id'];
    }
}

echo json_encode($attendance_id);