<?php
use Svea_Webpay_For_Woocommerce\Shortcodes;
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly

/** @var int $id */
?>
<div class="svea-fields svea-invoice-fields">
	<div class="customer-type-container">
		<?php if ( Shortcodes::is_using_get_address_shortcode() ) : ?>
			<input type="hidden" value="<?php echo isset( $post_data['iv_billing_customer_type'] ) ? esc_attr( $post_data['iv_billing_customer_type'] ) : ''; ?>"
				name="iv_billing_customer_type">
			<?php
		else :
			woocommerce_form_field(
				'iv_billing_customer_type',
				[
					'type'     => 'select',
					'required' => true,
					'class'    => [ 'form-row-wide', 'invoice-customer-type' ],
					'options'  => [
						'false'      => __( '- Choose customer type -', 'svea-webpay-for-woocommerce' ),
						'individual' => __( 'Individual', 'svea-webpay-for-woocommerce' ),
						'company'    => __( 'Company', 'svea-webpay-for-woocommerce' ),
					],
					'label'    => __( 'Customer Type', 'svea-webpay-for-woocommerce' ),
				],
				isset( $post_data['iv_billing_customer_type'] ) ? $post_data['iv_billing_customer_type'] : false
			);

		endif;
		?>
	</div>
	<div class="organisation-number-container">
		<?php if ( Shortcodes::is_using_get_address_shortcode() ) : ?>
			<input type="hidden" value="<?php echo isset( $post_data['iv_billing_org_number'] ) ? esc_attr( $post_data['iv_billing_org_number'] ) : ''; ?>"
				name="iv_billing_org_number" />
			<?php
			else :
				if ( ! empty( $b2b_text ) ) {
					echo esc_html( $b2b_text );
				}
				woocommerce_form_field(
					'iv_billing_org_number',
					[
						'type'     => 'text',
						'required' => true,
						'class'    => [ 'form-row-wide' ],
						'label'    => __( 'Organisation number', 'svea-webpay-for-woocommerce' ),
					],
					isset( $post_data['iv_billing_org_number'] ) ? $post_data['iv_billing_org_number'] : null
				);
			endif;
			?>
	</div>
	<div class="personal-number-container">
		<?php if ( Shortcodes::is_using_get_address_shortcode() ) : ?>
			<input type="hidden" value="<?php echo isset( $post_data['iv_billing_ssn'] ) ? esc_attr( $post_data['iv_billing_ssn'] ) : ''; ?>"
				name="iv_billing_ssn" />
			<?php
			else :
				if ( ! empty( $b2c_text ) ) {
					echo esc_html( $b2c_text );
				}
				woocommerce_form_field(
					'iv_billing_ssn',
					[
						'type'     => 'text',
						'required' => true,
						'class'    => [ 'form-row-wide' ],
						'label'    => __( 'Personal number', 'svea-webpay-for-woocommerce' ),
					],
					isset( $post_data['iv_billing_ssn'] ) ? $post_data['iv_billing_ssn'] : null
				);
		endif;
			?>
	</div>
	<?php if ( ! Shortcodes::is_using_get_address_shortcode() ) : ?>
		<div class="svea-get-address-button-container">
			<a class="svea-get-address-button" href="#"><?php esc_html_e( 'Get address', 'svea-webpay-for-woocommerce' ); ?></a>
		</div>
	<?php endif; ?>
	<div class="org-address-selector-container">
		<?php if ( ! Shortcodes::is_using_get_address_shortcode() ) : ?>
		<p class="form-row form-row-wide">
			<select name="address_selector" class="org-address-selector"></select>
		</p>
		<?php else : ?>
		<input type="hidden" name="address_selector" class="address-selector" />
		<?php endif; ?>
	</div>
</div>
