diff --git a/homepage/machs/lib/machs/achievementGroup.php b/homepage/machs/lib/machs/achievementGroup.php index 315ce84..e156f52 100644 --- a/homepage/machs/lib/machs/achievementGroup.php +++ b/homepage/machs/lib/machs/achievementGroup.php @@ -108,8 +108,6 @@ SQL; $this->unlockingAchievementId = ($unlockingAchievementId == null ? null : (int)$unlockingAchievementId); $this->imageUrl = $imageUrl; $this->canHaveRecords = (bool)$canHaveRecords; -# echo("bool(".$canHaveRecords.")=".$this->canHaveRecords."\n"); -# var_dump($canHaveRecords, $this->canHaveRecords); } /// get the next achievement, the user has to accomplish in that group @@ -162,8 +160,6 @@ SQL; if(!$getAll) $params[':achievementGroupId'] = array('value'=>$this->getId(), 'data_type'=>PDO::PARAM_INT); $result = dbQuery($this->getDbConnection(), $query, $params); -# var_dump($query); -# var_dump($result); return $result; } diff --git a/homepage/participo/attendance.php b/homepage/participo/attendance.php index def7efb..5a31526 100644 --- a/homepage/participo/attendance.php +++ b/homepage/participo/attendance.php @@ -25,6 +25,80 @@ setlocale (LC_ALL, 'de_DE@euro', 'de_DE', 'de', 'ge'); $userData = getUserData($dbConnection, $_SESSION['user']['userId']); $usersKids = getUsersKids($dbConnection, $_SESSION['user']['userId']); + abstract class AttendanceType { + const __default = null; + + const Training = 1; + const Excused = 2; + const Ill = 3; + const SpecialTraining = 4; + const Competition = 5; + } + + abstract class UserAttribute { + const __default = null; + + const IsAdmin = 1; + const WantsNewsLetter = 2; + const Passive = 3; + const InTraining = 4; + } + /** + * Datastructure and interface for an user + */ + class User{ + private $id = null; + private $familyName = null; + private $givenName = null; + + private $attributes = null; + + function __construct($id, $familyName, $givenName){ + $this->id = (int)$id; + $this->familyName = $familyName; + $this->givenName = $givenName; + } + static function fromArray($member){ + $id = $member['id']; + $familyName = $member['familyName']; + $givenName = $member['givenName']; + return new User($id, $familyName, $givenName); + } + static function getUsers($db, $options = []){ + $attributeId = $options["attributeId"] ?? null; + $params = []; + $query = "SELECT ". + "`cwsvjudo`.`wkParticipo_Users`.`id` AS `id`". + ", `cwsvjudo`.`wkParticipo_Users`.`vorname` AS `givenName`". + ", `cwsvjudo`.`wkParticipo_Users`.`name` AS `familyName`". + ", `cwsvjudo`.`wkParticipo_userAttributes`.`name` AS `attributeName`". + "FROM `cwsvjudo`.`wkParticipo_Users` ". + "JOIN `cwsvjudo`.`wkParticipo_user<=>userAttributes` ". + "ON `cwsvjudo`.`wkParticipo_Users`.`id` = `cwsvjudo`.`wkParticipo_user<=>userAttributes`.`userId`". + "JOIN `cwsvjudo`.`wkParticipo_userAttributes` ". + "ON `cwsvjudo`.`wkParticipo_user<=>userAttributes`.`attributeId` = `cwsvjudo`.`wkParticipo_userAttributes`.`id`"; + if($attributeId != null){ + $query .= " WHERE `cwsvjudo`.`wkParticipo_userAttributes`.`id` = :attributeId"; + $params['attributeId'] = ['value'=>$attributeId, 'data_type'=>PDO::PARAM_INT]; + } + $query .= ";"; + $response = dbQuery($db, $query, $params); + + $users = []; + foreach( $response as $r){ + $users[] = User::fromArray($r); + } + return $users; + } + static function htmlTable($users){ + echo("
| Id | Name | Vorname |
|---|---|---|
| ".$u->id." | ".$u->familyName." | ".$u->givenName." |