/**
  * Sets this registration's data if this registration is newly created instead of from a DB query.
  *
  * This function must be called directly after construction or this object will not be usable.
  *
  * @param tx_seminars_seminar $seminar the seminar object (that's the seminar we would like to register for)
  * @param int $userUid UID of the FE user who wants to sign up
  * @param array $registrationData associative array with the registration data the user has just entered, may be empty
  *
  * @return void
  */
 public function setRegistrationData(tx_seminars_seminar $seminar, $userUid, array $registrationData)
 {
     $this->seminar = $seminar;
     $this->recordData = array();
     $this->recordData['seminar'] = $seminar->getUid();
     $this->recordData['user'] = $userUid;
     $this->recordData['registration_queue'] = !$seminar->hasVacancies() ? 1 : 0;
     $seats = (int) $registrationData['seats'];
     if ($seats < 1) {
         $seats = 1;
     }
     $this->recordData['seats'] = $seats;
     $this->recordData['registered_themselves'] = $registrationData['registered_themselves'] ? 1 : 0;
     $availablePrices = $seminar->getAvailablePrices();
     // If no (available) price is selected, use the first price by default.
     $selectedPrice = isset($registrationData['price']) && $seminar->isPriceAvailable($registrationData['price']) ? $registrationData['price'] : key($availablePrices);
     $this->recordData['price'] = $availablePrices[$selectedPrice]['caption'];
     $this->recordData['total_price'] = $seats * $availablePrices[$selectedPrice]['amount'];
     $this->recordData['attendees_names'] = $registrationData['attendees_names'];
     $this->recordData['kids'] = $registrationData['kids'];
     $methodOfPayment = $registrationData['method_of_payment'];
     // Auto-select the only payment method if no payment method has been
     // selected, there actually is anything to pay and only one payment
     // method is provided.
     if (!$methodOfPayment && $this->recordData['total_price'] > 0.0 && $seminar->getNumberOfPaymentMethods() == 1) {
         $rows = tx_oelib_db::selectMultiple('uid', 'tx_seminars_payment_methods, tx_seminars_seminars_payment_methods_mm', 'tx_seminars_payment_methods.uid = tx_seminars_seminars_payment_methods_mm.uid_foreign ' . 'AND tx_seminars_seminars_payment_methods_mm.uid_local = ' . $seminar->getTopicUid() . tx_oelib_db::enableFields('tx_seminars_payment_methods'), '', 'tx_seminars_seminars_payment_methods_mm.sorting');
         $methodOfPayment = $rows[0]['uid'];
     }
     $this->recordData['method_of_payment'] = $methodOfPayment;
     $this->recordData['account_number'] = $registrationData['account_number'];
     $this->recordData['bank_code'] = $registrationData['bank_code'];
     $this->recordData['bank_name'] = $registrationData['bank_name'];
     $this->recordData['account_owner'] = $registrationData['account_owner'];
     $this->recordData['company'] = $registrationData['company'];
     $this->recordData['gender'] = $registrationData['gender'];
     $this->recordData['name'] = $registrationData['name'];
     $this->recordData['address'] = $registrationData['address'];
     $this->recordData['zip'] = $registrationData['zip'];
     $this->recordData['city'] = $registrationData['city'];
     $this->recordData['country'] = $registrationData['country'];
     $this->recordData['telephone'] = $registrationData['telephone'];
     $this->recordData['email'] = $registrationData['email'];
     $this->lodgings = isset($registrationData['lodgings']) && is_array($registrationData['lodgings']) ? $registrationData['lodgings'] : array();
     $this->recordData['lodgings'] = count($this->lodgings);
     $this->foods = isset($registrationData['foods']) && is_array($registrationData['foods']) ? $registrationData['foods'] : array();
     $this->recordData['foods'] = count($this->foods);
     $this->checkboxes = isset($registrationData['checkboxes']) && is_array($registrationData['checkboxes']) ? $registrationData['checkboxes'] : array();
     $this->recordData['checkboxes'] = count($this->checkboxes);
     $this->recordData['interests'] = $registrationData['interests'];
     $this->recordData['expectations'] = $registrationData['expectations'];
     $this->recordData['background_knowledge'] = $registrationData['background_knowledge'];
     $this->recordData['accommodation'] = $registrationData['accommodation'];
     $this->recordData['food'] = $registrationData['food'];
     $this->recordData['known_from'] = $registrationData['known_from'];
     $this->recordData['notes'] = $registrationData['notes'];
     $this->recordData['pid'] = $this->seminar->hasAttendancesPid() ? $this->seminar->getAttendancesPid() : $this->getConfValueInteger('attendancesPID');
     $this->processAdditionalRegistrationData($registrationData);
     if ($this->isOk()) {
         // Stores the user data in $this->userData.
         $this->retrieveUserData();
         $this->createTitle();
     }
 }
 /**
  * Gets the CSS classes (space-separated) for the Vacancies TD.
  *
  * @param tx_seminars_seminar $seminar the current seminar object
  *
  * @return string class attribute value filled with a list a space-separated CSS classes
  */
 public function getVacanciesClasses(tx_seminars_seminar $seminar)
 {
     if (!$seminar->needsRegistration() || !$seminar->hasDate() && !$this->configGetter->getConfValueBoolean('allowRegistrationForEventsWithoutDate')) {
         return '';
     }
     $classes = array();
     if ($seminar->hasDate() && $seminar->hasStarted()) {
         $classes[] = 'event-begin-date-over';
     }
     if ($seminar->hasVacancies()) {
         $classes[] = 'vacancies-available';
         if ($seminar->hasUnlimitedVacancies()) {
             $classes[] = 'vacancies-unlimited';
         } else {
             $classes[] = 'vacancies-' . $seminar->getVacancies();
         }
     } else {
         $classes[] = 'vacancies-0';
         if ($seminar->hasRegistrationQueue()) {
             $classes[] = 'has-registration-queue';
         }
     }
     // We add this class in addition to the number of vacancies so that
     // user stylesheets still can use the number of vacancies even for
     // events for which the registration deadline is over.
     if ($seminar->hasDate() && $seminar->isRegistrationDeadlineOver()) {
         $classes[] = 'registration-deadline-over';
     }
     $prefixedClasses = array_map(array($this, 'pi_getClassName'), $classes);
     return ' ' . implode(' ', $prefixedClasses);
 }
 /**
  * Checks whether the given event allows registration as far as the number of vacancies are concerned.
  *
  * @param tx_seminars_seminar $event the event to check the registration for
  *
  * @return bool TRUE if the event has enough seats for registration, FALSE otherwise
  */
 public function allowsRegistrationBySeats(tx_seminars_seminar $event)
 {
     return $event->hasRegistrationQueue() || $event->hasUnlimitedVacancies() || $event->hasVacancies();
 }