function getbookingdate($t, $is_end = FALSE) { global $eveningends, $eveningends_minutes, $resolution; $date = getdate($t); $t_secs = ($date['hours'] * 60 + $date['minutes']) * 60; $e_secs = (($eveningends * 60 + $eveningends_minutes) * 60 + $resolution) % SECONDS_PER_DAY; if (day_past_midnight()) { if ($t_secs < $e_secs || $t_secs == $e_secs && $is_end) { $date = getdate(mktime($date['hours'], $date['minutes'], $date['seconds'], $date['mon'], $date['mday'] - 1, $date['year'])); $date['hours'] += 24; } } return $date; }
function get_n_time_slots() { global $morningstarts, $morningstarts_minutes, $eveningends, $eveningends_minutes; global $resolution; $start_first = ($morningstarts * 60 + $morningstarts_minutes) * 60; // seconds $end_last = ($eveningends * 60 + $eveningends_minutes) * 60 + $resolution; // seconds $end_last = $end_last % SECONDS_PER_DAY; if (day_past_midnight()) { $end_last += SECONDS_PER_DAY; } $n_slots = ($end_last - $start_first) / $resolution; return $n_slots; }
if ($enable_periods) { $start_seconds = 12 * SECONDS_PER_HOUR; // This is actually the start of the last period, which is what the form would // have returned. It will get corrected in a moment. $end_seconds = $start_seconds + (count($periods) - 1) * 60; } else { $start_seconds = ($morningstarts * 60 + $morningstarts_minutes) * 60; $end_seconds = ($eveningends * 60 + $eveningends_minutes) * 60; $end_seconds += $resolution; // We want the end of the last slot, not the beginning } } // If we're operating on a booking day that stretches past midnight, it's more convenient // for the sections past midnight to be shown as being on the day before. That way the // $returl will end up taking us back to the day we started on if (day_past_midnight()) { $end_last = (($eveningends * 60 + $eveningends_minutes) * 60 + $resolution) % SECONDS_PER_DAY; if ($start_seconds < $end_last) { $start_seconds += SECONDS_PER_DAY; $day_before = getdate(mktime(0, 0, 0, $start_month, $start_day - 1, $start_year)); $start_day = $day_before['mday']; $start_month = $day_before['mon']; $start_year = $day_before['year']; } } // Check that the user has permission to create/edit an entry for this room. // Get the id of the room that we are creating/editing if (isset($id)) { // Editing an existing booking: get the room_id from the database (you can't // get it from $rooms because they are the new rooms) $target_room = sql_query1("SELECT room_id FROM {$tbl_entry} WHERE id={$id} LIMIT 1");