<?php
    
    include("../include/connection.php");
    $json = array();
    
    if(isset($_POST['uuid'])){
        $uuid = $_POST['uuid'];
    } 
    else{
        $uuid = '';
    }

    $sql = "SELECT * FROM ods WHERE uuid='$uuid' AND status='verified'";
    $result = mysqli_query($link, $sql);
    if($result->num_rows > 0){
        while ($row = $result->fetch_assoc()){
            $u_uname = mysqli_real_escape_string($link, $row['uuid']);
            $br_id = mysqli_real_escape_string($link, $row['uuid']);
        }
    } 
    else{
        $json['status'] = false;
        $json['message'] = 'uuid mismatch logout';
        echo json_encode($json, JSON_PRETTY_PRINT);
        exit;
    }

    $empId = $_POST['empId'];
   
    $sql = "SELECT * FROM `empHoliday` WHERE empId='$empId'";
    $result = mysqli_query($link, $sql);
    $empData = array();
    if ($result->num_rows > 0) {
        while ($emp = mysqli_fetch_array($result)) {
            $temp = array();
            $temp['empId'] = $emp['empId'];
            $temp['monthly_paid_holidays'] = $emp['mph'];
            $temp['loss_of_pay'] = $emp['lop'];
        
            $empData[] = $temp;
        }
    } 
    else{
      $json['status'] = false;
      $json['message'] = 'no history';
      echo json_encode($json, JSON_PRETTY_PRINT);
      exit;
    }

    if (!empty($empData)) {
      $json['status'] = true;
      $json['message'] = 'Data Found';
      $json['data'] = $empData;
    }

    echo json_encode($json, JSON_PRETTY_PRINT);
    exit;

?>