<?php

defined( 'ABSPATH' ) or exit;

$rewards = pwlpar_get_rewards( array(
    'user_id' => $member->get_id(),
    'status__not_in' => array( 'trash' ),
) );

?>
<table class="pwlpara-table">
    <thead>
        <tr>
            <th><?php esc_html_e( 'Date claimed', 'pw-loyalty-points-and-rewards-for-woocommerce' ); ?></th>
            <th><?php esc_html_e( 'Offer', 'pw-loyalty-points-and-rewards-for-woocommerce' ); ?></th>
            <th><?php esc_html_e( 'Points', 'pw-loyalty-points-and-rewards-for-woocommerce' ); ?></th>
            <th><?php esc_html_e( 'Status', 'pw-loyalty-points-and-rewards-for-woocommerce' ); ?></th>
            <th><?php esc_html_e( 'Actions', 'pw-loyalty-points-and-rewards-for-woocommerce' ); ?></th>
        </tr>
    </thead>
    <tbody>
        <?php
            if ( !empty( $rewards ) ) {
                foreach ( $rewards as $reward ) {
                    ?>
                    <tr class="pwlpara-member-rewards-table-reward" data-id="<?php echo esc_attr( $reward->get_id() ); ?>" data-status="<?php echo esc_attr( $reward->get_status( 'edit' ) ); ?>">
                        <td><?php echo esc_html( $reward->get_create_date() ); ?></td>
                        <td><a href="<?php echo esc_attr( pwlpar_get_offer_edit_url( $reward->get_pimwick_rewards_offer_id() ) ); ?>"><?php echo esc_html( $reward->get_offer_title() ); ?></a></td>
                        <td><?php echo esc_html( $reward->get_offer_points() ); ?></td>
                        <td><?php echo esc_html( $reward->get_status() ); ?></td>
                        <td>
                            <a href="#" class="pwlpara-delete-reward-button button pwlpara-button-danger"></i> <?php esc_html_e( 'Delete', 'pw-loyalty-points-and-rewards-for-woocommerce' ); ?></a>
                        </td>
                    </tr>
                    <?php
                }
            } else {
                ?>
                <tr>
                    <td colspan="99"><?php esc_html_e( 'No rewards claimed.', 'pw-loyalty-points-and-rewards-for-woocommerce' ); ?></td>
                </tr>
                <?php
            }
        ?>
    </tbody>
</table>
<?php
