<?php

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

/**
 * 領収書 PDF テンプレート
 *
 * @var array $receipt      領収書データ
 * @var array $payment      決済データ
 * @var array $registration 申込データ
 * @var array $event        イベントデータ
 */
?>
<h1>領 収 書</h1>

<table class="header" cellpadding="0" cellspacing="0">
	<tr>
		<td class="header-left">
			<div class="addressee">
				<?php echo esc_html( $receipt['addressee_name'] ); ?>
				<?php if ( ! empty( $receipt['addressee_dept'] ) ) : ?>
					<br><?php echo esc_html( $receipt['addressee_dept'] ); ?>
				<?php endif; ?>
				<span style="font-size: 12pt;">様</span>
			</div>
			<p style="font-size: 10pt; color: #666; margin-top: 10px;">領収書番号: <?php echo esc_html( $receipt['receipt_no'] ); ?></p>
		</td>
		<td class="header-right">
			<p>発行日: <?php echo esc_html( wp_date( 'Y年n月j日', strtotime( $receipt['issued_at'] ) ) ); ?></p>
			<?php if ( ! empty( $event['organizer_info'] ) ) : ?>
				<p style="margin-top: 10px; font-size: 10pt; color: #333;"><?php echo nl2br( esc_html( $event['organizer_info'] ) ); ?></p>
			<?php endif; ?>
		</td>
	</tr>
</table>

<div class="amount-box">
	<span class="amount">&yen;<?php echo number_format( (int) ( $payment['amount'] ?? 0 ) + (int) ( $payment['tax'] ?? 0 ) ); ?>-</span>
</div>

<p class="proviso">但 <?php echo esc_html( $receipt['proviso'] ?? '参加費として' ); ?></p>

<table class="detail">
	<tr>
		<th>イベント名</th>
		<td><?php echo esc_html( $event['title'] ?? '' ); ?></td>
	</tr>
	<tr>
		<th>金額（税抜）</th>
		<td>&yen;<?php echo number_format( (int) ( $payment['amount'] ?? 0 ) ); ?></td>
	</tr>
	<tr>
		<th>消費税（10%）</th>
		<td>&yen;<?php echo number_format( (int) ( $payment['tax'] ?? 0 ) ); ?></td>
	</tr>
	<tr>
		<th>お支払方法</th>
		<td>
			<?php
			$conf_method_labels = [
				'stripe' => __( 'Credit Card (Stripe)', 'conferencemanager' ),
				'bank'   => __( 'Bank Transfer', 'conferencemanager' ),
			];
			echo esc_html( $conf_method_labels[ $payment['method'] ?? '' ] ?? __( 'Other', 'conferencemanager' ) );
			?>
		</td>
	</tr>
	<tr>
		<th>入金日</th>
		<td><?php echo esc_html( $payment['paid_at'] ? wp_date( 'Y年n月j日', strtotime( $payment['paid_at'] ) ) : '' ); ?></td>
	</tr>
</table>

<?php if ( ! empty( $receipt['tax_registration_no'] ) ) : ?>
<p style="font-size: 9pt; color: #666; margin-top: 10px;">適格請求書発行事業者登録番号: <?php echo esc_html( $receipt['tax_registration_no'] ); ?></p>
<?php endif; ?>

<div class="footer">
	<p>上記の金額を正に領収いたしました。</p>
</div>
