<?php
/**
 * Order details Summary
 *
 * This template displays a summary of Desposit payments for email template
 *
 * @version 1.5
 */

use Bright_Deposits_For_WooCommerce\Helpers\Helper;

if ( !defined( 'ABSPATH' ) ) {
    exit;
}
if ( !$order ) {
    return;
}
$bdfwbp_args = array(
    'type'   => 'shop_deposit',
    'parent' => $order->get_id(),
);

$bdfwbp_deposit_list = wc_get_orders( $bdfwbp_args );
if ( ! empty( $bdfwbp_deposit_list ) ) {

?> <h3> <?php echo esc_html( Helper::getOptionValue( 'bdfw_deposit_payments_summary_label' ) ); ?> </h3>

<table border="0" cellpadding="20" cellspacing="0" style="width:100%; margin-bottom:15px">

    <thead>
    <tr>

        <th class="td" style="color: #636363; border: 1px solid #e5e5e5; vertical-align: middle; padding: 12px;"><?php echo esc_html( Helper::getOptionValue( 'bdfw_payment_id_label' ) ); ?></th>
        <th class="td" style="color: #636363; border: 1px solid #e5e5e5; vertical-align: middle; padding: 12px;"><?php echo esc_html( Helper::getOptionValue( 'bdfw_status_label' ) ); ?></th>
        <th class="td" style="color: #636363; border: 1px solid #e5e5e5; vertical-align: middle; padding: 12px;"><?php echo esc_html( Helper::getOptionValue( 'bdfw_amount_label' ) ); ?></th>
        <th class="td" style="color: #636363; border: 1px solid #e5e5e5; vertical-align: middle; padding: 12px;"><?php echo esc_html( Helper::getOptionValue( 'bdfw_actions_label' ) ); ?></th>

    </tr>

    </thead>

    <tbody>
    <?php
foreach ( $bdfwbp_deposit_list as $bdfwbp_deposit_order ) {?>

        <tr class="order_item">

            <td class="td" style="color: #636363; border: 1px solid #e5e5e5; vertical-align: middle; padding: 12px;">
              <?php echo '<strong>#' . esc_html( $bdfwbp_deposit_order->get_meta( '_deposit_id', true ) ) . '</strong>'; ?>

            </td>
            <td class="td" style="color: #636363; border: 1px solid #e5e5e5; vertical-align: middle; padding: 12px;">
            <?php $bdfwbp_deposit_status = $bdfwbp_deposit_order->get_status(); // order status ?>
            <?php echo esc_html( wc_get_order_status_name( $bdfwbp_deposit_status ) ); ?>
            </td>
            <td class="td" style="color: #636363; border: 1px solid #e5e5e5; vertical-align: middle; padding: 12px;">
            <?php echo wp_kses_post( wc_price( $bdfwbp_deposit_order->get_total() ) ); ?>
            </td>


            <td class="td" style="color: #636363; border: 1px solid #e5e5e5; vertical-align: middle; padding: 12px;">
            <?php
if ( $bdfwbp_deposit_order->get_status() === 'pending' ) {
        echo '<a href="' . esc_url( $bdfwbp_deposit_order->get_checkout_payment_url() ) . '" class="woocommerce-button button deposit-pay-button"> ' . esc_html( Helper::getOptionValue( 'bdfw_make_payment_label' ) ) . ' </a>';
    } else {
        echo '-';
    }
    ?>
            </td>
        </tr>
        <?php
}
?>

    </tbody>

    <tfoot>


    </tfoot>
</table>
<?php
} // end if