id = (int) $id; $this->date = DateTime::createFromFormat('Y-m-d', $date); $this->name = $name; $this->ageclasses = $ageclasses; $this->place = $place; $this->announcementUrl = $announcementUrl; $this->routeUrl = $routeUrl; $this->galleryUrl = $galleryUrl; $this->promoImgUrl = $promoImgUrl; } public function getId() { return $this->id; } public function getName() { return ($this->name != null ? $this->name : 'Wettkampf ohne Namen'); } public function getHtmlDate() { return ($this->date != null ? $this->date->format('Y-m-d') : 'fehlendes Datum'); } public function getAgeClasses() { return ($this->ageclasses != null ? $this->ageclasses : '-'); } public function getPlace() { return ($this->place != null ? $this->place : '-'); } public static function fromArray($member) { return new shiai( $member['lfdeNr'] ?? null, $member['Datum'] ?? null, $member['Veranstaltung'] ?? '', $member['Altersklassen'] ?? null, $member['Ort'] ?? '', $member['Ausschreibung'] ?? null, $member['Routenplaner'] ?? null, $member['galleryLink'] ?? null, $member['promoPic'] ?? null ); } /** * shiai event as html code for displaying * * @return html formated string */ public function getHtml() { $retHtml = ''; $retHtml = '
' . '

' . $this->getName() . '

' . '
' . '
Datum:
' . $this->getHtmlDate() . '
' . '
Altersklassen
' . $this->getAgeClasses() . '
' . '
Ort
' . $this->getPlace() . '
' . '
'; return $retHtml; } } // end class shiai class event { private $id = null; //< unique id of the event in the db private $date = null; //< date for the event (@todo ranges?) private $shiaiId = null; //< unique id of the shiai in the db (if appropriate) private $deadline = null; //< until when one can register for the event private $remarks = null; //< remarks to the event (special rules) or a json object for missing data (e.g. non-shiai events) private $shiai = null; public function __construct($id, $date, $shiaiId, $deadline, $remarks, $shiai) { //! @todo InputValidation $this->id = (int) $id; $this->date = DateTime::createFromFormat('Y-m-d', $date); $this->shiaiId = (($shiaiId != null) ? ((int)$shiaiId) : (null)); $this->deadline = DateTime::createFromFormat('Y-m-d', $deadline); $this->remarks = $remarks; $this->shiai = $shiai; } public function asHtmlCard() { return '
' . '
' . '' . $this->shiai->getName() . '' . '
' . '
Datum
' . '
' . $this->date->format('Y-m-d') . '
' . '
Meldefrist
' . '
' . $this->deadline->format('Y-m-d') . '
' . '
Altersklassen
' . '
' . $this->shiai->getAgeClasses() . '
' . '
' . '
'; } public function htmlTableRow() { return '' . '' . $this->date->format('Y-m-d') . '' . '' . $this->shiai->getName() . '' . 'add' . ''; } public function htmlModal() { return ''; } public static function fromArray($member) { $shiai = json_decode($member['bemerkungen'], true); return new event( $member['id'] ?? null, $member['date'] ?? null, $member['wkId'] ?? null, $member['meldefrist'] ?? null, $member['bemerkungen'] ?? null, shiai::fromArray(($shiai != null) ? $shiai : $member) ); } } // end class event class eventPlaner { private static $db = null; // set the dbConnection (just setting, no establishing) public static function setDbConnection($dbConnection) { if ($dbConnection instanceof PDO) { self::$db = $dbConnection; } else { self::$db = null; } return; } public static function getCommingWkEvents($someOptions = []) { // wir befinden uns in der Übergangsphase: // - als Standard wird das derzeitige Verhalten definiert (ISO-8859-1 // und die Konvertierung erfolgt ausserhalb) // - wenn einmal alle mbConvertEncoding weg sind, kann der Standard auf // das gewünschte Verhalten umgestellt werden $dbCharset = $someOptions['dbCharset'] ?? 'ISO-8859-1'; // dbCharset = $someOptions['outCharset'] ?? "UTF-8";// das spätere, gewünschte Verhalten $outCharset = $someOptions['outCharset'] ?? 'ISO-8859-1'; $query = 'SELECT ' . 'wkParticipo_Events.id, ' . 'wkParticipo_Events.date, ' . 'wkParticipo_Events.wkId, ' . 'wkParticipo_Events.meldefrist, ' . 'wkParticipo_Events.bemerkungen, ' . 'wkParticipo_Events.kvOptions, ' . 'wettkampfkalender.Datum, ' . 'wettkampfkalender.Veranstaltung, ' . 'wettkampfkalender.Altersklassen, ' . 'wettkampfkalender.Ort, ' . 'wettkampfkalender.Ausschreibung, ' . 'wettkampfkalender.Routenplaner ' . 'FROM wkParticipo_Events ' . 'LEFT JOIN wettkampfkalender ' . 'ON wettkampfkalender.lfdeNr = wkParticipo_Events.wkId ' . 'WHERE wkParticipo_Events.date >= CURDATE() ' . 'ORDER BY wkParticipo_Events.date;'; $ret = dbQuery(self::$db, $query); $events = []; foreach ($ret as $event) { array_push($events, event::fromArray($event)); } return $events; } public static function getHtmlEventTable($eventList) { $ret = ''; $ret .= ''; foreach ($eventList as $event) { $ret .= $event->htmlTableRow(); } $ret .= '
'; foreach ($eventList as $event) { $ret .= $event->htmlModal(); } return $ret; } }