<?php
/**
 * Account form shared fields table partial.
 *
 * Included by templates/admin/account-form.php.
 *
 * Variables in scope:
 *
 * @var string              $label
 * @var string              $country
 * @var string              $name
 * @var string              $tax_id
 * @var string              $address
 * @var array<string,string> $countries
 *
 * @since   1.0.0
 * @package DonationRouter
 */

declare( strict_types=1 );

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

?>
<table class="ador-form-table" role="presentation">
	<tr>
		<th scope="row">
			<label for="ador_account_label">
				<?php esc_html_e( 'Account Label', 'alamin-donation-router' ); ?>
				<span class="required" aria-hidden="true">*</span>
			</label>
		</th>
		<td>
			<input
				type="text"
				id="ador_account_label"
				name="account_label"
				value="<?php echo esc_attr( $label ); ?>"
				maxlength="191"
				required
				class="regular-text"
			/>
			<p class="description"><?php esc_html_e( 'A human-readable name for this account (e.g. "US Main Entity").', 'alamin-donation-router' ); ?></p>
		</td>
	</tr>

	<tr>
		<th scope="row">
			<label for="ador_account_country">
				<?php esc_html_e( 'Account Country', 'alamin-donation-router' ); ?>
				<span class="required" aria-hidden="true">*</span>
			</label>
		</th>
		<td>
			<select id="ador_account_country" name="account_country" required class="ador-select">
				<?php foreach ( $countries as $ador_code => $ador_display ) : ?>
					<option value="<?php echo esc_attr( $ador_code ); ?>" <?php selected( $country, $ador_code ); ?>>
						<?php echo esc_html( $ador_display ); ?>
					</option>
				<?php endforeach; ?>
			</select>
			<p class="description"><?php esc_html_e( 'Country where this PayPal Business account is registered.', 'alamin-donation-router' ); ?></p>
		</td>
	</tr>

	<tr>
		<th scope="row">
			<label for="ador_legal_entity_name">
				<?php esc_html_e( 'Legal Entity Name', 'alamin-donation-router' ); ?>
				<span class="required" aria-hidden="true">*</span>
			</label>
		</th>
		<td>
			<input
				type="text"
				id="ador_legal_entity_name"
				name="legal_entity_name"
				value="<?php echo esc_attr( $name ); ?>"
				required
				class="regular-text"
			/>
			<p class="description"><?php esc_html_e( 'The registered legal name of the organisation that owns this account.', 'alamin-donation-router' ); ?></p>
		</td>
	</tr>

	<tr>
		<th scope="row">
			<label for="ador_legal_entity_tax_id">
				<?php esc_html_e( 'Tax ID / EIN', 'alamin-donation-router' ); ?>
				<span class="required" aria-hidden="true">*</span>
			</label>
		</th>
		<td>
			<input
				type="text"
				id="ador_legal_entity_tax_id"
				name="legal_entity_tax_id"
				value="<?php echo esc_attr( $tax_id ); ?>"
				required
				class="regular-text ador-tax-id-field"
			/>
			<p class="description">
				<?php esc_html_e( 'Employer Identification Number (US), Company Number (UK), ABN (AU), or equivalent tax identifier for the legal entity.', 'alamin-donation-router' ); ?>
			</p>
		</td>
	</tr>

	<tr>
		<th scope="row">
			<label for="ador_legal_entity_address">
				<?php esc_html_e( 'Legal Entity Address', 'alamin-donation-router' ); ?>
				<span class="required" aria-hidden="true">*</span>
			</label>
		</th>
		<td>
			<textarea
				id="ador_legal_entity_address"
				name="legal_entity_address"
				rows="4"
				required
				class="large-text"
			><?php echo esc_textarea( $address ); ?></textarea>
			<p class="description"><?php esc_html_e( 'Full registered mailing address of the legal entity.', 'alamin-donation-router' ); ?></p>
		</td>
	</tr>
</table>
