<?php

//error_reporting(0);
		
		
		//Get transaction details
		$query = $pdo->prepare("SELECT * FROM transactions WHERE id=:id");
		$query->bindParam(":id",$transactID,PDO::PARAM_STR);
		$query->execute();
		$trans=$query->fetch();
		
		
		//get user info
		$stmt=$pdo->prepare("SELECT * FROM users WHERE userid = :userid");
		$stmt->bindParam(":userid",$trans["userid"], PDO::PARAM_STR);
		$stmt->execute();
		$GetUser=$stmt->fetch();
		
		
		

  //User Information
  $fullName = htmlspecialchars($GetUser["fullName"]);							//investor Name & email
  $userEmail = $GetUser["email"];
  
  
  $dateTime = date("jS F, Y | H:i", strtotime($trans["dateTime"]));			//Transaction Date
  $ref = $trans["ref"];															//Ref
  $amountValue = "$ ". number_format($trans["amount"]).'.00';					//Transaction Amount
  $transactType = '<span style="text-transform:capitalize">'.$trans["type"].'</span>';
  $ttype = $trans["type"];
  
  
 
 //define investment plan incase transactType is investment
 if(!empty($trans["plan"])){
	  $TransactPlan = $trans["plan"];
 }else{
	 $TransactPlan = "- -";
 }
 
 
 
 //$amount - transaction amount
//$plan - investment Plan 
//$ref - Reference ID
//$type - Transaction type (either of withdrawal or investment)





$msg = '
<html><head>

