public static function fetchFromDbForCode($emailContentsCode)
 {
     EmailContents::$staticErrors = array();
     $sql = "SELECT * FROM bsi_email_contents WHERE trim(lower(email_code)) = '" . strtolower(trim(mysql_escape_string($emailContentsCode))) . "'";
     $query = mysql_query($sql);
     if (!$query) {
         global $logger;
         $logger->LogFatal("Error executing query: {$sql}");
         $logger->LogFatal("Database error: " . mysql_errno() . ". Message: " . mysql_error());
         die("Database error: " . mysql_errno() . ". Message: " . mysql_error());
     }
     if ($row = mysql_fetch_assoc($query)) {
         $emailContents = EmailContents::fetchFromParameters($row);
         return $emailContents;
     } else {
         EmailContents::setStaticError("Email contents with code: " . $emailContentsCode . " does not exist.");
         return null;
     }
 }
Example #2
0
 $invoiceHtml .= '	</tr>' . "\n";
 $invoiceHtml .= '</table>' . "\n";
 $booking->invoice .= $invoiceHtml;
 $booking->paymentTransactionId = $transactionId;
 $booking->paypalEmail = $paypalEmail;
 $booking->isPaymentSuccessful = true;
 $logger->LogInfo("Saving booking ...");
 if (!$booking->save(true)) {
     $logger->LogFatal("Error saving booking!");
     $logger->LogFatal($booking->errors);
     die("Error: " . $booking->errors[0]);
 }
 $logger->LogInfo("Save is successful.");
 // Send email to client that txn was processed
 $logger->LogInfo("Getting confirmation email contents ...");
 $confirmationEmailContents = EmailContents::fetchFromDbForCode("Confirmation Email");
 if ($confirmationEmailContents == null) {
     $logger->LogError("Cannot find confirmation email contents!");
     $logger->LogError(EmailContents::$staticErrors);
 }
 $client = $booking->getClient();
 $clientEmail = $client->email;
 $logger->LogInfo("Personalizing email ...");
 $emailPersonalizer = new EmailPersonalizer($booking);
 $emailBody = $emailPersonalizer->customizeEmailContents($confirmationEmailContents->emailText->getText($booking->languageCode));
 $logger->LogDebug("Email body:");
 $logger->LogDebug($emailBody);
 $logger->LogInfo("Sending email to client...");
 if (!$emailSender->sendEmail($clientEmail, $confirmationEmailContents->emailSubject->getText($booking->languageCode), $emailBody)) {
     $logger->LogError("Failed to send confirmation email to client.");
 }
