Example #1
0
    }
    if (time() >= $fromtime && time() < $totime) {
        $diff = abs(($totime - time()) / 60);
        if ($diff <= 60) {
            $timeMessage = "Closing soon.";
        } else {
            $timeMessage = "Open Now.";
        }
    } else {
        $timeMessage = "Closed Now.";
    }
}
$cnt = $restaurantDb->getRestaurantImageCount($resId);
$n = intval($cnt[0]) >= 5 ? 5 : intval($cnt[0]);
//total number of images for the restaurant in multimedia table
$reviews = $restaurantDb->getRestaurantReviews($resId);
$ratings = array(1 => 0, 2 => 0, 3 => 0, 4 => 0, 5 => 0);
foreach ($reviews as $review) {
    if ($review['rating'] != null) {
        $ratings[$review['rating']]++;
    }
}
$avgRating = $ratingCount = 0;
for ($i = 1; $i <= 5; $i++) {
    $avgRating += $i * $ratings[$i];
    $ratingCount += $ratings[$i];
}
if ($ratingCount > 0) {
    $avgRating /= $ratingCount;
}
if ($avgRating >= 1) {
require_once __DIR__ . '/../models/Owner_model.php';
require_once __DIR__ . '/../models/Event_model.php';
require_once __DIR__ . '/../models/Hostess_model.php';
require_once __DIR__ . '/../models/Login_model.php';
require_once __DIR__ . '/../models/OperationHours_model.php';
$username = $_SESSION['username'];
$ownerDb = new Owner_model();
$ownerInfo = $ownerDb->getOwnerInfo($username);
$resId = intval($ownerInfo['restaurant_id']);
$restaurantDb = new Restaurant_model();
$restaurantInfo = $restaurantDb->findRestaurantById($resId);
$restaurantImages = $restaurantDb->getRestaurantImages($resId);
$imageCount = count($restaurantImages) >= 4 ? 4 : count($restaurantImages);
//total number of images for the restaurant in multimedia table
$foodCategory = $restaurantDb->getFoodCategories();
$reviewArray = $restaurantDb->getRestaurantReviews($resId);
$oprDb = new OperationHours_model();
$oprHours = $oprDb->getOperatingHoursByRestaurantId($resId);
$eventDb = new Event_model();
$eventArray = $eventDb->getEventsByRestaurantId($resId);
$hostessDb = new Hostess_model();
$hostessArray = $hostessDb->getHostessByRestaurantId($resId);
$loginDb = new Login_model();
$existingUsernames = $loginDb->getAllUsernames();
if (!empty($oprHours)) {
    $oprHours = $oprHours[0];
}
if ($_POST) {
    /*
     * For uploading images
     */