Bugfix: hidden select menu in starting type selection replaced by radio buttons
This commit is contained in:
@@ -90,10 +90,32 @@ class Event
|
||||
return $this->shiai;
|
||||
}
|
||||
|
||||
public static function loadFromDb(int $id)
|
||||
/** load the Event by id from the db
|
||||
*
|
||||
* - Frontend function: sanitizes the input and calls the backend function
|
||||
*
|
||||
* @param integer>0 $id id of the Event to load from the data base
|
||||
* @return Event Event from the db with this id, null in case the Event couldn't be loaded
|
||||
*/
|
||||
public static function loadFromDb($id)
|
||||
{
|
||||
$id = filterId($id);
|
||||
if ($id) {
|
||||
return self::loadFromDbById($id);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* loads an event from the db by id
|
||||
*
|
||||
* - Backend function, input is supposed to be sanitized
|
||||
*
|
||||
* @param integer>0 $id sanitized id of the event to load
|
||||
* @return Event Event from the db with this id, null in case the Event couldn't be loaded
|
||||
*/
|
||||
private static function loadFromDbById(int $id)
|
||||
{
|
||||
$query = 'SELECT * FROM `cwsvjudo`.`wkParticipo_Events` WHERE `id` = :id;';
|
||||
$params = [':id' => ['value' => $id, 'data_type' => PDO::PARAM_INT]];
|
||||
$response = dbConnector::query($query, $params);
|
||||
@@ -105,6 +127,16 @@ class Event
|
||||
return self::fromDbArray($response[0]);
|
||||
}
|
||||
|
||||
public function htmlDate($format = 'Y-m-d')
|
||||
{
|
||||
return $this->date->format($format);
|
||||
}
|
||||
|
||||
public function htmlDeadLine($format = 'Y-m-d')
|
||||
{
|
||||
return $this->deadline->format($format);
|
||||
}
|
||||
|
||||
/** Representation of an event as (materializeCss) card
|
||||
*
|
||||
* @return string string with the html code of the event
|
||||
@@ -118,9 +150,9 @@ class Event
|
||||
'<span class="card-title">' . $shiai->getHtmlName() . '</span>' .
|
||||
'<dl>' .
|
||||
'<dt>Datum</dt>' .
|
||||
'<dd>' . $this->date->format('Y-m-d') . '</dd>' .
|
||||
'<dd>' . $this->htmlDate() . '</dd>' .
|
||||
'<dt>Einschreibefrist</dt>' .
|
||||
'<dd>' . $this->deadline->format('Y-m-d') . '</dd>' .
|
||||
'<dd>' . $this->htmlDeadLine() . '</dd>' .
|
||||
'<dt>Altersklassen</dt>' .
|
||||
'<dd>' . $this->shiai()->getHtmlDescriptiveAgeClasses() . '</dd>' .
|
||||
'</dl>' .
|
||||
@@ -128,12 +160,23 @@ class Event
|
||||
'</div>';
|
||||
}
|
||||
|
||||
public function getHtmlEventDetails()
|
||||
{
|
||||
$html .= '<dl>';
|
||||
$html .= '<dt>Datum</dt><dd>' . $this->event()->htmlDate() . '</dd>';
|
||||
$html .= '<dt>Deadline zum Einschreiben:</dt><dd>' . $this->event()->htmlDeadline() . '</dd>';
|
||||
$html .= '</dl>';
|
||||
$html .= $this->event()->shiai()->getHtml();
|
||||
$html .= $this->event()->getHtmlStarterStatistic();
|
||||
$html .= $this->event()->getHtmlStarterList();
|
||||
}
|
||||
|
||||
public function htmlTableRow()
|
||||
{
|
||||
$shiai = $this->shiai();
|
||||
return
|
||||
'<tr>' .
|
||||
'<td>' . $this->date->format('Y-m-d') . '</td>' .
|
||||
'<td>' . $this->htmlDate() . '</td>' .
|
||||
'<td><a href="/participo/events#' . $this->id . '" >' . $shiai->getHtmlName() . '</a></td>' .
|
||||
'<td>' . $shiai->getHtmlDescriptiveAgeClasses() . '</td>' .
|
||||
'<td><a class="waves-effect waves-light btn modal-trigger" href="#event-modal-' . $this->id . '"><i class="material-icons">zoom_in</i></a></td>' .
|
||||
@@ -146,10 +189,13 @@ class Event
|
||||
'<div id="event-modal-' . $this->id . '" class="modal black-text">'
|
||||
. '<div class="modal-content">'
|
||||
. $this->shiai->getHtml()
|
||||
. '<hr />'
|
||||
. $this->getHtmlStarterStatistic()
|
||||
. $this->getHtmlStarterList();
|
||||
. '<hr />'
|
||||
. $this->getHtmlStarterList()
|
||||
. '<hr />';
|
||||
$modal .= '<div class="row">';
|
||||
$modal .= '<div class="s12">Deadline zum Eintragen: ' . $this->deadline->format('Y-m-d') . '</div>';
|
||||
$modal .= '<div class="s12">Deadline zum Eintragen: ' . $this->htmlDeadLine() . '</div>';
|
||||
|
||||
$today = new DateTime();
|
||||
if (
|
||||
@@ -160,13 +206,6 @@ class Event
|
||||
foreach ($kids as $k) {
|
||||
$modal .= $this->getHtmlAddStarterForm($k, ['returnToUrl' => '/participo/events#' . $this->id]);
|
||||
}
|
||||
|
||||
// foreach ($this->shiai()->ageGroups() as $ageClass => $starterList) {
|
||||
// // $modal .= '<h3>' . $ageClass ?? 'keiner Altersklasse zugeordnet' . '</h3>';
|
||||
// foreach ($starterList as $starter) {
|
||||
// $modal .= $this->getHtmlAddStarterForm($k, ['returnToUrl' => '/participo/events#' . $this->id]);
|
||||
// }
|
||||
// }
|
||||
} else {
|
||||
$modal .= '<div>Es ist leider zu spät noch jemanden einzutragen!</div>';
|
||||
}
|
||||
@@ -175,7 +214,7 @@ class Event
|
||||
$modal .=
|
||||
'</div>' . // end modal-content
|
||||
'<div class="modal-footer">' .
|
||||
'<a href="/pages/desktop/wkParticipo/showWkEvent.php?eventId=' . $this->id . '" class="modal-close waves-effect waves-green btn-flat">Zum Event im Planer</a>' .
|
||||
'<a href="/pages/desktop/wkParticipo/showWkEvent.php?eventId=' . $this->id . '" class="modal-close waves-effect waves-green btn-flat">Zum Event im alten Planer</a>' .
|
||||
'<a href="#!" class="modal-close waves-effect waves-green btn-flat">Schließen</a>' .
|
||||
'</div>' . // end modal-footer
|
||||
'</div>';
|
||||
@@ -206,7 +245,7 @@ class Event
|
||||
*
|
||||
* @todo docu
|
||||
*/
|
||||
private function getStarter()
|
||||
public function getStarter()
|
||||
{
|
||||
$userId = $_SESSION['user']['userId'] ?? null;
|
||||
|
||||
@@ -221,7 +260,7 @@ class Event
|
||||
|
||||
$starter = [];
|
||||
foreach ($response as $r) {
|
||||
$starter[] = Starter::loadFromDb($r['starterId']);
|
||||
$starter[$r['starterId']] = Starter::loadFromDb($r['starterId']);
|
||||
}
|
||||
return $starter;
|
||||
}
|
||||
@@ -250,16 +289,21 @@ class Event
|
||||
|
||||
public function getHtmlStarterStatistic()
|
||||
{
|
||||
$isEmpty = true;
|
||||
$retHtml = '<dl>';
|
||||
foreach ([StartingType::Fighter, StartingType::NoParticipation, StartingType::Audience] as $type) {
|
||||
$count = $this->getStarterCount($type);
|
||||
if ($count > 0) {
|
||||
$isEmpty = false;
|
||||
$retHtml .= '<dt>' . StartingType::$AsString[$type] . '</dt><dd>' . $count . '</dd>';
|
||||
}
|
||||
}
|
||||
$retHtml .= '<dt>Mitfahrgelegenheiten</dt><dd>' . $this->getSeatCount() . '</dd>';
|
||||
if ($this->getSeatCount() > 0) {
|
||||
$isEmpty = false;
|
||||
$retHtml .= '<dt>Mitfahrgelegenheiten</dt><dd>' . $this->getSeatCount() . '</dd>';
|
||||
}
|
||||
$retHtml .= '</dl>';
|
||||
return $retHtml;
|
||||
return $isEmpty ? '' : $retHtml;
|
||||
}
|
||||
|
||||
public static function fromDbArray($member)
|
||||
@@ -305,7 +349,7 @@ class Event
|
||||
{
|
||||
$defaults = [
|
||||
'formClass' => 's12 m6 xl3',
|
||||
'inputClass' => 'input-field col s12',
|
||||
'inputClass' => 'col s12',
|
||||
'buttonClass' => 'btn'
|
||||
];
|
||||
|
||||
@@ -322,14 +366,29 @@ class Event
|
||||
. '<input type="hidden" name="userId" id="userId" value="' . $user->getId() . '">'
|
||||
. '<input type="hidden" name="returnToUrl" id="returnToUrl" value="' . $returnToUrl . '" >'
|
||||
. '<div class="' . $options['inputClass'] . '">'
|
||||
. '<label for="' . $selectId . '">' . $user->getName() . ', ' . $user->getFirstname() . '</label>'
|
||||
. '<select id="' . $selectId . '" name="type">'
|
||||
. '<option value="1" selected="">als Starter</option>'
|
||||
. '<option value="2">als Zuschauer</option>'
|
||||
. '<option value="3">keine Teilnahme</option>'
|
||||
. '</select>'
|
||||
. '<fieldset id="' . $selectId . '>'
|
||||
. '<label for="' . $selectId . '">' . $user->getName() . ', ' . $user->getFirstname() . '</label>'
|
||||
. '<p>'
|
||||
. '<label for="' . $selectId . '-asStarter">'
|
||||
. '<input name="type" type="radio" id="' . $selectId . '-asStarter" value="1" />'
|
||||
. '<span>als Starter</span>'
|
||||
. '</label>'
|
||||
. '</p>'
|
||||
. '<p>'
|
||||
. '<label for="' . $selectId . '-asWatcher">'
|
||||
. '<input name="type" type="radio" id="' . $selectId . '-asWatcher" value="2" />'
|
||||
. '<span>als Zuschauer</span>'
|
||||
. '</label>'
|
||||
. '</p>'
|
||||
. '<p>'
|
||||
. '<label for="' . $selectId . '-asNone">'
|
||||
. '<input name="type" type="radio" id="' . $selectId . '-asNone" value="3" checked />'
|
||||
. '<span>keine Teilnahme</span>'
|
||||
. '</label>'
|
||||
. '</p>'
|
||||
. '<input class="' . $options['buttonClass'] . '" type="submit" name="submit" value="eintragen" />'
|
||||
. '</fieldset>'
|
||||
. '</div>'
|
||||
. '<input class="' . $options['buttonClass'] . '" type="submit" name="submit" value="eintragen">'
|
||||
. '</form>';
|
||||
|
||||
return $form;
|
||||
|
||||
Reference in New Issue
Block a user