<?php
if ( ! defined( 'ABSPATH' ) ) {
	exit; // Exit if accessed directly.
}

$payment_report_filters = SftcyWordformBase::wordform_get_payment_report_filter_options();
?>
<div id="wordformPaymentReportsWrapperTable" class="wordform-payment-reports-wrapper">
	<div class="wordform-payment-report-toolbar wordform-connection-status-toolbar-panel">
		<div class="wordform-connection-status-filter-grid wordform-payment-report-filter-grid">
			<div class="wordform-connection-status-filter">
				<label for="WordFormPaymentReportSelectForm"><strong><?php esc_html_e( 'Filter by Form', 'wordform-pro' ); ?></strong></label><br/>
				<select id="WordFormPaymentReportSelectForm" name="wordform-payment-report-selected-form">
					<option value=""><?php esc_html_e( 'All Forms', 'wordform-pro' ); ?></option>
					<?php
					if ( ! empty( $all_created_forms ) ) {
						foreach ( $all_created_forms as $data ) {
							echo '<option value="' . esc_attr( $data['form_id'] ) . '">' . esc_html( $data['form_name'] ) . '</option>';
						}
					}
					?>
				</select>
			</div>

			<div class="wordform-connection-status-filter">
				<label for="WordFormPaymentReportSelectGateway"><strong><?php esc_html_e( 'Filter by Gateway', 'wordform-pro' ); ?></strong></label><br/>
				<select id="WordFormPaymentReportSelectGateway" name="wordform-payment-report-selected-gateway">
					<option value=""><?php esc_html_e( 'All Gateways', 'wordform-pro' ); ?></option>
					<?php
					foreach ( $payment_report_filters['gateways'] as $gateway_slug => $gateway_name ) {
						echo '<option value="' . esc_attr( $gateway_slug ) . '">' . esc_html( $gateway_name ) . '</option>';
					}
					?>
				</select>
			</div>

			<div class="wordform-connection-status-filter">
				<label for="WordFormPaymentReportSelectStatus"><strong><?php esc_html_e( 'Filter by Status', 'wordform-pro' ); ?></strong></label><br/>
				<select id="WordFormPaymentReportSelectStatus" name="wordform-payment-report-selected-status">
					<option value=""><?php esc_html_e( 'All Statuses', 'wordform-pro' ); ?></option>
					<?php
					foreach ( $payment_report_filters['statuses'] as $status_key => $status_label ) {
						echo '<option value="' . esc_attr( $status_key ) . '">' . esc_html( $status_label ) . '</option>';
					}
					?>
				</select>
			</div>

			<div class="wordform-connection-status-filter wordform-connection-status-filter-summary">
				<h4><?php esc_html_e( 'Current View', 'wordform-pro' ); ?></h4>
				<p class="description wordform-payment-report-current-view" id="wordformPaymentReportCurrentView"><?php esc_html_e( 'Showing all payment records across all forms, gateways, and statuses.', 'wordform-pro' ); ?></p>
				<p class="description"><?php esc_html_e( 'Use the filters and search box together to inspect successful, processing, or failed payments by form and gateway.', 'wordform-pro' ); ?></p>
				<p class="description"><?php esc_html_e( 'Filters update the report instantly without leaving the Payment Reports tab.', 'wordform-pro' ); ?></p>
				<p class="wordform-payment-report-reset-line">
					<button type="button" class="button button-secondary" id="wordformPaymentReportResetFilters"><?php esc_html_e( 'Reset Filters', 'wordform-pro' ); ?></button>
				</p>
			</div>
		</div>
	</div>

	<table id="wordformPaymentReportsDataTable" class="display hover stripe wp-list-table widefat fixed striped table-view-list wordform-payment-reports-table">
		<thead>
			<tr>
				<th><?php esc_html_e( 'Form Name', 'wordform-pro' ); ?></th>
				<th><?php esc_html_e( 'Gateway', 'wordform-pro' ); ?></th>
				<th><?php esc_html_e( 'Payment Status', 'wordform-pro' ); ?></th>
				<th><?php esc_html_e( 'Amount', 'wordform-pro' ); ?></th>
				<th><?php esc_html_e( 'Coupon', 'wordform-pro' ); ?></th>
				<th><?php esc_html_e( 'Currency', 'wordform-pro' ); ?></th>
				<th><?php esc_html_e( 'Transaction Ref', 'wordform-pro' ); ?></th>
				<th><?php esc_html_e( 'Submission Date', 'wordform-pro' ); ?></th>
				<th><?php esc_html_e( 'Details', 'wordform-pro' ); ?></th>
			</tr>
		</thead>
		<tbody></tbody>
	</table>
</div>

<div id="WordFormPaymentReportDetailModal" class="WordFormPaymentReportDetailModal" title="<?php esc_attr_e( 'Payment Details', 'wordform-pro' ); ?>" style="display:none;"></div>
