Files
cwsvJudo/homepage/machs/index.php
2021-12-21 10:21:17 +01:00

128 lines
4.1 KiB
PHP

<?php
setlocale (LC_ALL, 'de_DE@euro', 'de_DE', 'de', 'ge');
require_once("config.php");
require_once("./local/dbConf.php");
require_once("./local/achievementsConf.php");
require_once("./lib/db.php");
require_once("./lib/achievementsLib.php");
require_once("./lib/api.php");
require_once("./lib/machs/achievementGroup.php");
$basePath = "/users/cwsvjudo/www";
require_once($basePath."/config/cwsvJudo.config.php");
require_once($basePath."/config/phpcount.config.php");
$dbConnection = getPdoDbConnection(
$cwsvJudoConfig["db"]["host"],
$cwsvJudoConfig["db"]["name"],
$cwsvJudoConfig["db"]["user"],
$cwsvJudoConfig["db"]["password"]
);
require_once("./auth.php");
achievementGroup::setDbConnection($dbConnection);
$achievementGroups = achievementGroup::getAllAchievementGroups();
processPostData($dbConnection, $_POST);
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<!-- Compiled and minified CSS -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@materializecss/materialize@1.1.0-alpha/dist/css/materialize.min.css">
<!-- Compiled and minified JavaScript -->
<script src="https://cdn.jsdelivr.net/npm/@materializecss/materialize@1.1.0-alpha/dist/js/materialize.min.js"></script>
<!-- inits for the materializeCss -->
<?php include("lib/machs/materializeInit.php");?>
<title>Achievements</title>
<meta name="description" content="Achievements">
<link rel="icon" href="<?echo($config['ressourceUrl']);?>/graphiken/icons/cwsv.ico" />
<link rel="apple-touch-icon" href="<?echo($config['baseUrl']);?>/apple-touch-icon.png">
</head>
<body>
<?php include("lib/machs/sidenav.php");?>
<?php // Für die 12-Nächte-Challenge
$now = new DateTime();
$promoStart = new DateTime("2021-11-24");
$promoEnd = new DateTime("2022-02-06");
$from = new DateTime("2021-12-24");
if($promoStart <= $now && $now <= $promoEnd) {
echo("<h1 style=\"font-size:1.5rem;\">12-Nächte-Challenge</h1>");
if($now < $from) echo("<p>Die 12-Nächte-Challenge geht vom 24.12.2021--06.01.2022. Ziel ist es möglichts an allen Tagen ein Achievement zu erhalten. Sobald es losgeht, wird hier die aktuelle Rangliste stehen.");
record::setDbConnection($dbConnection);
$zwölfer = record::getTopAchievers(array('from'=>"2021-12-24", 'to'=>"2022-01-06"));
echo("<table>");
record::setDbConnection($dbConnection);
foreach( record::getTopAchievers(array('from'=>"2021-12-24", 'to'=>"2022-01-06")) as $t ){
echo("<tr><td>".$t['vorname']."</td><td>".$t['name']."</td><td>".$t['COUNT(*)']."</td></tr>");
}
echo("</table>");
}
?>
<?php
if( hasUserAttribute($dbConnection, $_SESSION['user']['userId'], "inTraining" ) ){
echo( "<h2>Eigene Achievements</h2>" );
// echo( htmlUsersUploadBox($dbConnection, $_SESSION['user']['userId']) );
echo(htmlAchievementListForUser(
$dbConnection,
$achievementGroups,
$_SESSION['user']['userId'],
getUsersAchievements($dbConnection, $_SESSION['user']['userId'])
));
}
?>
<?php
$usersKids = getUsersKids($dbConnection, $_SESSION['user']['userId']);
foreach($usersKids as $k){
if( hasUserAttribute($dbConnection, $k['kidId'], "inTraining" ) and ($k['kidId']!=$_SESSION['user']['userId']) ){
echo( "<h2>".$k['vorname']." ".$k['name']."</h2>" );
// echo( htmlUsersUploadBox($dbConnection, $k['kidId']) );
echo(htmlAchievementListForUser(
$dbConnection,
$achievementGroups,
$k['id'],
getUsersAchievements($dbConnection, $k['id'])
));
}
}
?>
<?php
if(isUserAdmin($dbConnection, $_SESSION['user']['userId'])){
echo("<h2 id=\"addAchievementBox\">Add Achievements</h2>");
echo(htmlAddAchievementBox());
echo("<h2>Update Achievements</h2>");
$achievements = getAchievements($dbConnection);
foreach($achievements as $a){
echo( htmlUpdateAchievementBox(
$a['id'],
$a['name'],
$a['rootId'],
$a['achievementGroupId'],
$a['level'],
$a['description'],
$a['imgUrl']
));
echo("<hr />");
}
}
?>
<span id="endOfUpdateAchievementBoxes" style="display:none;" ></span>
</body>
</html>