<?php
if(isset($_POST["paramValues"])){
    $paramObj= json_decode($_POST["paramValues"]);
    $clsObj= new getDuplicateT_Ids();
    $clsObj->getDuplicateTransactionDetails($paramObj->transactionIdsArray);
    
}else{
    echo "Result Not Found";
}
class getDuplicateT_Ids{
    function __construct(){
        require_once dirname(__DIR__).'../../../php/DB_Connect.php';
        $dbClsObj= new DB_conncect();
        $this->db=$dbClsObj->connectToDB();
        $this->db_Pdo=$dbClsObj->connectToDBVia_PDO();
    }
    function getDuplicateTransactionDetails($transactionIdsArray){
        $returnArray=array();
        $tempArray=array();
        $query=$this->getSelectQuery($transactionIdsArray);
        $stmt=$this->db_Pdo->prepare($query);
        try{
            $this->db_Pdo->beginTransaction();
                if(!$stmt->execute()){
                    $returnArray["error"]=true;
                }else{
                    $returnArray["error"]=false;
                    while($data=$stmt->fetch(PDO::FETCH_ASSOC)){
                        array_push($tempArray, $data);
                    }
                    $returnArray["responseArray"]=$tempArray;
                }
            $this->db_Pdo->commit();
        }
        catch(PDOException $e){
            $returnArray["error"]=true;
        }
        echo json_encode($returnArray);
    }
    function getSelectQuery($transactionIdsArray){
        $query="SELECT * FROM `fn_adjustments` WHERE `TRANSACTION_ID` IN(";
        $lastLoopIndex=count($transactionIdsArray)-1;
        foreach($transactionIdsArray as  $index=>$transactionId){
            if($index!=$lastLoopIndex){
                $query.="'$transactionId',";
            }else{
                 $query.="'$transactionId')";
            }
        }
        return $query;
    }
}



?>