<?php
/**
 * Daily Summary Email Template
 *
 * Displays the daily affiliate summary email content.
 *
 * @since 2.15.0
 * @package wc-affiliate
 * @var string $title The email title
 * @var string $date_label The date label
 * @var string $date The formatted date
 * @var array $stats The 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 $top_affiliates_title The top affiliates title
 * @var array $top_affiliates The top affiliates data
 * @var string $referrals_text The referrals text
 */
?>

<h2><?php echo esc_html( $title ); ?></h2>
<p><strong><?php echo esc_html( $date_label ); ?></strong> <?php echo esc_html( $date ); ?></p>
<ul>
	<li><strong><?php echo esc_html( $visits_label ); ?></strong> <?php echo number_format( $stats['total_visits'] ); ?></li>
	<li><strong><?php echo esc_html( $referrals_label ); ?></strong> <?php echo number_format( $stats['total_referrals'] ); ?></li>
	<li><strong><?php echo esc_html( $commissions_label ); ?></strong> <?php echo wca_format_price( $stats['total_commissions'] ); ?></li>
</ul>

<?php if ( ! empty( $top_affiliates ) ) : ?>
	<h3><?php echo esc_html( $top_affiliates_title ); ?></h3>
	<ul>
		<?php foreach ( $top_affiliates as $affiliate ) : ?>
			<?php
			$user = get_userdata( $affiliate->affiliate );
			$name = $user ? $user->display_name : __( 'Unknown', 'wc-affiliate' );
			?>
			<li><?php echo esc_html( $name ); ?>: <?php echo number_format( $affiliate->referral_count ); ?> <?php echo esc_html( $referrals_text ); ?>, <?php echo wca_format_price( $affiliate->total_commission ); ?></li>
		<?php endforeach; ?>
	</ul>
<?php endif; ?>
