/**
  * Returns an array of payment methods configured in the event
  *
  * @param Event $event
  * @return array
  */
 public function getRestrictedPaymentMethods($event)
 {
     $restrictedPaymentMethods = [];
     $allPaymentMethods = $this->getPaymentMethods();
     $selectedPaymentMethods = explode(',', $event->getSelectedPaymentMethods());
     foreach ($selectedPaymentMethods as $selectedPaymentMethod) {
         if (isset($allPaymentMethods[$selectedPaymentMethod])) {
             $restrictedPaymentMethods[$selectedPaymentMethod] = $allPaymentMethods[$selectedPaymentMethod];
         }
     }
     return $restrictedPaymentMethods;
 }
 /**
  * Returns an array with the amount of possible simultaneous registrations
  * respecting the maxRegistrationsPerUser setting and also respects the amount
  * of remaining free places.
  *
  * The returned array index starts at 1 if at least one registration is possible
  *
  * @param \DERHANSEN\SfEventMgt\Domain\Model\Event $event Event
  *
  * @return array
  */
 public function render($event)
 {
     $minPossibleRegistrations = 1;
     $maxPossibleRegistrations = $event->getFreePlaces();
     $result = array($maxPossibleRegistrations);
     if ($event->getMaxRegistrationsPerUser() <= $maxPossibleRegistrations) {
         $maxPossibleRegistrations = $event->getMaxRegistrationsPerUser();
     }
     if ($maxPossibleRegistrations >= $minPossibleRegistrations) {
         $arrayWithZeroAsIndex = range($minPossibleRegistrations, $maxPossibleRegistrations);
         $result = array_combine(range(1, count($arrayWithZeroAsIndex)), $arrayWithZeroAsIndex);
     }
     return $result;
 }
 /**
  * Returns an array with the amount of possible simultaneous registrations
  * respecting the maxRegistrationsPerUser setting and also respects the amount
  * of remaining free places.
  *
  * The returned array index starts at 1 if at least one registration is possible
  *
  * @param \DERHANSEN\SfEventMgt\Domain\Model\Event $event Event
  *
  * @return array
  */
 public function render($event)
 {
     $minPossibleRegistrations = 1;
     if ($event->getMaxParticipants() > 0 && $event->getMaxRegistrationsPerUser() >= $event->getFreePlaces() && !$event->getEnableWaitlist()) {
         $maxPossibleRegistrations = $event->getFreePlaces();
     } else {
         $maxPossibleRegistrations = $event->getMaxRegistrationsPerUser();
     }
     $result = [$maxPossibleRegistrations];
     if ($maxPossibleRegistrations >= $minPossibleRegistrations) {
         $arrayWithZeroAsIndex = range($minPossibleRegistrations, $maxPossibleRegistrations);
         $result = array_combine(range(1, count($arrayWithZeroAsIndex)), $arrayWithZeroAsIndex);
     }
     return $result;
 }
Example #4
0
 /**
  * Test if notifyOrganisator can be set
  *
  * @test
  * @return void
  */
 public function setNotifyOrganisatorSetsValueForNotifyOrganisator()
 {
     $this->subject->setNotifyOrganisator(TRUE);
     $this->assertTrue($this->subject->getNotifyOrganisator());
 }
 /**
  * Registration view for an event
  *
  * @param \DERHANSEN\SfEventMgt\Domain\Model\Event $event Event
  *
  * @return void
  */
 public function registrationAction(Event $event)
 {
     if ($event->getRestrictPaymentMethods()) {
         $paymentMethods = $this->paymentService->getRestrictedPaymentMethods($event);
     } else {
         $paymentMethods = $this->paymentService->getPaymentMethods();
     }
     $this->view->assign('event', $event);
     $this->view->assign('paymentMethods', $paymentMethods);
 }
Example #6
0
 /**
  * @test
  * @dataProvider cancellationPossibleDataProvider
  */
 public function getCancellationPossibleReturnsExpectedValues($enabled, $deadline, $expected)
 {
     $this->subject->setEnableCancel($enabled);
     $this->subject->setCancelDeadline($deadline);
     $this->assertEquals($expected, $this->subject->getCancellationPossible());
 }
 /**
  * Checks, if the registration can successfully be created. Note, that
  * $result is passed by reference!
  *
  * @param \DERHANSEN\SfEventMgt\Domain\Model\Event $event Event
  * @param \DERHANSEN\SfEventMgt\Domain\Model\Registration $registration Registration
  * @param RegistrationResult $result Result
  *
  * @return bool
  */
 protected function checkRegistrationSuccess(Event $event, Registration $registration, &$result)
 {
     $success = TRUE;
     if ($event->getEnableRegistration() === FALSE) {
         $success = FALSE;
         $result = RegistrationResult::REGISTRATION_NOT_ENABLED;
     } elseif ($event->getRegistrationDeadline() != NULL && $event->getRegistrationDeadline() < new \DateTime()) {
         $success = FALSE;
         $result = RegistrationResult::REGISTRATION_FAILED_DEADLINE_EXPIRED;
     } elseif ($event->getStartdate() < new \DateTime()) {
         $success = FALSE;
         $result = RegistrationResult::REGISTRATION_FAILED_EVENT_EXPIRED;
     } elseif ($event->getRegistration()->count() >= $event->getMaxParticipants() && $event->getMaxParticipants() > 0) {
         $success = FALSE;
         $result = RegistrationResult::REGISTRATION_FAILED_MAX_PARTICIPANTS;
     } elseif ($event->getFreePlaces() < $registration->getAmountOfRegistrations() && $event->getMaxParticipants() > 0) {
         $success = FALSE;
         $result = RegistrationResult::REGISTRATION_FAILED_NOT_ENOUGH_FREE_PLACES;
     } elseif ($event->getMaxRegistrationsPerUser() < $registration->getAmountOfRegistrations()) {
         $success = FALSE;
         $result = RegistrationResult::REGISTRATION_FAILED_MAX_AMOUNT_REGISTRATIONS_EXCEEDED;
     }
     return $success;
 }
 /**
  * @test
  * @return void
  */
 public function isWaitlistRegistrationReturnsTrueIfEventFullyBookedAndNotEnoughFreePlaces()
 {
     $registrations = $this->getMock('TYPO3\\CMS\\Extbase\\Persistence\\ObjectStorage', [], [], '', false);
     $registrations->expects($this->any())->method('count')->will($this->returnValue(11));
     $event = new Event();
     $event->setEnableWaitlist(true);
     $event->setMaxParticipants(10);
     $event->setRegistration($registrations);
     $this->assertTrue($this->subject->isWaitlistRegistration($event, 1));
 }
 /**
  * Returns if the given amount of registrations for the event will be registrations for the waitlist
  * (depending on the total amount of registrations and free places)
  *
  * @param \DERHANSEN\SfEventMgt\Domain\Model\Event $event
  * @param int $amountOfRegistrations
  * @return bool
  */
 public function isWaitlistRegistration($event, $amountOfRegistrations)
 {
     if ($event->getMaxParticipants() === 0 || !$event->getEnableWaitlist()) {
         return false;
     }
     $result = false;
     if ($event->getFreePlaces() > 0 && $event->getFreePlaces() < $amountOfRegistrations) {
         $result = true;
     } elseif ($event->getFreePlaces() <= 0) {
         $result = true;
     }
     return $result;
 }