bugfix remove starter, return to shiai modal after add starter, startertype info in startertable and shiai modal
This commit is contained in:
@@ -16,12 +16,10 @@ dbConnector::connect(
|
|||||||
|
|
||||||
participo::authentificate();
|
participo::authentificate();
|
||||||
|
|
||||||
$eventId = $_POST['eventId'] ?? null;
|
$starterId = $_POST['starterId'] ?? null;
|
||||||
$starterId = $_POST['userId'] ?? null;
|
|
||||||
|
|
||||||
$returnToUrl = $_POST['returnToUrl'] ?? 'participo/';
|
$returnToUrl = $_POST['returnToUrl'] ?? 'participo/';
|
||||||
|
|
||||||
$starter = new Starter(null, $eventId, null, $starterId);
|
$starter = Starter::loadFromDb($starterId);
|
||||||
$starter->removeFromDb();
|
$starter->removeFromDb();
|
||||||
|
|
||||||
header('Location: ' . urldecode($returnToUrl), true, 301);
|
header('Location: ' . urldecode($returnToUrl), true, 301);
|
||||||
|
|||||||
@@ -38,6 +38,8 @@ class dbConnector
|
|||||||
if (empty($someOptions['dontFetch'])) {
|
if (empty($someOptions['dontFetch'])) {
|
||||||
$someOptions['dontFetch'] = false;
|
$someOptions['dontFetch'] = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$ignoreErrors = $someOptions['ignoreErrors'] ?? false;
|
||||||
|
|
||||||
/// @toDo: Bisher wird nur die Rückgabe konvertiert. Eigentlich muss
|
/// @toDo: Bisher wird nur die Rückgabe konvertiert. Eigentlich muss
|
||||||
/// doch auch die Eingabe konvertiert werden. Aber das jetzt
|
/// doch auch die Eingabe konvertiert werden. Aber das jetzt
|
||||||
@@ -63,7 +65,7 @@ class dbConnector
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
$pdoResult = $pdoStatement->execute();
|
$pdoResult = $pdoStatement->execute();
|
||||||
if (!$pdoResult) {
|
if (!$ignoreErrors && !$pdoResult) {
|
||||||
echo("Error during dbQuery!\n");
|
echo("Error during dbQuery!\n");
|
||||||
echo("DB-Error:\n");
|
echo("DB-Error:\n");
|
||||||
var_dump(self::$db->errorInfo());
|
var_dump(self::$db->errorInfo());
|
||||||
|
|||||||
@@ -150,7 +150,7 @@ class Event
|
|||||||
$kids = participo::getKids();
|
$kids = participo::getKids();
|
||||||
$modal .= '<div class="row">';
|
$modal .= '<div class="row">';
|
||||||
foreach ($kids as $k) {
|
foreach ($kids as $k) {
|
||||||
$modal .= $this->getHtmlAddStarterForm($k);
|
$modal .= $this->getHtmlAddStarterForm($k, ['returnToUrl'=>'/participo/events#' . $this->id]);
|
||||||
}
|
}
|
||||||
$modal .= '</div>';
|
$modal .= '</div>';
|
||||||
$modal .=
|
$modal .=
|
||||||
@@ -174,7 +174,7 @@ class Event
|
|||||||
foreach ($listOfStarter as $start) {
|
foreach ($listOfStarter as $start) {
|
||||||
$startingUser = $start->loadStarter();
|
$startingUser = $start->loadStarter();
|
||||||
$starterList .= '<div class="col s12 m6"><div class="row valign-wrapper">'
|
$starterList .= '<div class="col s12 m6"><div class="row valign-wrapper">'
|
||||||
. '<div class="col s6">' . $startingUser->getName() . ', ' . $startingUser->getFirstname() . ':</div>'
|
. '<div class="col s6">' . $startingUser->getName() . ', ' . $startingUser->getFirstname() . ' ('.StartingType::$AsString[$start->getTypeId()].'):</div>'
|
||||||
. '<div class="col s6">' . $start->getHtmlFormRemove() . '</div>'
|
. '<div class="col s6">' . $start->getHtmlFormRemove() . '</div>'
|
||||||
. '</div></div>';
|
. '</div></div>';
|
||||||
}
|
}
|
||||||
@@ -236,34 +236,16 @@ class Event
|
|||||||
return dbConnector::query($query, $params);
|
return dbConnector::query($query, $params);
|
||||||
}
|
}
|
||||||
|
|
||||||
// @todo docu
|
public function getHtmlAddStarterForm($user, $options = [])
|
||||||
public function getHtmlRemoveStarterForm($starterId)
|
|
||||||
{
|
{
|
||||||
$html = self::getHtmlRemoveStarterFromEventForm($this->id, $starterId);
|
$returnToUrl = $options['returnToUrl'] ?? urlencode(getCurPagesUrl());
|
||||||
}
|
|
||||||
|
|
||||||
// returns html code for a button to remove the user from an event
|
|
||||||
public static function getHtmlRemoveStarterFromEventForm($eventId, $userId, $class = null)
|
|
||||||
{
|
|
||||||
$form =
|
|
||||||
'<form ' . (isset($class) ? ('class="' . $class . '"') : '') . ' action="api.starter.remove.php" method="post">'
|
|
||||||
. '<input type="hidden" name="returnToUrl" id="returnToUrl" value="' . urlencode(getCurPagesUrl()) . '" >'
|
|
||||||
. '<input type="hidden" name="eventId" id="eventId" value="' . $eventId . '">'
|
|
||||||
. '<input type="hidden" name="userId" id="userId" value="' . $userId . '">'
|
|
||||||
. '<button class="btn red" type="submit" name="submit">austragen</button>'
|
|
||||||
. '</form>';
|
|
||||||
|
|
||||||
return $form;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getHtmlAddStarterForm($user)
|
|
||||||
{
|
|
||||||
$key = isset($_SESSION['apiKey']) ? $_SESSION['apiKey'] : null;
|
$key = isset($_SESSION['apiKey']) ? $_SESSION['apiKey'] : null;
|
||||||
$form =
|
$form =
|
||||||
'<form class="card col s12 m6" action="api.starter.add.php" method="post">'
|
'<form class="card col s12 m6" action="api.starter.add.php" method="post">'
|
||||||
. '<input type="hidden" name="eventId" id="eventId" value="' . $this->id . '">'
|
. '<input type="hidden" name="eventId" id="eventId" value="' . $this->id . '">'
|
||||||
. '<input type="hidden" name="userId" id="userId" value="' . $user->getId() . '">'
|
. '<input type="hidden" name="userId" id="userId" value="' . $user->getId() . '">'
|
||||||
. '<input type="hidden" name="returnToUrl" id="returnToUrl" value="' . urlencode(getCurPagesUrl()) . '" >'
|
. '<input type="hidden" name="returnToUrl" id="returnToUrl" value="' . $returnToUrl . '" >'
|
||||||
. '<div class="input-field">'
|
. '<div class="input-field">'
|
||||||
. '<select id="selectTypeForm" name="type">'
|
. '<select id="selectTypeForm" name="type">'
|
||||||
. '<option value="1" selected="">als Starter</option>'
|
. '<option value="1" selected="">als Starter</option>'
|
||||||
|
|||||||
@@ -527,8 +527,7 @@ function getCurPagesUrl()
|
|||||||
return $pageURL;
|
return $pageURL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/** space saving way to put a date
|
||||||
* space saving way to put a date
|
|
||||||
*
|
*
|
||||||
* @param [DateTime] $date
|
* @param [DateTime] $date
|
||||||
* @return string html tag containing the date
|
* @return string html tag containing the date
|
||||||
|
|||||||
@@ -202,7 +202,7 @@ class Starter
|
|||||||
if ($today > $eventDeadline) {
|
if ($today > $eventDeadline) {
|
||||||
return self::getHtmlModalToLate($this->id);
|
return self::getHtmlModalToLate($this->id);
|
||||||
}
|
}
|
||||||
return self::getHtmlFormRemoveStarterFromEvent($this->id, $this->eventId, $class);
|
return self::getHtmlFormRemoveStarterFromEvent($this->getId(), $class);
|
||||||
}
|
}
|
||||||
|
|
||||||
// inject html code of table with coming starts for the session user
|
// inject html code of table with coming starts for the session user
|
||||||
@@ -212,7 +212,7 @@ class Starter
|
|||||||
echo(self::getHtmlTableComingStarts($userId));
|
echo(self::getHtmlTableComingStarts($userId));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Member
|
// member variables
|
||||||
// - static member
|
// - static member
|
||||||
/** Name of the table with all the starts
|
/** Name of the table with all the starts
|
||||||
*
|
*
|
||||||
@@ -338,8 +338,9 @@ class Starter
|
|||||||
':typeId' => ['value' => $typeId, 'data_type' => PDO::PARAM_INT],
|
':typeId' => ['value' => $typeId, 'data_type' => PDO::PARAM_INT],
|
||||||
':userId' => ['value' => $userId, 'data_type' => PDO::PARAM_INT]
|
':userId' => ['value' => $userId, 'data_type' => PDO::PARAM_INT]
|
||||||
];
|
];
|
||||||
|
// @todo remove ignoreErrors again
|
||||||
$response = dbConnector::query($query, $params);
|
// @todo Inserting-Starter-Statement returns false on execution: Why? It seems to succeed!
|
||||||
|
$response = dbConnector::query($query, $params, ['ignoreErrors'=>true]);
|
||||||
return dbConnector::getLastInsertId();
|
return dbConnector::getLastInsertId();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -405,7 +406,7 @@ class Starter
|
|||||||
private static function getHtmlTable($starts)
|
private static function getHtmlTable($starts)
|
||||||
{
|
{
|
||||||
$html = '<table>'
|
$html = '<table>'
|
||||||
. '<thead><tr><th>Datum</th><th>Veranstaltung</th><th>Starter</th><th></th></tr></thead>'
|
. '<thead><tr><th>Datum</th><th>Veranstaltung</th><th>Starter</th><th></th><th></th></tr></thead>'
|
||||||
. '<tbody>';
|
. '<tbody>';
|
||||||
foreach ($starts as $start) {
|
foreach ($starts as $start) {
|
||||||
$today = new DateTime();
|
$today = new DateTime();
|
||||||
@@ -421,6 +422,7 @@ class Starter
|
|||||||
. '<td>' . getHtmlSquareDate($eventDate) . '</td>'
|
. '<td>' . getHtmlSquareDate($eventDate) . '</td>'
|
||||||
. '<td>' . $shiai->getHtmlName() . '</td>'
|
. '<td>' . $shiai->getHtmlName() . '</td>'
|
||||||
. '<td>' . $startingUser->getName() . ', ' . $startingUser->getFirstName() . '</td>'
|
. '<td>' . $startingUser->getName() . ', ' . $startingUser->getFirstName() . '</td>'
|
||||||
|
. '<td>' . StartingType::$AsString[$start->getTypeId()] . '</td>'
|
||||||
. '<td>' . $start->getHtmlFormRemove() . '</td>'
|
. '<td>' . $start->getHtmlFormRemove() . '</td>'
|
||||||
. '</tr>';
|
. '</tr>';
|
||||||
}
|
}
|
||||||
@@ -430,7 +432,7 @@ class Starter
|
|||||||
|
|
||||||
private static function getHtmlModalToLate($startId, $caption = 'Austragen')
|
private static function getHtmlModalToLate($startId, $caption = 'Austragen')
|
||||||
{
|
{
|
||||||
$modal = $html = '<a class="btn grey waves-effect waves-light modal-trigger" href="#modal-remove-starter-' . $startId . '">' . $caption . '</a>'
|
$modal = '<a class="btn grey waves-effect waves-light modal-trigger" href="#modal-remove-starter-' . $startId . '">' . $caption . '</a>'
|
||||||
. '<div id="modal-remove-starter-' . $startId . '" class="modal">'
|
. '<div id="modal-remove-starter-' . $startId . '" class="modal">'
|
||||||
. '<div class="modal-content">'
|
. '<div class="modal-content">'
|
||||||
. '<p>Das Fenster zum Ein- und Austragen ist bereits geschlossen.</p>'
|
. '<p>Das Fenster zum Ein- und Austragen ist bereits geschlossen.</p>'
|
||||||
@@ -443,13 +445,13 @@ class Starter
|
|||||||
return $modal;
|
return $modal;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static function getHtmlFormRemoveStarterFromEvent($starterId, $eventId, $class = null)
|
private static function getHtmlFormRemoveStarterFromEvent($starterId, $class = null)
|
||||||
{
|
{
|
||||||
|
$returnToUrl = urlencode(getCurPagesUrl());
|
||||||
$form =
|
$form =
|
||||||
'<form ' . (isset($class) ? ('class="' . $class . '"') : '') . ' action="api.starter.remove.php" method="post">'
|
'<form ' . (isset($class) ? ('class="' . $class . '"') : '') . ' action="api.starter.remove.php" method="post">'
|
||||||
. '<input type="hidden" name="returnToUrl" id="returnToUrl" value="' . urlencode(getCurPagesUrl()) . '" >'
|
. '<input type="hidden" name="returnToUrl" id="returnToUrl" value="' . $returnToUrl . '" >'
|
||||||
. '<input type="hidden" name="eventId" id="eventId" value="' . $eventId . '">'
|
. '<input type="hidden" name="starterId" id="starterId" value="' . $starterId . '">'
|
||||||
. '<input type="hidden" name="userId" id="userId" value="' . $starterId . '">'
|
|
||||||
. '<button class="btn red" type="submit" name="submit">austragen</button>'
|
. '<button class="btn red" type="submit" name="submit">austragen</button>'
|
||||||
. '</form>';
|
. '</form>';
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user