Skip to content
Permalink
master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
<?php
$title = 'Members Page';
require 'layout/header.php';
include_once (__DIR__."/Utility/surveyData.php");
include_once (__DIR__."/Utility/dataConnect.php");
include_once (__DIR__."/Utility/profileData.php");
include_once (__DIR__."/Utility/hleData.php");
include_once (__DIR__."/Utility/weekCalculations.php");
include_once (__DIR__."/Utility/groupFunctions.php");
include_once (__DIR__."/Utility/healthUpdate.php");
//$AccountName = $_COOKIE['LivingHealthy'];
$AccountName = 'hhp14001';
$memberData = new userProfile($AccountName);
$myGroups = array(array('GroupID'=>'1', 'GroupName'=>'One'),array('GroupID'=>'2', 'GroupName'=>'Two'));
//$myGroups = getGroups($AccountNameD);
if($memberData->getIsProfilePresent() == false) {
echo '<script type="text/javascript">',
'window.location.href = "profile.php";',
'</script>';
}
function debug_to_console( $data ) {
$output = $data;
if ( is_array( $output ) )
$output = implode( ',', $output);
echo "<script>console.log( 'Debug Objects: " . $output . "' );</script>";
}
$now = new DateTime('now');
$month = $now->format('m');
$year = $now->format('Y');
$weeks_in_month = weeks_in_month();
$today = date("Y/m/d");
$pointsWeek = [];
$rHLEWeek = [];
$bHLEWeek = [];
$rankWeek = [];
$totalParticipantsWeek = [];
$weekStartDate = [];
for ($i = 1; $i <= 6; $i++) {
$surveyWeek = new survey($AccountName, $year, $month, $i);
if($surveyWeek->getIsSurveyPresent()) {
if($i == $weeks_in_month)
$hleWeek = new hleData($memberData, $surveyWeek,false,true);
else {
$hleWeek = new hleData($memberData, $surveyWeek,false,false);
}
$pointsWeek[$i] = $hleWeek->getPoints();
$totalParticipantsWeek[$i] = $hleWeek->getRankTotal();
$rankWeek[$i] = $hleWeek->getRankPosition();
$rHLEWeek[$i] = $hleWeek->getrHle();
$bHLEWeek[$i] = $hleWeek->getbHle();
} else {
$pointsWeek[$i] = 0;
$totalParticipantsWeek[$i] = 0;
$rankWeek[$i] = 0;
$rHLEWeek[$i] = 0;
$bHLEWeek[$i] = 0;
}
$weekOfYear = LH_getWeek($year, $month, $i);
$prevWeekOfYear = LH_getWeek($year, $month, $i -1);
$yearTemp = $prevWeekOfYear > $weekOfYear ? $year + 1: $year;
$weekStartDate[$i] = date("Y/m/d", strtotime(getStartAndEndDate($weekOfYear,$yearTemp)['week_start']));
}
$currentrHLEScores = array_filter($rHLEWeek);
if ( sizeof($currentrHLEScores) > 0) {
$rHLELatest = end($currentrHLEScores);
$rHLELatestWeek = key($currentrHLEScores);
$bHLELatest = $bHLEWeek[$rHLELatestWeek];
$healthStatus = getHealthStatus($rHLELatest,$rHLELatestWeek,$currentrHLEScores[1],$bHLELatest);
debug_to_console($healthStatus);
}
?>
<body>
<div class="container">
<header class="clearfix">
<b>Hello <?php echo $AccountName; ?>,</b><br>
<h1><b>Summary for <?php echo $now->format('F');; ?></b></h1>
<nav>
<a href="summary.php" data-info="Summary"><span class = "glyphicon glyphicon-stats"></a>
<a href="leaderboard.php" data-info="Leaderboard"><span class = "glyphicon glyphicon-star"></a>
<a href="profile.php" data-info="Your Profile"><span class = "glyphicon glyphicon-user"></span></a>
</nav>
</header>
<div class="main">
<ul id="cbp-ntaccordion" class="cbp-ntaccordion">
<li class="cbp-ntopen">
<h3 class="cbp-nttrigger">Individual</h3>
<div class="cbp-ntcontent">
<div class="leaderboard flex column wrap">
<div class="leaderboard-table flex column">
<?php if($healthStatus) { echo $healthStatus; } ?>
<div class="leaderboard-header flex column grow">
<div class="leaderboard-row flex align-center row--header" style="border-radius: 0 !important;">
<div class="row-position">Week</div>
<div class="row-user">Survey Status</div>
<div class="row-rank">Score</div>
<div class="row-rank">Total Participant</div>
<div class="row-rank">Rank</div>
</div>
</div>
<div class="leaderboard-body flex column grow" <?php if (1 > $weeks_in_month) {?>style="display:none"<?php } ?> >
<div class="leaderboard-row flex align-center">
<div class="row-position">1st</div>
<div class="row-user">
<input type="button"
class="btn btn-primary"
value="Available"
onclick="selectedWeek('1')"
<?php If($today<$weekStartDate[1]){ ?> disabled <?php } ?> >
</div>
<div class="row-rank"><?php echo(round($pointsWeek[1],2)); ?></div>
<div class="row-rank"><?php echo($totalParticipantsWeek[1]); ?></div>
<div class="row-rank"><?php echo($rankWeek[1]); ?></div>
</div>
</div>
<div class="leaderboard-body flex column grow" <?php if (2 > $weeks_in_month) {?>style="display:none"<?php } ?> >
<div class="leaderboard-row flex align-center">
<div class="row-position">2nd</div>
<div class="row-user">
<input type="button"
class="btn btn-primary"
value="Available"
onclick="selectedWeek('2')"
<?php If($today<$weekStartDate[2]){ ?> disabled <?php } ?> >
</div>
<div class="row-rank"><?php echo(round($pointsWeek[2],2)); ?></div>
<div class="row-rank"><?php echo($totalParticipantsWeek[2]); ?></div>
<div class="row-rank"><?php echo($rankWeek[2]); ?></div>
</div>
</div>
<div class="leaderboard-body flex column grow" <?php if (3 > $weeks_in_month) {?>style="display:none"<?php } ?> >
<div class="leaderboard-row flex align-center">
<div class="row-position">3rd</div>
<div class="row-user">
<input type="button"
class="btn btn-primary"
value="Available"
onclick="selectedWeek('3')"
<?php If($today<$weekStartDate[3]){ ?> disabled <?php } ?> >
</div>
<div class="row-rank"><?php echo(round($pointsWeek[3],2)); ?></div>
<div class="row-rank"><?php echo($totalParticipantsWeek[3]); ?></div>
<div class="row-rank"><?php echo($rankWeek[3]); ?></div>
</div>
</div>
<div class="leaderboard-body flex column grow" <?php if (4 > $weeks_in_month) {?>style="display:none"<?php } ?> >
<div class="leaderboard-row flex align-center">
<div class="row-position">4th</div>
<div class="row-user">
<input type="button"
class="btn btn-primary"
value="Available"
onclick="selectedWeek('4')"
<?php If($today<$weekStartDate[4]){ ?> disabled <?php } ?> >
</div>
<div class="row-rank"><?php echo(round($pointsWeek[4],2)); ?></div>
<div class="row-rank"><?php echo($totalParticipantsWeek[4]); ?></div>
<div class="row-rank"><?php echo($rankWeek[4]); ?></div>
</div>
</div>
<div class="leaderboard-body flex column grow" <?php if (5 > $weeks_in_month) {?>style="display:none"<?php } ?> >
<div class="leaderboard-row flex align-center">
<div class="row-position">5th</div>
<div class="row-user">
<input type="button"
class="btn btn-primary"
value="Available"
onclick="selectedWeek('5')"
<?php If($today<$weekStartDate[5]){ ?> disabled <?php } ?> >
</div>
<div class="row-rank"><?php echo(round($pointsWeek[5],2)); ?></div>
<div class="row-rank"><?php echo($totalParticipantsWeek[5]); ?></div>
<div class="row-rank"><?php echo($rankWeek[5]); ?></div>
</div>
</div>
<div class="leaderboard-body flex column grow" <?php if (6 > $weeks_in_month) {?>style="display:none"<?php } ?> >
<div class="leaderboard-row flex align-center">
<div class="row-position">6th</div>
<div class="row-user">
<input type="button"
class="btn btn-primary"
value="Available"
onclick="selectedWeek('6')"
<?php If($today<$weekStartDate[6]){ ?> disabled <?php } ?> >
</div>
<div class="row-rank"><?php echo(round($pointsWeek[6],2)); ?></div>
<div class="row-rank"><?php echo($totalParticipantsWeek[6]); ?></div>
<div class="row-rank"><?php echo($rankWeek[6]); ?></div>
</div>
</div>
</div>
</div>
</div>
</li>
<li>
<h3 class="cbp-nttrigger">Groups</h3>
<div class="cbp-ntcontent">
<ul class="cbp-ntsubaccordion">
<?php for($i=0; $i<count($myGroups); $i++) { ?>
<li>
<h4 class="cbp-nttrigger"><?php echo $myGroups[$i]['GroupName'] ?></h4>
<div class="cbp-ntcontent">
<div class="leaderboard-header flex column grow">
<div class="leaderboard-row flex align-center row--header" style="border-radius: 0 !important;">
<div class="row-position">Week</div>
<div class="row-rank">Total Participant</div>
<div class="row-rank">Rank</div>
</div>
</div>
<?php for($j=1; $j<=$weeks_in_month; $j++) { ?>
<div class="leaderboard-body flex column grow">
<div class="leaderboard-row flex align-center">
<div class="row-position"> <?php echo $j ?> </div>
<div class="row-rank"> <?php echo getWeeklyMemberCount($myGroups[$i]['GroupID'], $j, $year) ?> </div>
<div class="row-rank"> <?php echo getWeeklyMemberRank($myGroups[$i]['GroupID'], $AccountName, $j, $year) ?> </div>
</div>
</div>
<?php } ?>
</div>
</li>
<?php } ?>
</ul>
</div>
</li>
</ul>
</div>
</div>
<script src="js/jquery.cbpNTAccordion.min.js"></script>
<script>
$( function() {
/*
- how to call the plugin:
$( selector ).cbpNTAccordion( [options] );
- destroy:
$( selector ).cbpNTAccordion( 'destroy' );
*/
$( '#cbp-ntaccordion' ).cbpNTAccordion();
} );
function selectedWeek(week) {
$.cookie("selectedWeek", week);
window.location.href = "survey.php";
}
</script>
</body>