<?php

defined( 'ABSPATH' ) or exit;

?>
<div class="pwlpara-fieldset-title">
    <?php echo esc_html( $member->get_display_name() ); ?>
</div>
<div class="pwlpara-field-section pwlpara-member-edit-read-only-fields-container">
    <div>
        <label>
            <?php esc_html_e( 'Login', 'pw-loyalty-points-and-rewards-for-woocommerce' ); ?><br>
            <strong><a href="<?php echo esc_attr( $member->get_edit_url() ); ?>"><?php echo esc_html( $member->get_login() ); ?></a></strong>
        </label>
    </div>
    <div>
        <label>
            <?php esc_html_e( 'Email', 'pw-loyalty-points-and-rewards-for-woocommerce' ); ?><br>
            <strong><a href="mailto: <?php echo esc_attr( $member->get_email() ); ?>"><?php echo esc_html( $member->get_email() ); ?></a></strong>
        </label>
    </div>
</div>

<div class="pwlpara-field-section">
    <form id="pwlpara-member-edit-form" method="post" data-action="save_member">
        <input type="hidden" id="pwlpara-member-edit-user-id" name="member_id" value="<?php echo esc_attr( $member->get_id() ); ?>">
        <div class="pwlpara-member-edit-fields-container">
            <div class="pwlpara-form-field">
                <label>
                    <input type="checkbox" id="pwlpara-member-edit-is-enrolled" name="is_enrolled" <?php checked( $member->get_is_enrolled() ); ?>>
                    <?php esc_html_e( 'Enrolled in rewards program', 'pw-loyalty-points-and-rewards-for-woocommerce' ); ?>
                </label>
            </div>

            <div>
                <label>
                    <?php esc_html_e( 'Balance', 'pw-loyalty-points-and-rewards-for-woocommerce' ); ?><br>
                    <div id="pwlpara-member-edit-balance" style="font-weight: bold;"><?php echo esc_html( $member->get_balance() ); ?></div>
                </label>
            </div>
            <div>
                <label>
                    <?php esc_html_e( 'Member since', 'pw-loyalty-points-and-rewards-for-woocommerce' ); ?><br>
                    <?php if ( $member->get_is_enrolled() ) : ?>
                    <strong><?php echo esc_html( $member->get_join_date() ); ?></strong>
                    <?php else : ?>
                    <strong style="color: red;"><?php esc_html_e( 'Not enrolled', 'pw-loyalty-points-and-rewards-for-woocommerce' ); ?></strong>
                    <?php endif; ?>
                </label>
            </div>
            <div class="pwlpara-form-field">
                <div id="pwlpara-member-edit-form-message"></div>
                <div id="pwlpara-member-edit-form-buttons-container">
                    <input type="submit" class="button button-primary" value="<?php esc_attr_e( 'Update member', 'pw-loyalty-points-and-rewards-for-woocommerce' ); ?>">
                    <a href="<?php echo esc_attr( pwlpara_admin_url( 'members' ) ); ?>" class="pwlpara-cancel-button button button-secondary"><?php esc_html_e( 'Cancel', 'pw-loyalty-points-and-rewards-for-woocommerce' ); ?></a>
                </div>
            </div>
        </div>
    </form>
</div>

<div class="pwlpara-field-section" style="margin-top: 42px;">
    <div class="pwlpara-fieldset-title">
        <?php esc_html_e( 'Rewards', 'pw-loyalty-points-and-rewards-for-woocommerce' ); ?>
    </div>
    <div id="pwlpara-section-member-edit-actions" class="pwlpara-section-actions">
        <div>
            <label for="pwlpara-member-edit-reward-status-filter"><?php esc_html_e( 'Filter by status', 'pw-loyalty-points-and-rewards-for-woocommerce' ); ?></label>
            <select id="pwlpara-member-edit-reward-status-filter">
                <option value=""><?php esc_html_e( 'All statuses', 'pw-loyalty-points-and-rewards-for-woocommerce' ); ?></option>
                <?php foreach ( pwlpar_get_reward_statuses() as $status => $name ) : ?>
                    <option value="<?php echo esc_attr( $status ); ?>"><?php echo esc_html( $name ); ?></option>
                <?php endforeach; ?>
            </select>
        </div>
    </div>
    <div id="pwlpara-member-edit-rewards">
        <?php
            require_once( PWLPAR_PLUGIN_DIR . '/admin/ui/sections/member-rewards.php' );
        ?>
    </div>
</div>

<div class="pwlpara-field-section" style="margin-top: 42px;">
    <div class="pwlpara-fieldset-title">
        <?php esc_html_e( 'Transactions', 'pw-loyalty-points-and-rewards-for-woocommerce' ); ?>
    </div>
    <div id="pwlpara-section-member-edit-actions" class="pwlpara-section-actions">
        <a href="#" id="pwlpara-member-edit-add-transaction-button" class="button button-secondary"><?php esc_html_e( 'Add a transaction', 'pw-loyalty-points-and-rewards-for-woocommerce' ); ?></a>
    </div>
    <div id="pwlpara-member-edit-transactions">
        <?php
            require_once( PWLPAR_PLUGIN_DIR . '/admin/ui/sections/member-transactions.php' );
        ?>
    </div>
</div>
