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

include_once SFTCY_WORDFORM_PLUGIN_DIR . 'admin/views/pages-header-template.php';

$form_id   = isset( $_GET['form_id'] ) ? sanitize_text_field( wp_unslash( $_GET['form_id'] ) ) : '';
$form_row  = ! empty( $form_id ) ? SftcyWordformBase::sc_wordform_db_query( $form_id ) : [];
$form_name = ! empty( $form_row ) && ! empty( $form_row[0]['form_name'] ) ? sanitize_text_field( $form_row[0]['form_name'] ) : '';
?>
<div id="wordformConnectionStatusSendLogWrapperTable" class="wrap" data-form-id="<?php echo esc_attr( $form_id ); ?>">
	<div class="wordform-connection-send-log-page-header">
		<h3><i class="fa-solid fa-wave-square"></i>&nbsp;<?php esc_html_e( 'Connection Send Log', 'wordform-pro' ); ?></h3>
		<?php if ( ! empty( $form_name ) ) { ?>
			<p class="description">
				<?php
				echo esc_html(
					sprintf(
						/* translators: 1: form name, 2: form id */
						__( 'Showing send results for %1$s ( %2$s ).', 'wordform-pro' ),
						$form_name,
						$form_id
					)
				);
				?>
			</p>
		<?php } else { ?>
			<p class="description"><?php esc_html_e( 'Showing form send results for the selected WordForm.', 'wordform-pro' ); ?></p>
		<?php } ?>
		<p><a class="button button-secondary" href="<?php echo esc_url( admin_url( 'admin.php?page=wordform-connects#scWordFormConnectionStatus' ) ); ?>"><i class="fa-solid fa-arrow-left"></i> <?php esc_html_e( 'Back to Connection Status', 'wordform-pro' ); ?></a></p>
	</div>

	<table id="wordformConnectionStatusSendLogTable" class="display hover stripe wp-list-table widefat fixed striped table-view-list wordform-connection-send-log-table">
		<thead>
			<tr>
				<th><?php esc_html_e( 'Form Name', 'wordform-pro' ); ?></th>
				<th><?php esc_html_e( 'Application', 'wordform-pro' ); ?></th>
				<th><?php esc_html_e( 'Send Status', 'wordform-pro' ); ?></th>
				<th><?php esc_html_e( 'Sending Datetime', 'wordform-pro' ); ?></th>
				<th><?php esc_html_e( 'Details', 'wordform-pro' ); ?></th>
			</tr>
		</thead>
		<tbody></tbody>
	</table>

	<div id="WordFormConnectionSendLogFailDetailModal" class="WordFormConnectionSendLogFailDetailModal" title="<?php esc_attr_e( 'Send Failure Details', 'wordform-pro' ); ?>" style="display:none;"></div>
	<div id="WordFormConnectionSendLogSuccessDetailModal" class="WordFormConnectionSendLogSuccessDetailModal" title="<?php esc_attr_e( 'Submitted Data', 'wordform-pro' ); ?>" style="display:none;"></div>
</div>
