<?php 
	
	include ('includes/db1config.php');
	include ('../includes/mysql_connect.php');
    include('../phpMailer/vendor/phpmailer/phpmailer/PHPMailerAutoload.php');
    
    
    $query = "SELECT guestLogin.Email,guestLogin.FirstName,guestLogin.LastName FROM customer_invoices INNER JOIN guestLogin ON guestLogin.UserKey = customer_invoices.customer_id where customer_invoices.recordkey = ".$_POST['id'];
	$rt       = mysql_query($query); // query executed
	echo mysql_error(); // if any error is there that will be printed to the screen
    $row      = mysql_fetch_assoc($rt);
    $to       = $row['Email'];
    $fromName = "Accounts Payable";

    $subject  = "Your invoice from tastedev.com";

    $headers  = "From: " . strip_tags($fromName) . "\r\n";
    $headers .= "MIME-Version: 1.0\r\n";
    $headers .= "Content-Type: text/html; charset=UTF-8\r\n";
    $message .= '<table cellpadding="40" cellspacing="0" border="0" style="background:#f6f6f6; width:100%; margin:0; padding:0;">
        <tbody>
        <tr>
        <td style="border-collapse: collapse; font-family: Arial, Sans-serif; font-size: 12px; color: #535353; line-height: 160%">
        <!--     Header     -->
        <table cellpadding="0" cellspacing="0" border="0" width="600" align="center" id="container" style="font-family: Arial, Sans-serif; font-size: 12px; color: #535353; line-height: 160%; border-bottom-left-radius: 5px; border-bottom-right-radius: 5px; margin: 0 auto; ">
        <tbody>
        <tr>
        <td style="border-collapse: collapse; font-family: Arial, Sans-serif; font-size: 12px; color: #535353; line-height: 160%; border-bottom: 1px solid #FFF; border-top: 1px solid #CCC; background: #F0F0F0; border: 1px solid #DBDBDB">
        <table cellpadding="30" cellspacing="0" width="100%">
        <tbody>
        <tr>
        <td style="border-collapse: collapse; font-family: Arial, Sans-serif; font-size: 12px; color: #535353; line-height: 160%">
        <table cellpadding="0" cellspacing="0" width="100%">
        <tbody>
        <tr>
        <td style="border-collapse: collapse; font-family: Arial, Sans-serif; font-size: 12px; color: #535353; line-height: 160%">

        <p style="margin: 0; margin-bottom: 10px"> Dear <strong>'.$row["FirstName"].' '.$row["LastName"].',</strong> </p>
        <p>You have a new invoice ready at :- <strong><a href="tastedev.com/my-account">tastedev.com</a></strong>.</p>
        <p>Please log into your account at <strong><a href="tastedev.com/my-account">tastedev.com/my-account</a></strong> to view and securely pay your invoice.  </p>

        <br>Thank you !<br>
        Accounts Payable<br>
        <a href="tastedev.com/my-account">tastedev.com</a>


        <table cellpadding="5" cellspacing="0" style="background: #5FC660; color: #FFF; font-weight: 700; border-radius: 5px; font-family: Arial, Sans-serif; font-size: 12px; padding: 0 10px">
        <tbody>
        <tr>

        </tr>
        </tbody>
        </table>
        </td>
        <td style="border-collapse: collapse; font-family: Arial, Sans-serif; font-size: 12px; color: #535353; line-height: 160%; width: 280px">

        </td>
        </tr>
        </tbody>
        </table>
        </td>
        </tr>
        </tbody>
        </table>
        </td>
        </tr>
        <tr>

        <td id="content" style="border-collapse: collapse; font-family: Arial, Sans-serif; font-size: 12px; color: #535353; line-height: 160%; background: #FFF; border: 1px solid #DBDBDB; border-top: none">
        <table width="100%" cellpadding="30" cellspacing="0">
        <tbody>
        <tr>

        </tr>
        </tbody>
        </table>
        </td>
        </tr>

        </tbody>
        </table>
        </td>
        </tr>
        </tbody>
        </table>
        ';


    mail($to, $subject, $message, $headers);
    echo 1;        
?>