<?php
/**
 * GiveWP success-page receipt rows template.
 *
 * Appended to the donation confirmation table via give_payment_receipt_after.
 *
 * Variables in scope (passed by Receipt_Customizer::render_receipt_rows()):
 *
 * @var \DonationRouter\PayPal_Account $account
 * @var string                                           $receipt_number
 * @var string                                           $tax_statement
 * @var int                                              $payment_id
 *
 * @since   1.0.0
 * @package DonationRouter
 */

declare( strict_types=1 );

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}
use DonationRouter\Receipt_PDF_Generator;
?>

<?php if ( '' !== $account->legal_entity_name ) : ?>
<tr>
	<td scope="row"><strong><?php esc_html_e( 'Receiving Organization', 'alamin-donation-router' ); ?></strong></td>
	<td><?php echo esc_html( $account->legal_entity_name ); ?></td>
</tr>
<?php endif; ?>

<?php if ( '' !== $account->legal_entity_tax_id ) : ?>
<tr>
	<td scope="row"><strong><?php esc_html_e( 'Tax / Registration ID', 'alamin-donation-router' ); ?></strong></td>
	<td><?php echo esc_html( $account->legal_entity_tax_id ); ?></td>
</tr>
<?php endif; ?>

<?php if ( '' !== $receipt_number ) : ?>
<tr>
	<td scope="row"><strong><?php esc_html_e( 'Receipt Number', 'alamin-donation-router' ); ?></strong></td>
	<td><?php echo esc_html( $receipt_number ); ?></td>
</tr>
<?php endif; ?>

<?php if ( '' !== $tax_statement ) : ?>
<tr>
	<td colspan="2" style="padding-top:1em;">
		<?php echo wp_kses_post( $tax_statement ); ?>
	</td>
</tr>
<?php endif; ?>

<?php if ( get_option( 'ador_pdf_receipts_enabled', false ) && class_exists( Receipt_PDF_Generator::class ) ) : ?>
<tr>
	<td colspan="2" style="padding-top:1em;">
		<?php
		$ador_pdf_url = add_query_arg(
			array(
				'action'     => Receipt_PDF_Generator::AJAX_ACTION,
				'payment_id' => $payment_id,
				'nonce'      => wp_create_nonce( Receipt_PDF_Generator::NONCE_ACTION_PREFIX . $payment_id ),
			),
			admin_url( 'admin-ajax.php' )
		);
		?>
		<a href="<?php echo esc_url( $ador_pdf_url ); ?>" style="display:inline-block;padding:8px 16px;background:#2271b1;color:#ffffff;text-decoration:none;border-radius:3px;font-size:13px;font-weight:600;line-height:1.4;">
			<?php esc_html_e( 'Download PDF Receipt', 'alamin-donation-router' ); ?>
		</a>
	</td>
</tr>
<?php endif; ?>
