protected function PopulateTemplate() { $currentInstance = $this->reservationSeries->CurrentInstance(); $this->Set('UserName', $this->reservationOwner->FullName()); $this->Set('StartDate', $currentInstance->StartDate()->ToTimezone($this->timezone)); $this->Set('EndDate', $currentInstance->EndDate()->ToTimezone($this->timezone)); $this->Set('ResourceName', $this->reservationSeries->Resource()->GetName()); $this->Set('Title', $this->reservationSeries->Title()); $this->Set('Description', $this->reservationSeries->Description()); $repeatDates = array(); if ($this->reservationSeries->IsRecurring()) { foreach ($this->reservationSeries->Instances() as $repeated) { $repeatDates[] = $repeated->StartDate()->ToTimezone($this->timezone); } } $this->Set('RepeatDates', $repeatDates); $this->Set('RequiresApproval', $this->reservationSeries->RequiresApproval()); $this->Set('ReservationUrl', sprintf("%s?%s=%s", Pages::RESERVATION, QueryStringKeys::REFERENCE_NUMBER, $currentInstance->ReferenceNumber())); $this->Set('ICalUrl', sprintf("export/%s?%s=%s", Pages::CALENDAR_EXPORT, QueryStringKeys::REFERENCE_NUMBER, $currentInstance->ReferenceNumber())); $resourceNames = array(); foreach ($this->reservationSeries->AllResources() as $resource) { $resourceNames[] = $resource->GetName(); } $this->Set('ResourceNames', $resourceNames); $this->Set('Accessories', $this->reservationSeries->Accessories()); $attributes = $this->attributeRepository->GetByCategory(CustomAttributeCategory::RESERVATION); $attributeValues = array(); foreach ($attributes as $attribute) { $attributeValues[] = new Attribute($attribute, $this->reservationSeries->GetAttributeValue($attribute->Id())); } $this->Set('Attributes', $attributeValues); }
private function PopulateTemplate() { $this->Set('UserName', $this->reservationOwner->FullName()); $currentInstance = $this->reservationSeries->CurrentInstance(); $this->Set('StartDate', $currentInstance->StartDate()->ToTimezone($this->timezone)); $this->Set('EndDate', $currentInstance->EndDate()->ToTimezone($this->timezone)); $this->Set('ResourceName', $this->resource->GetName()); $this->Set('Title', $this->reservationSeries->Title()); $this->Set('Description', $this->reservationSeries->Description()); $repeatDates = array(); foreach ($this->reservationSeries->Instances() as $repeated) { $repeatDates[] = $repeated->StartDate()->ToTimezone($this->timezone); } $this->Set('RequiresApproval', $this->reservationSeries->RequiresApproval()); $this->Set('RepeatDates', $repeatDates); $this->Set('ReservationUrl', Pages::RESERVATION . "?" . QueryStringKeys::REFERENCE_NUMBER . '=' . $currentInstance->ReferenceNumber()); $resourceNames = array(); foreach ($this->reservationSeries->AllResources() as $resource) { $resourceNames[] = $resource->GetName(); } $this->Set('ResourceNames', $resourceNames); $this->Set('Accessories', $this->reservationSeries->Accessories()); $attributes = $this->attributeRepository->GetByCategory(CustomAttributeCategory::RESERVATION); $attributeValues = array(); foreach ($attributes as $attribute) { $attributeValues[] = new Attribute($attribute, $this->reservationSeries->GetAttributeValue($attribute->Id())); } $this->Set('Attributes', $attributeValues); $bookedBy = $this->reservationSeries->BookedBy(); if ($bookedBy != null && $bookedBy->UserId != $this->reservationOwner->Id()) { $this->Set('CreatedBy', new FullName($bookedBy->FirstName, $bookedBy->LastName)); } }
/** * @param ReservationSeries $reservationSeries * @return int newly created series_id */ private function InsertSeries(ReservationSeries $reservationSeries) { $database = ServiceLocator::GetDatabase(); $insertReservationSeries = new AddReservationSeriesCommand(Date::Now(), $reservationSeries->Title(), $reservationSeries->Description(), $reservationSeries->RepeatOptions()->RepeatType(), $reservationSeries->RepeatOptions()->ConfigurationString(), ReservationTypes::Reservation, $reservationSeries->StatusId(), $reservationSeries->UserId(), $reservationSeries->GetAllowParticipation()); $reservationSeriesId = $database->ExecuteInsert($insertReservationSeries); $reservationSeries->WithSeriesId($reservationSeriesId); $insertReservationResource = new AddReservationResourceCommand($reservationSeriesId, $reservationSeries->ResourceId(), ResourceLevel::Primary); $database->Execute($insertReservationResource); foreach ($reservationSeries->AdditionalResources() as $resource) { $insertReservationResource = new AddReservationResourceCommand($reservationSeriesId, $resource->GetResourceId(), ResourceLevel::Additional); $database->Execute($insertReservationResource); } foreach ($reservationSeries->Accessories() as $accessory) { $insertAccessory = new AddReservationAccessoryCommand($accessory->AccessoryId, $accessory->QuantityReserved, $reservationSeriesId); $database->Execute($insertAccessory); } foreach ($reservationSeries->AttributeValues() as $attribute) { $insertAttributeValue = new AddAttributeValueCommand($attribute->AttributeId, $attribute->Value, $reservationSeriesId, CustomAttributeCategory::RESERVATION); $database->Execute($insertAttributeValue); } foreach ($reservationSeries->AddedAttachments() as $attachment) { $this->AddReservationAttachment($attachment); } if ($reservationSeries->GetStartReminder()->Enabled()) { $reminder = $reservationSeries->GetStartReminder(); $insertAccessory = new AddReservationReminderCommand($reservationSeriesId, $reminder->MinutesPrior(), ReservationReminderType::Start); $database->Execute($insertAccessory); } if ($reservationSeries->GetEndReminder()->Enabled()) { $reminder = $reservationSeries->GetEndReminder(); $insertAccessory = new AddReservationReminderCommand($reservationSeriesId, $reminder->MinutesPrior(), ReservationReminderType::End); $database->Execute($insertAccessory); } return $reservationSeriesId; }