<?php
if(isset($_POST["savingId"])){
    require_once("/home/fundbridge/crons.ballng.com/db.php");
    require_once("/home/fundbridge/crons.ballng.com/pdf.php");
    $file = getData("savings", $_POST["userId"], $_POST["savingId"]);
    if($file){
        require_once("/home/fundbridge/crons.ballng.com/email.php");
        $data = mysqli_fetch_assoc(mysqli_query($conn, "select uid,name from savings where sid = '".$_POST["savingId"]."' limit 1"));
        $userData = mysqli_fetch_assoc(mysqli_query($conn, "select concat(fname,' ',lname) as name,email,fname,lname from users where uid = '".$data["uid"]."' limit 1"));
        send($userData["name"], $userData["email"], "savings_letter",array("name"=>$userData["fname"],"attachments"=>array("/home/fundbridge/assets.fundbridgeinvestment.com/generated/".$file),"savingsName"=>$data["name"]));
        echo "success";
    }else{
        echo 'error';
    }
}
?>