<?php
defined('ABSPATH') || exit;
/**
 * Booking cancelled notification.
 *
 * Expected variables:
 * - $service, $date
 * - Optional: $recipient, $actor, $owner, $provider, $reason, $date_range
 * - Optional: $date_to when using day interval
 */
$bookaro_subject = __( 'Booking cancelled', 'mybookaro' );
$bookaro_preheader = __( 'A booking has been cancelled.', 'mybookaro' );
require bookaro_locate_template( 'templates/emails/partials/header.php' );
?>

<h2 style="font-size:20px; margin-bottom:12px;"><?php esc_html_e( 'Booking cancelled', '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_reason = isset( $reason ) ? (string) $reason : '';
$bookaro_recipient = isset( $recipient ) && $recipient !== '' ? (string) $recipient : (string) ( $owner ?? '' );
$bookaro_actor = isset( $actor ) && $actor !== '' ? (string) $actor : __( 'A booking update', 'mybookaro' );
$bookaro_intro_fallback = sprintf(
    /* translators: 1: recipient, 2: actor, 3: service, 4: date or range */
    __( 'Hello %1$s, %2$s cancelled the booking for "%3$s" scheduled for %4$s.', 'mybookaro' ),
    $bookaro_recipient,
    $bookaro_actor,
    (string) $service,
    (string) ( $date_range ?? $bookaro_date_display )
);
if ( $bookaro_reason !== '' ) {
    $bookaro_intro_fallback .= ' ' . sprintf(
        /* translators: %s: cancellation reason. */
        __( 'Reason: %s', 'mybookaro' ),
        $bookaro_reason
    );
}
require bookaro_locate_template( 'templates/emails/partials/intro.php' );
?>
<?php
$bookaro_details = isset( $bookaro_details ) && is_array( $bookaro_details ) ? $bookaro_details : [];
if ( empty( $bookaro_details ) ) {
    $bookaro_details = [
        esc_html__( 'Service', 'mybookaro' ) => $service,
        esc_html__( 'Date', 'mybookaro' )    => $bookaro_date_display,
    ];
}
if ( $bookaro_reason !== '' ) {
    $bookaro_details[ esc_html__( 'Reason', 'mybookaro' ) ] = $bookaro_reason;
}
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' ); ?>
