Ejemplo n.º 1
0
function emailReceipt($db_conn, $id)
{
    // get the customer information from the database
    $customer = tcCustomer::getCustomerById($db_conn, $id);
    $totalPoints = tcVisits::getTotalPointsById($db_conn, $id);
    $toAddr = $customer->email;
    $subject = "Thanks for visiting Classic Polish 168!";
    $msg = "";
    $header = "MIME-Version: 1.0" . "\r\n";
    $header .= "Content-type:text/html;charset=UTF-8" . "\r\n";
    $param = "-FClassicPolish168";
    // populate the email body
    $visits = new tcVisits($id, $db_conn);
    $visits->initVisits();
    $msg = $msg . '<html>';
    $msg = $msg . '<head><title>Visit History</title></head>';
    $msg = $msg . '<body>';
    $msg = $msg . '<p>Dear ' . "{$customer->fname} {$customer->lname}:";
    $msg = $msg . '<p>Below is a copy of your visit history and point balance for your reference.';
    $msg = $msg . 'We look forward to serve you again. Have a great day!</p>';
    $msg = $msg . '<table align="center" border="1">';
    $msg = $msg . '<th>Date</th>';
    $msg = $msg . '<th>Points</th>';
    for ($i = 0; $i < count($visits->visits); ++$i) {
        $msg = $msg . '<tr>';
        $msg = $msg . '<td align="center">' . $visits->visits[$i]->dtime . '</td>';
        $msg = $msg . '<td align="right">' . $visits->visits[$i]->point . '</td>';
        $msg = $msg . '</tr>';
    }
    $msg = $msg . '<tr>';
    $msg = $msg . '<td align="left"><strong>Balance:</strong></td>';
    $totalPtrs = tcVisits::getTotalPointsById($db_conn, $id);
    $msg = $msg . '<td align="right">' . $totalPtrs . '</td>';
    $msg = $msg . '</tr>';
    $msg = $msg . '</table>';
    $msg = $msg . '</body>';
    $msg = $msg . '</html>';
    if (mail($toAddr, $subject, $msg, $header, $param)) {
        $infoMsg = "Email sent successfully to {$customer->fname} {$customer->lname}!";
        if (isset($_POST["id"])) {
            print $msg;
            print '<br/>';
            print '<p align="center"><font color="green" size=20><strong>' . $infoMsg . '</strong></font></p>';
            header("refresh:5; url=showdetails.php?custId=" . $id);
        } else {
            print $infoMsg;
        }
    } else {
        $errorMsg = "Failed to send email to {$customer->fname} {$customer->lname} with email {$customer->email}!";
        if (isset($_POST["id"])) {
            print '<p align="center"><font color="red" size=20><strong>' . $errorMsg . '</strong></font></p>';
        } else {
            print $errorMsg;
        }
    }
}
Ejemplo n.º 2
0
<html>
  <head>
  <title>
    <?php 
require_once "mysql_db_defs.php";
require_once "htmlUtil.php";
require_once "tcCustomer.php";
require_once "tcVisits.php";
global $db_conn;
$custId = $_GET["custId"];
$customer = tcCustomer::getCustomerById($db_conn, $custId);
echo "{$customer->fname} {$customer->lname}";
?>
  </title>
  </head>

  <body>

      <?php 
// display the search panel on the top
showSearchPanel();
// display detailed information about the customer
$customer->showDetailTable();
print '<br/>';
print '<br/>';
// this section outputs the drop down menu to add points for the visit
print '<table align="center">';
print ' <tr>';
print '   <form method="post" action="addpoint.php" >';
print '     <td>';
print '       <select name="intSign">';