class PricingEvent in Rooms - Drupal Booking for Hotels, B&Bs and Vacation Rentals 7
@file contains PricingEvent.
Hierarchy
- class \RoomsEvent implements RoomsEventInterface
- class \PricingEvent implements PricingEventInterface
Expanded class hierarchy of PricingEvent
File
- modules/
rooms_pricing/ includes/ rooms_pricing.pricing_event.inc, line 8 - contains PricingEvent.
View source
class PricingEvent extends RoomsEvent implements PricingEventInterface {
/**
* The amount for this period.
*
* @var int
*/
public $amount;
/**
* The operation to perform.
*
* @var string
*/
public $operation;
/**
* Constructs a BookingPrice item.
*
* @param int $unit_id
* The unit ID.
* @param int $amount
* The booking amount.
* @param DateTime $start_date
* The start date of the event.
* @param DateTime $end_date
* The start date of the event.
* @param string $operation
* The operation to perform.
*/
public function __construct($unit_id, $amount, $start_date, $end_date, $operation = '') {
$this->unit_id = $unit_id;
$this->amount = $amount;
$this->start_date = $start_date;
$this->end_date = $end_date;
$this->operation = $operation;
}
/**
* {@inheritdoc}
*/
protected function createEvent(DateTime $start_date, DateTime $end_date) {
return new PricingEvent($this->unit_id, $this->amount, $start_date, $end_date, $this->operation);
}
/**
* {@inheritdoc}
*/
public function applyOperation($amount, $operation) {
switch ($operation) {
case ROOMS_REPLACE:
$this->amount = $amount;
break;
case ROOMS_ADD:
$this->amount = $this->amount + $amount;
break;
case ROOMS_SUB:
$this->amount = $this->amount - $amount;
break;
case ROOMS_INCREASE:
$this->amount = $this->amount + $this->amount * ($amount / 100);
break;
case ROOMS_DECREASE:
$this->amount = $this->amount - $this->amount * ($amount / 100);
break;
default:
break;
}
}
/**
* {@inheritdoc}
*/
public function formatJson() {
$amount = $this->amount;
$event = array(
"id" => $amount,
"start" => $this
->startYear() . '-' . $this
->startMonth('m') . '-' . $this
->startDay('d') . 'T13:00:00',
"end" => $this
->endYear() . '-' . $this
->endMonth('m') . '-' . $this
->endDay('d') . 'T13:00:00',
);
// Set the color.
if ($amount < 100) {
$event['color'] = variable_get('rooms_price_low_value_color', '#F3C776');
$event['title'] = $amount;
}
elseif ($amount >= 100) {
$event['color'] = variable_get('rooms_price_high_value_color', '#9DDC9D');
$event['title'] = $amount;
}
return $event;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
PricingEvent:: |
public | property | The amount for this period. | |
PricingEvent:: |
public | property | The operation to perform. | |
PricingEvent:: |
public | function |
Applies an operation against a Price event. Overrides PricingEventInterface:: |
|
PricingEvent:: |
protected | function |
Creates a new event Overrides RoomsEvent:: |
|
PricingEvent:: |
public | function |
Returns event in a format amenable to FullCalendar display or generally
sensible json. Overrides PricingEventInterface:: |
|
PricingEvent:: |
public | function | Constructs a BookingPrice item. | |
RoomsEvent:: |
public | property | The end date for the event. | |
RoomsEvent:: |
public | property | The default state for the room if it has no specific booking. | |
RoomsEvent:: |
public | property | The booking unit the event is relevant to | |
RoomsEvent:: |
public | function |
Returns the date interval between end and start date. Overrides RoomsEventInterface:: |
|
RoomsEvent:: |
public | function |
Returns the booking end day. Overrides RoomsEventInterface:: |
|
RoomsEvent:: |
public | function |
Returns the booking end month. Overrides RoomsEventInterface:: |
|
RoomsEvent:: |
public | function |
Returns the booking end year. Overrides RoomsEventInterface:: |
|
RoomsEvent:: |
public | function |
Checks if the event starts and ends in the same month. Overrides RoomsEventInterface:: |
|
RoomsEvent:: |
public | function |
Checks if the event starts and ends in the same year. Overrides RoomsEventInterface:: |
|
RoomsEvent:: |
public | function |
Returns the booking start day. Overrides RoomsEventInterface:: |
|
RoomsEvent:: |
public | function |
Returns the booking start month. Overrides RoomsEventInterface:: |
|
RoomsEvent:: |
public | function |
Returns the booking start year. Overrides RoomsEventInterface:: |
|
RoomsEvent:: |
public | function |
Takes a single event that spans several months and transforms it to
monthly events - this assumes that the event is contained within a year Overrides RoomsEventInterface:: |
|
RoomsEvent:: |
public | function |
Takes an event that spans several years and transforms it to yearly events Overrides RoomsEventInterface:: |