<?php
/**
 * Authorize.net My Account Edit Card Template
 *
 * This template handles the credit card editing form for customer payment profiles.
 * Enqueues the CSS file that contains our styles.
 *
 * @package Authorize_Net_Payments_For_Woocommerce
 * @var array $profile
 * @var int $user_id
 * @var int $payment_profile_id
 * @var int $customer_profile_id
 */

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

// Enqueue the CSS file that contains our styles.
wp_enqueue_style('anet-credit-card-css', plugin_dir_url(__FILE__) . '../../assets/css/anet-credit-card-normal-checkout.css', array(), ANET_PLUGIN_VERSION);
wc_print_notices();
$anet_card_number = $profile['card_number'] ?? '';
?>
<div id="anet-credit-card-edit-form" class="woocommerce">
    <h2><?php esc_html_e('Update Credit Card Details', 'authorize-net-payments-for-woocommerce'); ?></h2>
    <form method="post" class="woocommerce-form woocommerce-form-login login">
        <div id="anet-credit-card-edit-error" style="color:#b32d2e; margin-bottom:12px; display:none;"></div>
        <p class="woocommerce-form-row woocommerce-form-row--wide form-row form-row-wide">
            <label for="anet-credit-card-edit-card-number"><?php esc_html_e('Card Number', 'authorize-net-payments-for-woocommerce'); ?></label>
            <input type="text" class="woocommerce-Input woocommerce-Input--text input-text" id="anet-credit-card-edit-card-number" name="card_number" maxlength="19" placeholder="Enter Card Number" autocomplete="off" required
                value="<?php echo esc_attr($anet_card_number); ?>" />
        </p>
        <div class="expiry-row">
            <p class="woocommerce-form-row woocommerce-form-row--wide form-row form-row-wide">
                <label for="anet-credit-card-edit-expiry-month"><?php esc_html_e('Expiry Month', 'authorize-net-payments-for-woocommerce'); ?></label>
                <select id="anet-credit-card-edit-expiry-month" class="woocommerce-Input woocommerce-Input--text input-text" name="expiry_month" style="height: 50px;" required>
                    <option value="" disabled selected><?php esc_html_e('Select Month', 'authorize-net-payments-for-woocommerce'); ?></option>
                    <option value="01"><?php esc_html_e('January', 'authorize-net-payments-for-woocommerce'); ?></option>
                    <option value="02"><?php esc_html_e('February', 'authorize-net-payments-for-woocommerce'); ?></option>
                    <option value="03"><?php esc_html_e('March', 'authorize-net-payments-for-woocommerce'); ?></option>
                    <option value="04"><?php esc_html_e('April', 'authorize-net-payments-for-woocommerce'); ?></option>
                    <option value="05"><?php esc_html_e('May', 'authorize-net-payments-for-woocommerce'); ?></option>
                    <option value="06"><?php esc_html_e('June', 'authorize-net-payments-for-woocommerce'); ?></option>
                    <option value="07"><?php esc_html_e('July', 'authorize-net-payments-for-woocommerce'); ?></option>
                    <option value="08"><?php esc_html_e('August', 'authorize-net-payments-for-woocommerce'); ?></option>
                    <option value="09"><?php esc_html_e('September', 'authorize-net-payments-for-woocommerce'); ?></option>
                    <option value="10"><?php esc_html_e('October', 'authorize-net-payments-for-woocommerce'); ?></option>
                    <option value="11"><?php esc_html_e('November', 'authorize-net-payments-for-woocommerce'); ?></option>
                    <option value="12"><?php esc_html_e('December', 'authorize-net-payments-for-woocommerce'); ?></option>
                </select>
            </p>
            <p class="woocommerce-form-row woocommerce-form-row--wide form-row form-row-wide">
                <label for="anet-credit-card-edit-expiry-month"><?php esc_html_e('Expiry Year', 'authorize-net-payments-for-woocommerce'); ?></label>
                <select id="anet-credit-card-edit-expiry-year" class="woocommerce-Input woocommerce-Input--text input-text" name="expiry_year" style="height: 50px;" required>
                    <!-- Years will be populated by JS -->
                </select>
            </p>
            <input type="hidden" name="anet_edit_nonce" value="<?php echo esc_attr(wp_create_nonce('anet_edit_nonce')); ?>" />
        </div>
        <p class="form-row">
            <button style="margin: 1em;" id="anet-credit-card-save-btn" type="submit" class="woocommerce-button button wp-element-button" name="save_card">Save</button>
            <a href="<?php echo esc_url(wc_get_account_endpoint_url(ANET_PAYMENT_METHODS)); ?>" id="anet-credit-card-cancel-btn" class="woocommerce-button button wp-element-button">Cancel</a>
        </p>
    </form>
</div>