function sendBookingConfirmation($bookingID, $instanceID, $enrolVar, $ccEmail = false) { $enrolVar['state'] = getStateFromPostcode($enrolVar['postcode']); //$instanceID = "161835"; $courseDetailObj = getEventDetails($instanceID); $courseDetails['name'] = $courseDetailObj['websiteName']; $courseDetails['date'] = date("l", strtotime($courseDetailObj['courseDate'])) . "<br>" . date("j", strtotime($courseDetailObj['courseDate'])) . "<sup>" . date("S", strtotime($courseDetailObj['courseDate'])) . "</sup> " . date("F Y", strtotime($courseDetailObj['courseDate'])); $courseDetails['date_nb'] = date("l", strtotime($courseDetailObj['courseDate'])) . " " . date("j", strtotime($courseDetailObj['courseDate'])) . "<sup>" . date("S", strtotime($courseDetailObj['courseDate'])) . "</sup> " . date("F Y", strtotime($courseDetailObj['courseDate'])); $courseDetails['time'] = date("g:i a", strtotime($courseDetailObj['startDateTime'])) . " to " . date("g:i a", strtotime($courseDetailObj['endDateTime'])); $courseDetails['location'] = str_replace(", ", "<br>", str_replace("\n", "<br>", $courseDetailObj['StreetAddress'])); $courseDetails['maplink'] = "https://www.google.com.au/maps?q=" . str_replace(" ", "+", str_replace("\n", " ", $courseDetailObj['StreetAddress'])); //var_dump($courseDetails); //die(); $emailKey = sha1(date("r", strtotime("now")) . generateRandomString(5) . $bookingID . $instanceID); //$bookingID = "123456789-123456789"; $viewonlinelink = "https://www.australiawidefirstaid.com.au/email/?k=" . $emailKey; $livedata = $enrolVar['fname'] . " " . $enrolVar['lname'] . "|" . $enrolVar['email'] . "|" . $bookingID; $livechatURL = "https://www.australiawidefirstaid.com.au/?livechat=true&data=" . base64_encode($livedata); $html = getEmailTemplate("template_CouponEmailConfirmation_generic.htm"); $html = varReplace("bookingID", $bookingID, $html); $html = varReplace("emailviewlink", $viewonlinelink, $html); $html = varReplace("livechatURL", $livechatURL, $html); $html = varReplace("user.firstname", $enrolVar['fname'], $html); $html = varReplace("user.lastname", $enrolVar['lname'], $html); $html = varReplace("user.address", $enrolVar['address'], $html); $html = varReplace("user.suburb", $enrolVar['suburb'], $html); $html = varReplace("user.state", $enrolVar['state'], $html); $html = varReplace("user.postcode", $enrolVar['postcode'], $html); $html = varReplace("user.phone", $enrolVar['mobile'], $html); $html = varReplace("user.email", $enrolVar['email'], $html); $html = varReplace("user.orginisation", $enrolVar['workplace'], $html); $html = varReplace("course.name", $courseDetails['name'], $html); $html = varReplace("course.date", $courseDetails['date'], $html); $html = varReplace("course.date_nb", $courseDetails['date_nb'], $html); $html = varReplace("course.time", $courseDetails['time'], $html); $html = varReplace("course.location", $courseDetails['location'], $html); $html = varReplace("course.maplink", $courseDetails['maplink'], $html); $message = $html; $semail = "*****@*****.**"; $sname = "Australia Wide First Aid"; $rname = ""; $priority = "high"; $type = "text/html"; $replysemail = $semail; $fullmessage = ""; //$remail = "*****@*****.**"; $remail = $enrolVar['email']; $subject = "First Aid Course Booking Confirmation - " . $enrolVar['fname'] . " " . $enrolVar['lname'] . " - " . $enrolVar['workplace']; email::logEmail($remail, "", $ccEmail, $subjet, $message, $bookingID, $instanceID, $emailKey); esmtp::sendemail_smtp($remail, $subject, $message, $ccEmail); }
function sendManualInvoice($processgroupID) { $emailKey = $processgroupID; $html = getEmailTemplate("template_invoicenotification.htm"); $processgroupID = db::esc($processgroupID); $mainData = db::runQuery("select * from process_group left join events on events.instanceID = process_group.eventID left join courses on courses.courseID = events.courseID left join locations on locations.ID = events.locationID left join coupons on coupons.couponCode = process_group.campaign_code where processgroupID = '{$processgroupID}'"); if (!$mainData) { return false; } else { $mData = $mainData[0]; $courseName = $mData['CourseName']; $couponName = $mData['campaignName']; $normalCost = $mData['cost']; $totalTrainees = $mData['total_trainee']; $discountcost = $mData['totalcost']; $costNormalTotal = $normalCost * $totalTrainees; $discountcostPerperson = $discountcost / $totalTrainees; $amountDiscountedTot = $costNormalTotal - $discountcost; $invoiceItems = ""; for ($tr = 0; $tr < $totalTrainees; $tr++) { $subHTML = ""; $subHTML = $subHTML . "\t\t<tr style='font-size:13px;'>"; $subHTML = $subHTML . "\t\t\t<td>" . $courseName . " - " . $couponName . "</td>"; $subHTML = $subHTML . "\t\t\t<td>\$" . number_format($normalCost, 2) . "</td>"; $subHTML = $subHTML . "\t\t\t<td>\$" . number_format($discountcostPerperson, 2) . "</td>"; $subHTML = $subHTML . "\t\t</tr>"; $invoiceItems = $invoiceItems . $subHTML; } $html = varReplace("invoiceItemsRow", $invoiceItems, $html); $html = varReplace("order.totalNormal", number_format($costNormalTotal, 2), $html); $html = varReplace("order.Total", number_format($discountcost, 2), $html); $html = varReplace("order.amountDiscounted", number_format($amountDiscountedTot, 2), $html); $html = varReplace("order.subTotal", number_format($discountcost, 2), $html); if ($mData['payment_status'] == "completed") { $html = varReplace("order.amountPaid", number_format($discountcost, 2), $html); $html = varReplace("order.balanceDue", "0.00", $html); } else { $html = varReplace("order.amountPaid", "0.00", $html); $html = varReplace("order.balanceDue", number_format($discountcost, 2), $html); } $html = varReplace("amountToInvoice", number_format($discountcost, 2), $html); $html = varReplace("eventID", $mData['eventID'], $html); $html = varReplace("courseName", $mData['CourseName'], $html); $html = varReplace("courseDateTime", $mData['startDateTime'], $html); $html = varReplace("courseLocation", $mData['LocationState'] . " " . $mData['LocationName'] . " - " . $mData['StreetAddress'], $html); $html = varReplace("totalTrainees", $mData['total_trainee'], $html); $html = varReplace("courseNormalCost", "\$" . number_format($costNormalTotal, 2), $html); $html = varReplace("couponCode", $mData['campaign_code'], $html); $html = varReplace("couponName", $couponName, $html); if ($mData['discountType'] == "0") { $html = varReplace("couponDiscount", "\$" . $mData['discountAmount'] . " off total", $html); } if ($mData['discountType'] == "1") { $html = varReplace("couponDiscount", $mData['discountAmount'] . "% off total", $html); } if ($mData['discountType'] == "2") { $html = varReplace("couponDiscount", "Custom price for Location", $html); } if ($mData['discountType'] == "3") { $html = varReplace("couponDiscount", "Custom price for Course", $html); } $trainees = db::runQuery("select * from process_trainee where processgroupID = '{$processgroupID}'"); if (!$trainees) { return false; } else { $currentTrainee = 1; $traineehtml = ""; foreach ($trainees as $trainee) { $trhtml = ""; $trhtml = $trhtml . '<b>Trainee ' . $currentTrainee . '</b>'; $trhtml = $trhtml . ' <table style="width:100%; margin-left:70px;">'; $trhtml = $trhtml . ' <tr style="font-size:13px;">'; $trhtml = $trhtml . ' <th width="30%" style="text-align:left;">Contact ID</th>'; $trhtml = $trhtml . ' <td style="text-align:left;"><a href="https://admin.axcelerate.com.au/management/management2/Contact_View.cfm?ContactID=' . $trainee['contactID'] . '">' . $trainee['contactID'] . '</a></th>'; $trhtml = $trhtml . ' </tr>'; $trhtml = $trhtml . ' <tr style="font-size:13px;">'; $trhtml = $trhtml . ' <th width="30%" style="text-align:left;">Learner ID</th>'; $trhtml = $trhtml . ' <td style="text-align:left;">' . $trainee['leanerID'] . '</td>'; $trhtml = $trhtml . ' </tr>'; $trhtml = $trhtml . ' <tr style="font-size:13px;">'; $trhtml = $trhtml . ' <th width="30%" style="text-align:left;">Invoice ID</th>'; $trhtml = $trhtml . ' <td style="text-align:left;">' . $trainee['invoiceID'] . '</td>'; $trhtml = $trhtml . ' </tr>'; $trhtml = $trhtml . ' <tr style="font-size:13px;">'; $trhtml = $trhtml . ' <th width="30%" style="text-align:left;">Amount to Invoice</th>'; $trhtml = $trhtml . ' <td style="text-align:left;">$' . number_format($trainee['cost'], 2) . '</td>'; $trhtml = $trhtml . ' </tr>'; $trhtml = $trhtml . ' <tr style="font-size:13px;">'; $trhtml = $trhtml . ' <th width="30%" style="text-align:left;"> </th>'; $trhtml = $trhtml . ' <td style="text-align:left;"></td>'; $trhtml = $trhtml . ' </tr>'; $trhtml = $trhtml . ' <tr style="font-size:13px;">'; $trhtml = $trhtml . ' <th width="30%" style="text-align:left;">Name</th>'; $trhtml = $trhtml . ' <td style="text-align:left;">' . $trainee['firstname'] . ' ' . $trainee['lastname'] . '</td>'; $trhtml = $trhtml . ' </tr>'; $trhtml = $trhtml . ' <tr style="font-size:13px;">'; $trhtml = $trhtml . ' <th width="30%" style="text-align:left;">USI</th>'; $trhtml = $trhtml . ' <td style="text-align:left;">' . $trainee['usi'] . '</td>'; $trhtml = $trhtml . ' </tr>'; $trhtml = $trhtml . ' <tr style="font-size:13px;">'; $trhtml = $trhtml . ' <th width="30%" style="text-align:left;">Email Address</th>'; $trhtml = $trhtml . ' <td style="text-align:left;">' . $trainee['email'] . '</td>'; $trhtml = $trhtml . ' </tr>'; $trhtml = $trhtml . ' <tr style="font-size:13px;">'; $trhtml = $trhtml . ' <th width="30%" style="text-align:left;">Mobile/Phone</th>'; $trhtml = $trhtml . ' <td style="text-align:left;">' . $trainee['mobile'] . '</td>'; $trhtml = $trhtml . ' </tr>'; $trhtml = $trhtml . ' <tr style="font-size:13px;">'; $trhtml = $trhtml . ' <th width="30%" style="text-align:left;">Workplace</th>'; $trhtml = $trhtml . ' <td style="text-align:left;">' . $trainee['workplace'] . '</td>'; $trhtml = $trhtml . ' </tr>'; $trhtml = $trhtml . ' <tr style="font-size:13px;">'; $trhtml = $trhtml . ' <th width="30%" style="text-align:left;">Address</th>'; $trhtml = $trhtml . ' <td style="text-align:left;">' . $trainee['address'] . '<br>' . $trainee['suburb'] . ' ' . $trainee['postcode'] . '</td>'; $trhtml = $trhtml . ' </tr>'; $trhtml = $trhtml . ' </table><br><br>'; $traineehtml = $traineehtml . $trhtml; $currentTrainee++; } $html = varReplace("traineeDetails", $traineehtml, $html); $remail = $mData['awfaSendInvoiceNotification']; //$remail = "*****@*****.**"; $subject = "MANUAL INVOICE: Please generate a manual invoice for this Discounted Enrolment"; $message = $html; $bookingID = ""; $instanceID = ""; $ccEmail = ""; //$ccEmail = "*****@*****.**"; email::logEmail($remail, $ccEmail, "", $subject, $message, $bookingID, $instanceID, $emailKey); esmtp::sendemail_smtp($remail, $subject, $message, $ccEmail); echo $html; } } }