<?php
if ( ! defined( 'ABSPATH' ) ) {
	exit; // Exit if accessed directly.
}

/**
 * HTML Template: Job Order Cancel Response
 *
 * Sent to the user when a cancellation request is accepted or rejected.
 *
 * @var string   $email_heading
 * @var string   $recipient_name
 * @var string   $responder_name
 * @var string   $job_title
 * @var int      $job_id
 * @var int      $order_id
 * @var string   $status
 * @var string   $order_link
 * @var string   $employer_label
 * @var string   $freelancer_label
 * @var bool     $sent_to_admin
 * @var bool     $plain_text
 * @var WC_Email $email
 */

$status_text = ( 'accepted' === $status ) ? esc_html__( 'Accepted', 'gigneo' ) : esc_html__( 'Rejected', 'gigneo' );
// phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound
do_action( 'woocommerce_email_header', $email_heading, $email );
?>

<table role="presentation" cellspacing="0" cellpadding="0" style="width: 100%; margin: 0 auto; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen-Sans, Ubuntu, Cantarell, sans-serif;">
	<tr>
		<td style="padding: 40px 20px;">

			<!-- Greeting -->
			<p style="margin: 0 0 20px 0;">
				<?php
				printf(
					// translators: %s is a recipient name
					esc_html__( 'Hello %s,', 'gigneo' ),
					esc_html( $recipient_name )
				);
				?>
			</p>

			<!-- Introduction -->
			<p style="margin: 0 0 30px 0;">
				<?php
				printf(
					// translators: %1$s: Responder name, %2$s: Job title, %3$s: Status
					esc_html__( '%1$s has %3$s your cancellation request for the job order "%2$s".', 'gigneo' ),
					'<strong>' . esc_html( $responder_name ) . '</strong>',
					'<strong>' . esc_html( $job_title ) . '</strong>',
					'<strong>' . esc_html( $status_text ) . '</strong>'
				);
				?>
			</p>

			<!-- Section heading -->
			<h3 style="color:margin: 0 0 15px 0;">
				<?php echo esc_html__( 'Order summary', 'gigneo' ); ?>
			</h3>

			<!-- Details table -->
			<table role="presentation" cellspacing="0" cellpadding="0" style="width: 100%; background: #F7F7F7; border: 1px solid #f0f0f0; border-radius: 12px; margin: 0 0 30px 0;">
				<!-- Order ID -->
				<tr>
					<td style="padding: 14px 16px; border-bottom: 1px solid #f0f0f0; width: 50%;">
						<?php echo esc_html__( 'Order ID', 'gigneo' ); ?>
					</td>
					<td style="padding: 14px 16px; border-bottom: 1px solid #f0f0f0; text-align: right;">
						<?php echo esc_html( gigneo_format_id( $order_id, 'order', false ) ); ?>
					</td>
				</tr>

				<!-- Job ID -->
				<tr>
					<td style="padding: 14px 16px; border-bottom: 1px solid #f0f0f0;">
						<?php echo esc_html__( 'Job ID', 'gigneo' ); ?>
					</td>
					<td style="padding: 14px 16px; border-bottom: 1px solid #f0f0f0; text-align: right;">
						<?php echo esc_html( gigneo_format_id( $job_id, 'job', false ) ); ?>
					</td>
				</tr>

				<!-- Status -->
				<tr>
					<td style="padding: 14px 16px; border-bottom: 1px solid #f0f0f0;">
						<?php echo esc_html__( 'Request status', 'gigneo' ); ?>
					</td>
					<td style="padding: 14px 16px; border-bottom: 1px solid #f0f0f0; text-align: right;">
						<?php echo esc_html( $status_text ); ?>
					</td>
				</tr>

				<!-- Job Title -->
				<tr>
					<td style="padding: 14px 16px;">
						<?php echo esc_html__( 'Job title', 'gigneo' ); ?>
					</td>
					<td style="padding: 14px 16px; text-align: right;">
						<?php echo esc_html( $job_title ); ?>
					</td>
				</tr>
			</table>

			<!-- CTA Button -->
			<table role="presentation" cellspacing="0" cellpadding="0" style="width: 100%; margin: 0 0 30px 0;">
				<tr>
					<td style="text-align: center; padding: 10px 0;">
						<a href="<?php echo esc_url( $order_link ); ?>" target="_blank" rel="noopener">
							<?php echo esc_html__( 'View order details', 'gigneo' ); ?> &rarr;
						</a>
					</td>
				</tr>
			</table>

			<!-- Closing note -->
			<p style="margin: 0 0 10px 0;">
				<?php
				if ( 'accepted' === $status ) {
					echo esc_html__( 'The order has been successfully cancelled and any refunds will be processed accordingly.', 'gigneo' );
				} else {
					echo esc_html__( 'Since the request was rejected, the project remains active. Please communicate with the other party to resolve any issues.', 'gigneo' );
				}
				?>
			</p>

		</td>
	</tr>
</table>

<?php
// phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound
do_action( 'woocommerce_email_footer', $email );
