<?php
/**
 * TutorHelper Booking email definitions.
 *
 * @package TutorHelper_Bookings
 */

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

/**
 * Registers the Core email templates used by Bookings.
 */
final class TutorHelper_Booking_Email_Templates {

	/**
	 * Tutor notification for a new student request.
	 *
	 * @var string
	 */
	const STUDENT_REQUEST_TUTOR =
		'booking_student_request_tutor';

	/**
	 * Student acknowledgement for a submitted request.
	 *
	 * @var string
	 */
	const STUDENT_REQUEST_RECEIVED =
		'booking_student_request_received';

	/**
	 * Student notification for a confirmed lesson.
	 *
	 * @var string
	 */
	const STUDENT_BOOKING_CONFIRMED =
		'booking_student_confirmed';

	/**
	 * Student notification for a cancelled lesson.
	 *
	 * @var string
	 */
	const STUDENT_BOOKING_CANCELLED =
		'booking_student_cancelled';


	/**
	 * Tutor notification when a student cancels a lesson.
	 *
	 * @var string
	 */
	const STUDENT_CANCELLED_TUTOR =
		'booking_student_cancelled_tutor';


	/**
	 * Register Booking email templates.
	 *
	 * @return void
	 */
	public static function register() {
		self::register_student_request_tutor();

		self::register_student_request_received();

		self::register_student_booking_confirmed();

		self::register_student_booking_cancelled();

		self::register_student_cancelled_tutor();
	}

	/**
	 * Register the tutor's new-request notification.
	 *
	 * @return void
	 */
	private static function register_student_request_tutor() {
		TutorHelper_Email_Templates::register(
			self::STUDENT_REQUEST_TUTOR,
			array(
				'module' =>
					'bookings',

				'label' =>
					__(
						'New lesson request — Tutor',
						'tutorhelper-bookings'
					),

				'description' =>
					__(
						'Sent to the tutor when a student submits a new lesson request.',
						'tutorhelper-bookings'
					),

				'heading' =>
					__(
						'New Lesson Request',
						'tutorhelper-bookings'
					),

				'recipient' =>
					'tutor',

				'enabled' =>
					true,

				'subject' =>
					__(
						'New lesson request from {student_name}',
						'tutorhelper-bookings'
					),

				'body' =>
					__(
						"Hello {tutor_name},\n\n{student_name} has requested a {booking_type} lesson.\n\nDate: {lesson_date}\nTime: {lesson_time}\nLocation: {location_type}\nStatus: Awaiting confirmation\n\nStudent notes:\n{student_notes}\n\nPlease review the request in your TutorHelper calendar:\n{calendar_url}\n\nIf you would like to accept the request, open the booking and change its status to Confirmed.\n\nBest wishes,\nTutorHelper",
						'tutorhelper-bookings'
					),

				'placeholders' =>
					array(
						'{student_name}',
						'{student_email}',
						'{booking_type}',
						'{lesson_date}',
						'{lesson_time}',
						'{location_type}',
						'{student_notes}',
						'{tutor_name}',
						'{site_name}',
						'{calendar_url}',
					),
			)
		);
	}

	/**
	 * Register the student request acknowledgement.
	 *
	 * @return void
	 */
	private static function register_student_request_received() {
		TutorHelper_Email_Templates::register(
			self::STUDENT_REQUEST_RECEIVED,
			array(
				'module' =>
					'bookings',

				'label' =>
					__(
						'Lesson request received — Student',
						'tutorhelper-bookings'
					),

				'description' =>
					__(
						'Sent to the student after they submit a new lesson request.',
						'tutorhelper-bookings'
					),

				'heading' =>
					__(
						'Lesson Request Received',
						'tutorhelper-bookings'
					),

				'recipient' =>
					'student',

				'enabled' =>
					true,

				'subject' =>
					__(
						'We have received your {booking_type} lesson request',
						'tutorhelper-bookings'
					),

				'body' =>
					__(
						"Hello {student_name},\n\nYour lesson request has been sent to {tutor_name} and is awaiting confirmation.\n\nLesson: {booking_type}\nDate: {lesson_date}\nTime: {lesson_time}\nLocation: {location_type}\n\nYou can view your lessons here:\n{student_dashboard_url}\n\nBest wishes,\n{tutor_name}",
						'tutorhelper-bookings'
					),

				'placeholders' =>
					array(
						'{student_name}',
						'{booking_type}',
						'{lesson_date}',
						'{lesson_time}',
						'{location_type}',
						'{tutor_name}',
						'{site_name}',
						'{student_dashboard_url}',
					),
			)
		);
	}

