<?php
if(isset($_POST['paramValues'])){
    $paramObj= json_decode($_POST["paramValues"]);
    $clsObj=new deleteAdvanceAmountDetails();
    $clsObj->deleteDetails($paramObj);
}

class deleteAdvanceAmountDetails{
    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 deleteDetails($paramObj){
        $responseArray=array();
        $stmt=$this->db->prepare("DELETE FROM `fn_advances` WHERE `ID`=?");
        $stmt->bind_param("s",$paramObj->db_tableIndex);
        try{
            $this->db_Pdo->beginTransaction();
                $executionStatus= $stmt->execute();
            $this->db_Pdo->commit();
            if(!$executionStatus){
                $responseArray["error"]=true;
                $responseArray["message"]="Unable to execute delete query";
            }else{
                $responseArray["error"]=false;
                $responseArray["message"]="Successfully Deleted.";
            }
        }catch(PDOException $e){
            $responseArray["error"]=true;
            $responseArray["message"]="Internal error 500!";
        }
        echo json_encode($responseArray);
    }
}

?>