PATH:
home
/
ediuae
/
petalwellnessspa.com
/
wp-content
/
plugins
/
simply-schedule-appointments
/
includes
<?php /** * Simply Schedule Appointments Period Object. * * @since 3.6.2 * @package Simply_Schedule_Appointments */ use League\Period\Period; /** * Simply Schedule Appointments Period Object. * * @since 3.6.2 */ class SSA_Period { private $raw_start_date; private $raw_end_date; private $appointment_type_object; private $appointment_type_id; private $appointment_object; private $appointment_id; /* calculated variables */ private $buffer_before_period; private $raw_period; private $buffer_after_period; private $full_buffered_period; /** * Constructor. * * @since 3.6.2 */ public function __construct() { } public static function create_from_dates( $start_date, $end_date ) { $period = new Period( $start_date, $end_date ); $ssa_period = self::create_from_period( $period ); return $ssa_period; } public static function create_from_appointment_id( $appointment_id ) { $ssa_period = new self; $ssa_period->set_appointment_object( $appointment_id ); return $ssa_period; } public static function create_from_appointment_type_duration( $start_date, $appointment_type ) { $ssa_period = new self; $ssa_period->raw_start_date = ssa_datetime( $start_date ); $ssa_period->set_appointment_type_object( $appointment_type ); return $ssa_period; } public static function create_from_period( Period $period, $appointment_type_object = null ) { $ssa_period = new self; $ssa_period->raw_period = $period; if ( ! empty( $appointment_type_object ) ) { // phpcs:ignore $this->set_appointment_type_object( $appointment_type_object ); } else { $ssa_period->buffer_before_period = false; $ssa_period->buffer_after_period = false; $ssa_period->full_buffered_period = $ssa_period->raw_period; } return $ssa_period; } public static function extend_buffered_period_by_one_week_on_each_side( Period $buffered_period ) { $extended_buffered_period = new Period( $buffered_period->getStartDate()->sub( new DateInterval( 'P1W' ) ), $buffered_period->getEndDate()->add( new DateInterval( 'P1W' ) ) ); return $extended_buffered_period; } /** * Initiate our hooks. * * @since 3.6.2 */ public function hooks() { } public function get_appointment_type_object() { if ( ! empty( $this->appointment_type_object ) ) { return $this->appointment_type_object; } } /** * calculate_raw_period * * update raw period based on other instance variables * * @return void * @author **/ public function get_raw_period() { if ( null !== $this->raw_period ) { return $this->raw_period; } $this->calculate_raw_period_by_instance_variables(); $this->calculate_raw_period_by_appointment_id(); $this->calculate_raw_period_by_appointment_type_id(); return $this->raw_period; } public function get_full_buffered_period() { if ( null !== $this->full_buffered_period ) { return $this->full_buffered_period; } $buffer_before_period = $this->get_buffer_before_period(); if ( empty( $buffer_before_period ) ) { $start_date = $this->get_raw_period()->getStartDate(); } else { $start_date = $buffer_before_period->getStartDate(); } $buffer_after_period = $this->get_buffer_after_period(); if ( empty( $buffer_after_period ) ) { $end_date = $this->get_raw_period()->getEndDate(); } else { $end_date = $buffer_after_period->getEndDate(); } $this->full_buffered_period = new Period( $start_date, $end_date ); return $this->full_buffered_period; } public function get_buffer_before_period() { if ( null !== $this->buffer_before_period ) { return $this->buffer_before_period; } $buffer_before = $this->get_appointment_type_object()->buffer_before; if ( empty( $buffer_before ) ) { $this->buffer_before_period = false; } else { $buffer_before = '-' . absint( $buffer_before ) . ' MIN'; $calculated_period = new Period( $this->get_raw_period()->getStartDate(), $this->get_raw_period()->getStartDate() ); $calculated_period = $calculated_period->moveStartDate( $buffer_before ); $this->buffer_before_period = $calculated_period; } return $this->buffer_before_period; } public function get_buffer_after_period() { if ( null !== $this->buffer_after_period ) { return $this->buffer_after_period; } $buffer_after = $this->get_appointment_type_object()->buffer_after; if ( empty( $buffer_after ) ) { $this->buffer_after_period = false; } else { $buffer_after = '+' . absint( $buffer_after ) . ' MIN'; $calculated_period = new Period( $this->get_raw_period()->getEndDate(), $this->get_raw_period()->getEndDate() ); $calculated_period = $calculated_period->moveEndDate( $buffer_after ); $this->buffer_after_period = $calculated_period; } return $this->buffer_after_period; } private function set_appointment_object( $appointment ) { if ( null !== $this->appointment_object ) { throw new Exception( 'SSA_Period ivars can\'t be modified' ); } $appointment = SSA_Appointment_Object::instance( $appointment ); $this->appointment_object = $appointment; $this->appointment_id = $appointment->id; $this->set_appointment_type_object( $appointment->get_appointment_type() ); } private function set_appointment_type_object( $appointment_type ) { if ( null !== $this->appointment_type_object ) { throw new Exception( 'SSA_Period ivars can\'t be modified' ); } $appointment_type = SSA_Appointment_Type_Object::instance( $appointment_type ); $this->appointment_type_object = $appointment_type; $this->appointment_type_id = $appointment_type->id; } /** * clear_calculated_variables * * update dependent variables * * @return void * @author **/ public function clear_calculated_variables() { $this->raw_period = null; $this->buffer_before_period = null; $this->buffer_after_period = null; } private function calculate_raw_period_by_instance_variables() { if ( null !== $this->raw_period ) { return; // already calculated } if ( empty( $this->raw_start_date ) || empty( $this->raw_end_date ) ) { return; } $this->raw_period = new Period( $this->raw_start_date, $this->raw_end_date ); } private function calculate_raw_period_by_appointment_id() { if ( null !== $this->raw_period ) { return; // already calculated } if ( empty( $this->appointment_object ) ) { return; } $this->raw_period = new Period( $this->appointment_object->start_date, $this->appointment_object->end_date ); } private function calculate_raw_period_by_appointment_type_id() { if ( null !== $this->raw_period ) { return; // already calculated } if ( null !== $this->appointment_object ) { return; } if ( null === $this->appointment_type_object ) { return; } if ( null === $this->raw_start_date ) { return; } $duration = $this->appointment_type_object->duration; $calculated_end_date = ssa_datetime( $this->raw_start_date )->add( new DateInterval( 'PT'.$duration.'M' ) ); $this->raw_period = new Period( $this->raw_start_date, $calculated_end_date ); } public function log() { ssa_debug_log( '-------------------- SSA_Period --------------------' ); ssa_debug_log( $this->appointment_id, 1, 'appointment_id:' ); ssa_debug_log( $this->appointment_type_id, 1, 'appointment_type_id:' ); ssa_debug_log( $this->get_buffer_before_period(), 1, 'buffer_before_period:' ); ssa_debug_log( $this->get_raw_period(), 1, 'raw_period:' ); ssa_debug_log( $this->get_buffer_after_period(), 1, 'buffer_after_period:' ); ssa_debug_log( $this->get_full_buffered_period(), 1, 'full_buffered_period:' ); ssa_debug_log( '--------------------------------------------------------------------------------' ); } }
[-] class-settings.php
[edit]
[-] class-hooks.php
[edit]
[-] class-availability-query.php
[edit]
[-] class-appointment-model.php
[edit]
[-] class-beaver-builder.php
[edit]
[-] class-web-meetings.php
[edit]
[-] class-availability-model.php
[edit]
[-] class-recipient-admin.php
[edit]
[-] class-recipient-customer.php
[edit]
[-] class-constants.php
[edit]
[-] class-async-action-model.php
[edit]
[-] class-support.php
[edit]
[-] class-google-calendar-client.php
[edit]
[+]
..
[-] class-capabilities.php
[edit]
[-] class-encryption.php
[edit]
[-] class-availability-cache-invalidation.php
[edit]
[-] class-calendar-events-settings.php
[edit]
[-] class-settings-global.php
[edit]
[-] class-translation.php
[edit]
[-] class-cli.php
[edit]
[-] class-missing.php
[edit]
[-] class-action-scheduler.php
[edit]
[-] class-templates-api.php
[edit]
[-] class-blackout-dates.php
[edit]
[-] class-calendar-events-object.php
[edit]
[-] class-divi.php
[edit]
[-] class-templates.php
[edit]
[-] class-wp-admin.php
[edit]
[-] class-appointment-factory.php
[edit]
[-] class-scheduling-max-per-day.php
[edit]
[-] class-notifications-api.php
[edit]
[-] class-shortcodes.php
[edit]
[-] class-validation.php
[edit]
[-] class-resource-group-object-factory.php
[edit]
[-] class-payment-object.php
[edit]
[-] class-locale.php
[edit]
[-] class-ics-exporter.php
[edit]
[-] class-filesystem.php
[edit]
[-] class-recipient-shared.php
[edit]
[-] class-availability-schedule.php
[edit]
[-] class-block-upcoming-appointments.php
[edit]
[-] class-elementor.php
[edit]
[-] class-appointment-meta-model.php
[edit]
[-] class-revision-meta-model.php
[edit]
[+]
divi
[-] class-notifications.php
[edit]
[-] class-upgrade.php
[edit]
[-] class-utils.php
[edit]
[-] class-availability-functions.php
[edit]
[-] class-external-calendar-api.php
[edit]
[-] class-csv-exporter.php
[edit]
[-] class-external-google-calendar-api.php
[edit]
[-] class-twig-extension.php
[edit]
[-] class-bootstrap.php
[edit]
[-] class-notices.php
[edit]
[-] class-availability-schedule-factory.php
[edit]
[-] class-blackout-dates-settings.php
[edit]
[-] class-support-status.php
[edit]
[-] class-block-booking.php
[edit]
[-] class-advanced-scheduling-availability.php
[edit]
[-] class-exception.php
[edit]
[-] class-styles-settings.php
[edit]
[-] class-forms.php
[edit]
[-] class-recipient-staff.php
[edit]
[+]
beaver-builder
[-] class-users.php
[edit]
[-] class-sequence-factory.php
[edit]
[+]
third-party
[-] class-locales.php
[edit]
[-] class-db-model.php
[edit]
[-] class-db.php
[edit]
[-] class-availability-default.php
[edit]
[-] class-staff-settings.php
[edit]
[-] class-notification-model.php
[edit]
[-] class-settings-installed.php
[edit]
[-] class-appointment-object.php
[edit]
[-] class-notices-api.php
[edit]
[-] class-translation-settings.php
[edit]
[-] class-support-status-api.php
[edit]
[-] class-notices-data.php
[edit]
[-] class-appointment-type-object.php
[edit]
[-] class-appointment-type-object-factory.php
[edit]
[-] class-availability-block-factory.php
[edit]
[-] class-recipient.php
[edit]
[-] class-revision-model.php
[edit]
[-] class-customers.php
[edit]
[-] class-settings-api.php
[edit]
[-] class-cache.php
[edit]
[-] class-availability-detective-case.php
[edit]
[-] class-styles.php
[edit]
[-] class-capacity-settings.php
[edit]
[-] class-gcal-exporter.php
[edit]
[-] class-advanced-scheduling-settings.php
[edit]
[-] class-appointment-type-model.php
[edit]
[-] class-notifications-settings.php
[edit]
[-] class-period.php
[edit]
[-] class-external-api.php
[edit]
[-] class-error-notices.php
[edit]
[-] class-availability-cache.php
[edit]
[-] class-developer-settings.php
[edit]
[-] class-dashboard-upcoming-appointments-widget.php
[edit]
[-] class-availability-external-model.php
[edit]
[-] class-availability-block.php
[edit]
[-] class-customer-information.php
[edit]
[+]
elementor
[-] class-appointment-type-label-model.php
[edit]
[-] class-embed-booking-app-api.php
[edit]
[+]
lib
[-] class-sequence.php
[edit]
[-] class-debug.php
[edit]
[-] class-appointment-types-db.php
[edit]