<?php

class kavehboardOptions
{
    private $prefix;

    public function __construct($prefix)
    {
        $this->prefix = $prefix;
        $this->create_options();

    }

    public function create_options()
    {
        if (class_exists('CSF')) {
            CSF::createOptions(
                $this->prefix,
                array(
                    'menu_title' => __('User Dashboard Options', 'kavehTheme'),
                    'menu_slug' => 'kavehboard-options',
                    'menu_icon' => 'dashicons-admin-generic',
                )
            );

            $sections = array(
                array(
                    'id' => 'panel_tab',
                    'title' => __('Panel', 'kavehTheme'),
                    'fields' => $this->get_section_panel_fields(),
                ),
                array(
                    'id' => 'dashboard_tab',
                    'title' => __('Dashboard', 'kavehTheme'),
                    'fields' => $this->get_section_dashboard_fields(),
                ),
                array(
                    'id' => 'ticket_system_tab',
                    'title' => __('Ticket System', 'kavehTheme'),
                    'fields' => $this->get_section_ticket_system_fields(),
                ),
                array(
                    'id' => 'wallet_system_tab',
                    'title' => __('Wallet System', 'kavehTheme'),
                    'fields' => $this->get_section_wallet_system_fields(),
                ),

            );

            foreach ($sections as $section) {
                CSF::createSection($this->prefix, $section);
            }
        }
    }


