<?php
if(isset($_POST["paramValues"])){
    $paramObj=json_decode($_POST["paramValues"]);
    $clsObj=new getAvailableFortNight();
    $clsObj->getAvailableFortNightToAdjustRemaingAdvance($paramObj);
}else{
    echo "Result Not Found";
}

class getAvailableFortNight{
    function __construct(){
        require_once dirname(__DIR__).'../../../php/DB_Connect.php';
        $clsObj = new DB_conncect();
        $this->db=$clsObj->connectToDB();
        $this->db_Pdo=$clsObj->connectToDBVia_PDO();
    }
    function getAvailableFortNightToAdjustRemaingAdvance($paramValues){
        $mainArray=array();
        $query="SELECT 	`FORTNIGHT` FROM `fort_night_claims` WHERE `FROM_DATE` BETWEEN '".$paramValues->fromDate."' AND '".$paramValues->toDate."' AND `EMP_ID`='".$paramValues->empId."' ORDER BY FROM_DATE ASC LIMIT 1";
        $stmt=$this->db_Pdo->prepare($query);
        try{
            $this->db_Pdo->beginTransaction();
                if($stmt->execute()){
                    $data=$stmt->fetch(PDO::FETCH_ASSOC); // only single data
                    $mainArray["error"]=false;
                    $mainArray["response"]=$data;
                }else{
                    $mainArray["error"]=true;
                    $mainArray["message"]="Unable to execute query";
                }
            $this->db_Pdo->commit();
        }catch(PDOException $e){
            $mainArray["error"]=true;
            $mainArray["message"]="Internal Error 500";
        }
        echo json_encode($mainArray);
    }
}


?>