<?php require "../includes/includeMeBlank.php"; echo json_encode(array("hourSize" => getHourSize()));
<?php require_once 'guid.php'; $hourSize = getHourSize(); $showUnposted = 0; function getHourSize() { global $area, $db; try { $hourQuery = $db->prepare("SELECT hourSize FROM employeeAreas WHERE ID=:area"); $hourQuery->execute(array(':area' => $area)); } catch (PDOException $e) { exit("error in query"); } $result = $hourQuery->fetch(); return $result->hourSize; } function getStartDay() { global $area, $db; try { $startQuery = $db->prepare("SELECT startDay FROM employeeAreas WHERE ID=:area"); $startQuery->execute(array(':area' => $area)); } catch (PDOException $e) { exit("error in query"); } $result = $startQuery->fetch(); return $result->startDay; } function getEndDay() {
case SORT_DESC: arsort($sortable_array); break; } foreach ($sortable_array as $k => $v) { $new_array[$k] = $array[$k]; } } return $new_array; } if (isset($_GET['hourMod'])) { $hourMod = $_GET['hourMod']; } else { $hourMod = 0; } $hSize = getHourSize(); $hourModPlus = $hSize * ($hourMod + 1); $hourModMinus = $hSize * ($hourMod - 1); $hourModPlus *= 60; //Converts it to minutes so that strtotime can read it. $hourModMinus *= 60; $hourMod *= 60; $hourMod *= $hSize; //Accounts for the shift size. $now = strtotime("{$hourMod} minutes"); //It is the previous hour, the next hour and the current time depending on what was passed to the page. //The strtotime function takes string arguments (see documentation). $date = date('Y-m-d', $now); $next = strtotime("{$hourModPlus} minutes"); //Takes care of rounding to the nearest increment (can be half hour, hour, etc.). Corresponds to shift size of the area. $next -= $next % (3600 * $hSize);
function getHourSelect() { for ($i = 0.0; $i < 24.0; $i += getHourSize()) { echo "<option value=\"" . hourToMilitary($i) . "\">" . hourToTimeFullSuffix($i) . "</option>"; } }