    private function get_section_dashboard_fields()
    {
        return array(
            array(
                'id' => 'kavehboard_header_text',
                'type' => 'group',
                'title' => __('Dashboard Header Text', 'kavehTheme'),
                'desc' => __('Configure the header text displayed on dashboard', 'kavehTheme'),
                'fields' => array(
                    array(
                        'id' => 'page_name',
                        'type' => 'text',
                        'title' => __('Page Name', 'kavehTheme'),
                        'default' => 'داشبورد',
                    ),
                    array(
                        'id' => 'description',
                        'type' => 'textarea',
                        'title' => __('Description Text', 'kavehTheme'),
                        'default' => 'این یک پیام است که میتواند هرچه را دوست داشته باشد بنویسد 👋',
                    ),
                ),
            ),
            array(
                'id' => 'kavehboard_menu_type',
                'type' => 'select',
                'title' => __('Dashboard Menu Type', 'kavehTheme'),
                'desc' => __('Choose how to display dashboard menu items', 'kavehTheme'),
                'options' => array(
                    'custom' => __('Custom Menu Only', 'kavehTheme'),
                    'woocommerce' => __('WooCommerce Menu Only', 'kavehTheme'),
                    'combined' => __('Combined (Custom + WooCommerce)', 'kavehTheme'),
                ),
                'default' => 'custom',
            ),
            array(
                'id' => 'kavehboard_dashboard_menu',
                'type' => 'repeater',
                'title' => __('Dashboard Menu', 'kavehTheme'),
                'fields' => array(
                    array(
                        'id' => 'icon',
                        'type' => 'text',
                        'title' => __('Icon', 'kavehTheme'),
                        'desc' => __('CSS class for the icon', 'kavehTheme'),
                    ),
                    array(
                        'id' => 'text',
                        'type' => 'text',
                        'title' => __('Text', 'kavehTheme'),
                    ),
                    array(
                        'id' => 'slug',
                        'type' => 'text',
                        'title' => __('Slug', 'kavehTheme'),
                    ),
                    array(
                        'id' => 'elementor_template',
                        'type' => 'select',
                        'title' => __('Elementor Template', 'kavehTheme'),
                        'options' => 'kavehboard_get_elementor_templates',
                        'desc' => __('Select an Elementor template', 'kavehTheme'),
                    ),
                    array(
                        'id' => 'shortcode',
                        'type' => 'textarea',
                        'title' => __('Shortcode', 'kavehTheme'),
                        'desc' => __('Alternative shortcode content', 'kavehTheme'),
                    ),
                ),
                'default' => array(
                    array(
                        'icon' => 'icon-wallet',
                        'text' => __('Wallet', 'kavehTheme'),
                        'slug' => 'wallet',
                        'elementor_template' => '',
                        'shortcode' => '',
                    ),
                ),
            ),
            array(
                'id' => 'kavehboard_dashboard_carousel',
                'type' => 'repeater',
                'title' => __('Dashboard Carousel Slides', 'kavehTheme'),
                'desc' => __('Configure the carousel slides displayed on the dashboard', 'kavehTheme'),
                'fields' => array(
                    array(
                        'id' => 'image',
                        'type' => 'media',
                        'title' => __('Slide Image', 'kavehTheme'),
                        'desc' => __('Upload or select an image for this slide', 'kavehTheme'),
                        'library' => 'image',
                    ),
                    array(
                        'id' => 'title',
                        'type' => 'text',
                        'title' => __('Slide Title', 'kavehTheme'),
                        'desc' => __('Optional title for the slide (for accessibility)', 'kavehTheme'),
                    ),
                    array(
                        'id' => 'link',
                        'type' => 'text',
                        'title' => __('Slide Link', 'kavehTheme'),
                        'desc' => __('URL to link to when slide is clicked (optional)', 'kavehTheme'),
                    ),
                    array(
                        'id' => 'link_target',
                        'type' => 'select',
                        'title' => __('Link Target', 'kavehTheme'),
                        'options' => array(
                            '_self' => __('Same Window', 'kavehTheme'),
                            '_blank' => __('New Window', 'kavehTheme'),
                        ),
                        'default' => '_self',
                        'dependency' => array('link', '!=', ''),
                    ),
                ),
                'default' => array(
                    array(
                        'image' => array(
                            'url' => KAVEHBOARD_URL . '/assets/images/dashboard/carousel.png',
                        ),
                        'title' => __('Default Slide 1', 'kavehTheme'),
                        'link' => '#',
                        'link_target' => '_self',
                    ),
                    array(
                        'image' => array(
                            'url' => KAVEHBOARD_URL . '/assets/images/dashboard/carousel.png',
                        ),
                        'title' => __('Default Slide 2', 'kavehTheme'),
                        'link' => '#',
                        'link_target' => '_self',
                    ),
                ),
            ),
            array(
                'id' => 'kavehboard_discount_code',
                'type' => 'group',
                'title' => __('Discount Code Section', 'kavehTheme'),
                'desc' => __('Configure the discount code display on dashboard', 'kavehTheme'),
                'fields' => array(
                    array(
                        'id' => 'enable',
                        'type' => 'switcher',
                        'title' => __('Enable Discount Code Section', 'kavehTheme'),
                        'default' => true,
                    ),
                    array(
                        'id' => 'image',
                        'type' => 'media',
                        'title' => __('Discount Code Image', 'kavehTheme'),
                        'desc' => __('Upload or select an image for the discount code section', 'kavehTheme'),
                        'library' => 'image',
                        'default' => array(
                            'url' => KAVEHBOARD_URL . '/assets/images/dashboard/gift.png',
                        ),
                        'dependency' => array('enable', '==', 'true'),
                    ),
                    array(
                        'id' => 'code',
                        'type' => 'text',
                        'title' => __('Discount Code', 'kavehTheme'),
                        'desc' => __('The discount code to display and copy', 'kavehTheme'),
                        'default' => 'kave.unamirix',
                        'dependency' => array('enable', '==', 'true'),
                    ),
                    array(
                        'id' => 'description',
                        'type' => 'textarea',
                        'title' => __('Discount Description', 'kavehTheme'),
                        'desc' => __('Description text for the discount code', 'kavehTheme'),
                        'default' => 'کد تخفیف ۲۰ درصدی تا ۱۸ خرداد روی تممام سفارشات سایت',
                        'dependency' => array('enable', '==', 'true'),
                    ),
                ),
            ),
        );
    }

