// start the session
session_start();
header("Cache-control: private"); //IE 6 Fix
include ("constants.php");
include ("db_utils.php");
include ("html-utils.php");
if (isset($_GET['mode'])) {
$mode = $_GET['mode'];
$_SESSION['mode'] = $mode;
} else if (isset($_SESSION['mode'])) {
$mode = $_SESSION['mode'];
} else {
// Set default mode
$mode = 'home';
$_SESSION['mode'] = $mode;
}
// Hardcode company name. Later, we figure how each OEM company's name is parametrized
$CompanyName = 'Rewired';
$AcctID = $UN_INITIALIZED;
if (isset($_POST['enroll'])) { // Called as a post from "Signup"
if ($_POST['enroll'] == 'employee') {
$mysqli = db_connect();
if (mysqli_connect_errno()) {
} else {
$AcctID = reg_employee($mysqli, $CompanyName,
$_POST['AcctName'], $_POST['AcctPass'],
$_POST['fname'], $_POST['lname'],
$_POST['group'], $_POST['title'],
$_POST['dob'], $_POST['gender'],
$_POST['race'], $_POST['ethnicity'], 0,
$_POST['phone'], $_POST['email']);
$mysqli->close();
}
}
} else if (isset($_POST['AcctName'])) { // Called as a post from "Login"
$aName = $_POST['AcctName'];
$aPass = $_POST['AcctPass'];
$AcctID = is_valid_user($aName, $aPass);
// $AcctID = 5;
} else if (isset($_POST['logout'])) { // Called as a post from "Logout"
unset($AcctName);
unset($AcctPass);
unset($AcctID);
$mode = 'home';
session_unset();
} else if (isset($_SESSION['AcctName'])) { // Already logged in
$AcctName = $_SESSION['AcctName'];
$AcctPass = $_SESSION['AcctPass'];
$AcctID = $_SESSION['AcctID'];
}
if ($AcctID > 0) {
if (isset($_POST['AcctName']) || isset($_POST['enroll'])) {
$AcctName = $_POST['AcctName'];
$AcctPass = $_POST['AcctPass'];
$_SESSION['AcctName'] = $AcctName;
$_SESSION['AcctPass'] = $AcctPass;
$_SESSION['AcctID'] = $AcctID;
$mode = 'profile'; // Now that we have done signing up, switch to profile
$_SESSION['mode'] = $mode;
}
} else if ($mode == 'profile') {
$mode = 'signup'; // 'profile' is invalid without an AcctId
$_SESSION['mode'] = $mode;
}
?>
Coarys - The complete solution for managing your employees wellness
if ($mode == 'home') {
?>
} // if ($mode == 'home') {
?>
print("\n");
if (isset($_POST['AcctName']) && $AcctID <= 0) { // Failed "Login"
print("Login failed. Check User name and/or Password
\n");
}
?>
Coarys Health Solutions
|
if (isset($AcctID) && $AcctID > 0) {
print("
|
MenuTd($mode, 'home', 'Home', 'Go to Home Page');
if (isset($AcctID) && $AcctID > 0) {
MenuTd($mode, 'profile', 'Profile', 'Edit your account');
MenuTd($mode, 'health', 'Health', 'Add new health data or view past history');
} else {
MenuTd($mode, 'signup', 'Sign Up', 'Sign up to get started!');
}
MenuTd($mode, 'aggregate', 'Aggregate', 'Aggregate metrics and trends over all employees');
MenuTd($mode, 'wellness', 'Wellness', 'Suggestions on staying healthy');
MenuTd($mode, 'forum', 'Forum', 'Discuss health issues with fellow user');
?>
|
|
if (isset($_POST['enroll'])) {
if (!isset($AcctID) || $AcctID == $UN_INITIALIZED) {
print("Uninitialized var error. Contact Administrator.\n");
} else if ($AcctID > 0) {
print("Account $AcctName created.\n");
} else if ($AcctID == $BAD_COMPANY) {
print("Company $CompanyName does not exist2.\n");
} else if ($AcctID == $ALREADY_EXISTS) {
$AcctName = $_POST['AcctName'];
print("Account ID $AcctName already exists. Choose another id.\n");
} else if ($AcctID == $DB_ERROR) {
print("System Error. Contact Administrator.\n");
} else {
print("Unknown Error $AcctID. Contact Administrator.\n");
}
}
?>
if ($mode == 'home') {
include ("home.php");
} else if ($mode == 'profile') {
$mysqli = db_connect();
include ("profile.php");
ShowEmployee($mysqli, $AcctID);
$mysqli->close();
} else if ($mode == 'health') {
$mysqli = db_connect();
$gender = db_getVal($mysqli, "RB_Employee", "Gender", "AcctId", $AcctID);
include ("health.php");
ShowHealth($mysqli, $AcctID, $gender);
$mysqli->close();
} else if ($mode == 'aggregate') {
include ("aggregate.php");
} else if ($mode == 'wellness') {
include ("wellness.php");
} else if ($mode == 'forum') {
include ("forum.php");
} else if ($mode == 'signup') {
include ("signup.php");
ShowEmployeeForm($_POST['AcctName'], $_POST['AcctPass'], $_POST['fname'], $_POST['lname'],
$_POST['group'], $_POST['title'], $_POST['dob'], $_POST['gender'],
$_POST['race'], $_POST['ethnicity'],
$_POST['phone'], $_POST['email']);
}
?>