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

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

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

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

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

    // Delete the transient after displaying the message.
    delete_transient('iafwzdesk_error_log_success');
}
// Retrieve the transient.
$iafwzdesk_message = get_transient('iafwzdesk_error_log_fail');

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

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

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

</div>

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