modernize look

This commit is contained in:
marko
2021-10-19 18:20:03 +02:00
parent ff7363b370
commit 6f5e2ee405
3 changed files with 176 additions and 51 deletions

View File

@@ -1,7 +1,13 @@
<?php
require_once('machs.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");
PHPCount::AddHit("Achievementsystem (".htmlspecialchars($_SESSION['user']['username']).")");
require_once("./lib/db.php");
require_once("./lib/achievementsLib.php");
require_once("./lib/api.php");
$dbConnection = getPdoDbConnection(
$cwsvJudoConfig["db"]["host"],
@@ -9,12 +15,26 @@ $dbConnection = getPdoDbConnection(
$cwsvJudoConfig["db"]["user"],
$cwsvJudoConfig["db"]["password"]
);
require_once("./auth.php");
record::setDbConnection($dbConnection);
achievementGroup::setDbConnection($dbConnection);
$achievementGroups = achievementGroup::getAllAchievementGroups();
$basePath = "/users/cwsvjudo/www";
require_once($basePath."/config/cwsvJudo.config.php");
require_once($basePath."/config/phpcount.config.php");
// require_once($basePath."/ressourcen/phpLib/phpcount/phpcount.php");
// require_once($basePath."/ressourcen/phpLib/cwsvJudo/miscAssis.php");
// $dbConnection = getCwsvJudoDbConn();
$dbConnection = getPdoDbConnection(
$cwsvJudoConfig["db"]["host"],
$cwsvJudoConfig["db"]["name"],
$cwsvJudoConfig["db"]["user"],
$cwsvJudoConfig["db"]["password"]
);
$achievementGroups = getAchievementGroups($dbConnection);
processPostData($dbConnection, $_POST);
?>
<!DOCTYPE html>
<html>
@@ -38,34 +58,56 @@ processPostData($dbConnection, $_POST);
</head>
<body>
<!-- sidenav -->
<?php include("lib/machs/sidenav.php");?>
<!-- end sidenav -->
<?php // show own achievements, if oneself is inTraining
<?php echo $login_status; ?>
<?php
if( hasUserAttribute($dbConnection, $_SESSION['user']['userId'], "inTraining" ) ){
echo( "<h2>Eigene Achievements</h2>" );
echo( "<div style=\"display:flex; flex-wrap:wrap; align-items:stretch;\" class=\"row\">");
foreach($achievementGroups as $g){
echo($g->asHtmlCard($_SESSION['user']['userId']));
}
echo("</div>" );
echo( htmlUsersUploadBox($dbConnection, $_SESSION['user']['userId']) );
echo(htmlAchievementListForUser(
$dbConnection,
$achievementGroups,
$_SESSION['user']['userId'],
getUsersAchievements($dbConnection, $_SESSION['user']['userId'])
));
}
?>
<?php // show the achievements of each kid
$usersKids = getUsersKids($dbConnection, $_SESSION['user']['userId']);
foreach($usersKids as $k){
if( hasUserAttribute($dbConnection, $k['kidId'], "inTraining" ) ){
echo( "<h2>".$k['vorname']." ".$k['name']."</h2>" );
echo( "<div style=\"display:flex; flex-wrap:wrap; align-items:stretch;\" class=\"row\">");
foreach($achievementGroups as $g){
echo($g->asHtmlCard($k['kidId'], ['noForm'=>false]));
<?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'])
));
}
echo("</div>" );
}
}
?>
</body>
<?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['description'],
$a['rootId'],
$a['level']
));
echo("<hr />");
}
}
?>
<span id="endOfUpdateAchievementBoxes" style="display:none;" ></span>
</body>
</html>

View File

