<?php
/**
 * pageSettingsTabs.php
 *
 * @since      1.0.0
 * @author     alfiopiccione <alfio.piccione@gmail.com>
 * @license    http://opensource.org/licenses/gpl-2.0.php GPL v2
 *
 * Copyright (C) 2025 POP
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 */

if (! defined('ABSPATH')) {
    exit; // Exit if accessed directly.
}

$uidOption = (int)get_option('pop_account_user_id', false);
$tabs      = array(
    // General tab.
    'general'              => array(
        'header'     => array(
            '<i class="dashicons dashicons-admin-settings"></i>',
            esc_html__('General', WC_EL_INV_TEXTDOMAIN),
        ),
        'section_id' => 'setting_section_general',
        'submit'     => false,
    ),
    // Provider Integration.
    'provider-integration' => array(
        'header'     => array(
            '<i class="dashicons dashicons-cart"></i>',
            esc_html__('Checkout', WC_EL_INV_TEXTDOMAIN),
        ),
        'section_id' => 'setting_section_provider-integration',
        'submit'     => true,
    ),
    // Numeration.
    'numeration'           => array(
        'header'     => array(
            '<i class="dashicons dashicons-editor-ol-rtl"></i>',
            esc_html__('Numeration', WC_EL_INV_TEXTDOMAIN),
        ),
        'section_id' => 'setting_section_numeration',
        'submit'     => true,
    ),
    // Invoice / Documents
    'invoice'              => array(
        'header'     => array(
            '<i class="dashicons dashicons-media-text"></i>',
            esc_html__('Documents', WC_EL_INV_TEXTDOMAIN),
        ),
        'section_id' => 'setting_section_invoice',
        'submit'     => true,
    ),
    // Advanced
    'advanced'             => array(
        'header'     => array(
            '<i class="dashicons dashicons-admin-generic"></i>',
            esc_html__('Advanced', WC_EL_INV_TEXTDOMAIN),
        ),
        'section_id' => 'setting_section_advanced',
        'submit'     => true,
    ),
    // Xml tab.
    'xml'                  => array(
        'header'     => array(
            '<i class="dashicons dashicons-media-code"></i>',
            esc_html__('Invoices', WC_EL_INV_TEXTDOMAIN),
        ),
        'section_id' => 'setting_section_xml',
        'submit'     => false,
    ),
);

$tabs['integration'] = array(
    'header'     => array(
        '<i class="dashicons dashicons-store"></i>',
        esc_html__('Integrations', WC_EL_INV_TEXTDOMAIN),
    ),
    'section_id' => 'setting_section_integration',
    'submit'     => false,
);

// Addon.
$sdiPecActive = boolval(get_option('wc_el_inv-addon-sdi-pec'));
$arubaActive  = boolval(get_option('wc_el_inv-addon-aruba'));
$ficActive    = boolval(get_option('wc_el_inv-addon-fattureincloud'));

$addonTitle = null;
if ($sdiPecActive) {
    $addonTitle = 'SdI PEC';
} elseif ($arubaActive) {
    $addonTitle = 'Fatture Aruba';
} elseif ($ficActive) {
    $addonTitle = 'Fatture in Cloud';
}
if ($addonTitle) {
    $tabs['addon'] = array(
        'header'     => array(
            '<i class="dashicons dashicons-admin-settings"></i>',
            esc_html__($addonTitle, WC_EL_INV_TEXTDOMAIN),
        ),
        'section_id' => 'setting_section_addon',
        'submit'     => true,
    );
}
if (! $uidOption) {
    // Wizard tab.
    $tabs['wizard'] = array(
        'header'     => array(
            '<i class="dashicons dashicons-admin-settings"></i>',
            esc_html__('Wizard setup', WC_EL_INV_TEXTDOMAIN),
        ),
        'section_id' => 'setting_section_wizard',
        'submit'     => false,
    );
}

return apply_filters('wc_el_inv-page_settings_tab', $tabs);