  private function get_section_panel_fields()
    {
        return array(
            array(
                'id' => 'kavehboard_logo',
                'type' => 'media',
                'title' => __('Dashboard Logo', 'kavehTheme'),
                'desc' => __('Upload a custom logo for the dashboard. If not set, the default logo will be used.', 'kavehTheme'),
                'library' => 'image',
                'default' => array(
                    'url' => KAVEHBOARD_URL . '/assets/images/dashboard/logo.svg',
                ),
            ),
            array(
                'id' => 'kavehboard_page',
                'type' => 'select',
                'title' => __('Dashboard Page', 'kavehTheme'),
                'options' => 'kavehboard_get_pages_options',
                'desc' => __('Select the page to use as dashboard', 'kavehTheme'),
            ),
            array(
                'id' => 'kavehboard_woo_redirect',
                'type' => 'switcher',
                'title' => __('WooCommerce Redirect', 'kavehTheme'),
                'desc' => __('Enable WooCommerce redirect functionality', 'kavehTheme'),
                'default' => false,
            ),
            array(
                'id' => 'kavehboard_social_media_title',
                'type' => 'text',
                'title' => __('Social Media Title', 'kavehTheme'),
                'default' => __('Follow Us', 'kavehTheme'),
            ),
            array(
                'id' => 'kavehboard_social_media_links',
                'type' => 'repeater',
                'title' => __('Social Media Links', 'kavehTheme'),
                'fields' => array(
                    array(
                        'id' => 'name',
                        'type' => 'text',
                        'title' => __('Name', 'kavehTheme'),
                    ),
                    array(
                        'id' => 'url',
                        'type' => 'text',
                        'title' => __('URL', 'kavehTheme'),
                    ),
                    array(
                        'id' => 'icon_class',
                        'type' => 'text',
                        'title' => __('Icon Class', 'kavehTheme'),
                        'desc' => __('CSS class for the icon (e.g., fab fa-facebook)', 'kavehTheme'),
                    ),
                ),
            ),
            array(
                'id' => 'kavehboard_copyright_text',
                'type' => 'text',
                'title' => __('Copyright Text', 'kavehTheme'),
                'default' => __('© 2024 All rights reserved', 'kavehTheme'),
            ),
            array(
                'id' => 'kavehboard_contact_info',
                'type' => 'group',
                'title' => __('Contact Information', 'kavehTheme'),
                'desc' => __('Configure contact information displayed in dashboard sidebar', 'kavehTheme'),
                'fields' => array(
                    array(
                        'id' => 'enable',
                        'type' => 'switcher',
                        'title' => __('Enable Contact Section', 'kavehTheme'),
                        'default' => true,
                    ),
                    array(
                        'id' => 'title',
                        'type' => 'text',
                        'title' => __('Contact Title', 'kavehTheme'),
                        'default' => __('Contact Us', 'kavehTheme'),
                        'dependency' => array('enable', '==', 'true'),
                    ),
                    array(
                        'id' => 'phone',
                        'type' => 'text',
                        'title' => __('Phone Number', 'kavehTheme'),
                        'default' => '0913 693 7892',
                        'dependency' => array('enable', '==', 'true'),
                    ),
                    array(
                        'id' => 'icon',
                        'type' => 'text',
                        'title' => __('Contact Icon Class', 'kavehTheme'),
                        'default' => 'icon-call-calling',
                        'desc' => __('CSS class for the contact icon', 'kavehTheme'),
                        'dependency' => array('enable', '==', 'true'),
                    ),
                ),
            ),
        );
    }