	/**
	 * Register the student confirmation notification.
	 *
	 * @return void
	 */
	private static function register_student_booking_confirmed() {
		TutorHelper_Email_Templates::register(
			self::STUDENT_BOOKING_CONFIRMED,
			array(
				'module' =>
					'bookings',

				'label' =>
					__(
						'Lesson confirmed — Student',
						'tutorhelper-bookings'
					),

				'description' =>
					__(
						'Sent to the student when their lesson is confirmed.',
						'tutorhelper-bookings'
					),

				'heading' =>
					__(
						'Lesson Confirmed',
						'tutorhelper-bookings'
					),

				'recipient' =>
					'student',

				'enabled' =>
					true,

				'subject' =>
					__(
						'Your {booking_type} lesson is confirmed',
						'tutorhelper-bookings'
					),

				'body' =>
					__(
						"Hello {student_name},\n\nYour lesson has been confirmed.\n\nLesson: {booking_type}\nDate: {lesson_date}\nTime: {lesson_time}\nLocation: {location_type}\n\n{joining_details}\n\nYou can view your lessons here:\n{student_dashboard_url}\n\nBest wishes,\n{tutor_name}",
						'tutorhelper-bookings'
					),

				'placeholders' =>
					array(
						'{student_name}',
						'{booking_type}',
						'{lesson_date}',
						'{lesson_time}',
						'{location_type}',
						'{joining_details}',
						'{tutor_name}',
						'{site_name}',
						'{student_dashboard_url}',
					),
			)
		);
	}

	/**
	 * Register the student cancellation notification.
	 *
	 * @return void
	 */
	private static function register_student_booking_cancelled() {
		TutorHelper_Email_Templates::register(
			self::STUDENT_BOOKING_CANCELLED,
			array(
				'module' =>
					'bookings',

				'label' =>
					__(
						'Lesson cancelled — Student',
						'tutorhelper-bookings'
					),

				'description' =>
					__(
						'Sent to the student when a lesson is cancelled.',
						'tutorhelper-bookings'
					),

				'heading' =>
					__(
						'Lesson Cancelled',
						'tutorhelper-bookings'
					),

				'recipient' =>
					'student',

				'enabled' =>
					true,

				'subject' =>
					__(
						'{booking_type} lesson on {lesson_date} has been cancelled',
						'tutorhelper-bookings'
					),

				'body' =>
					__(
						"Hello {student_name},\n\nYour lesson has been cancelled.\n\nLesson: {booking_type}\nDate: {lesson_date}\nTime: {lesson_time}\nLocation: {location_type}\n\nCancellation reason:\n{cancellation_reason}\n\nYou can view your lessons here:\n{student_dashboard_url}\n\nIf you have any questions about this cancellation, please reply to this email.\n\nBest wishes,\n{tutor_name}",
						'tutorhelper-bookings'
					),

				'placeholders' =>
					array(
						'{student_name}',
						'{booking_type}',
						'{lesson_date}',
						'{lesson_time}',
						'{location_type}',
						'{tutor_name}',
						'{site_name}',
						'{student_dashboard_url}',
						'{cancellation_reason}',
					),
			)
		);
	}

	/**
	 * Register the tutor notification for a student cancellation.
	 *
	 * @return void
	 */
	private static function register_student_cancelled_tutor() {
		TutorHelper_Email_Templates::register(
			self::STUDENT_CANCELLED_TUTOR,
			array(
				'module' =>
					'bookings',

				'label' =>
					__(
						'Lesson cancelled by student — Tutor',
						'tutorhelper-bookings'
					),

				'description' =>
					__(
						'Sent to the tutor when a student cancels one of their lessons.',
						'tutorhelper-bookings'
					),

				'heading' =>
					__(
						'Lesson Cancelled by Student',
						'tutorhelper-bookings'
					),

				'recipient' =>
					'tutor',

				'enabled' =>
					true,

				'subject' =>
					__(
						'{student_name} cancelled their {booking_type} lesson on {lesson_date}',
						'tutorhelper-bookings'
					),

				'body' =>
					__(
						"Hello {tutor_name},\n\n{student_name} has cancelled their {booking_type} lesson.\n\nDate: {lesson_date}\nTime: {lesson_time}\nLocation: {location_type}\n\nCancellation reason:\n{cancellation_reason}\n\nYou can review the booking in your TutorHelper calendar:\n{calendar_url}\n\nBest wishes,\nTutorHelper",
						'tutorhelper-bookings'
					),

				'placeholders' =>
					array(
						'{student_name}',
						'{student_email}',
						'{booking_type}',
						'{lesson_date}',
						'{lesson_time}',
						'{location_type}',
						'{cancellation_reason}',
						'{tutor_name}',
						'{site_name}',
						'{calendar_url}',
					),
			)
		);
	}

}
