<?php
/**
 * Weekly Report Email Template
 *
 * Displays the weekly affiliate report email content.
 *
 * @since 2.15.0
 * @package wc-affiliate
 * @var string $title The email title
 * @var string $period_label The period label
 * @var string $start_date The start date
 * @var string $end_date The end date
 * @var array $weekly_stats The weekly statistics data
 * @var string $visits_label The visits label
 * @var string $referrals_label The referrals label
 * @var string $commissions_label The commissions label
 * @var string $sales_label The sales label
 * @var string $conversion_label The conversion rate label
 * @var string $top_performers_title The top performers title
 * @var array $top_performers The top performers data
 * @var string $referrals_text The referrals text
 * @var string $commissions_text The commissions text
 */
?>

<h2><?php echo esc_html( $title ); ?></h2>
<p><strong><?php echo esc_html( $period_label ); ?></strong> <?php echo esc_html( $start_date ); ?> - <?php echo esc_html( $end_date ); ?></p>
<ul>
	<li><strong><?php echo esc_html( $visits_label ); ?></strong> <?php echo number_format( $weekly_stats['total_visits'] ); ?></li>
	<li><strong><?php echo esc_html( $referrals_label ); ?></strong> <?php echo number_format( $weekly_stats['total_referrals'] ); ?></li>
	<li><strong><?php echo esc_html( $commissions_label ); ?></strong> <?php echo wca_format_price( $weekly_stats['total_commissions'] ); ?></li>
	<li><strong><?php echo esc_html( $sales_label ); ?></strong> <?php echo wca_format_price( $weekly_stats['total_sales'] ); ?></li>
	<li><strong><?php echo esc_html( $conversion_label ); ?></strong> <?php echo number_format( $weekly_stats['conversion_rate'], 2 ); ?>%</li>
</ul>

<?php if ( ! empty( $weekly_stats['top_performers'] ) ) : ?>
	<h3><?php echo esc_html( $top_performers_title ); ?></h3>
	<ul>
		<?php foreach ( $weekly_stats['top_performers'] as $performer ) : ?>
			<?php
			$user = get_userdata( $performer->affiliate );
			$name = $user ? $user->display_name : __( 'Unknown', 'wc-affiliate' );
			?>
			<li><?php echo esc_html( $name ); ?>: <?php echo number_format( $performer->referrals ); ?> <?php echo esc_html( $referrals_text ); ?>, <?php echo wca_format_price( $performer->commissions ); ?> <?php echo esc_html( $commissions_text ); ?></li>
		<?php endforeach; ?>
	</ul>
<?php endif; ?>
