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

?>
<div id="iafwzcai-content-errorlog" class="iafwzcai-tab-content" style="display:none;">

    <span class="iafwzcai-span-header"><?php esc_html_e('Logs', 'integrate-with-zoho-campaigns'); ?></span>

    <div class="iafwzcai-help-icon-wrapper">
        <span class="iafwzcai-help-icon">?</span>
        <div class="iafwzcai-help-tooltip">
        <p>View and manage your Zoho Campaigns submission logs. Track successful syncs, identify failed records, retry submissions, and monitor your integration activity in one place.</p>        </div>
    </div>
    <?php
    $message = get_transient('iafwzcai_error_log_success');

// If there is a message, display it as an admin notice.
if ($message) {
    echo '<div class="notice notice-success is-dismissible">
                <p>' . esc_html($message) . '</p>
              </div>';

    // Delete the transient after displaying the message.
    delete_transient('iafwzcai_error_log_success');
}
// Retrieve the transient.
$message = get_transient('iafwzcai_error_log_fail');

// If there is a message, display it as an admin notice.
if ($message) {
    echo '<div class="notice notice-error is-dismissible">
                  <p>' . esc_html($message) . '</p>
                </div>';

    // Delete the transient after displaying the message.
    delete_transient('iafwzcai_error_log_fail');
}
?>
    <form id="error-log-form" method="post" action="">
        <?php
    // Add a nonce field for security
    wp_nonce_field('iafwzcai_error_log_form_action', 'iafwzcai_error_log_form_action_nonce');
?>
        <input type="hidden" name="page" value="integrate-with-zoho-campaigns">
        <input type="hidden" name="tab" value="errorlog">
        <?php

// Display the error log table
$error_log_table = new IAFWZCAI_Error_Log_Extend();
$error_log_table->prepare_items(); // Prepare error log table items
$error_log_table->display();       // Display error log table
?>
    </form>

</div>

<div id="iafwzcai-error-overlay" class="iafwzcai-error-overlay">
    <div class="iafwzcai-error-modal">
        <span class="iafwzcai-error-close" onclick="iafwzcai_closeErrorOverlay()">&times;</span>
        <div id="iafwzcai-error-content"></div>
    </div>
</div>