diff --git a/homepage/participo/events.php b/homepage/participo/events.php index c498160..feeaf72 100644 --- a/homepage/participo/events.php +++ b/homepage/participo/events.php @@ -30,24 +30,9 @@ include_once 'events.inc.php';
-' - . 'DatumVeranstaltungStarter' - . ''; - foreach ($eventList as $event) { - $eventDate = DateTime::createFromFormat('Y-m-d', $event['eventDate']); - $htmlTable .= '' . getHtmlSquareDate($eventDate) . '' . $event['eventName'] . '' . $event['userName'] . ', ' . $event['userFirstname'] . ''; - } - $htmlTable .= ''; - echo('

Aktuelle Einschreibungen

'); - echo($htmlTable); - } else { - echo($eventList ? $htmlTable : '
Keine Meldungen zu bevorstehenden Events'); - } - ?> +

Eingeschriebene Starter

+ +

Übersicht anstehender Events

diff --git a/homepage/participo/events.sidenav.inc.php b/homepage/participo/events.sidenav.inc.php index c1c367d..ab7c65f 100644 --- a/homepage/participo/events.sidenav.inc.php +++ b/homepage/participo/events.sidenav.inc.php @@ -5,7 +5,7 @@ \ No newline at end of file diff --git a/homepage/participo/index.php b/homepage/participo/index.php index 859299d..5cc3864 100644 --- a/homepage/participo/index.php +++ b/homepage/participo/index.php @@ -40,7 +40,6 @@ $userData = getUserData(dbConnector::getDbConnection(), $_SESSION['user']['userI // init materialize elements initModals(); initSidenav(); - initSelects(); }); function initSidenav() { diff --git a/homepage/participo/lib/api.php b/homepage/participo/lib/api.php index 1b54126..700f3b8 100644 --- a/homepage/participo/lib/api.php +++ b/homepage/participo/lib/api.php @@ -162,7 +162,8 @@ function changePassword($db, $changerId, $changeeId, $changerPassword, $newPassw // if( !in_array($changeeId, $changersKidsIds) ){ if (!isUserInKidIds($changeeId, $changersKidsIds)) { -// echo("not your child: ".$changeeId." not in "); var_dump($changersKidsIds); + // echo("not your child: ".$changeeId." not in "); + // var_dump($changersKidsIds); return false; } } diff --git a/homepage/participo/lib/participoLib/event.php b/homepage/participo/lib/participoLib/event.php index b8ae51f..5c2cb5a 100644 --- a/homepage/participo/lib/participoLib/event.php +++ b/homepage/participo/lib/participoLib/event.php @@ -1,9 +1,13 @@ id = (int) $id; + $this->id = filterId($id); $this->date = DateTime::createFromFormat('Y-m-d', $date); - $this->shiaiId = (($shiaiId != null) ? ((int)$shiaiId) : (null)); + $this->shiaiId = filterId($shiaiId); $this->deadline = DateTime::createFromFormat('Y-m-d', $deadline); $this->remarks = $remarks; $this->shiai = $shiai; } + // Getter + + /** Getter for the id + * + * @return (int) Id of the event + */ + public function getId() + { + return $this->id; + } + + /** Getter for the date + * + * @return DateTime date of the event + */ + public function getDate() + { + return $this->date; + } + + /** Getter for the shiaiId + * + * @return int>0 id for the shiai in the db + */ + public function getShiaiId() + { + return $this->shiaiId; + } + + /** Getter for the deadline + * + * @return DateTime deadline for the event + */ + public function getDeadLine() + { + return $this->deadline; + } + + /** Getter for the shiai + * + * @return Shiai shiai for the event + */ + public function getShiai() + { + return $this->shiai; + } + + public function loadShiai() + { + if ($this->shiaiId != null) { + $this->shiai = Shiai::loadFromDb($this->shiaiId); + } + return $this->shiai; + } + public static function loadFromDb(int $id) { + $id = filterId($id); + $query = 'SELECT * FROM `cwsvjudo`.`wkParticipo_Events` WHERE `id` = :id;'; $params = [':id' => ['value' => $id, 'data_type' => PDO::PARAM_INT]]; $response = dbConnector::query($query, $params); @@ -43,7 +103,7 @@ class Event if (count($response) != 1) { return null; } - return Event::fromDbArray($response[0]); + return self::fromDbArray($response[0]); } /** Representation of an event as (materializeCss) card @@ -52,10 +112,11 @@ class Event */ public function asHtmlCard() { + $shiai = self::loadShiai(); return '
' . '
' . - '' . $this->shiai->getHtmlName() . '' . + '' . $shiai->getHtmlName() . '' . '
' . '
Datum
' . '
' . $this->date->format('Y-m-d') . '
' . @@ -69,11 +130,12 @@ class Event public function htmlTableRow() { + $shiai = $this->loadShiai(); return '' . '' . $this->date->format('Y-m-d') . '' . - '' . $this->shiai->getHtmlName() . '' . - '' . $this->shiai->getAgeClasses() . '' . + '' . $shiai->getHtmlName() . '' . + '' . $shiai->getAgeClasses() . '' . 'zoom_in' . ''; } @@ -109,9 +171,12 @@ class Event return ''; } $starterList .= 'Bereits eingetragen:
'; - foreach ($listOfStarter as $s) { - $u = $s->getUser(); - $starterList .= '
' . $u->getName() . ', ' . $u->getFirstname() . $this->getHtmlRemoveStarterForm($s->getEventId(), $s->getUserId()) . '
'; + foreach ($listOfStarter as $start) { + $startingUser = $start->loadStarter(); + $starterList .= '
' + . '
' . $startingUser->getName() . ', ' . $startingUser->getFirstname() . ':
' + . '
' . $start->getHtmlFormRemove() . '
' + . '
'; } $starterList .= '
'; return $starterList; @@ -141,7 +206,7 @@ class Event return $starter; } - public static function fromArray($member) + public static function fromDbArray($member) { $shiai = json_decode($member['bemerkungen'], true); @@ -151,7 +216,7 @@ class Event $member['wkId'] ?? null, $member['meldefrist'] ?? null, $member['bemerkungen'] ?? null, - shiai::fromArray(($shiai != null) ? $shiai : $member) + shiai::fromDbArray(($shiai != null) ? $shiai : $member) ); } @@ -172,7 +237,13 @@ class Event } // @todo docu - public static function getHtmlRemoveStarterForm($eventId, $userId, $class = null) + public function getHtmlRemoveStarterForm($starterId) + { + $html = self::getHtmlRemoveStarterFromEventForm($this->id, $starterId); + } + + // returns html code for a button to remove the user from an event + public static function getHtmlRemoveStarterFromEventForm($eventId, $userId, $class = null) { $form = '
' diff --git a/homepage/participo/lib/participoLib/participo.php b/homepage/participo/lib/participoLib/participo.php index f6db71e..9b42446 100644 --- a/homepage/participo/lib/participoLib/participo.php +++ b/homepage/participo/lib/participoLib/participo.php @@ -23,6 +23,15 @@ class participo return (isset($_SESSION) && array_key_exists('login', $_SESSION) && $_SESSION['login'] == true); } + public static function getSessionUserId() + { + $userId = null; + if (isset($_SESSION) && array_key_exists('user', $_SESSION) && array_key_exists('userId', $_SESSION['user'])) { + $userId = $_SESSION['user']['userId']; + } + return $userId; + } + /** Remove all login data from the session data * * @return void @@ -541,3 +550,17 @@ function getHtmlSquareDate($date = null) . '
' . $year . '
' . '
'; } + +/** + * filter_var for a (db)id + * + * check for valid id; null is default; only values > 0 are excepted + * + * @param [type] $id + * @retval int>0 filtered id + * @retval null sth. went wrong + */ +function filterId($id) +{ + return filter_var($id, FILTER_VALIDATE_INT, ['options' => ['default' => null, 'min_range' => 1]]); +} diff --git a/homepage/participo/lib/participoLib/planer.php b/homepage/participo/lib/participoLib/planer.php index 73aca47..9d00bfb 100644 --- a/homepage/participo/lib/participoLib/planer.php +++ b/homepage/participo/lib/participoLib/planer.php @@ -18,9 +18,10 @@ class eventPlaner 'wardship' => 'vormundschaft' ]; + // request coming starts from the db private static function getComingStarts($sinceDate = null, $userId = null) { - $userId = $userId ?? $_SESSION['user']['userId']; + $userId = $userId ?? participo::getSessionUserId(); $sinceDate = $sinceDate ?? new DateTime(); $params = [ @@ -91,7 +92,7 @@ class eventPlaner $ret = dbConnector::query($query); $events = []; foreach ($ret as $event) { - array_push($events, event::fromArray($event)); + array_push($events, event::fromDbArray($event)); } return $events; } @@ -108,39 +109,4 @@ class eventPlaner } return $ret; } - - // inserting html code - - /** Generate the htmlCode for the list of upcoming starts of - * - * @return void - */ - public static function htmlComingStarts() - { - $comingStarts = self::getComingStarts(); - $htmlTable = null; - if ($comingStarts) { - $htmlTable = '' - . '' - . ''; - foreach ($comingStarts as $s) { - $eventDeadline = DateTime::createFromFormat('Y-m-d', $s['deadline']); - $eventDate = DateTime::createFromFormat('Y-m-d', $s['eventDate']); - $today = new DateTime(); - $htmlTable .= '' - . '' - . '' - . '' - . '' - // . '' - . ''; - } - $htmlTable .= '
DatumVeranstaltungStarter
' . getHtmlSquareDate($eventDate) . '' . $s['eventName'] . '' . $s['userName'] . ', ' . $s['userFirstname'] . '' . ($eventDeadline >= $today ? Event::getHtmlRemoveStarterForm($s['eventId'], $s['userId']) : '') . '' . $eventDeadline->format('Y-m-d') . ' <= ' . $today->format('Y-m-d') . ': ' . ($eventDeadline <= $today ? 'true' : 'false') . '
'; - echo('

Aktuelle Einschreibungen

'); - echo($htmlTable); - } else { - echo('
Keine Meldungen zu bevorstehenden Events
'); - } - return; - } } diff --git a/homepage/participo/lib/participoLib/shiai.php b/homepage/participo/lib/participoLib/shiai.php index f6d7685..b619a5f 100644 --- a/homepage/participo/lib/participoLib/shiai.php +++ b/homepage/participo/lib/participoLib/shiai.php @@ -57,7 +57,20 @@ class Shiai return ($this->place != null ? $this->place : '-'); } - public static function fromArray($member) + public static function loadFromDb(int $id) + { + $query = 'SELECT * FROM `cwsvjudo`.`wettkampfkalender` WHERE `lfdeNr` = :id;'; + $params = [':id' => ['value' => $id, 'data_type' => PDO::PARAM_INT]]; + $response = dbConnector::query($query, $params); + + // ids are considered unique. so every other count then 1 is treated as error to prevent unprivileged access + if (count($response) != 1) { + return null; + } + return self::fromDbArray($response[0]); + } + + public static function fromDbArray($member) { return new shiai( $member['lfdeNr'] ?? null, diff --git a/homepage/participo/lib/participoLib/starter.php b/homepage/participo/lib/participoLib/starter.php index 4c7155d..18971d1 100644 --- a/homepage/participo/lib/participoLib/starter.php +++ b/homepage/participo/lib/participoLib/starter.php @@ -29,31 +29,6 @@ abstract class StartingType /** Frame for a start to a shiai */ class Starter { - private $id = null; //< id of the event in the database - private $eventId = null; //< dbId of the event one is starting - private $typeId = null; //< type(id) of the starter - private $userId = null; //< id of the starting user - private $rideId = null; //< id of the ride where the starter can car pool - private $mass = null; //< mass in kg on the scale - private $result = null; //< result of the start (array of places if multi start) - - private $shiai = null; //< to store the shiai if needed - private $user = null; - - /** columns in the table (in the database) with their type - * - * @var array - */ - private static $dbColumns = [ - 'id' => PDO::PARAM_INT, - 'eventId' => PDO::PARAM_INT, - 'type' => PDO::PARAM_INT, - 'userId' => PDO::PARAM_INT, - 'fahrtId' => PDO::PARAM_INT, - 'masse' => PDO::PARAM_STR, - 'platz' => PDO::PARAM_STR, - ]; - /** Constructor * * @todo Document @@ -80,101 +55,64 @@ class Starter } } - /** Create a Starter from an assoziative array like it is returned from db requests + //// + // dbInterface + /// + + /** Load a Start from the db via an id * - * @param array $member associative array with the UserData from the dbRequest - * @param $columnMappings renaming of columnNames, e.g., if the id isn't under id in the array, add 'id'=>'starterId' to the mappings - * @return User initialized user + * @param int $startId + * @return loaded start or null (if sth. wrong) */ - public static function fromDbArray($member, $columnMappings = []) + public static function loadFromDb($startId) { - // if it isn't remapped, take default column name - foreach (self::$dbColumns as $columnName => $columnDataType) { - if (!array_key_exists($columnName, $columnMappings)) { - $columnMappings[$columnName] = $columnName; + $startId = filterId($startId); + if (!isset($startId)) { + return null; + } + return self::loadFromDbBy('id', $startId); + } + + /** Retrieve the linked Event from the database + * + * @param bool $force By default, if there already is an event in the buffer it is reused. Set this parameter to true to enforce the loading. + * @return Event the event in the db identified via the eventId + */ + public function loadEvent(bool $force = false) + { + if ($force || (!isset($this->event))) { + if (isset($this->eventId)) { + $this->event = Event::loadFromDb($this->eventId); } } - - return new Starter( - $member[$columnMappings['id']] ?? null, - $member[$columnMappings['eventId']] ?? null, - $member[$columnMappings['type']] ?? null, - $member[$columnMappings['userId']] ?? null, - $member[$columnMappings['fahrtId']] ?? null, - $member[$columnMappings['masse']] ?? null, - $member[$columnMappings['platz']] ?? null - ); + return $this->event; } - /** Load a starter from the db by a column + /** Retrieve the linked User from the database * - * @param [string] $name name of the column - * @param [mixed] $value value to look for - * @param [bool] $unique if the value is unique (true->return single value) or not (false->return array) - * @return loaded user or null (if sth. wrong) + * @param bool $force By default, if there already is an user in the buffer it is reused. Set this parameter to true to enforce the loading. + * @return User the user in the db identified via the userId */ - public static function loadFromDbBy($name, $value) + public function loadStarter(bool $force = false) { - if (!array_key_exists($name, self::$dbColumns)) { - return null; + if ($force || (!isset($this->user))) { + if (isset($this->userId)) { + $this->user = User::loadFromDb($this->userId); + } } - - $response = dbConnector::query( - 'SELECT * FROM `wkParticipo_Starter` WHERE `' . $name . '` = :' . $name, - [$name => ['value' => $value, 'data_type' => self::$dbColumns[$name]]] - ); - - if (count($response) != 1) { - return null; - } - - return self::fromDbArray($response[0]); + return $this->user; } - /** Load a Starter from the db via an id + /** Add the shiai to the database * - * @param int $starterId - * @return loaded starter or null (if sth. wrong) + * - before adding to the db it is checked wether the currently logged in user has sufficient rights + * - all starts of the same user to the same event get deleted before adding the start (again) + * + * @todo an admin should also be allowed + * @todo the deadline of the event should be checked as well + * + * @return int id under which the */ - public static function loadFromDb($starterId) - { - return self::loadFromDbBy('id', $starterId); - } - - /** Add a Start to the db - * - * - backend function no input validation/sanitation is done - * - * @param [int] $eventId eventId for the start - * @param [int] $typeId type(Id) for the start - * @param [int] $userId id of the starting user - * @return [int] lastInserted id of the Start - */ - private static function dbInsert($eventId, $typeId, $userId) - { - $query = 'INSERT INTO `cwsvjudo`.`wkParticipo_Starter` (eventId, type, userId) values (:eventId, :typeId, :userId);'; - $params = [ - ':eventId' => ['value' => $eventId, 'data_type' => PDO::PARAM_INT], - ':typeId' => ['value' => $typeId, 'data_type' => PDO::PARAM_INT], - ':userId' => ['value' => $userId, 'data_type' => PDO::PARAM_INT] - ]; - - $response = dbConnector::query($query, $params); - return dbConnector::getLastInsertId(); - } - - private static function dbDelete($eventId, $userId) - { - $query = 'DELETE FROM `cwsvjudo`.`wkParticipo_Starter` WHERE eventId = :eventId AND userId = :userId;'; - $params = [ - ':eventId' => ['value' => $eventId, 'data_type' => PDO::PARAM_INT], - ':userId' => ['value' => $userId, 'data_type' => PDO::PARAM_INT] - ]; - - $response = dbConnector::query($query, $params); - return; - } - public function addToDb() { // - if the id is already set it *has* to be already in the DB hence we don't add it @@ -182,37 +120,33 @@ class Starter if (isset($this->id) && !participo::isWardOf($this->userId)) { return null; } + // You can only start once to an event so delete *all* other starts of this user to this event self::dbDelete($this->eventId, $this->userId); $this->id = self::dbInsert($this->eventId, $this->typeId, $this->userId); return $this->id; } + /** Remove the start from the db + * + * - check if the currently logged in user is allowed to remove the start first + * + * @todo an admin should also be allowed + * @todo the deadline of the event should be checked as well + * + * @return void + */ public function removeFromDb() { // - the logged in user must have wardship over the starter if (!participo::isWardOf($this->userId)) { - return null; + return; } self::dbDelete($this->eventId, $this->userId); return; } - // create starter from assoc array - public static function create($parameter) - { - $id = $parameter['id'] ?? null; //< id of the event in the database - $eventId = $parameter['eventId'] ?? null; //< dbId of the event one is starting - $typeId = $parameter['typeId'] ?? null; //< type(id) of the starter - $userId = $parameter['userId'] ?? null; //< id of the starting user - $rideId = $parameter['rideId'] ?? null; //< id of the ride where the starter can car pool - $mass = $parameter['mass'] ?? null; //< mass in kg on the scale - $result = $parameter['result'] ?? null; //< result of the start (array of places if multi start) - - return new Starter($id, $eventId, $typeId, $userId, $rideId, $mass, $result); - } - // Getter for the member public function getId() { @@ -253,4 +187,300 @@ class Starter { return User::loadFromDb($this->userId); } + + public function getEvent() + { + return $this->event; + } + + public function getHtmlFormRemove($class = null) + { + $today = new DateTime(); + $event = $this->loadEvent(); + $eventDeadline = $event->getDeadline(); + + if ($today > $eventDeadline) { + return self::getHtmlModalToLate($this->id); + } + return self::getHtmlFormRemoveStarterFromEvent($this->id, $this->eventId, $class); + } + + // inject html code of table with coming starts for the session user + public static function htmlTableComingStarts() + { + $userId = participo::getSessionUserId(); + echo(self::getHtmlTableComingStarts($userId)); + } + + // Member + // - static member + /** Name of the table with all the starts + * + * @var string + */ + private static $tableName = 'wkParticipo_Starter'; + /** Names of the columns in the table (in the database) with their type + * + * @var array + */ + private static $dbColumns = [ + 'id' => PDO::PARAM_INT, + 'eventId' => PDO::PARAM_INT, + 'type' => PDO::PARAM_INT, + 'userId' => PDO::PARAM_INT, + 'fahrtId' => PDO::PARAM_INT, + 'masse' => PDO::PARAM_STR, + 'platz' => PDO::PARAM_STR, + ]; + // - non-static member + // data that's stored in the start table + /** unique database id for the start + * + * @var int/null + */ + private $id = null; + /** unique database id of the event one is starting + * + * @var int/null + */ + private $eventId = null; + /** type(id) of the starter + * + * @var int/null + */ + private $typeId = null; + /** unique database id of the starting user + * + * @var int/null + */ + private $userId = null; + /** unique database id of the ride where the starter can car pool + * + * @var int/null + */ + private $rideId = null; + /** the mass(-class) the starter had at the event, comma separated list if multiple + * + * @var string + */ + private $mass = null; + /** place result of the starter at the event, comma separated list if multiple + * + * @var string + */ + private $result = null; + + /** Create a Starter from an assoziative array like it is returned from db requests + * + * @param array $member associative array with the UserData from the dbRequest + * @param $columnMappings renaming of columnNames, e.g., if the id isn't under id in the array, add 'id'=>'starterId' to the mappings + * @return User initialized user + */ + private static function fromDbArray($member, $columnMappings = []) + { + // if it isn't remapped, take default column name + foreach (self::$dbColumns as $columnName => $columnDataType) { + if (!array_key_exists($columnName, $columnMappings)) { + $columnMappings[$columnName] = $columnName; + } + } + + return new Starter( + $member[$columnMappings['id']] ?? null, + $member[$columnMappings['eventId']] ?? null, + $member[$columnMappings['type']] ?? null, + $member[$columnMappings['userId']] ?? null, + $member[$columnMappings['fahrtId']] ?? null, + $member[$columnMappings['masse']] ?? null, + $member[$columnMappings['platz']] ?? null + ); + } + + /** Load a starter from the db by a column + * + * @param [string] $name name of the column + * @param [mixed] $value value to look for + * @param [bool] $unique if the value is unique (true->return single value) or not (false->return array) + * @return loaded user or null (if sth. wrong) + */ + private static function loadFromDbBy($name, $value) + { + if (!array_key_exists($name, self::$dbColumns)) { + return null; + } + + $response = dbConnector::query( + 'SELECT * FROM `wkParticipo_Starter` WHERE `' . $name . '` = :' . $name, + [$name => ['value' => $value, 'data_type' => self::$dbColumns[$name]]] + ); + + if (count($response) != 1) { + return null; + } + + return self::fromDbArray($response[0]); + } + + /** Add a Start to the db + * + * - backend function no input validation/sanitation is done + * + * @param [int] $eventId eventId for the start + * @param [int] $typeId type(Id) for the start + * @param [int] $userId id of the starting user + * @return [int] lastInserted id of the Start + */ + private static function dbInsert($eventId, $typeId, $userId) + { + $query = 'INSERT INTO `cwsvjudo`.`wkParticipo_Starter` (eventId, type, userId) values (:eventId, :typeId, :userId);'; + $params = [ + ':eventId' => ['value' => $eventId, 'data_type' => PDO::PARAM_INT], + ':typeId' => ['value' => $typeId, 'data_type' => PDO::PARAM_INT], + ':userId' => ['value' => $userId, 'data_type' => PDO::PARAM_INT] + ]; + + $response = dbConnector::query($query, $params); + return dbConnector::getLastInsertId(); + } + + private static function dbDelete($eventId, $userId) + { + $query = 'DELETE FROM `cwsvjudo`.`wkParticipo_Starter` WHERE eventId = :eventId AND userId = :userId;'; + $params = [ + ':eventId' => ['value' => $eventId, 'data_type' => PDO::PARAM_INT], + ':userId' => ['value' => $userId, 'data_type' => PDO::PARAM_INT] + ]; + + $response = dbConnector::query($query, $params); + return; + } + + // request coming starts of a user from the db + private static function getComingStarts($userId = null, $sinceDate = null) + { + // if no user is given, take it from the session data + $userId = $userId ?? participo::getSessionUserId(); + + // If no data is given, we take today + if (!$sinceDate) { + $sinceDate = 'CURDATE()'; + } else { + $sinceDate = 'DATE("' . $sinceDate . '")'; + } + + // Query all interesting starts + $query = + 'SELECT ' + . '`wkParticipo_Starter`.`id` as startId, ' + . '`wkParticipo_Starter`.`userId` as starterId, ' + . '`wkParticipo_Starter`.`eventId` as eventId, ' + . '`wkParticipo_Events`.`wkId` as shiaiId ' + . 'FROM `wkParticipo_Starter` ' + // link to the event (to get the date) + . 'LEFT JOIN `wkParticipo_Events` ON `wkParticipo_Starter`.`eventId` = `wkParticipo_Events`.`id` ' + // link to all wardships for the starter + . 'LEFT JOIN `vormundschaft` ON `wkParticipo_Starter`.`userId` = `vormundschaft`.`kidId` ' + // link to the shiai of the event + . 'LEFT JOIN `wettkampfkalender` on `wettkampfkalender`.`lfdeNr` = `wkParticipo_Events`.`wkId` ' + . 'WHERE ' + // only events after + . '`wkParticipo_Events`.`date` >= ' . $sinceDate . ' AND ' + // only if the current user is warden of the starte + . '`vormundschaft`.`userId` = :userId ' + . 'ORDER BY `wkParticipo_Events`.`date` ASC;'; + $params = [':userId' => ['value' => $userId, 'data_type' => PDO::PARAM_INT]]; + + $response = dbConnector::query($query, $params); + + $comingStarts = []; + foreach ($response as $r) { + $start = Starter::loadFromDb($r['startId']); + $comingStarts[] = $start; + } + + return $comingStarts; + } + + // get html code of a list of starts + private static function getHtmlTable($starts) + { + $html = '' + . '' + . ''; + foreach ($starts as $start) { + $today = new DateTime(); + + $startingUser = User::loadFromDb($start->getUserId()); + $event = Event::loadFromDb($start->getEventId()); + $shiai = Shiai::loadFromDb($event->getShiaiId()); + + $eventDeadline = $event->getDeadline(); + $eventDate = $event->getDate(); + + $html .= '' + . '' + . '' + . '' + . '' + . ''; + } + $html .= '
DatumVeranstaltungStarter
' . getHtmlSquareDate($eventDate) . '' . $shiai->getHtmlName() . '' . $startingUser->getName() . ', ' . $startingUser->getFirstName() . '' . $start->getHtmlFormRemove() . '
'; + return $html; + } + + private static function getHtmlModalToLate($startId, $caption = 'Austragen') + { + $modal = $html = '' . $caption . '' + . ''; + + return $modal; + } + + private static function getHtmlFormRemoveStarterFromEvent($starterId, $eventId, $class = null) + { + $form = + '' + . '' + . '' + . '' + . '' + . ''; + + return $form; + } + + /** Generate the htmlCode for the list of upcoming starts of wards of the current user + * + * @return void + */ + private static function getHtmlTableComingStarts($userId = null) + { + $userId = $userId ?? participo::getSessionUserId(); + + $starts = self::getComingStarts($userId); + if (!(count($starts) > 0)) { + return '
Keine Meldungen zu bevorstehenden Events
'; + } + return self::getHtmlTable($starts); + } + + // buffers to reduce db access + /** Event of the start + * + * @var Event/null + */ + private $event = null; + + /** Starting user of the start + * + * @var User/null + */ + private $user = null; }