Basic implementation event signup
This commit is contained in:
45
modules/event-participants/Models/class-event.php
Normal file
45
modules/event-participants/Models/class-event.php
Normal file
@ -0,0 +1,45 @@
|
||||
<?php
|
||||
namespace Bdp\Modules\EventParticipants\Models;
|
||||
|
||||
use Bdp\Libs\CommonModel;
|
||||
|
||||
class Event extends CommonModel {
|
||||
public static function loadById(int $event_id) : Event {
|
||||
|
||||
|
||||
global $dbHandler;
|
||||
|
||||
$data = $dbHandler->readFromDb('kompass_veranstaltungen_index', ['id' => $event_id]);
|
||||
$class = new Event();
|
||||
$class->groups = ['participant' => [], 'volunteer' => [], 'other' => []];
|
||||
|
||||
|
||||
foreach (get_object_vars($data[0]) as $key => $value) {
|
||||
$class->$key = $value;
|
||||
}
|
||||
|
||||
foreach (EventParticipant::list_for_event($event_id) as $participant) {
|
||||
$class->groups[$participant->teilnahme][] = $participant;
|
||||
}
|
||||
|
||||
|
||||
foreach ($class->groups as $group) {
|
||||
foreach ($group as $participant) {
|
||||
if (!isset($class->tribes[$participant->stamm])) {
|
||||
$class->tribes[$participant->stamm] = [];
|
||||
}
|
||||
$class->tribes[$participant->stamm][] = $participant;
|
||||
}
|
||||
}
|
||||
|
||||
#echo '<pre>';print_r($class);die();
|
||||
return $class;
|
||||
|
||||
}
|
||||
|
||||
public function __construct() {
|
||||
$this->_tablename = 'kompass_veranstaltungen_index';
|
||||
$this->groups = [];
|
||||
$this->tribes = [];
|
||||
}
|
||||
}
|
57
modules/event-participants/Models/class-eventgroup.php
Normal file
57
modules/event-participants/Models/class-eventgroup.php
Normal file
@ -0,0 +1,57 @@
|
||||
<?php
|
||||
namespace Bdp\Modules\EventParticipants\Models;
|
||||
|
||||
use Bdp\Libs\CommonModel;
|
||||
|
||||
class EventGroup extends CommonModel {
|
||||
public static function loadById(int $group_id) {
|
||||
global $dbHandler;
|
||||
|
||||
$data = $dbHandler->readFromDb('kompass_veranstaltungen_gruppen', ['id' => $group_id]);
|
||||
$class = new EventGroup();
|
||||
|
||||
foreach (get_object_vars($data[0]) as $key => $value) {
|
||||
$class->$key = $value;
|
||||
}
|
||||
|
||||
foreach (EventParticipant::list_for_group($group_id) as $participant_id) {
|
||||
$class->participants[] = EventParticipant::loadById($participant_id);
|
||||
}
|
||||
|
||||
return $class;
|
||||
}
|
||||
|
||||
public static function list_simple_for_event(int $event_id) : array {
|
||||
global $dbHandler;
|
||||
|
||||
$data = $dbHandler->readFromDb('kompass_veranstaltungen_gruppen', ['eventId' => $event_id]);
|
||||
$return = [];
|
||||
foreach ($data as $group) {
|
||||
$group_class = new EventGroup();
|
||||
foreach (get_object_vars($group) as $key => $value) {
|
||||
$group_class->$key = $value;
|
||||
}
|
||||
|
||||
$return[] = $group_class;
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
public static function list_for_event(int $event_id) : array {
|
||||
global $dbHandler;
|
||||
|
||||
$data = $dbHandler->readFromDb('kompass_veranstaltungen_teilis', ['eventId' => $event_id]);
|
||||
$return = [];
|
||||
foreach ($data as $group) {
|
||||
$return[] = $group->id;
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
public function __construct() {
|
||||
$this->_tablename = 'kompass_veranstaltungen_gruppen';
|
||||
$this->participants = [];
|
||||
}
|
||||
}
|
32
modules/event-participants/Models/class-eventparticipant.php
Normal file
32
modules/event-participants/Models/class-eventparticipant.php
Normal file
@ -0,0 +1,32 @@
|
||||
<?php
|
||||
namespace Bdp\Modules\EventParticipants\Models;
|
||||
|
||||
use Bdp\Libs\CommonModel;
|
||||
use Bdp\Modules\EventParticipants\Controllers\MainController;
|
||||
|
||||
class EventParticipant extends CommonModel {
|
||||
public static function loadById(int $event_id) {
|
||||
return parent::load_by_id('kompass_veranstaltungen_teilis', $event_id);
|
||||
}
|
||||
|
||||
public static function list_for_event(int $event_id) : array {
|
||||
global $dbHandler;
|
||||
|
||||
$data = $dbHandler->readFromDb('kompass_veranstaltungen_teilis', ['eventId' => $event_id]);
|
||||
$return = [];
|
||||
foreach ($data as $participant) {
|
||||
$part = EventParticipant::loadById($participant->id);
|
||||
$return[] = $part;
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
public function get_group() : CommonModel {
|
||||
return EventGroup::load_by_id(MainController::KOMPASS_EVENTS_GROUPS, $this->gruppe_id);
|
||||
}
|
||||
|
||||
public function __construct() {
|
||||
$this->_tablename = 'kompass_veranstaltungen_teilis';
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user