Example #3
0
function processPayOnArrival()
{
    global $bookingDetails;
    global $systemConfiguration;
    global $logger;
    global $language_selected;
    $logger->LogInfo("Processing payment on arrival ...");
    $transactionId = "N/A";
    $booking = $bookingDetails->booking;
    $paymentGateway = $bookingDetails->paymentGateway;
    $logger->LogInfo("Creating bottom portion of invoice ...");
    $logger->LogInfo("Compposing invoice ...");
    $invoiceHtml = '<br />' . "\n";
    $invoiceHtml .= '<table  style="font-family:Verdana, Geneva, sans-serif; font-size: 12px; background:#999999; width:700px; border:none;" cellpadding="4" cellspacing="1">' . "\n";
    $invoiceHtml .= '	<tr>' . "\n";
    $invoiceHtml .= '		<td align="left" colspan="2" style="font-weight:bold; font-variant:small-caps; background:#eeeeee;">' . "\n";
    $invoiceHtml .= '			' . BOOKING_DETAILS_BILLING . "\n";
    $invoiceHtml .= '		</td>' . "\n";
    $invoiceHtml .= '	</tr>' . "\n";
    $invoiceHtml .= '	<tr>' . "\n";
    $invoiceHtml .= '		<td align="left" width="30%" style="font-weight:bold; font-variant:small-caps;background:#ffffff;" width="33%">' . "\n";
    $invoiceHtml .= '			' . BOOKING_DETAILS_PAYMENT_OPTION . "\n";
    $invoiceHtml .= '		</td>' . "\n";
    $invoiceHtml .= '		<td align="left" style="background:#ffffff;">' . "\n";
    $invoiceHtml .= '			' . $paymentGateway->gatewayName->getText($language_selected) . "\n";
    $invoiceHtml .= '		</td>' . "\n";
    $invoiceHtml .= '	</tr>' . "\n";
    $invoiceHtml .= '	<tr>' . "\n";
    $invoiceHtml .= '		<td align="left" width="30%" style="font-weight:bold; font-variant:small-caps; background:#ffffff;" width="33%">' . "\n";
    $invoiceHtml .= '			' . BOOKING_DETAILS_TRANSACTION . "\n";
    $invoiceHtml .= '		</td>' . "\n";
    $invoiceHtml .= '		<td align="left" style="background:#ffffff;">' . "\n";
    $invoiceHtml .= '			' . $transactionId . "\n";
    $invoiceHtml .= '		</td>' . "\n";
    $invoiceHtml .= '	</tr>' . "\n";
    $invoiceHtml .= '</table>' . "\n";
    $booking->invoice .= $invoiceHtml;
    $booking->paymentTransactionId = $transactionId;
    $booking->paypalEmail = "";
    $booking->isPaymentSuccessful = true;
    $logger->LogInfo("Saving booking ...");
    if (!$booking->save(true)) {
        $logger->LogFatal("Error saving booking!");
        $logger->LogFatal($booking->errors);
        die("Error: " . $booking->errors[0]);
    }
    $logger->LogInfo("Save is successful.");
    // Send email to client that txn was processed
    $logger->LogInfo("Getting confirmation email contents ...");
    $confirmationEmailContents = EmailContents::fetchFromDbForCode("Confirmation Email");
    if ($confirmationEmailContents == null) {
        $logger->LogFatal("Could not find confirmation email contents.");
        die("Cannot find confirmation email details");
    }
    $client = $booking->getClient();
    $clientEmail = $client->email;
    $logger->LogInfo("Personalizing email ...");
    $emailPersonalizer = new EmailPersonalizer($booking);
    $emailBody = $emailPersonalizer->customizeEmailContents($confirmationEmailContents->emailText->getText($booking->languageCode));
    $logger->LogDebug("Email body:");
    $logger->LogDebug($emailBody);
    $logger->LogInfo("Sending email to client at " . $clientEmail . " ...");
    $emailSender = new EmailSender();
    if (!$emailSender->sendEmail($clientEmail, $confirmationEmailContents->emailSubject->getText($booking->languageCode), $emailBody)) {
        $logger->LogError("Failed to send confirmation email to client.");
    }
    /* Notify Email for Hotel about Booking */
    $notifyEmailSubject = "Booking no." . $booking->id . " - Notification of Room Booking by " . $client->firstName . " " . $client->lastName;
    $logger->LogInfo("Sending email to hotel admin...");
    if (!$emailSender->sendEmail($systemConfiguration->getHotelDetails()->getHotelEmail(), $notifyEmailSubject, $invoiceHtml)) {
        $logger->LogError("Failed to send email to the hotel admin.");
    }
    header('Location: booking-confirm.php');
}
    $logger->LogInfo("Form was submitted.");
    $emailContents = EmailContents::fetchFromParameters($_POST);
    if (!$emailContents->save()) {
        $logger->LogError("Email contents failed to save.");
        foreach ($emailContents->errors as $error) {
            $logger->LogError($error);
            $errors[] = $error;
        }
    } else {
        $message = "Values were updated successfully!";
    }
} else {
    if (isset($_REQUEST['id']) && is_numeric($_REQUEST['id'])) {
        $logger->LogInfo("Form was called with id: " . $_REQUEST['id']);
        $id = intval($_REQUEST['id']);
        $emailContents = EmailContents::fetchFromDb($id);
    }
}
$defaultLanguage = Language::fetchDefaultLangauge();
$languages = Language::fetchAllFromDbActive();
?>
<script type="text/javascript" src="../ckeditor/ckeditor.js"></script>
</td>
</tr>

<tr>
  <td height="400" valign="top">
  <?php 
if (sizeof($errors) > 0) {
    echo '			<table width="100%">' . "\n";
    foreach ($errors as $error) {