<?php
if ( ! defined( 'ABSPATH' ) ) {
    exit;
}
// Log Tab Content
?>
<div id="integrazo_fwcrm_form-content-errorlog" class="integrazo_fwcrm_form-tab-content" style="display:none;">

    <span class="integrazo_fwcrm_form-span-header"><?php esc_html_e('Error Logs', 'crm-integration-freshworks-any-form'); ?></span>

    <div class="integrazo_fwcrm_form-help-icon-wrapper">
        <span class="integrazo_fwcrm_form-help-icon">?</span>
       <div class="integrazo_fwcrm_form-help-tooltip">
            <p>View and manage your Freshsales CRM 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('integrazo_fwcrm_form_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('integrazo_fwcrm_form_error_log_success');
}
// Retrieve the transient.
$message = get_transient('integrazo_fwcrm_form_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('integrazo_fwcrm_form_error_log_fail');
}
?>
    <form id="error-log-form" method="post" action="">
        <?php
    // Add a nonce field for security
    wp_nonce_field('integrazo_fwcrm_form_error_log_form_action', 'integrazo_fwcrm_form_error_log_form_action_nonce');
?>
        <input type="hidden" name="page" value="crm-integration-freshworks-any-form">
        <input type="hidden" name="tab" value="errorlog">
        <?php

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

</div>

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