Example #1
0
 private static function fetchFromSqlMultiple($sql)
 {
     global $logger;
     $logger->LogDebug(__METHOD__ . " line: " . __LINE__);
     $logger->LogDebug("Fetching multiple " . __CLASS__ . " objects for SQL: " . $sql);
     if ($sql == null) {
         $logger->LogDebug("SQL is null!");
         return null;
     }
     Client::$staticErrors = array();
     $clients = array();
     $query = mysql_query($sql);
     if (!$query) {
         $logger->LogError("Error executing query!");
         $logger->LogFatal("Database error: " . mysql_errno() . ". Message: " . mysql_error());
         die("There was an error connecting to the database. Please try your request again or contact the system administrator.");
     }
     while ($row = mysql_fetch_assoc($query)) {
         $client = Client::fetchFromParameters($row);
         $clients[] = $client;
     }
     $logger->LogDebug("Fetched " . count($clients) . " clients.");
     return $clients;
 }
Example #2
0
            $bookingDetails->extraServices[] = $extraServiceDetails;
        } else {
            $logger->LogWarn("Extra service has a quntity of 0. Skipping!");
        }
    }
}
// Calculate price details
$logger->LogInfo("Calculating price ...");
$bookingDetails->calculatePriceDetails($language_selected);
// Get entered promo code and client info
$promoErrorMessage = null;
$clientEmailAddress = null;
$client = new Client();
if (isset($_POST['promo_code'])) {
    $logger->LogInfo("Promo code was entered: " . $_POST['promo_code']);
    $client = Client::fetchFromParameters($_POST);
    $bookingDetails->promoCode = null;
    if (isset($_POST['email'])) {
        $logger->LogInfo("Email was entered: " . $_POST['email']);
        $clientsEmailAddress = $_POST['email'];
    }
    $promoCode = PromoCode::fetchFromDBForCode($_POST['promo_code']);
    if ($promoCode == null) {
        $logger->LogWarn("Promo could not be found in the database!");
        $logger->LogWarn("Errors:");
        $logger->LogWarn(PromoCode::$staticErrors);
        $promoErrorMessage = PromoCode::$staticErrors[0];
    } else {
        if ($promoCode->isApplicable($bookingDetails->priceDetails->grandTotal, $clientsEmailAddress, $bookingDetails->searchCriteria->getNightCount(), $promoErrorMessage)) {
            $logger->LogInfo("Promo is applicable!");
            $bookingDetails->promoCode = $promoCode;