
Add bookable room to summit POST /api/v1/summits/{id}/locations/venues/{venue_id}/bookable-rooms payload time_slot_cost: required|numeric currency:required|iso_currency_code(USD,EUR) capacity:required|integer floor_id:sometimes|integer name:sometimes|string|max:255 description:sometimes|string order:sometimes|integer|min:1 update bookable room per summit PUT /api/v1/summits/{id}/locations/venues/{venue_id}/bookable-rooms/{room_id} payload time_slot_cost: required|numeric currency:required|iso_currency_code(USD,EUR) capacity:required|integer floor_id:sometimes|integer name:sometimes|string|max:255 description:sometimes|string order:sometimes|integer|min:1 delete bookable room DELETE /api/v1/summits/{id}/locations/venues/{venue_id}/bookable-rooms/{room_id} add attribute value to bookable room PUT /api/v1/summits/{id}/locations/venues/{venue_id}/bookable-rooms/{room_id}/attributes/{attribute_id} delete attribute value from bookable room DELETE /api/v1/summits/{id}/locations/venues/{venue_id}/bookable-rooms/{room_id}/attributes/{attribute_id} Added missing endpoints to CRUD bookable rooms attributes per summit Get all bookable rooms attribute types GET /api/v1/summits/{id}/bookable-room-attribute-types Get bookable room attribute type by id GET /api/v1/summits/{id}/bookable-room-attribute-types/{type_id} Add bookable room attribute type POST /api/v1/summits/{id}/bookable-room-attribute-types payload type [required|string] Update bookable room attribute type PUT /api/v1/summits/{id}/bookable-room-attribute-types/{type_id} payload type [required|string] delete attribute type by id DELETE /api/v1/summits/{id}/bookable-room-attribute-types/{type_id} get all attribute values by attribute type GET /api/v1/summits/{id}/bookable-room-attribute-types/{type_id}/values add attribute value to attribute type POST /api/v1/summits/{id}/bookable-room-attribute-types/{type_id}/values payload value [required|string] update attribute value PUT /api/v1/summits/{id}/bookable-room-attribute-types/{type_id}/values/{value_id} payload value [required|string] delete attribute value by id DELETE /api/v1/summits/{id}/bookable-room-attribute-types/{type_id}/values/{value_id} refund endpoint (admin only) DELETE /api/v1/summits/{id}/bookable-rooms/{room_id}/reservations/{reservation_id}/refund payload amount [numeric|required] get all reservations by summit (admin) GET /api/v1/summits/{id}/locations/bookable-rooms/all/reservations query params page:integer|min:1 per_page:required_with:page|integer|min:1|max:100 filter: allowed filters summit_id: ['=='] room_name: ['==', '=@'] room_id: ['=='] owner_id: ['=='] status: ['=='] start_datetime: ['>', '<', '<=', '>=', '=='] end_datetime: ['>', '<', '<=', '>=', '=='] order allowed ordering id,start_datetime,end_datetime Change-Id: Ic7f6ed7defaf20b8799a7d94beb0a82103b206f0
328 lines
7.4 KiB
PHP
328 lines
7.4 KiB
PHP
<?php namespace models\summit;
|
|
/**
|
|
* Copyright 2019 OpenStack Foundation
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
* you may not use this file except in compliance with the License.
|
|
* You may obtain a copy of the License at
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
* See the License for the specific language governing permissions and
|
|
* limitations under the License.
|
|
**/
|
|
use Doctrine\ORM\Mapping AS ORM;
|
|
use models\main\Member;
|
|
use models\utils\SilverstripeBaseModel;
|
|
/**
|
|
* @ORM\Entity(repositoryClass="App\Repositories\Summit\DoctrineSummitRoomReservationRepository")
|
|
* @ORM\Table(name="SummitRoomReservation")
|
|
* Class SummitRoomReservation
|
|
* @package models\summit
|
|
*/
|
|
class SummitRoomReservation extends SilverstripeBaseModel
|
|
{
|
|
/**
|
|
* @var \DateTime
|
|
* @ORM\Column(name="StartDateTime", type="datetime")
|
|
*/
|
|
private $start_datetime;
|
|
|
|
/**
|
|
* @var \DateTime
|
|
* @ORM\Column(name="EndDateTime", type="datetime")
|
|
*/
|
|
private $end_datetime;
|
|
|
|
/**
|
|
* @var \DateTime
|
|
* @ORM\Column(name="ApprovedPaymentDate", type="datetime")
|
|
*/
|
|
private $approved_payment_date;
|
|
|
|
/**
|
|
* @var string
|
|
* @ORM\Column(name="Status", type="string")
|
|
*/
|
|
private $status;
|
|
|
|
/**
|
|
* @var string
|
|
* @ORM\Column(name="LastError", type="string")
|
|
*/
|
|
private $last_error;
|
|
|
|
/**
|
|
* @var string
|
|
* @ORM\Column(name="PaymentGatewayCartId", type="string")
|
|
*/
|
|
private $payment_gateway_cart_id;
|
|
|
|
/**
|
|
* @var string
|
|
*/
|
|
private $payment_gateway_client_token;
|
|
|
|
/**
|
|
* @var string
|
|
* @ORM\Column(name="Currency", type="string")
|
|
*/
|
|
private $currency;
|
|
|
|
/**
|
|
* @var float
|
|
* @ORM\Column(name="Amount", type="float")
|
|
*/
|
|
private $amount;
|
|
|
|
/**
|
|
* @ORM\ManyToOne(targetEntity="models\main\Member", inversedBy="reservations")
|
|
* @ORM\JoinColumn(name="OwnerID", referencedColumnName="ID")
|
|
* @var Member
|
|
*/
|
|
private $owner;
|
|
|
|
/**
|
|
* @ORM\ManyToOne(targetEntity="models\summit\SummitBookableVenueRoom", inversedBy="reservations")
|
|
* @ORM\JoinColumn(name="RoomID", referencedColumnName="ID")
|
|
* @var SummitBookableVenueRoom
|
|
*/
|
|
private $room;
|
|
|
|
const ReservedStatus = "Reserved";
|
|
const ErrorStatus = "Error";
|
|
const PayedStatus = "Payed";
|
|
const RequestedRefundStatus = "RequestedRefund";
|
|
const RefundedStatus = "Refunded";
|
|
|
|
public static $valid_status = [
|
|
self::ReservedStatus,
|
|
self::PayedStatus,
|
|
self::RequestedRefundStatus,
|
|
self::RefundedStatus,
|
|
self::ErrorStatus,
|
|
];
|
|
|
|
/**
|
|
* @return \DateTime
|
|
*/
|
|
public function getStartDatetime(): \DateTime
|
|
{
|
|
return $this->start_datetime;
|
|
}
|
|
|
|
/**
|
|
* @return \DateTime
|
|
*/
|
|
public function getLocalStartDatetime(): \DateTime
|
|
{
|
|
return $this->room->getSummit()->convertDateFromUTC2TimeZone($this->start_datetime);
|
|
}
|
|
|
|
/**
|
|
* @param \DateTime $start_datetime
|
|
*/
|
|
public function setStartDatetime(\DateTime $start_datetime): void
|
|
{
|
|
$this->start_datetime = $start_datetime;
|
|
}
|
|
|
|
/**
|
|
* @return \DateTime
|
|
*/
|
|
public function getEndDatetime(): \DateTime
|
|
{
|
|
return $this->end_datetime;
|
|
}
|
|
|
|
/**
|
|
* @return \DateTime
|
|
*/
|
|
public function getLocalEndDatetime(): \DateTime
|
|
{
|
|
return $this->room->getSummit()->convertDateFromUTC2TimeZone($this->end_datetime);
|
|
}
|
|
|
|
/**
|
|
* @param \DateTime $end_datetime
|
|
*/
|
|
public function setEndDatetime(\DateTime $end_datetime): void
|
|
{
|
|
$this->end_datetime = $end_datetime;
|
|
}
|
|
|
|
/**
|
|
* @return string
|
|
*/
|
|
public function getStatus(): string
|
|
{
|
|
return $this->status;
|
|
}
|
|
|
|
/**
|
|
* @param string $status
|
|
*/
|
|
public function setStatus(string $status): void
|
|
{
|
|
$this->status = $status;
|
|
}
|
|
|
|
/**
|
|
* @return Member
|
|
*/
|
|
public function getOwner(): Member
|
|
{
|
|
return $this->owner;
|
|
}
|
|
|
|
/**
|
|
* @param Member $owner
|
|
*/
|
|
public function setOwner(Member $owner): void
|
|
{
|
|
$this->owner = $owner;
|
|
}
|
|
|
|
/**
|
|
* @return SummitBookableVenueRoom
|
|
*/
|
|
public function getRoom(): SummitBookableVenueRoom
|
|
{
|
|
return $this->room;
|
|
}
|
|
|
|
/**
|
|
* @param SummitBookableVenueRoom $room
|
|
*/
|
|
public function setRoom(SummitBookableVenueRoom $room): void
|
|
{
|
|
$this->room = $room;
|
|
}
|
|
|
|
/**
|
|
* @return string
|
|
*/
|
|
public function getPaymentGatewayCartId(): string
|
|
{
|
|
return $this->payment_gateway_cart_id;
|
|
}
|
|
|
|
/**
|
|
* @param string $payment_gateway_cart_id
|
|
*/
|
|
public function setPaymentGatewayCartId(string $payment_gateway_cart_id): void
|
|
{
|
|
$this->payment_gateway_cart_id = $payment_gateway_cart_id;
|
|
}
|
|
|
|
/**
|
|
* @return \DateTime|null
|
|
*/
|
|
public function getApprovedPaymentDate(): ?\DateTime
|
|
{
|
|
return $this->approved_payment_date;
|
|
}
|
|
|
|
/**
|
|
* @param \DateTime $approved_payment_date
|
|
*/
|
|
public function setApprovedPaymentDate(\DateTime $approved_payment_date): void
|
|
{
|
|
$this->approved_payment_date = $approved_payment_date;
|
|
}
|
|
|
|
/**
|
|
* @return string
|
|
*/
|
|
public function getCurrency(): string
|
|
{
|
|
return $this->currency;
|
|
}
|
|
|
|
/**
|
|
* @param string $currency
|
|
*/
|
|
public function setCurrency(string $currency): void
|
|
{
|
|
$this->currency = $currency;
|
|
}
|
|
|
|
/**
|
|
* @return float
|
|
*/
|
|
public function getAmount(): float
|
|
{
|
|
return $this->amount;
|
|
}
|
|
|
|
/**
|
|
* @param float $amount
|
|
*/
|
|
public function setAmount(float $amount): void
|
|
{
|
|
$this->amount = $amount;
|
|
}
|
|
|
|
public function __construct()
|
|
{
|
|
parent::__construct();
|
|
$this->amount = 0.0;
|
|
$this->status = self::ReservedStatus;
|
|
}
|
|
|
|
/**
|
|
* @return string|null
|
|
*/
|
|
public function getPaymentGatewayClientToken(): ?string
|
|
{
|
|
return $this->payment_gateway_client_token;
|
|
}
|
|
|
|
/**
|
|
* @param string $payment_gateway_client_token
|
|
*/
|
|
public function setPaymentGatewayClientToken(string $payment_gateway_client_token): void
|
|
{
|
|
$this->payment_gateway_client_token = $payment_gateway_client_token;
|
|
}
|
|
|
|
public function setPayed():void{
|
|
$this->status = self::PayedStatus;
|
|
$now = new \DateTime('now', new \DateTimeZone('UTC'));
|
|
$this->approved_payment_date = $now;
|
|
}
|
|
|
|
public function requestRefund():void{
|
|
$this->status = self::RequestedRefundStatus;
|
|
}
|
|
|
|
public function setPaymentError(string $error):void{
|
|
$this->status = self::ErrorStatus;
|
|
$this->last_error = $error;
|
|
}
|
|
|
|
/**
|
|
* @return int
|
|
*/
|
|
public function getOwnerId(){
|
|
try {
|
|
return is_null($this->owner) ? 0 : $this->owner->getId();
|
|
}
|
|
catch(\Exception $ex){
|
|
return 0;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* @return int
|
|
*/
|
|
public function getRoomId(){
|
|
try {
|
|
return is_null($this->room) ? 0 : $this->room->getId();
|
|
}
|
|
catch(\Exception $ex){
|
|
return 0;
|
|
}
|
|
}
|
|
|
|
} |