Exemplo n.º 1
0
    $fromtime = strtotime($from, time());
    if ($fromtime > $totime) {
        $totime = strtotime($to . ' +1 day', time());
    }
    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) {