'
. '
'
. $this->shiai->getHtml()
+ . $this->getHtmlStarterStatistic()
. $this->getHtmlStarterList();
$kids = participo::getKids();
$modal .= '
';
- foreach ($kids as $k) {
- $modal .= $this->getHtmlAddStarterForm($k, ['returnToUrl'=>'/participo/events#' . $this->id]);
+ $modal .= '
Deadline zum Eintragen: '.$this->deadline->format('Y-m-d').'
';
+
+ $today = new DateTime();
+ if(
+ (isset($this->deadline) && ($today <= $this->deadline))
+ || participo::isUserAdmin($userData['id'])
+ ){
+ foreach ($kids as $k) {
+ $modal .= $this->getHtmlAddStarterForm($k, ['returnToUrl'=>'/participo/events#' . $this->id]);
+ }
+ }
+ else{
+
+ $modal .= '
Es ist leider zu spät noch jemanden einzutragen!
';
}
$modal .= '
';
$modal .=
@@ -204,6 +219,35 @@ class Event
return $starter;
}
+ /** get number of starters of a certain type for this event
+ *
+ * @param int $startingType it representation of the StartingType to count
+ * @return int count of starters
+ */
+ public function getStarterCount(int $startingType)
+ {
+ $query = 'SELECT COUNT(`wkParticipo_Starter`.`id`) AS starterCount FROM `wkParticipo_Starter` '
+ . ' WHERE `wkParticipo_Starter`.`eventId` = :eventId AND `wkParticipo_Starter`.`type` = :typeId;';
+ $params = [
+ ':eventId' => ['value' => $this->id, 'data_type' => PDO::PARAM_INT],
+ ':typeId' => ['value' => $startingType, 'data_type' => PDO::PARAM_INT],
+ ];
+ $response = dbConnector::query($query, $params);
+ return intval($response[0]['starterCount']);
+ }
+
+ public function getHtmlStarterStatistic(){
+ $retHtml = '
';
+ foreach([StartingType::Fighter, StartingType::NoParticipation, StartingType::Audience] as $type){
+ $count = $this->getStarterCount($type);
+ if($count > 0){
+ $retHtml .= '- '.StartingType::$AsString[$type].'
- '.$count.'
';
+ }
+ }
+ $retHtml .= '
';
+ return $retHtml;
+ }
+
public static function fromDbArray($member)
{
$shiai = json_decode($member['bemerkungen'], true);
@@ -236,11 +280,19 @@ class Event
public function getHtmlAddStarterForm($user, $options = [])
{
+ $defaults = [
+ 'formClass' =>'card col s12 m6 l3',
+ 'inputClass' =>'input-field',
+ 'buttonClass'=>'btn'
+ ];
+
+ $options = array_merge($defaults, $options);
+
$returnToUrl = $options['returnToUrl'] ?? urlencode(getCurPagesUrl());
$key = isset($_SESSION['apiKey']) ? $_SESSION['apiKey'] : null;
$form =
- '
'
- . '
'
+ . '
'
. '';
return $form;
diff --git a/homepage/participo/lib/participoLib/participo.php b/homepage/participo/lib/participoLib/participo.php
index 7a25818..74958d4 100644
--- a/homepage/participo/lib/participoLib/participo.php
+++ b/homepage/participo/lib/participoLib/participo.php
@@ -564,3 +564,17 @@ function filterId($id)
{
return filter_var($id, FILTER_VALIDATE_INT, ['options' => ['default' => null, 'min_range' => 1]]);
}
+
+/** filter a variable as count
+ *
+ * - count means a non negative integer
+ * - helper function to stay DRY
+ *
+ * @param mixed $variable
+ * @param integer $min
+ * @return integer the input variable as integer >= 0
+ */
+function filterCount($variable, int $min = 0){
+ return filter_var($variable, FILTER_VALIDATE_INT, ['options' => ['default' => null, 'min_range' => 1]]);
+}
+
diff --git a/homepage/participo/lib/participoLib/shiai.php b/homepage/participo/lib/participoLib/shiai.php
index 0480e76..8d11037 100644
--- a/homepage/participo/lib/participoLib/shiai.php
+++ b/homepage/participo/lib/participoLib/shiai.php
@@ -8,7 +8,7 @@ class Shiai
private $id = null; //< unique id
private $date = null; //< date of the shiai
private $name = null; //< name of the shiai as string
- private $ageclasses = null; //< age classes as space separated Uxy in a string
+ private $ageclasses = null; //< age classes as space separated 'Uxy' in a string
private $place = null; //< place of the shiai as string
private $announcementUrl = null; //< url to the announcement
private $routeUrl = null; //< url to a routing planner
@@ -88,8 +88,7 @@ class Shiai
);
}
- /**
- * shiai event as html code for displaying
+ /** shiai event as html code for displaying
*
* @return html formatted string
*/
diff --git a/homepage/participo/lib/participoLib/starter.php b/homepage/participo/lib/participoLib/starter.php
index a260e1e..61889b7 100644
--- a/homepage/participo/lib/participoLib/starter.php
+++ b/homepage/participo/lib/participoLib/starter.php
@@ -405,7 +405,7 @@ class Starter
// get html code of a list of starts
private static function getHtmlTable($starts)
{
- $html = '