<?php
defined('ABSPATH') || exit;
/**
 * Booking rescheduled notification.
 *
 * Expected variables:
 * - $recipient, $actor, $service, $date
 * - Optional: $manage_booking_url, $add_to_calendar_url
 * - Optional: $date_to, $old_date, $old_date_to
 */
$bookaro_subject = __( 'Booking rescheduled', 'mybookaro' );
$bookaro_preheader = __( 'A booking time was updated.', 'mybookaro' );
require bookaro_locate_template( 'templates/emails/partials/header.php' );
?>

<h2 style="font-size:20px; margin-bottom:12px;"><?php esc_html_e( 'Booking rescheduled', 'mybookaro' ); ?></h2>
<?php
$bookaro_date_display = $date;
if ( ! empty( $date_to ) ) {
    $bookaro_date_display = sprintf(
        /* translators: 1: start date, 2: end date */
        __( '%1$s to %2$s', 'mybookaro' ),
        $date,
        $date_to
    );
}

$bookaro_old_display = $old_date ?? '';
if ( ! empty( $old_date_to ) ) {
    $bookaro_old_display = sprintf(
        /* translators: 1: old start date, 2: old end date */
        __( '%1$s to %2$s', 'mybookaro' ),
        $old_date,
        $old_date_to
    );
}

$bookaro_intro_fallback = sprintf(
    /* translators: 1: recipient, 2: actor, 3: service, 4: new date */
    __( 'Hello %1$s, %2$s rescheduled the booking for "%3$s". New time: %4$s.', 'mybookaro' ),
    (string) $recipient,
    (string) $actor,
    (string) $service,
    (string) ( $date_range ?? $bookaro_date_display )
);
if ( $bookaro_old_display !== '' ) {
    $bookaro_intro_fallback .= ' ' . sprintf(
        /* translators: %s: previous booking date or range. */
        __( 'Previous time: %s.', 'mybookaro' ),
        (string) ( $old_date_range ?? $bookaro_old_display )
    );
}
require bookaro_locate_template( 'templates/emails/partials/intro.php' );

$bookaro_details = isset( $bookaro_details ) && is_array( $bookaro_details ) ? $bookaro_details : [];
if ( empty( $bookaro_details ) ) {
    $bookaro_details = [
        esc_html__( 'Service', 'mybookaro' ) => $service,
    ];
}
$bookaro_details[ esc_html__( 'New Date', 'mybookaro' ) ] = $bookaro_date_display;
$bookaro_details[ esc_html__( 'Previous Date', 'mybookaro' ) ] = $bookaro_old_display;
$bookaro_details[ esc_html__( 'Rescheduled By', 'mybookaro' ) ] = $actor;
require bookaro_locate_template( 'templates/emails/partials/booking-details.php' );
require bookaro_locate_template( 'templates/emails/partials/contact-details.php' );
require bookaro_locate_template( 'templates/emails/partials/timezone.php' );
require bookaro_locate_template( 'templates/emails/partials/action-summary.php' );
require bookaro_locate_template( 'templates/emails/partials/policy-snippet.php' );
require bookaro_locate_template( 'templates/emails/partials/booking-actions.php' );
?>

<?php require bookaro_locate_template( 'templates/emails/partials/footer.php' ); ?>
