0 && intval($party) < $min_guests) return false; if ($max_guests > 0 && intval($party) > $max_guests) return false; } // To get the week day $day = evavel_date_createFromFormat('Y-m-d', $date); $dayOfWeek = $day->dayOfWeek; // 1-mon , 7-sun // Check weekdays if (!isset($rule['weekdays'])) return false; $rule_weekdays = $rule['weekdays']; $weekdays = ['sun','mon','tue','wed','thu','fri','sat', 'sun']; if ($rule_weekdays[ $weekdays[$dayOfWeek] ] === false) return false; // Check date ranges. Only apply if not empty if (!isset($rule['date_range'])) return false; $rule_dates = $rule['date_range']; $found_match = false; foreach($rule_dates as $range) { if(preg_match("#(.+) to (.+)#", $range, $matches)) { if ($matches[1] <= $date && $matches[2] >= $date) { $found_match = true; } } } if (!empty($rule_dates) && !$found_match) return false; // Check include specific dates. If not empty date should be in the list if (!isset($rule['include_days'])) return false; $include_days = $rule['include_days']; if (!empty($include_days)){ if (!in_array($date, $include_days)){ return false; } } // Check exclude dates. If not empty check it is not included here if (!isset($rule['exclude_days'])) return false; $exclude_days = $rule['exclude_days']; if (!empty($exclude_days)){ if (in_array($date, $exclude_days)){ return false; } } // Check time slot is accepted if (!isset($rule['slots'])) return false; $slots = $rule['slots']; foreach ($slots as $slot) { if ($slot['time'] == $time){ // block=true means the slot is blocked for this rule return !$slot['block']; } } return true; } }