@@ -23,8 +23,8 @@ foreach($lastAttendances as $a){
array_push( $lastAttendancesAssocArray[ $a['date'] ], $a );
}
$dateLastWendsday = new DateTime("wednesday this week");
$dateLastFriday = new DateTime("friday this week");
$dateLastWendsday = new DateTime("tomorrow last wednesday");
$dateLastFriday = new DateTime("tomorrow last friday");
$lastTrainingDay = max($dateLastWendsday, $dateLastFriday);
?>
@@ -34,18 +34,43 @@ $lastTrainingDay = max($dateLastWendsday, $dateLastFriday);
<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 materializecss-->
<script>
options={};
document.addEventListener('DOMContentLoaded', function() {
var elems = document.querySelectorAll('select');
var instances = M.FormSelect.init(elems);
});
document.addEventListener('DOMContentLoaded', function() {
var elems = document.querySelectorAll('.modal');
var instances = M.Modal.init(elems, options);
});
document.addEventListener('DOMContentLoaded', function() {
var elems = document.querySelectorAll('.sidenav');
var instances = M.Sidenav.init(elems, options);
});
document.addEventListener('DOMContentLoaded', function() {
var elems = document.querySelectorAll('.collapsible');
var instances = M.Collapsible.init(elems, options);
});
</script>
<!--Let browser know website is optimized for mobile-->
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<title>Corona-Anwesenheitsliste der Judoka des Chemnitzer WSV</title>
</header>
<body>
<h1>Corona-Anwesenheitsliste der Judoka des Chemnitzer WSV</h1>
<h2>Anwesenheiten hinzufügen</h2>
<ul id="slide-out" class="sidenav">
<li><a href="#addAttendences">Anwesenheiten hinzufügen</a></li>
<li><a href="#addCoronaUser">Trainee hinzufügen</a></li>
<li><a href="#showAttendences">Anwesenheiten anzeigen</a></li>
</ul>
<a href="#" data-target="slide-out" class="sidenav-trigger" style="font-size: 2em;">&#9776; mams</a>
<h2 id="addAttendences">Anwesenheiten hinzufügen</h2>
<form action="./index.php" method="POST">
<div class="input-field">
<input id="giveAttendanceAction" name="action" value="giveAttendance" type="hidden" />
@@ -56,7 +81,28 @@ $lastTrainingDay = max($dateLastWendsday, $dateLastFriday);
<input type="submit" value="Submit">
</div>
</form>
<h2>Anwesenheiten</h2>
<h2 id="addCoronaUser">Corona-Trainee hinzufügen</h2>
<?php
if( array_key_exists('addCoronaUserSuccess', $_GET) ){
if($_GET['addCoronaUserSuccess'] == "true"){
echo("<div>Added user.</div>");
}else{
echo("<div>ERROR</div>");
}
}
?>
<form action="." method="POST">
<input name="action" value="addCoronaUser" type="hidden" />
<input placeholder="Name" name="name" type="text" />
<input placeholder="Vorname" name="vorname" type="text" />
<input placeholder="PLZ" name="corona_PLZ" type ="text" />
<input placeholder="Telefon" name="corona_telephon" type="text" />
<input placeholder="eMail" name="corona_eMail" type="text" />
<input type="submit" value="Neuen Corona-User eintragen" />
</form>
<h2 id="showAttendences">Anwesenheiten</h2>
<h3>Sende Anwesenheitsliste an eMail</h3>
<form method="POST" action="." >
<input name="toEmail" type="text" placeholder="toEmail" />
@@ -86,15 +132,5 @@ $lastTrainingDay = max($dateLastWendsday, $dateLastFriday);
echo("</table>");
}
?>
<h2>Trainee hinzufügen</h2>
<form action="." method="POST">
<input name="action" value="addCoronaUser" type="hidden" />
<input placeholder="Name" name="name" type="text" />
<input placeholder="Vorname" name="vorname" type="text" />
<input placeholder="PLZ" name="corona_PLZ" type ="text" />
<input placeholder="Telefon" name="corona_telephon" type="text" />
<input placeholder="eMail" name="corona_eMail" type="text" />
<input type="submit" value="Neuen Corona-User eintragen" />
</form>
</body>
</html>

View File

@@ -9,14 +9,27 @@ function processPostData($db, $post, $redirectLocation = "."){
updateCoronaData($db, $post['userId'], $post['columnName'], $post['columnValue']);
}
if($post['action'] == "addCoronaUser"){
addCoronaUser(
$db,
$post['name'],
$post['vorname'],
$post['corona_PLZ'],
$post['corona_telephon'],
$post['corona_eMail']
);
if(
isValid($post['corona_PLZ'], "plz")
// && isValid($post['name'], "name")
// && isValid($post['vorname'], "name")
// && isValid($post['corona_telephon'], "phonenumber")
// && isValid($post['corona_eMail'], "email")
){
addCoronaUser(
$db,
$post['name'],
$post['vorname'],
$post['corona_PLZ'],
$post['corona_telephon'],
$post['corona_eMail']
);
$redirectLocation .= "?addCoronaUserSuccess=true";
}
else{
$redirectLocation .= "?addCoronaUserSuccess=false";
}
$redirectLocation .= "#addCoronaUser";
}
if($post['action'] == "sendAttandeesPerEmail"){
sendEmail(
@@ -78,4 +91,38 @@ function attendancesAssocArray2mdList($attendancesAssocArray, $date=null){
}
return $ret;
}
/// Validaing a phone number
/// true if it validates, false if not
function validate_phone_number($phone)
{
// Allow +, - and . in phone number
$filtered_phone_number = filter_var($phone, FILTER_SANITIZE_NUMBER_INT);
// Remove "-" from number
$phone_to_check = str_replace("-", "", $filtered_phone_number);
// Check the lenght of number
// This can be customized if you want phone number from a specific country
if (strlen($phone_to_check) < 10 || strlen($phone_to_check) > 14) {
return false;
} else {
return true;
}
}
/// validate different types of input
function isValid($toValidate, $type){
// for now we disable the name validation: what do i know how people can be called!
// $regexName="/^[A-Z][a-zA-Z]*$/";
$regexPlz ="/^[0-9]{5}$/";
if($type == "plz" )
return preg_match($regexPlz, $toValidate) > 0;
if($type == "name")
return preg_match($regexName, $toValidate) > 0;
if($type == "phonenumber" )
return validate_phone_number($toValidate);
if($type == "email")
return filter_var($toValidate, FILTER_VALIDATE_EMAIL);
return false;
}
?>