add offered rided count to event overview
This commit is contained in:
@@ -160,9 +160,7 @@ class Event
|
||||
foreach ($kids as $k) {
|
||||
$modal .= $this->getHtmlAddStarterForm($k, ['returnToUrl' => '/participo/events#' . $this->id]);
|
||||
}
|
||||
}
|
||||
else{
|
||||
|
||||
} else {
|
||||
$modal .= '<div>Es ist leider zu spät noch jemanden einzutragen!</div>';
|
||||
}
|
||||
$modal .= '</div>';
|
||||
@@ -236,7 +234,13 @@ class Event
|
||||
return intval($response[0]['starterCount']);
|
||||
}
|
||||
|
||||
public function getHtmlStarterStatistic(){
|
||||
public function getSeatCount()
|
||||
{
|
||||
return self::getSeatCountOf($this->id);
|
||||
}
|
||||
|
||||
public function getHtmlStarterStatistic()
|
||||
{
|
||||
$retHtml = '<dl>';
|
||||
foreach ([StartingType::Fighter, StartingType::NoParticipation, StartingType::Audience] as $type) {
|
||||
$count = $this->getStarterCount($type);
|
||||
@@ -244,6 +248,7 @@ class Event
|
||||
$retHtml .= '<dt>' . StartingType::$AsString[$type] . '</dt><dd>' . $count . '</dd>';
|
||||
}
|
||||
}
|
||||
$retHtml .= '<dt>Mitfahrgelegenheiten</dt><dd>' . $this->getSeatCount() . '</dd>';
|
||||
$retHtml .= '</dl>';
|
||||
return $retHtml;
|
||||
}
|
||||
@@ -266,8 +271,6 @@ class Event
|
||||
/// Es erfolgt keine Überprüfung der Meldeberechtigung!
|
||||
public static function addStarter($dbConnection, $starter)
|
||||
{
|
||||
$retMessage = [];
|
||||
|
||||
$query = 'INSERT INTO `wkParticipo_Starter` (eventId, userId, type) values (:eventId, :userId, :typeId);';
|
||||
$params = [
|
||||
':eventId' => ['value' => $starter->getEventId(), 'data_type' => PDO::PARAM_INT],
|
||||
@@ -278,6 +281,17 @@ class Event
|
||||
return dbConnector::query($query, $params);
|
||||
}
|
||||
|
||||
public static function getSeatCountOf(int $id)
|
||||
{
|
||||
$query = 'SELECT SUM(plaetze) AS sumSeats FROM `cwsvjudo`.`wkParticipo_Fahrten` WHERE eventId = :eventId;';
|
||||
$params = [
|
||||
'eventId' => ['value' => $id, 'data_type' => PDO::PARAM_INT]
|
||||
];
|
||||
$response = dbConnector::query($query, $params);
|
||||
$sumSeats = filterCount($response[0]['sumSeats']);
|
||||
return $sumSeats;
|
||||
}
|
||||
|
||||
public function getHtmlAddStarterForm($user, $options = [])
|
||||
{
|
||||
$defaults = [
|
||||
|
||||
@@ -3,13 +3,17 @@
|
||||
require_once 'participoLib/participo.php';
|
||||
|
||||
/** Frame for a variable synced with a db*/
|
||||
class PdoCellValue{
|
||||
public function __construct(string $name, $value, $type){
|
||||
class PdoCellValue
|
||||
{
|
||||
public function __construct(string $name, $value, $type)
|
||||
{
|
||||
$this->name = $name;
|
||||
$this->value = $value;
|
||||
$this->type = $type;
|
||||
}
|
||||
static public function collect(array $row){
|
||||
|
||||
public static function collect(array $row)
|
||||
{
|
||||
$names = [];
|
||||
foreach ($row as $entry) {
|
||||
if (isset($entry->name)) {
|
||||
@@ -18,14 +22,25 @@ class PdoCellValue{
|
||||
}
|
||||
return $names;
|
||||
}
|
||||
public function value(){return $this->value;}
|
||||
public function setValue($value){$this->value = $value;}
|
||||
private string $name = null;
|
||||
private $value = null;
|
||||
private int $data_type = null;
|
||||
|
||||
public function value()
|
||||
{
|
||||
return $this->value;
|
||||
}
|
||||
|
||||
class Ride{
|
||||
public function setValue($value)
|
||||
{
|
||||
$this->value = $value;
|
||||
}
|
||||
|
||||
// private member variables
|
||||
private ?string $name = null;
|
||||
private $value = null;
|
||||
private ?int $type = null;
|
||||
}
|
||||
|
||||
class Ride
|
||||
{
|
||||
/** Constructor
|
||||
*
|
||||
* - filters/sanitizes all inputs
|
||||
@@ -37,7 +52,8 @@ class Ride{
|
||||
* @param mixed $seats setValue for the seats
|
||||
* @param string $passengerIds string of comma separated values
|
||||
*/
|
||||
public function __construct($id, $eventId, $driverId, $seats, string $passengerIds){
|
||||
public function __construct($id, $eventId, $driverId, $seats, string $passengerIds)
|
||||
{
|
||||
$this->id = new PdoCellValue('id', filterId($id), PDO::PARAM_INT);
|
||||
$this->eventId = new PdoCellValue('eventId', filterId($eventId), PDO::PARAM_INT);
|
||||
$this->driverId = new PdoCellValue('fahrerId', filterId($driverId), PDO::PARAM_INT);
|
||||
@@ -46,7 +62,8 @@ class Ride{
|
||||
}
|
||||
|
||||
/** parse and sanitize a csvFormatted string */
|
||||
function filterCsv(string $list, $callback, string $separator=',', bool $dontTrim = false){
|
||||
public function filterCsv(string $list, $callback, string $separator = ',', bool $dontTrim = false)
|
||||
{
|
||||
$list = explode($separator, $list);
|
||||
foreach ($list as &$element) {
|
||||
$element = $callback($element);
|
||||
@@ -62,9 +79,9 @@ class Ride{
|
||||
////
|
||||
|
||||
// DbInterface
|
||||
private static $dbName = 'cwsvjudo';
|
||||
private static $dbTableName = 'wkParticipo_Fahrten';
|
||||
private static $dbFullTableNameString = '`'.$dbName.'`.`'.$dbTableName.'`';
|
||||
private const dbName = 'cwsvjudo';
|
||||
private const dbTableName = 'wkParticipo_Fahrten';
|
||||
private const dbFullTableNameString = '`' . self::dbName . '`.`' . self::dbTableName . '`';
|
||||
|
||||
/** Slice a list of arrays 'horizontal' through a specific key
|
||||
*
|
||||
@@ -75,7 +92,8 @@ class Ride{
|
||||
* @param mixed $key key to collect
|
||||
* @return array list of array entries
|
||||
*/
|
||||
function sliceArrayByKey(array $array, $key){
|
||||
public function sliceArrayByKey(array $array, $key)
|
||||
{
|
||||
$sliced = [];
|
||||
foreach ($array as $entry) {
|
||||
if (isset($entry[$key])) {
|
||||
@@ -85,8 +103,12 @@ class Ride{
|
||||
return $sliced;
|
||||
}
|
||||
|
||||
private static function dbSelect(){}
|
||||
private static function dbInsert(array $values){
|
||||
private static function dbSelect()
|
||||
{
|
||||
}
|
||||
|
||||
private static function dbInsert(array $values)
|
||||
{
|
||||
$names = [];
|
||||
$binds = [];
|
||||
$params = [];
|
||||
@@ -94,8 +116,7 @@ class Ride{
|
||||
$names[] = $value->name;
|
||||
$binds[] = ':' . $value->name;
|
||||
$params[':' . $value->name] = [
|
||||
'value' => $value->name
|
||||
, 'data_type' => $value->type
|
||||
'value' => $value->name, 'data_type' => $value->type
|
||||
];
|
||||
}
|
||||
|
||||
@@ -106,10 +127,14 @@ class Ride{
|
||||
$response = dbConnector::query($query, $params, ['ignoreErrors' => true]);
|
||||
return dbConnector::getLastInsertId();
|
||||
}
|
||||
private static function dbDelete(){}
|
||||
private static function dbUpdate(){}
|
||||
|
||||
private
|
||||
private static function dbDelete()
|
||||
{
|
||||
}
|
||||
|
||||
private static function dbUpdate()
|
||||
{
|
||||
}
|
||||
|
||||
////
|
||||
// private variables
|
||||
|
||||
Reference in New Issue
Block a user