    private function get_section_ticket_system_fields()
    {
        return array(
            array(
                'id' => 'kavehboard_ticket_auto_assign',
                'type' => 'switcher',
                'title' => __('Auto Assign Tickets', 'kavehTheme'),
                'desc' => __('Automatically assign tickets to department default agents', 'kavehTheme'),
                'default' => true,
            ),
            array(
                'id' => 'kavehboard_ticket_email_notifications',
                'type' => 'switcher',
                'title' => __('Email Notifications', 'kavehTheme'),
                'desc' => __('Send email notifications for ticket updates', 'kavehTheme'),
                'default' => false,
            ),
        );
    }



    private function get_section_wallet_system_fields()
    {
        return array(
            array(
                'id' => 'kavehboard_wallet_enable',
                'type' => 'switcher',
                'title' => __('Enable Wallet System', 'kavehTheme'),
                'desc' => __('Enable or disable the wallet system functionality', 'kavehTheme'),
                'default' => true,
            ),
            array(
                'id' => 'kavehboard_wallet_currency',
                'type' => 'text',
                'title' => __('Wallet Currency Symbol', 'kavehTheme'),
                'desc' => __('Currency symbol to display with wallet amounts', 'kavehTheme'),
                'default' => '$',
                'dependency' => array('kavehboard_wallet_enable', '==', 'true'),
            ),
            array(
                'id' => 'kavehboard_wallet_min_add_amount',
                'type' => 'number',
                'title' => __('Minimum Add Funds Amount', 'kavehTheme'),
                'desc' => __('Minimum amount users can add to their wallet', 'kavehTheme'),
                'default' => 10,
                'dependency' => array('kavehboard_wallet_enable', '==', 'true'),
            ),
            array(
                'id' => 'kavehboard_wallet_max_add_amount',
                'type' => 'number',
                'title' => __('Maximum Add Funds Amount', 'kavehTheme'),
                'desc' => __('Maximum amount users can add to their wallet in a single transaction', 'kavehTheme'),
                'default' => 1000,
                'dependency' => array('kavehboard_wallet_enable', '==', 'true'),
            ),
            array(
                'id' => 'kavehboard_wallet_quick_amounts',
                'type' => 'text',
                'title' => __('Quick Add Amounts', 'kavehTheme'),
                'desc' => __('Comma-separated list of quick add amounts (e.g., 10,25,50,100,250,500)', 'kavehTheme'),
                'default' => '10,25,50,100,250,500',
                'dependency' => array('kavehboard_wallet_enable', '==', 'true'),
            ),
            array(
                'id' => 'kavehboard_wallet_partial_payment',
                'type' => 'switcher',
                'title' => __('Allow Partial Payments', 'kavehTheme'),
                'desc' => __('Allow users to use wallet balance for partial payments when balance is insufficient', 'kavehTheme'),
                'default' => true,
                'dependency' => array('kavehboard_wallet_enable', '==', 'true'),
            ),
            array(
                'id' => 'kavehboard_wallet_show_on_dashboard',
                'type' => 'switcher',
                'title' => __('Show Wallet on Dashboard', 'kavehTheme'),
                'desc' => __('Display wallet balance and quick stats on the main dashboard', 'kavehTheme'),
                'default' => true,
                'dependency' => array('kavehboard_wallet_enable', '==', 'true'),
            ),
            array(
                'id' => 'kavehboard_wallet_transaction_limit',
                'type' => 'number',
                'title' => __('Transaction History Limit', 'kavehTheme'),
                'desc' => __('Number of transactions to display in wallet history (default: 20)', 'kavehTheme'),
                'default' => 20,
                'dependency' => array('kavehboard_wallet_enable', '==', 'true'),
            ),
            array(
                'id' => 'kavehboard_wallet_admin_notifications',
                'type' => 'switcher',
                'title' => __('Admin Email Notifications', 'kavehTheme'),
                'desc' => __('Send email notifications to admin when users add funds to wallet', 'kavehTheme'),
                'default' => false,
                'dependency' => array('kavehboard_wallet_enable', '==', 'true'),
            ),
        );
    }


}
