예제 #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);
 }
 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
 public function HandleDataRequest($dataRequest)
 {
     $categoryId = $this->page->GetRequestedCategory();
     if (empty($categoryId)) {
         $categoryId = CustomAttributeCategory::RESERVATION;
     }
     $this->page->BindAttributes($this->attributeRepository->GetByCategory($categoryId));
 }
예제 #4
0
 /**
  * @param ReservationItemView $reservation
  * @param string $format
  * @return string
  */
 public function Format(ReservationItemView $reservation, $format = null)
 {
     $shouldHideUser = Configuration::Instance()->GetSectionKey(ConfigSection::PRIVACY, ConfigKeys::PRIVACY_HIDE_USER_DETAILS, new BooleanConverter());
     $shouldHideDetails = ReservationDetailsFilter::HideReservationDetails($reservation->StartDate, $reservation->EndDate);
     if (($shouldHideUser || $shouldHideDetails) && (is_null($this->user) || $this->user->UserId != $reservation->UserId && !$this->user->IsAdminForGroup($reservation->OwnerGroupIds()))) {
         return '';
     }
     if (empty($format)) {
         $format = Configuration::Instance()->GetSectionKey(ConfigSection::SCHEDULE, ConfigKeys::SCHEDULE_RESERVATION_LABEL);
     }
     if ($format == 'none' || empty($format)) {
         return '';
     }
     $name = $this->GetFullName($reservation);
     $timezone = 'UTC';
     $dateFormat = Resources::GetInstance()->GetDateFormat('res_popup');
     if (!is_null($this->user)) {
         $timezone = $this->user->Timezone;
     }
     $label = $format;
     $label = str_replace('{name}', $name, $label);
     $label = str_replace('{title}', $reservation->Title, $label);
     $label = str_replace('{description}', $reservation->Description, $label);
     $label = str_replace('{email}', $reservation->OwnerEmailAddress, $label);
     $label = str_replace('{organization}', $reservation->OwnerOrganization, $label);
     $label = str_replace('{phone}', $reservation->OwnerPhone, $label);
     $label = str_replace('{position}', $reservation->OwnerPosition, $label);
     $label = str_replace('{startdate}', $reservation->StartDate->ToTimezone($timezone)->Format($dateFormat), $label);
     $label = str_replace('{enddate}', $reservation->EndDate->ToTimezone($timezone)->Format($dateFormat), $label);
     $label = str_replace('{resourcename}', $reservation->ResourceName, $label);
     $label = str_replace('{participants}', trim(implode(', ', $reservation->ParticipantNames)), $label);
     $label = str_replace('{invitees}', trim(implode(', ', $reservation->InviteeNames)), $label);
     $matches = array();
     preg_match_all('/\\{(att\\d+?)\\}/', $format, $matches);
     $matches = $matches[0];
     if (count($matches) > 0) {
         for ($m = 0; $m < count($matches); $m++) {
             $id = filter_var($matches[$m], FILTER_SANITIZE_NUMBER_INT);
             $value = $reservation->GetAttributeValue($id);
             $label = str_replace($matches[$m], $value, $label);
         }
     }
     if (BookedStringHelper::Contains($label, '{reservationAttributes}')) {
         $attributesLabel = new StringBuilder();
         $attributes = $this->attributeRepository->GetByCategory(CustomAttributeCategory::RESERVATION);
         foreach ($attributes as $attribute) {
             $attributesLabel->Append($attribute->Label() . ': ' . $reservation->GetAttributeValue($attribute->Id()) . ', ');
         }
         $label = str_replace('{reservationAttributes}', rtrim($attributesLabel->ToString(), ', '), $label);
     }
     return $label;
 }
