<?php
header('Content-Type: application/json');
$employ_id = $_GET['employ_id'];
include("dbConfig.php");

// get shift
$sql_daily_was = "SELECT * FROM hr_waseet_employ_shift_tbl WHERE employ_id='$employ_id'";
$result_daily_was = $conn->query($sql_daily_was);

if ($result_daily_was->num_rows > 0) {
    $row_daily_was = $result_daily_was->fetch_assoc();
    $Shif_id = $row_daily_was["shift_id"];
    $sql_shift = "SELECT * FROM hr_shift_tbl WHERE shift_id='$Shif_id'";
    $result_shift = $conn->query($sql_shift);

    if ($result_shift->num_rows > 0) {
        $row_shift = $result_shift->fetch_assoc();
        $shift_name_ar = $row_shift["shift_name_ar"];
        $shift_name_en = $row_shift["shift_name_en"];
        $min_start_time = $row_shift["min_start_time"];
        $start_time = $row_shift["start_time"];
        $max_start_time = $row_shift["max_start_time"];
        $min_end_time = $row_shift["min_end_time"];
        $end_time = $row_shift["end_time"];
        $max_end_time = $row_shift["max_end_time"];
        $number_hours = $row_shift["number_hours"];
        $allowed_minutes = $row_shift["allowed_minutes"];

        $response = array(
            'success' => true,
            'shift_name_ar' => $shift_name_ar,
            'shift_name_en' => $shift_name_en,
            'min_start_time' => $min_start_time,
            'start_time' => $start_time,
            'max_start_time' => $max_start_time,
            'min_end_time' => $min_end_time,
            'end_time' => $end_time,
            'max_end_time' => $max_end_time,
            'number_hours' => $number_hours,
            'allowed_minutes' => $allowed_minutes,
        );
    } else {
        $success = false;
        $response = array(
            'success' => $success,
            'msg' => "هناك خطأ الرجاء اعادة المحاولة",
            'status' => "unsuccess",
        );
    }

    echo json_encode($response);
} else {
    $success = false;
    $response = array(
        'success' => $success,
        'msg' => "هناك خطأ الرجاء اعادة المحاولة",
        'status' => "unsuccess",
    );

    echo json_encode($response);
}
?>