<?php
/*
 * Google Sheet configuration and settings page
 * @since 1.0
 */
if (!defined('ABSPATH')) {
    exit();
}
$active_tab = isset($_GET['tab']) ? sanitize_text_field(wp_unslash($_GET['tab'])) : 'integration';


$active_tab_name = '';
if ($active_tab == 'settings') {
    $active_tab_name = 'Settings';
}

$sub_tab = isset($_GET['sub_tab']) ? sanitize_text_field(wp_unslash($_GET['sub_tab'])) : 'general_settings';

switch ($active_tab) {
    case 'settings':
        // Render sub-navigation
        echo '</div><div class="sub-nav-bar">';
        $sub_tabs = array(
            'general_settings' => esc_html('General Settings', 'gsheetconnector-formidable-forms'),
            // 'role_settings' => esc_html('Role Settings', 'gsheetconnector-formidable-forms'),
            // 'beta_version' => esc_html('Beta Version Controls', 'gsheetconnector-formidable-forms'),
            'system_status' => esc_html('System Status', 'gsheetconnector-formidable-forms'),
        );

        foreach ($sub_tabs as $sub => $label) {
            $class = ($sub === $sub_tab) ? 'sub-nav-tab sub-nav-tab-active' : 'sub-nav-tab';
            echo '<a class="' . esc_attr($class) . '" href="' . esc_url(admin_url('admin.php?page=formidable-form-google-sheet-config&tab=settings&sub_tab=' . urlencode($sub))) . '">' . esc_html($label) . '</a>';
        }
        echo '</div> <div class="wrap-gsc">';

        // Load correct sub-tab content
        switch ($sub_tab) {
            case 'general_settings':
                include GSCFRMDFORM_VERSION_PATH . "includes/pages/formidable-general-settings.php";
                break;
            case 'beta_version':
                //include(GS_FLUENTFORM_CONNECTOR_PATH . "includes/pages/gs-fluentform-beta-version.php");
                break;
            case 'system_status':
                include GSCFRMDFORM_VERSION_PATH . 'includes/pages/formidable-forms-integrate-system-info.php';
                break;

        }
        break;

}
