|
|
|
|
@ -52,6 +52,7 @@ $selectedHour = 13;
|
|
|
|
|
$isLoggedIn = true;
|
|
|
|
|
$accessToken = $_COOKIE['access_token'];
|
|
|
|
|
$refreshToken = $_COOKIE['refresh_token'];
|
|
|
|
|
$newHour = $_COOKIE['hour'];
|
|
|
|
|
$customerNumber = '';
|
|
|
|
|
$connectionId = '';
|
|
|
|
|
$customerName = '';
|
|
|
|
|
@ -231,7 +232,12 @@ if (!isset($accessToken) && !isset($refreshToken)) {
|
|
|
|
|
try {
|
|
|
|
|
getCustomerDetails($vars, $accessToken, $customerNumber, $connectionId, $customerName);
|
|
|
|
|
getCurrentHour($vars, $accessToken, $customerNumber, $connectionId, $selectedHour);
|
|
|
|
|
$message = 'Select your hour of power.';
|
|
|
|
|
if ($newHour) {
|
|
|
|
|
$message = 'Done, changed to ' . $times[$newHour] . '.';
|
|
|
|
|
setcookie('hour', '', time() - 1000, "/");
|
|
|
|
|
} else {
|
|
|
|
|
$message = 'Select your hour of power.';
|
|
|
|
|
}
|
|
|
|
|
} catch (Exception $exception) {
|
|
|
|
|
if ($exception->getCode() === 401) {
|
|
|
|
|
try {
|
|
|
|
|
@ -265,7 +271,9 @@ if ($isLoggedIn && $_POST) {
|
|
|
|
|
if ($isValid) {
|
|
|
|
|
try {
|
|
|
|
|
setCurrentHour($vars, $accessToken, $customerNumber, $connectionId, $selectedHour);
|
|
|
|
|
$message = 'Done. Hour changed to ' . $times[$selectedHour] . '.';
|
|
|
|
|
setcookie('hour', $selectedHour, time() + 30000, "/");
|
|
|
|
|
header('Location: /');
|
|
|
|
|
die();
|
|
|
|
|
} catch (Exception $exception) {
|
|
|
|
|
$message = $exception->getMessage();
|
|
|
|
|
}
|
|
|
|
|
|