public function getCurrentRegistration() { $member = Member::currentUser(); if (!$member) { return false; } $reg = Registration::get()->filter(array('MemberID' => $member->ID, 'ParentID' => $this->getCurrentEvent()->ID)); if (!$reg) { return false; } return $reg->First(); }
public function getCMSFields() { $fields = parent::getCMSFields(); $fields->removeByName('Sort'); $siteConfig = SiteConfig::current_site_config(); $current = $siteConfig->getCurrentEventID(); if ($this->Event()->ID) { $event = $this->Event(); } else { if ($this->Parent()->ParentID > 0) { $event = Event::get()->byID($this->Parent()->ParentID); } else { $event = Event::get()->byID($current); } } if ($event) { $prefNum = $event->PreferencesPerSession ? $event->PreferencesPerSession : 2; } else { $prefNum = 2; } $pref = array(); for ($i = 1; $i <= $prefNum; $i++) { $pref[$i] = $i; } $preference = new DropdownField('Preference', 'Preference', $pref); $preference->setEmptyString(' '); $fields->insertAfter($preference, 'GameID'); $status = array(0 => "Pending/Declined", 1 => "Accepted"); $fields->insertAfter(new OptionsetField('Status', 'Status', $status), 'Preference'); $reg = Registration::get()->filter(array('ParentID' => $event->ID))->map('ID', "Title"); $player = new DropdownField('ParentID', 'Player', $reg); $player->setEmptyString(' '); $fields->insertAfter($player, 'Status'); $fields->insertAfter($fields->dataFieldByName('Favourite'), 'Status'); $fields->insertAfter($fields->dataFieldByName('ParentID'), 'GameID'); $event = HiddenField::create('EventID', 'Event', $event->ID); $fields->insertAfter($event, 'GameID'); return $fields; }
<?php View::composer(array('home', 'registrations.register'), function ($view) { $all = Registration::get()->sum('tickets'); $today = Registration::where(DB::raw('DATE(registrations.created_at)'), DB::raw('CURDATE()'))->get()->sum('tickets'); $expected = Booking::get()->sum('tickets'); $view->with('registration_count_total', $all)->with('registration_count_today', $today)->with('expected_count', $expected); });
function getRegistrations($callsign = null) { if (is_null($this->registrations)) { $this->registrations = Registration::get()->each(function ($registration) { $registration->prefix = str_replace('-', '', $registration->prefix); if (!$registration->regex) { $registration->prefix .= '.*'; } }); } if (!is_null($callsign)) { return $this->registrations->first(function ($key, $registration) use($callsign) { return preg_match('/^' . $registration->prefix . '$/', $callsign); }); } return $this->registrations; }
public function getRegistration($memberID) { $siteConfig = SiteConfig::current_site_config(); return Registration::get()->filter(array("MemberID" => $memberID, 'ParentID' => $siteConfig->CurrentEventID))->First(); }
/** * Attempts to save a game * * @return Game|null */ protected function addPlayerGame($data, $form) { $fields = $form->Fields(); $event = $this->getCurrentEvent(); $currentID = $event->ID; $prefNum = $event->PreferencesPerSession; $regID = $data['RegistrationID']; $reg = Registration::get()->byID($regID); if (!$reg) { return false; } // @todo - handle a proper 'change game' case if ($reg->PlayerGames()->Count() > 0) { foreach ($reg->PlayerGames() as $playerGame) { $reg->PlayerGames()->removeByID($playerGame->ID); $playerGame->delete(); } } $favouriteID = $data["FavouriteID"]; for ($session = 1; $session <= $event->NumberOfSessions; $session++) { $notPlay = $data["NotPlaying_" . $session]; $games = Game::get()->filter(array('Session' => $session, 'ParentID' => $currentID, 'Status' => true)); // Alter prefnumber so it stops when it encounters "not Playing" if ($notPlay != 0 && $notPlay < $prefNum) { $prefNum = $notPlay; } // if first choice is to not play, don't create any games if ($notPlay === 1) { continue; } foreach ($games as $game) { $gamePref = $data["GameID_" . $game->ID]; // only store games with a preference higher than our threshold if ($gamePref > $prefNum || !isset($gamePref)) { continue; } $playerGame = PlayerGame::create(); $form->saveInto($playerGame); $playerGame->GameID = $game->ID; $playerGame->ParentID = $regID; $playerGame->Preference = $gamePref; if ($favouriteID == $game->ID) { $playerGame->Favourite = true; } try { $playerGame->write(); } catch (ValidationException $e) { $form->sessionMessage($e->getResult()->message(), 'bad'); return; } } } return $playerGame; }
protected function prepareDatabase() { // Get database records for all airlines, airports, registrations $this->airlines = Airline::get(); $this->registrations = Registration::get()->each(function ($registration) { $registration->prefix = str_replace('-', '', $registration->prefix); if (!$registration->regex) { $registration->prefix .= '.*'; } }); }