Esempio n. 1
0
 /**
  * @param IRestServer $server
  * @param BookableResource $resource
  * @param IEntityAttributeList $attributes
  */
 public function __construct(IRestServer $server, $resource, $attributes)
 {
     $resourceId = $resource->GetId();
     $this->resourceId = $resourceId;
     $this->name = $resource->GetName();
     $this->location = $resource->GetLocation();
     $this->contact = $resource->GetContact();
     $this->notes = $resource->GetNotes();
     $this->maxLength = $resource->GetMaxLength()->__toString();
     $this->minLength = $resource->GetMinLength()->__toString();
     $this->maxNotice = $resource->GetMaxNotice()->__toString();
     $this->minNotice = $resource->GetMinNotice()->__toString();
     $this->requiresApproval = $resource->GetRequiresApproval();
     $this->allowMultiday = $resource->GetAllowMultiday();
     $this->maxParticipants = $resource->GetMaxParticipants();
     $this->description = $resource->GetDescription();
     $this->scheduleId = $resource->GetScheduleId();
     $this->statusId = $resource->GetStatusId();
     $this->statusReasonId = $resource->GetStatusReasonId();
     $this->bufferTime = $resource->GetBufferTime()->__toString();
     $attributeValues = $attributes->GetAttributes($resourceId);
     $i = 0;
     foreach ($attributeValues as $av) {
         $this->customAttributes[] = new CustomAttributeResponse($server, $av->Id(), $av->Label(), $av->Value());
         $i++;
     }
     if ($resource->GetIsCalendarSubscriptionAllowed()) {
         $url = new CalendarSubscriptionUrl(null, null, $resource->GetPublicId());
         $this->icsUrl = $url->__toString();
     }
     $this->AddService($server, WebServices::GetResource, array(WebServiceParams::ResourceId => $resourceId));
 }
Esempio n. 2
0
 /**
  * @param IRestServer $server
  * @param BookableResource $resource
  */
 public function __construct(IRestServer $server, $resource)
 {
     $this->resourceId = $resource->GetId();
     $this->name = $resource->GetName();
     $this->scheduleId = $resource->GetScheduleId();
     $this->statusId = $resource->GetStatusId();
     $this->statusReasonId = $resource->GetStatusReasonId();
     $this->AddService($server, WebServices::GetResource, array(WebServiceParams::ResourceId => $this->resourceId));
     $this->AddService($server, WebServices::GetSchedule, array(WebServiceParams::ScheduleId => $this->scheduleId));
 }
 /**
  * @param IRestServer $server
  * @param BookableResource $resource
  * @param ReservationItemView|null $conflictingReservation
  * @param ReservationItemView|null $nextReservation
  * @param Date|null $nextAvailableTime
  */
 public function __construct(IRestServer $server, $resource, $conflictingReservation, $nextReservation, $nextAvailableTime)
 {
     $this->resource = new ResourceReference($server, $resource);
     $this->available = $conflictingReservation == null;
     $this->AddService($server, WebServices::GetResource, array(WebServiceParams::ResourceId => $resource->GetId()));
     if (!$this->available) {
         $this->availableAt = $nextAvailableTime != null ? $nextAvailableTime->ToTimezone($server->GetSession()->Timezone)->ToIso() : null;
         $this->AddService($server, WebServices::GetUser, array(WebServiceParams::UserId => $conflictingReservation->UserId));
         $this->AddService($server, WebServices::GetReservation, array(WebServiceParams::ReferenceNumber => $conflictingReservation->ReferenceNumber));
     }
     if ($this->available && $nextReservation != null) {
         $this->availableUntil = $nextReservation->BufferedTimes()->GetBegin()->ToTimezone($server->GetSession()->Timezone)->ToIso();
     }
 }
 /**
  * @param int $userId
  * @param BookableResource $resource
  * @param string $title
  * @param string $description
  * @param UserSession $updatedBy
  */
 public function Update($userId, BookableResource $resource, $title, $description, UserSession $updatedBy)
 {
     $this->_bookedBy = $updatedBy;
     if ($this->seriesUpdateStrategy->RequiresNewSeries()) {
         $this->AddEvent(new SeriesBranchedEvent($this));
         $this->Repeats($this->seriesUpdateStrategy->GetRepeatOptions($this));
     }
     if ($this->_resource->GetId() != $resource->GetId()) {
         $this->AddEvent(new ResourceRemovedEvent($this->_resource, $this));
         $this->AddEvent(new ResourceAddedEvent($resource, ResourceLevel::Primary, $this));
     }
     if ($this->UserId() != $userId) {
         $this->AddEvent(new OwnerChangedEvent($this, $this->UserId(), $userId));
     }
     $this->_userId = $userId;
     $this->_resource = $resource;
     $this->_title = $title;
     $this->_description = $description;
 }
 public static function FromBookable(BookableResource $resource)
 {
     return new AdminResourceJson($resource->GetId(), $resource->GetName());
 }
Esempio n. 6
0
 public function Update(BookableResource $resource)
 {
     $db = ServiceLocator::GetDatabase();
     $updateResourceCommand = new UpdateResourceCommand($resource->GetResourceId(), $resource->GetName(), $resource->GetLocation(), $resource->GetContact(), $resource->GetNotes(), $resource->GetMinLength(), $resource->GetMaxLength(), $resource->GetAutoAssign(), $resource->GetRequiresApproval(), $resource->GetAllowMultiday(), $resource->GetMaxParticipants(), $resource->GetMinNotice(), $resource->GetMaxNotice(), $resource->GetDescription(), $resource->GetImage(), $resource->GetScheduleId(), $resource->GetAdminGroupId(), $resource->GetIsCalendarSubscriptionAllowed(), $resource->GetPublicId(), $resource->GetSortOrder(), $resource->GetResourceTypeId(), $resource->GetStatusId(), $resource->GetStatusReasonId(), $resource->GetBufferTime());
     $db->Execute($updateResourceCommand);
     foreach ($resource->GetRemovedAttributes() as $removed) {
         $db->Execute(new RemoveAttributeValueCommand($removed->AttributeId, $resource->GetId()));
     }
     foreach ($resource->GetAddedAttributes() as $added) {
         $db->Execute(new AddAttributeValueCommand($added->AttributeId, $added->Value, $resource->GetId(), CustomAttributeCategory::RESOURCE));
     }
     if ($resource->WasAutoAssignToggledOn()) {
         $db->Execute(new AutoAssignResourcePermissionsCommand($resource->GetId()));
     }
 }
Esempio n. 7
0
 /**
  * @param BookableResource $resource
  * @param ReservationItemView[][] $reservations
  * @return null|ReservationItemView
  */
 private function GetLastReservationBeforeAnOpening($resource, $reservations)
 {
     $resourceId = $resource->GetId();
     if (!array_key_exists($resourceId, $reservations)) {
         return null;
     }
     $resourceReservations = $reservations[$resourceId];
     for ($i = 0; $i < count($resourceReservations) - 1; $i++) {
         $current = $resourceReservations[$i];
         $next = $resourceReservations[$i + 1];
         if ($current->EndDate->Equals($next->StartDate)) {
             continue;
         }
         return $current;
     }
     return $resourceReservations[count($resourceReservations) - 1];
 }