コード例 #1
0
 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);
 }
コード例 #2
0
 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));
     }
 }
コード例 #3
0
 /**
  * @param ReservationSeries $series
  * @return bool
  */
 private function EvaluateCustomRule($series)
 {
     Log::Debug('Evaluating custom pre reservation rule');
     // make your custom checks here
     $configFile = Configuration::Instance()->File('PreReservationExample');
     $maxValue = $configFile->GetKey('custom.attribute.max.value');
     $customAttributeId = $configFile->GetKey('custom.attribute.id');
     $attributeValue = $series->GetAttributeValue($customAttributeId);
     $isValid = $attributeValue <= $maxValue;
     if ($isValid) {
         return new ReservationValidationResult();
     }
     return new ReservationValidationResult(false, "Value of custom attribute cannot be greater than {$maxValue}");
 }