예제 #5
0
 /**
  * @param array $rows
  * @param IAttributeRepository $attributeRepository
  */
 public function __construct($rows, IAttributeRepository $attributeRepository)
 {
     $this->resultCount = count($rows);
     $this->cols = new ReportColumns();
     if (count($rows) > 0) {
         foreach ($rows[0] as $columnName => $value) {
             if ($columnName == ColumnNames::ATTRIBUTE_LIST) {
                 $attributes = $attributeRepository->GetByCategory(CustomAttributeCategory::RESERVATION);
                 foreach ($attributes as $attribute) {
                     $this->cols->AddAttribute(CustomAttributeCategory::RESERVATION, $attribute->Id(), $attribute->Label());
                 }
             } else {
                 if ($columnName == ColumnNames::USER_ATTRIBUTE_LIST) {
                     $attributes = $attributeRepository->GetByCategory(CustomAttributeCategory::USER);
                     foreach ($attributes as $attribute) {
                         $this->cols->AddAttribute(CustomAttributeCategory::USER, $attribute->Id(), $attribute->Label());
                     }
                 } else {
                     if ($columnName == ColumnNames::RESOURCE_ATTRIBUTE_LIST) {
                         $attributes = $attributeRepository->GetByCategory(CustomAttributeCategory::RESOURCE);
                         foreach ($attributes as $attribute) {
                             $this->cols->AddAttribute(CustomAttributeCategory::RESOURCE, $attribute->Id(), $attribute->Label());
                         }
                     } else {
                         if ($columnName == ColumnNames::RESOURCE_TYPE_ATTRIBUTE_LIST) {
                             $attributes = $attributeRepository->GetByCategory(CustomAttributeCategory::RESOURCE_TYPE);
                             foreach ($attributes as $attribute) {
                                 $this->cols->AddAttribute(CustomAttributeCategory::RESOURCE_TYPE, $attribute->Id(), $attribute->Label());
                             }
                         } else {
                             $this->cols->Add($columnName);
                         }
                     }
                 }
             }
         }
     }
     $this->data = new CustomReportData($rows);
 }
예제 #6
0
 public function GetByCategory($category)
 {
     return $this->attributeRepository->GetByCategory($category);
 }
예제 #7
0
 public function Bind(IReservationComponentInitializer $initializer)
 {
     $attributes = $this->repository->GetByCategory(CustomAttributeCategory::RESERVATION);
     foreach ($attributes as $attribute) {
         $initializer->AddAttribute($attribute, $this->reservationView->GetAttributeValue($attribute->Id()));
     }
 }
예제 #8
0
 public function PageLoad()
 {
     $hideUserInfo = Configuration::Instance()->GetSectionKey(ConfigSection::PRIVACY, ConfigKeys::PRIVACY_HIDE_USER_DETAILS, new BooleanConverter());
     $hideReservationDetails = Configuration::Instance()->GetSectionKey(ConfigSection::PRIVACY, ConfigKeys::PRIVACY_HIDE_RESERVATION_DETAILS, new BooleanConverter());
     $tz = ServiceLocator::GetServer()->GetUserSession()->Timezone;
     $reservation = $this->_reservationRepository->GetReservationForEditing($this->_page->GetReservationId());
     if (!$reservation->IsDisplayable()) {
         return;
     }
     if ($hideReservationDetails || $hideUserInfo) {
         $canViewDetails = $this->_reservationAuthorization->CanViewDetails($reservation, ServiceLocator::GetServer()->GetUserSession());
         $hideReservationDetails = !$canViewDetails && $hideReservationDetails;
         $hideUserInfo = !$canViewDetails && $hideUserInfo;
     }
     $this->_page->SetHideDetails($hideReservationDetails);
     $this->_page->SetHideUser($hideUserInfo);
     $startDate = $reservation->StartDate->ToTimezone($tz);
     $endDate = $reservation->EndDate->ToTimezone($tz);
     $this->_page->SetName($reservation->OwnerFirstName, $reservation->OwnerLastName);
     $this->_page->SetResources($reservation->Resources);
     $this->_page->SetParticipants($reservation->Participants);
     $this->_page->SetSummary($reservation->Description);
     $this->_page->SetTitle($reservation->Title);
     $this->_page->SetAccessories($reservation->Accessories);
     $this->_page->SetDates($startDate, $endDate);
     $attributes = $this->_attributeRepository->GetByCategory(CustomAttributeCategory::RESERVATION);
     $attributeValues = array();
     foreach ($attributes as $attribute) {
         $attributeValues[] = new Attribute($attribute, $reservation->GetAttributeValue($attribute->Id()));
     }
     $this->_page->BindAttributes($attributeValues);
 }