private function sendConfirmationEmail($appendHTML = false) { // retrieve basic confirmation e-mail info. $INFO_FIELDS_TOTAL = 9; $emailInfo = $this->getConfirmEmailInfo($this->reg_id); $financeGetter = new FinancialTools(); // retrieve financial data for inclusion in e-mail $rulesApplied = array(); $basePriceForThisGuy = 0; $priceRules = array(); $scholarships = array(); $cash_paid = 0; $cash_owed = 0; $cc_paid = 0; $cc_owed = 0; $balance_owing = $financeGetter->calcBalanceOwing($this->reg_id, $rulesApplied, $basePriceForThisGuy, $priceRules, $scholarships, $cash_paid, $cash_owed, $cc_paid, $cc_owed); $eventBasePrice = $this->getEventBasePrice($this->event_id); if (isset($emailInfo) && count($emailInfo) == $INFO_FIELDS_TOTAL) { // $confirmationLabels = new MultiLingual_Labels( SITE_LABEL_PAGE_GENERAL, SITE_LABEL_SERIES_SITE, TEMPLATE_SIGNUP_CONFIRMATION, $langID ); $to = $emailInfo['email']; $subject = $this->labels->getLabel('[Subject]'); // HACK for french and eastern WC $headers = ''; $htmlBreak = ''; $message = ''; // To send HTML mail, the Content-type header must be set if ($appendHTML == true) { $headers .= 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; $htmlBreak = '<br/>'; $message .= '<html><body>'; } // Create the message $message .= $this->labels->getLabel('[ThankYou]') . " " . $emailInfo['event_name'] . "\n" . $htmlBreak; $message .= $this->labels->getLabel('[ConfirmationNumber]') . ': ' . $emailInfo['confirmNum'] . "\n" . $htmlBreak; $message .= $this->labels->getLabel('[fName]') . ': ' . $emailInfo['person_fname'] . "\n" . $htmlBreak; $message .= $this->labels->getLabel('[lName]') . ': ' . $emailInfo['person_lname'] . "\n" . $htmlBreak; $message .= $this->labels->getLabel('[campus]') . ': ' . $emailInfo['campus_name'] . "\n" . $htmlBreak; $message .= "\n" . $htmlBreak; $message .= "---- " . $this->labels->getLabel('[FinanceInfo]') . " ----\n" . $htmlBreak; $message .= "\n" . $htmlBreak; // event base price $message .= $this->labels->getLabel('[eventBasePrice]') . " "; $message .= '$' . $emailInfo['event_basePrice'] . "\n" . $htmlBreak; // first print out the rules the computer has applied foreach ($rulesApplied as $key => $ruleApplied) { $message .= $ruleApplied['pricerules_desc'] . ': ' . $ruleApplied['pricerules_discount'] . "\n" . $htmlBreak; } $message .= "\n" . $htmlBreak; // Total of above base price + discounts $message .= $this->labels->getLabel('[BasePriceForYou]') . " "; $message .= '$' . $basePriceForThisGuy . "\n" . $htmlBreak; $message .= "\n" . $htmlBreak; // print out the scholarships for the registrant if (isset($scholarships) && count($scholarships) > 0) { $message .= $this->labels->getLabel('[ScholarshipsInfo]') . ": \n" . $htmlBreak; } foreach ($scholarships as $key => $scholarship) { $message .= '$' . $scholarship['scholarship_amount'] . ' from: ' . $scholarship['scholarship_sourceDesc'] . "\n" . $htmlBreak; } $message .= "\n" . $htmlBreak; // cash and credit card transaction information $message .= $this->labels->getLabel('[cashReceived]') . " "; $message .= '$' . $cash_paid . " \t\t"; // "\n" . $htmlBreak; $message .= $this->labels->getLabel('[cashNotReceived]') . " "; $message .= '$' . $cash_owed . "\n" . $htmlBreak; $message .= "\n" . $htmlBreak; $message .= $this->labels->getLabel('[ccProcessed]') . " "; $message .= '$' . $cc_paid . " \t\t"; // "\n" . $htmlBreak; $message .= $this->labels->getLabel('[ccNotProcessed]') . " "; $message .= '$' . $cc_owed . "\n" . $htmlBreak; $message .= "\n" . $htmlBreak; $message .= $this->labels->getLabel('[BalanceOwing]') . " "; if (substr($balance_owing, 0, 1) == '-') { $message .= "-\$" . substr($balance_owing, 1) . "\n" . $htmlBreak; } else { $message .= "\$" . $balance_owing . "\n" . $htmlBreak; } $message .= "\n" . $htmlBreak; $message .= "---- " . $this->labels->getLabel('[ImpInfo]') . " ----\n" . $htmlBreak; $message .= "\n" . $htmlBreak; // event admin specific: event confirmation text $message .= $emailInfo['confirm_text']; $message .= "\n" . $htmlBreak; $message .= "-------------------------------\n" . $htmlBreak; $message .= "\n" . $htmlBreak; $message .= "\n" . $htmlBreak; // check if proper event e-mail address was found, if NOT then use default address $event_email = $emailInfo['event_email']; if (!eregi("^[_a-z0-9-]+(\\.[_a-z0-9-]+)*@[a-z0-9-]+(\\.[a-z0-9-]+)*(\\.[a-z]{2,3})\$", $event_email)) { // echo "The e-mail was not valid"; $isValid = false; $event_email = page_EditCampusRegistrations::DEFAULT_EMAIL; } $message .= $this->labels->getLabel('[footer]') . $event_email . "\n" . $htmlBreak; // add the end tags if ($appendHTML) { $message .= "</body></html>"; } $message = wordwrap($message, 70); $headers .= 'From: ' . $event_email . "\n" . 'Reply-To: ' . $event_email . "\n" . 'X-Mailer: PHP/' . phpversion(); // 'Bcc: '.$emailInfo['adminEmail'] . "\n" . // echo "<BR>HEADERS: ".$headers; // echo "TO: ".$to; // echo "<br>SUBJECT: ".$subject; // echo "<BR>MESSAGE: ".$message; ini_set('SMTP', EMAIL_SMTP_SERVER); ini_set('smtp_port', EMAIL_SMTP_PORT); $success = mail($to, $subject, $message, $headers); if (!$success) { return 'Error Sending Confirmation E-mail!'; // TODO: replace with a label } else { return 'Confirmation E-mail Successfully Sent'; // TODO: replace with a label } } else { return 'Error Retrieving Confirmation Information: E-mail *Not* Sent!'; // TODO: replace with a label } }