<?php

// phpcs:disable WordPress.WP.I18n.TextDomainMismatch -- Bridge to pay4all-for-twint :
// this WooCommerce integration re-emits the TWINT gateway strings the free
// plugin already ships and translates. Reusing its text domain avoids
// duplicating dozens of msgids × 4 locales in pay4all-pro's .po files.
defined( 'ABSPATH' ) || exit;

// This file is included via pay4all_for_twint_get_template() and returns an
// HTML string ; the "$pay4all_for_twint_*" variables below are file-local to
// the include, not truly global. Plugin Check treats top-level $vars as
// globals regardless, so silence the sniff for the whole template body.
// phpcs:disable WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- Template-local variables, not real globals ; already prefixed with the plugin slug.
$pay4all_for_twint_html = '<table><tbody>';

if ( !empty( $transactions ) ) {

    $pay4all_for_twint_html .= '<tr>';
    $pay4all_for_twint_html .= '<th>' . __( 'Date', 'pay4all-for-twint' ) . '</th>';
    $pay4all_for_twint_html .= '<th>' . __( 'Reference', 'pay4all-for-twint' ) . '</th>';
    $pay4all_for_twint_html .= '<th>' . __( 'Type', 'pay4all-for-twint' ) . '</th>';
    $pay4all_for_twint_html .= '<th>' . __( 'Amount', 'pay4all-for-twint' ) . '</th>';
    $pay4all_for_twint_html .= '<th>' . __( 'Fee', 'pay4all-for-twint' ) . '</th>';
    $pay4all_for_twint_html .= '</tr>';

    foreach ( $transactions as $pay4all_for_twint_transaction ) {
        $pay4all_for_twint_html .= '<tr>';
        $pay4all_for_twint_html .= '<td>' . ( isset( $pay4all_for_twint_transaction[ 'created_at' ] ) ? \Twnt4All\Support\WpBridge::get_local_formatted_datetime( strtotime( $pay4all_for_twint_transaction[ 'created_at' ] ) ) : '' ) . '</td>';
        $pay4all_for_twint_html .= '<td>' . ( $pay4all_for_twint_transaction[ 'reference' ] ?? '' ) . '</td>';
        $pay4all_for_twint_html .= '<td>' . ( isset( $pay4all_for_twint_transaction[ 'operation' ] ) ? $pay4all_for_twint_transaction[ 'operation' ] : ( isset( $pay4all_for_twint_transaction[ 'type' ] ) ? $pay4all_for_twint_transaction[ 'type' ] : '' ) ) . '</td>';
        $pay4all_for_twint_html .= '<td>' . ( $pay4all_for_twint_transaction[ 'amount' ] ?? '' ) . '</td>';
        $pay4all_for_twint_html .= '<td>' . ( $pay4all_for_twint_transaction[ 'fee' ] ?? '' ) . '</td>';
        $pay4all_for_twint_html .= '</tr>';
    }
}
$pay4all_for_twint_html .= '</tbody></table>';
return $pay4all_for_twint_html;
// phpcs:enable WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound