public function runSearch()
 {
     $this->errors = array();
     $searchResults = array();
     $totalCapacity = $this->searchCritieria->adultsCount + $this->searchCritieria->childrenCount;
     $searchSql = "SELECT * FROM bsi_rooms WHERE capacity >= {$totalCapacity} AND id NOT IN (SELECT room_id FROM bsi_bookings WHERE ((start_date + INTERVAL 1 DAY) BETWEEN CAST('" . $this->searchCritieria->checkInDate->formatMySql() . "' AS DATE) AND CAST('" . $this->searchCritieria->checkOutDate->formatMySql() . "' AS DATE) OR (end_date - INTERVAL 1 DAY) BETWEEN CAST('" . $this->searchCritieria->checkInDate->formatMySql() . "' AS DATE) AND CAST('" . $this->searchCritieria->checkOutDate->formatMySql() . "' AS DATE) OR ((start_date + INTERVAL 1 DAY) < CAST('" . $this->searchCritieria->checkInDate->formatMySql() . "' AS DATE) AND (end_date - INTERVAL 1 DAY) > CAST('" . $this->searchCritieria->checkOutDate->formatMySql() . "' AS DATE)) OR  ((start_date + INTERVAL 1 DAY) > CAST('" . $this->searchCritieria->checkInDate->formatMySql() . "' AS DATE) AND (end_date - INTERVAL 1 DAY) < CAST('" . $this->searchCritieria->checkOutDate->formatMySql() . "' AS DATE))) AND is_deleted = 0)";
     $searchQuery = mysql_query($searchSql);
     if (!$searchQuery) {
         die("Error: " . mysql_error());
     }
     while ($searchRow = mysql_fetch_assoc($searchQuery)) {
         $matchingRoom = Room::fetchFromParameters($searchRow);
         array_push($searchResults, $matchingRoom);
     }
     return $searchResults;
 }
示例#2
0
 public static function fetchFromDbApartments()
 {
     $rooms = array();
     $sql = "SELECT * FROM bsi_rooms WHERE is_apartment = 1";
     $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());
     }
     while ($row = mysql_fetch_assoc($query)) {
         $room = Room::fetchFromParameters($row);
         $rooms[] = $room;
     }
     return $rooms;
 }
示例#3
0
<?php

// TODO: Uncomment
include "access.php";
include_once "../includes/SystemConfiguration.class.php";
global $systemConfiguration;
global $logger;
$errors = array();
$message = "";
$room = new Room();
$roomPricePlan = new RoomPricePlan();
if (isset($_POST['SBMT_REG'])) {
    $logger->LogInfo("Form has been submitted.");
    $room = Room::fetchFromParameters($_POST);
    if (!$room->save()) {
        $logger->LogError("Error saving room.");
        foreach ($room->errors as $error) {
            $logger->LogError($error);
            $errors[] = $error;
        }
    } else {
        $roomPricePlan = RoomPricePlan::fetchFromParameters($_POST);
        $roomPricePlan->id = intval($_POST['price_plan_id']);
        $roomPricePlan->isDefault = true;
        $roomPricePlan->roomId = $room->id;
        if (!$roomPricePlan->save()) {
            $logger->LogError("Error saving room.");
            foreach ($room->errors as $error) {
                $logger->LogError($error);
                $errors[] = $error;
            }