<!-- basic -->
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <!-- mobile metas -->
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- site metas -->
    <title>'.$transactType.' Approved | </title>
    <meta name="keywords" content="tech, analytics ,">
    <meta name="description" content="we provides a full service focused on market. A certified legal company incorporated and headquartered in Australia.">
    <meta name="author" content="genuine">
	
	
    <style type="text/css">
        @media screen {
            @font-face {
                font-family: "Lato";
                font-style: normal;
                font-weight: 400;
                src: local("Lato Regular"), local("Lato-Regular"), url(https://fonts.gstatic.com/s/lato/v11/qIIYRU-oROkIk8vfvxw6QvesZW2xOQ-xsNqO47m55DA.woff) format("woff");
            }

            @font-face {
                font-family: "Lato";
                font-style: normal;
                font-weight: 700;
                src: local("Lato Bold"), local("Lato-Bold"), url(https://fonts.gstatic.com/s/lato/v11/qdgUG4U09HnJwhYI-uK18wLUuEpTyoUstqEm5AMlJo4.woff) format("woff");
            }

            @font-face {
                font-family: "Lato";
                font-style: italic;
                font-weight: 400;
                src: local("Lato Italic"), local("Lato-Italic"), url(https://fonts.gstatic.com/s/lato/v11/RYyZNoeFgb0l7W3Vu1aSWOvvDin1pK8aKteLpeZ5c0A.woff) format("woff");
            }

            @font-face {
                font-family: "Lato";
                font-style: italic;
                font-weight: 700;
                src: local("Lato Bold Italic"), local("Lato-BoldItalic"), url(https://fonts.gstatic.com/s/lato/v11/HkF_qI1x_noxlxhrhMQYELO3LdcAZYWl9Si6vvxL-qU.woff) format("woff");
            }
        }


        body {
            height: 100% !important;
            margin: 0 !important;
            padding: 0 !important;
            width: 100% !important;
			font-size:17px!important;
			color:#868585;
			background:#f9f9f9;
			font-family: "Lato", Helvetica, Arial, sans-serif;
        }


        /* MOBILE STYLES */
        @media screen and (max-width:600px) {
            h1 {
                font-size: 32px !important;
                line-height: 32px !important;
            }
        }

        /* ANDROID CENTER FIX */
        div[style*="margin: 16px 0;"] {
            margin: 0 !important;
        }
	
	
		.mailbdy{
			font-size:17px!important;
			margin:auto;
			max-width:700px;
			margin-top:10px;
			
		}
		a{
			text-decoration:none;
			color:#174d78!important;
		}
    </style>
</head>

<body>


	
              <div class="mailbdy">
			  
              <div style="text-align:center!important; border-radius:10px; border:1px solid #ccc5c5; padding-bottom:20px; background:#fff;">
			  
		<div style="background:#365a78; margin-bottom:10px;border-radius:10px 10px 0px 0px;font-size:30px; font-weight: 600; color:#fff; padding:10px;">
			  <span style="font-family:comic sans ms; color:#ffb56a;font-size:45px;">S</span>wiss <div style="background:#365a78; margin-bottom:10px;border-radius:10px 10px 0px 0px;font-size:30px; font-weight: 600; color:#fff; padding:10px;">
			 
			  <span style="font-family:comic sans ms; color:#ffb56a;font-size:45px;">W</span>ealth
			  </div>
                 
				 <br>
				<div style="font-family:comic sans ms;color:#406381;font-size:20px;display: inline; border:1px solid #5d819f;padding:10px; border-radius: 10px;">'.$transactType.' Declined</div>
			 <br><br>
			
							
			<br>							  
           <div align="left" style="padding: 0px 20px 0px 20px; color: #666666; line-height:1.5;">
           
		  Your '.$transactType.' request was declined. Below is your '.$transactType.' details. 
		  
		  <div style="height: 0;border-color:#dadee5!important;margin: .5rem 0;overflow: hidden;border-top: 1px solid #f7f7f7;"></div>
		  <p><br>
		  
		  
		  <div style="color:#3d6d95;margin-bottom:4px;font-size:15px"><b>Order Amount</b>&nbsp; '.$amountValue.'</div>
		  <div style="height: 0;border-color:#dadee5!important;margin: .5rem 0;overflow: hidden;border-top: 1px solid #f7f7f7;"></div>
		  <div style="color:#3d6d95;margin-bottom:4px;font-size:15px"><b>Order Type</b>&nbsp; '.$transactType.'</div>
		  <div style="height: 0;border-color:#dadee5!important;margin: .5rem 0;overflow: hidden;border-top: 1px solid #f7f7f7;"></div>
		  <div style="color:#3d6d95;margin-bottom:4px;font-size:15px"><b>Plan</b>&nbsp; '.$TransactPlan.'</div>
		  <div style="height: 0;border-color:#dadee5!important;margin: .5rem 0;overflow: hidden;border-top: 1px solid #f7f7f7;"></div>
		  <div style="color:#3d6d95;margin-bottom:4px;font-size:15px"><b>REF</b>&nbsp; '.$ref.'</div>
		  <div style="height: 0;border-color:#dadee5!important;margin: .5rem 0;overflow: hidden;border-top: 1px solid #f7f7f7;"></div>
		  <div style="color:#3d6d95;margin-bottom:4px;font-size:15px"><b>Order Date</b>&nbsp; '.$dateTime.'</div>
		  <div style="height: 0;border-color:#dadee5!important;margin: .5rem 0;overflow: hidden;border-top: 1px solid #f7f7f7;"></div>
		  <div style="color:#3d6d95;margin-bottom:4px;font-size:15px"><b>Status</b>&nbsp; <font color="#ff5959">Declined</font></div>
		  <div style="height: 0;border-color:#dadee5!important;margin: .5rem 0;overflow: hidden;border-top: 1px solid #f7f7f7;"></div>
		  
		  
		  
		  
		  <p><br>
		  
                 
			</div> 
			<br>
            <div style="text-align:left; border-top:1px solid #ededed; padding:10px;">
             Cheers<br> Team - 2022</p>
             </div>
			 
                   
				  
            <div align="center" style="padding: 30px; background:#f4f4f4; border-bottom: 1px solid #c0baa3; border-top: 1px solid #c0baa3;">
              
            <h2 style="font-size: 18px; font-weight: 400; color: #111111; margin: 0;">Need help?</h2>
			<p>				

		   
            </div>
					
			
						
		</div>


</body></html>

';


// Import PHPMailer classes into the global namespace
// These must be at the top of your script, not inside a function
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\SMTP;
use PHPMailer\PHPMailer\Exception;

// Load Composer"s autoloader - root directory
require "../vendor/autoload.php";

// Base files 
//require "PHPMailer/src/Exception.php";
//require "PHPMailer/src/PHPMailer.php";
//require "PHPMailer/src/SMTP.php";

// create object of PHPMailer class with boolean parameter which sets/unsets exception.

$mail = new PHPMailer(true);                              



try {
    //Server settings
    //$mail->SMTPDebug = SMTP::DEBUG_SERVER;                      //Enable verbose debug output
    $mail->isSMTP();                                            //Send using SMTP
	$mail->Host   = "server904.vebhost.com";                     //Set the SMTP server to send through
    $mail->SMTPAuth   = true;                                   //Enable SMTP authentication
    $mail->Username   = "info@secureswiss-wealth-pro.org";                     //SMTP username
    $mail->Password   = "Rydaman999$$&&";                               //SMTP password
    $mail->SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS;         //Enable TLS encryption; `PHPMailer::ENCRYPTION_SMTPS` encouraged
    $mail->Port   = 587;                                    //TCP port to connect to, use 465 for `PHPMailer::ENCRYPTION_SMTPS` above
	
	
    //Recipients
    $mail->setFrom("info@secureswiss-wealth-pro.org", "admin");
    $mail->addAddress($userEmail, $fullName);     //Add a recipient
    //$mail->addAddress("ellen@example.com");               //Name is optional
    //$mail->addReplyTo("info@example.com", "Information");
    //$mail->addCC("cc@example.com");
    //$mail->addBCC("bcc@example.com");

    //Attachments
  //  $mail->addAttachment("/var/tmp/file.tar.gz");         //Add attachments
   // $mail->addAttachment("/tmp/image.jpg", "new.jpg");    //Optional name

    //Content
    $mail->isHTML(true);                                  //Set email format to HTML
    $mail->Subject = $ttype." Declined";
    $mail->Body    = $msg;
   // $mail->AltBody = "This is the body in plain text for non-HTML mail clients";

    $mail->send();




	//Update DB from here




	
} catch (Exception $e) {
    echo "Message could not be sent. Mailer Error: {$mail->ErrorInfo}";
}


