/** * Handles validating the final step and writing the tickets data to the * registration object. */ public function finish($data, $form) { parent::finish($data, $form); $step = $this->getCurrentStep(); $datetime = $this->getController()->getDateTime(); $registration = $this->session->getRegistration(); $ticketsStep = $this->getSavedStepByClass('EventRegisterTicketsStep'); $tickets = $ticketsStep->loadData(); // Check that the requested tickets are still available. if (!$this->validateTickets($tickets['Tickets'], $form)) { Session::set("FormInfo.{$form->FormName()}.data", $form->getData()); $this->controller->redirectBack(); return false; } // Validate the final step. if (!$step->validateStep($data, $form)) { Session::set("FormInfo.{$form->FormName()}.data", $form->getData()); $this->controller->redirectBack(); return false; } $this->session->delete(); // If the registrations is already valid, then send a details email. if ($registration->Status == 'Valid') { EventRegistrationDetailsEmail::factory($registration)->send(); } $this->extend('onRegistrationComplete', $registration); $this->controller->redirect(Controller::join_links($datetime->Event()->Link(), 'registration', $registration->ID, '?token=' . $registration->Token)); }
public function finish($data, $form) { parent::finish($data, $form); $steps = DataObject::get('MultiFormStep', "SessionID = {$this->session->ID}"); if ($steps) { foreach ($steps as $step) { if ($step->class == 'Page2PersonalDetailsFormStep') { $member = new Member(); $data = $step->loadData(); if ($data) { $member->update($data); $member->write(); } } if ($step->class == 'Page2OrganisationDetailsFormStep') { $organisation = new Organisation(); $data = $step->loadData(); if ($data) { $organisation->update($data); if ($member && $member->ID) { $organisation->MemberID = $member->ID; } $organisation->write(); } } // Debug::show($step->loadData()); // Shows the step data (unserialized by loadData) } } $controller = $this->getController(); $controller->redirect($controller->Link() . 'finished'); }
/** * Handles validating the final step and writing the tickets data to the * registration object. */ public function finish($data, $form) { $step = $this->getCurrentStep(); $datetime = $this->getController()->getDateTime(); $registration = $this->session->getRegistration(); $ticketsStep = $this->getSavedStepByClass('EventRegisterTicketsStep'); $tickets = $ticketsStep->loadData(); // Check that the requested tickets are still available. if (!$this->validateTickets($tickets['Tickets'], $form)) { Session::set("FormInfo.{$form->FormName()}.data", $form->getData()); $this->controller->redirectBack(); return false; } $success = parent::finish($data, $form); if ($success === false) { return false; } // see whether we've been redirected by the step (most typically with Payment steps) $controller = Controller::curr(); /* @var $controller Controller */ if ($controller->redirectedTo()) { return; } $this->session->delete(); // If the registrations is already valid, then send a details email. if ($registration->Status == 'Valid') { EventRegistrationDetailsEmail::factory($registration)->send(); } $this->extend('onRegistrationComplete', $registration); $this->controller->redirect(Controller::join_links($datetime->Event()->Link(), 'registration', $registration->ID, '?token=' . $registration->Token)); }
public function finish($data, $form) { parent::finish($data, $form); $detailsStep = $this->getSavedStepByClass( 'RegistrationDetailsStep' ); $developer = new Developer(); $detailsStep->saveInto($developer); $developer->write(); $developer->logIn(); $referenceStep = $this->getSavedStepByClass( 'RegistrationReferenceStep' ); if($referenceStep->loadData()) { $reference = new Reference(); $referenceStep->saveInto($reference); $reference->DeveloperID = $developer->ID; $reference->write(); } return $this->controller->customise(array( 'Form' => false, 'Content' => ' Thank you for registering. You are now logged-in. ' ))->renderWith('Page'); }
/** * Handles validating the final step and writing the tickets data to the * registration object. */ public function finish($data, $form) { parent::finish($data, $form); $step = $this->getCurrentStep(); $datetime = $this->getController()->getDateTime(); $registration = $this->session->getRegistration(); $ticketsStep = $this->getSavedStepByClass('EventRegisterTicketsStep'); $tickets = $ticketsStep->loadData(); // Check that the requested tickets are still available. if (!$this->validateTickets($tickets['Tickets'], $form)) { Session::set("FormInfo.{$form->FormName()}.data", $form->getData()); Director::redirectBack(); return false; } // Validate the final step. if (!$step->validateStep($data, $form)) { Session::set("FormInfo.{$form->FormName()}.data", $form->getData()); Director::redirectBack(); return false; } // Reload the first step fields into a form, then save it into the // registration object. $ticketsStep->setForm($form); $fields = $ticketsStep->getFields(); $form = new Form($this, '', $fields, new FieldSet()); $form->loadDataFrom($tickets); $form->saveInto($registration); if ($member = Member::currentUser()) { $registration->Name = $member->getName(); $registration->Email = $member->Email; } $registration->TimeID = $datetime->ID; $registration->MemberID = Member::currentUserID(); $total = $ticketsStep->getTotal(); $registration->Total->setCurrency($total->getCurrency()); $registration->Total->setAmount($total->getAmount()); foreach ($tickets['Tickets'] as $id => $quantity) { if ($quantity) { $registration->Tickets()->add($id, array('Quantity' => $quantity)); } } $registration->write(); $this->session->delete(); // If the registrations is already valid, then send a details email. if ($registration->Status == 'Valid') { EventRegistrationDetailsEmail::factory($registration)->send(); } $this->extend('onRegistrationComplete', $registration); return Director::redirect(Controller::join_links($datetime->Event()->Link(), 'registration', $registration->ID, '?token=' . $registration->Token)); }
function finish($data, $form) { parent::finish($data, $form); $savedSteps = $this->getSavedSteps(); $savedData = array(); foreach ($savedSteps as $step) { $savedData = array_merge($savedData, $step->loadData()); } $fields = new FieldSet(); $fields->push(new LiteralField("Heading", "<h3>You have submitted the following information:</h3>")); foreach ($savedData as $key => $value) { $fields->push(new LiteralField($key . '_copy', "<p><strong>{$key}</strong> {$value}</p>")); } Session::set("MultiFormMessage", "Your information has been submitted."); Director::redirect(Director::BaseURL() . $this->Controller()->URLSegment); }