<?php
/**
 * PW Rewards History
 *
 * Shows rewards transaction history.
 *
 * This template can be overridden by copying it to yourtheme/pw-rewards/history.php.
 *
 * HOWEVER, on occasion Pimwick will need to update template files and you
 * (the theme developer) will need to copy the new files to your theme to
 * maintain compatibility. We try to do this as little as possible, but it does
 * happen. When this occurs the version of the template file will be bumped and
 * the readme will list any important changes.
 *
 * @see https://woocommerce.com/document/template-structure/
 */

defined( 'ABSPATH' ) || exit;

pwlpar_heading( array( 'show_history_button' => false ) );

do_action( 'pwlpar_before_history' );

?>
<div class="pwlpar-rewards-history-content">
    <table id="pwlpar-rewards-history-table">
        <thead>
            <tr>
                <th><?php esc_html_e( 'Date', '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( 'Description', 'pw-loyalty-points-and-rewards-for-woocommerce' ); ?></th>
            </tr>
        </thead>
        <tbody>
            <?php
                if ( !empty( $transactions ) ) {
                    foreach ( $transactions as $transaction ) {
                        ?>
                        <tr>
                            <td><?php echo esc_html( $transaction->get_create_date() ); ?></td>
                            <td>
                                <?php
                                    if ( $transaction->get_points( 'edit' ) > 0 ) {
                                        echo '<span class="pwlpar-history-points-earned">+' . esc_html( $transaction->get_points() ) . '</span>';
                                    } else {
                                        echo esc_html( $transaction->get_points() );
                                    }
                                ?>
                            </td>
                            <td><?php echo esc_html( $transaction->get_note() ); ?></td>
                        </tr>
                        <?php
                    }
                } else {
                    ?>
                    <tr>
                        <td colspan="99"><?php esc_html_e( 'No activity found.', 'pw-loyalty-points-and-rewards-for-woocommerce' ); ?></td>
                    </tr>
                    <?php
                }
            ?>
        </tbody>
    </table>
</div>
<?php

do_action( 'pwlpar_after_history' );
