<?php

namespace Bookingor\Backend\Controller\Templates;

class TemplatesControl
{
    /**
     * Prefix used for naming conventions in the booking system.
     *
     * @var string
     */
    public static $name_prefix = 'bookingor';

    public function updates_design_templates()
    {
        $nonce = wp_create_nonce('my_action_nonce');

        if (isset($_REQUEST['action'])) {


            if (isset($_POST['nonce'])) {
                if (!wp_verify_nonce(sanitize_text_field(wp_unslash($_POST['nonce'])), 'bookingor_ajax_nonce')) {
                    $response = [
                        'status' => htmlspecialchars('error'),
                        'message' => htmlspecialchars('Nonce verification failed.')
                    ];
                    echo wp_json_encode($response);
                }
            }
            if (!current_user_can('manage_options')) {
                $response = [
                    'status' => htmlspecialchars('error'),
                    'message' => htmlspecialchars('You do not have permission.')
                ];
                echo wp_json_encode($response);
                die();
            }

            if (sanitize_text_field(wp_unslash(isset($_REQUEST['editingId']))) && sanitize_text_field(wp_unslash($_REQUEST['editingId'])) === '1') {
                update_option(self::$name_prefix . '_settings_background_border_active_design_1', sanitize_text_field(wp_unslash(isset($_POST['settings_background_border_active_design_1']) . 'px' ?? '')));
                update_option(self::$name_prefix . '_settings_background_border_color_design_1', sanitize_text_field(wp_unslash($_POST['settings_background_border_color_design_1'] ?? '')));
                update_option(self::$name_prefix . '_settings_background_radius_design_1', sanitize_text_field(wp_unslash(isset($_POST['settings_background_radius_design_1']) . 'px' ?? '')));
                update_option(self::$name_prefix . '_settings_button_text_book', sanitize_text_field(wp_unslash($_POST['settings_button_text_book'] ?? '')));
                update_option(self::$name_prefix . '_settings_color_continue_button_text', sanitize_text_field(wp_unslash($_POST['setting_color_continue_button_text'] ?? '')));
                update_option(self::$name_prefix . '_settings_background_border_design_1_color', sanitize_text_field(wp_unslash($_POST['settings_background_border_design_1_color'] ?? '')));
            }
            if (sanitize_text_field(wp_unslash(isset($_REQUEST['editingId']))) && sanitize_text_field(wp_unslash($_REQUEST['editingId'])) === '2') {
                update_option(self::$name_prefix . '_settings_background_border_active_design_2', sanitize_text_field(wp_unslash(isset($_POST['settings_background_border_active_design_2']) . 'px' ?? '')));
                update_option(self::$name_prefix . '_settings_background_border_color_design_2', sanitize_text_field(wp_unslash($_POST['settings_background_border_color_design_2'] ?? '')));
                update_option(self::$name_prefix . '_settings_background_radius_design_2', sanitize_text_field(wp_unslash(isset($_POST['settings_background_radius_design_2']) . 'px' ?? '')));
                update_option(self::$name_prefix . '_settings_color_continue_button_text', sanitize_text_field(wp_unslash($_POST['setting_color_continue_button_text'] ?? '')));
            }

            if (sanitize_text_field(wp_unslash(isset($_REQUEST['editingId']))) && sanitize_text_field(wp_unslash($_REQUEST['editingId'])) === '3') {
                update_option(self::$name_prefix . '_settings_background_border_active_design_3', sanitize_text_field(wp_unslash(isset($_POST['settings_background_border_active_design_3']) . 'px' ?? '')));
                update_option(self::$name_prefix . '_settings_background_border_color_design_3', sanitize_text_field(wp_unslash($_POST['settings_background_border_color_design_3'] ?? '')));
                update_option(self::$name_prefix . '_settings_background_radius_design_3', sanitize_text_field(wp_unslash(isset($_POST['settings_background_radius_design_3']) . 'px' ?? '')));
                update_option(self::$name_prefix . '_settings_button_text_book', sanitize_text_field(wp_unslash($_POST['settings_button_text_book'] ?? '')));
                update_option(self::$name_prefix . '_settings_status_active_text_color', sanitize_text_field(wp_unslash($_POST['settings_status_active_text_color'] ?? '')));
                update_option(self::$name_prefix . '_settings_status_completed_text_color', sanitize_text_field(wp_unslash($_POST['settings_status_completed_text_color'] ?? '')));
                update_option(self::$name_prefix . '_settings_status_progress_bar_background_color', sanitize_text_field(wp_unslash($_POST['settings_status_progress_bar_background_color'] ?? '')));
                update_option(self::$name_prefix . '_settings_color_continue_button_text', sanitize_text_field(wp_unslash($_POST['setting_color_continue_button_text'] ?? '')));
            }
            if (sanitize_text_field(wp_unslash(isset($_REQUEST['editingId']))) && sanitize_text_field(wp_unslash($_REQUEST['editingId'])) === '4') {
                update_option(self::$name_prefix . '_settings_background_border_active_design_4', sanitize_text_field(wp_unslash(isset($_POST['settings_background_border_active_design_4']) . 'px' ?? '')));
                update_option(self::$name_prefix . '_settings_background_border_color_design_4', sanitize_text_field(wp_unslash($_POST['settings_background_border_color_design_4'] ?? '')));
                update_option(self::$name_prefix . '_settings_background_radius_design_4', sanitize_text_field(wp_unslash(isset($_POST['settings_background_radius_design_4']) . 'px' ?? '')));
                update_option(self::$name_prefix . '_settings_button_text_book', sanitize_text_field(wp_unslash($_POST['settings_button_text_book'] ?? '')));
                update_option(self::$name_prefix . '_settings_color_continue_button_text', sanitize_text_field(wp_unslash($_POST['setting_color_continue_button_text'] ?? '')));
            }
            if (sanitize_text_field(wp_unslash(isset($_REQUEST['editingId']))) && sanitize_text_field(wp_unslash($_REQUEST['editingId'])) === '5') {
                update_option(self::$name_prefix . '_settings_background_border_color_design_5', sanitize_text_field(wp_unslash($_POST['settings_background_border_color_design_5'] ?? '')));
                update_option(self::$name_prefix . '_settings_button_text_book', sanitize_text_field(wp_unslash($_POST['settings_button_text_book'] ?? '')));
                update_option(self::$name_prefix . '_settings_color_continue_button_text', sanitize_text_field(wp_unslash($_POST['setting_color_continue_button_text'] ?? '')));
            }
            if (sanitize_text_field(wp_unslash(isset($_REQUEST['editingId']))) && sanitize_text_field(wp_unslash($_REQUEST['editingId'])) === '6') {
                update_option(self::$name_prefix . '_settings_background_border_active_design_6', sanitize_text_field(wp_unslash(isset($_POST['settings_background_border_active_design_6']) . 'px' ?? '')));
                update_option(self::$name_prefix . '_settings_background_border_color_design_6', sanitize_text_field(wp_unslash($_POST['settings_background_border_color_design_6'] ?? '')));
                update_option(self::$name_prefix . '_settings_background_radius_design_6', sanitize_text_field(wp_unslash(isset($_POST['settings_background_radius_design_6']) . 'px' ?? '')));
                update_option(self::$name_prefix . '_settings_button_text_book', sanitize_text_field(wp_unslash($_POST['settings_button_text_book'] ?? '')));

                // business
                update_option(self::$name_prefix . '_settings_business_name_required', sanitize_text_field(wp_unslash($_POST['settings_business_name_required'] ?? 'off')));
                update_option(self::$name_prefix . '_settings_business_description_required', sanitize_text_field(wp_unslash($_POST['settings_business_description_required'] ?? 'off')));
                update_option(self::$name_prefix . '_settings_business_logo_required', sanitize_text_field(wp_unslash($_POST['settings_business_logo_required'] ?? 'off')));
                update_option(self::$name_prefix . '_settings_business_phone_required', sanitize_text_field(wp_unslash($_POST['settings_business_phone_required'] ?? 'off')));
            }

            if (sanitize_text_field(wp_unslash($_REQUEST['editingId'])) === '2' || sanitize_text_field(wp_unslash($_REQUEST['editingId'])) === '3' || sanitize_text_field(wp_unslash($_REQUEST['editingId'])) === '4' || sanitize_text_field(wp_unslash($_REQUEST['editingId'])) === '5') {
                // category
                update_option(self::$name_prefix . '_settings_category_active', sanitize_text_field(wp_unslash($_POST['category_front_active'] ?? '')));
                update_option(self::$name_prefix . '_settings_category_required', sanitize_text_field(isset($_POST['settings_category_required']) ? sanitize_text_field(wp_unslash($_POST['settings_category_required'])) : ''));
                update_option(self::$name_prefix . '_settings_category_name', sanitize_text_field(wp_unslash($_POST['settings_category_name'] ?? '')));
                update_option(self::$name_prefix . '_settings_category_images_icons', sanitize_text_field(wp_unslash($_POST['settings_category_images_icons'] ?? '')));
                update_option(self::$name_prefix . '_settings_category_position', sanitize_text_field(isset($_POST['settings_category_set_position']) ? sanitize_text_field(wp_unslash($_POST['settings_category_set_position'])) : ''));
            }

            if (isset($_REQUEST['editingId']) && sanitize_text_field(wp_unslash($_REQUEST['editingId'])) === '8') {
                // category starter settings
                update_option(self::$name_prefix . '_settings_category_name_show', sanitize_text_field(wp_unslash($_POST['settings_category_name_show'] ?? 'off')));
                update_option(self::$name_prefix . '_settings_category_allow_to_book', sanitize_text_field(wp_unslash($_POST['settings_category_allow_to_book'] ?? 'off')));
                update_option(self::$name_prefix . '_settings_category_name', sanitize_text_field(wp_unslash($_POST['settings_category_name'] ?? '')));
                update_option(self::$name_prefix . '_settings_category_image_radius', sanitize_text_field(wp_unslash($_POST['settings_category_image_radius'] ?? '0')));
                update_option(self::$name_prefix . '_settings_category_image_border_size', sanitize_text_field(wp_unslash($_POST['settings_category_image_border_size'] ?? '0')));
                update_option(self::$name_prefix . '_settings_category_image_border_color', sanitize_text_field(wp_unslash($_POST['settings_category_image_border_color'] ?? '#000000')));
                update_option(self::$name_prefix . '_settings_category_image_width', sanitize_text_field(wp_unslash($_POST['settings_category_image_width'] ?? '')));
                update_option(self::$name_prefix . '_settings_category_image_height', sanitize_text_field(wp_unslash($_POST['settings_category_image_height'] ?? '')));
                update_option(self::$name_prefix . '_settings_category_card_column', sanitize_text_field(wp_unslash($_POST['settings_category_card_column'] ?? '4')));
                update_option(self::$name_prefix . '_settings_category_cards_gap_x', sanitize_text_field(wp_unslash($_POST['settings_category_cards_gap_x'] ?? '10')));
                update_option(self::$name_prefix . '_settings_category_cards_gap_y', sanitize_text_field(wp_unslash($_POST['settings_category_cards_gap_y'] ?? '10')));
                update_option(self::$name_prefix . '_settings_category_view_type', sanitize_text_field(wp_unslash($_POST['settings_category_view_type'] ?? 'category-list-view')));
                // colors and fonts present on design category page
                update_option(self::$name_prefix . '_settings_color_border', sanitize_text_field(wp_unslash($_POST['setting_color_border'] ?? '')));
                update_option(self::$name_prefix . '_settings_fonts_headings', sanitize_text_field(wp_unslash($_POST['settings_headings_font_family'] ?? '')));
                update_option(self::$name_prefix . '_settings_category_bg_active', sanitize_text_field(wp_unslash($_POST['settings_category_bg_active'] ?? 'off')));
                update_option(self::$name_prefix . '_settings_category_bg_color', sanitize_text_field(wp_unslash($_POST['settings_category_bg_color'] ?? '#ffffff')));
                update_option(self::$name_prefix . '_settings_category_text_color', sanitize_text_field(wp_unslash($_POST['settings_category_text_color'] ?? '#000000')));
            }

            if (isset($_REQUEST['editingId']) && sanitize_text_field(wp_unslash($_REQUEST['editingId'])) === '10') {
                // staff starter settings

                update_option(self::$name_prefix . '_settings_staff_image_radius', sanitize_text_field(wp_unslash($_POST['settings_staff_image_radius'] ?? '56')));
                update_option(self::$name_prefix . '_settings_staff_image_border_size', sanitize_text_field(wp_unslash($_POST['settings_staff_image_border_size'] ?? '1')));
                update_option(self::$name_prefix . '_settings_staff_image_border_color', sanitize_text_field(wp_unslash($_POST['settings_staff_image_border_color'] ?? '#ffffff')));
                update_option(self::$name_prefix . '_settings_staff_image_width', sanitize_text_field(wp_unslash($_POST['settings_staff_image_width'] ?? '140')));
                update_option(self::$name_prefix . '_settings_staff_image_height', sanitize_text_field(wp_unslash($_POST['settings_staff_image_height'] ?? '140')));
                update_option(self::$name_prefix . '_settings_staff_card_column', sanitize_text_field(wp_unslash($_POST['settings_staff_card_column'] ?? '3')));
                update_option(self::$name_prefix . '_settings_staff_cards_gap_x', sanitize_text_field(wp_unslash($_POST['settings_staff_cards_gap_x'] ?? '10')));
                update_option(self::$name_prefix . '_settings_staff_cards_gap_y', sanitize_text_field(wp_unslash($_POST['settings_staff_cards_gap_y'] ?? '10')));
                update_option(self::$name_prefix . '_settings_staff_bg_active', sanitize_text_field(wp_unslash($_POST['settings_staff_bg_active'] ?? 'off')));
                update_option(self::$name_prefix . '_settings_staff_bg_color', sanitize_text_field(wp_unslash($_POST['settings_staff_bg_color'] ?? '#ffffff')));
                update_option(self::$name_prefix . '_settings_staff_border_active_color', sanitize_text_field(wp_unslash($_POST['settings_staff_border_active_color'] ?? '#7752DD')));
                update_option(self::$name_prefix . '_settings_staff_phone_show', sanitize_text_field(wp_unslash($_POST['settings_staff_phone_show'] ?? 'off')));
                update_option(self::$name_prefix . '_settings_staff_email_show', sanitize_text_field(wp_unslash($_POST['settings_staff_email_show'] ?? 'off')));
                update_option(self::$name_prefix . '_settings_staff_tagline_show', sanitize_text_field(wp_unslash($_POST['settings_staff_tagline_show'] ?? 'off')));
                update_option(self::$name_prefix . '_settings_staff_location_show', sanitize_text_field(wp_unslash($_POST['settings_staff_location_show'] ?? 'off')));
                update_option(self::$name_prefix . '_settings_staff_about_show', sanitize_text_field(wp_unslash($_POST['settings_staff_about_show'] ?? 'off')));
                update_option(self::$name_prefix . '_settings_fonts_headings', sanitize_text_field(wp_unslash($_POST['settings_headings_font_family'] ?? '')));
            }

            if (isset($_REQUEST['editingId']) && sanitize_text_field(wp_unslash($_REQUEST['editingId'])) === '9') {
                // service starter settings
                update_option(self::$name_prefix . '_settings_service_name', sanitize_text_field(wp_unslash($_POST['settings_service_name'] ?? '')));
                update_option(self::$name_prefix . '_settings_service_allow_to_book', sanitize_text_field(wp_unslash($_POST['settings_service_allow_to_book'] ?? 'off')));
                update_option(self::$name_prefix . '_settings_service_image_radius', sanitize_text_field(wp_unslash($_POST['settings_service_image_radius'] ?? '0')));
                update_option(self::$name_prefix . '_settings_service_image_border_size', sanitize_text_field(wp_unslash($_POST['settings_service_image_border_size'] ?? '0')));
                update_option(self::$name_prefix . '_settings_service_image_border_color', sanitize_text_field(wp_unslash($_POST['settings_service_image_border_color'] ?? '#ffffff')));
                update_option(self::$name_prefix . '_settings_service_image_width', sanitize_text_field(wp_unslash($_POST['settings_service_image_width'] ?? '')));
                update_option(self::$name_prefix . '_settings_service_image_height', sanitize_text_field(wp_unslash($_POST['settings_service_image_height'] ?? '140')));
                update_option(self::$name_prefix . '_settings_service_card_column', sanitize_text_field(wp_unslash($_POST['settings_service_card_column'] ?? '2')));
                update_option(self::$name_prefix . '_settings_service_cards_gap_x', sanitize_text_field(wp_unslash($_POST['settings_service_cards_gap_x'] ?? '10')));
                update_option(self::$name_prefix . '_settings_service_cards_gap_y', sanitize_text_field(wp_unslash($_POST['settings_service_cards_gap_y'] ?? '10')));
                update_option(self::$name_prefix . '_settings_service_bg_active', sanitize_text_field(wp_unslash($_POST['settings_service_bg_active'] ?? 'off')));
                update_option(self::$name_prefix . '_settings_service_bg_color', sanitize_text_field(wp_unslash($_POST['settings_service_bg_color'] ?? '#ffffff')));
                update_option(self::$name_prefix . '_settings_service_border_active_color', sanitize_text_field(wp_unslash($_POST['settings_service_border_active_color'] ?? '#7752DD')));
                update_option(self::$name_prefix . '_settings_fonts_headings', sanitize_text_field(wp_unslash($_POST['settings_headings_font_family'] ?? '')));
            }

            if (isset($_REQUEST['editingId']) && !in_array(sanitize_text_field(wp_unslash($_REQUEST['editingId'])), ['8', '9', '10'], true)) {
                // service
                update_option(self::$name_prefix . '_settings_service_active', sanitize_text_field(wp_unslash($_POST['service_front_active'] ?? '')));
                update_option(self::$name_prefix . '_settings_service_required', sanitize_text_field(isset($_POST['settings_service_required']) ? sanitize_text_field(wp_unslash($_POST['settings_service_required'])) : ''));
                update_option(self::$name_prefix . '_settings_service_name', sanitize_text_field(wp_unslash($_POST['settings_service_name'] ?? '')));
                update_option(self::$name_prefix . '_settings_service_price_show', sanitize_text_field(wp_unslash($_POST['settings_service_price_show'] ?? '')));
                update_option(self::$name_prefix . '_settings_service_duration_show', sanitize_text_field(wp_unslash($_POST['settings_service_duration_show'] ?? '')));
                update_option(self::$name_prefix . '_settings_service_capacity_show', sanitize_text_field(isset($_POST['settings_service_capacity_show']) ? sanitize_text_field(wp_unslash($_POST['settings_service_capacity_show'])) : ''));
                update_option(self::$name_prefix . '_settings_service_position', sanitize_text_field(isset($_POST['settings_service_set_position']) ? sanitize_text_field(wp_unslash($_POST['settings_service_set_position'])) : ''));
                update_option(self::$name_prefix . '_settings_service_description_show', sanitize_text_field(wp_unslash($_POST['settings_service_description_show'] ?? 'off')));
                update_option(self::$name_prefix . '_settings_service_images_icons', sanitize_text_field(wp_unslash($_POST['settings_service_images_icons'] ?? '')));

                update_option(self::$name_prefix . '_settings_cart_payment_information_required', sanitize_text_field(isset($_POST['settings_cart_payment_information_required']) ? sanitize_text_field(wp_unslash($_POST['settings_cart_payment_information_required'])) : ''));

                update_option(self::$name_prefix . '_settings_staff_active', sanitize_text_field(isset($_POST['staff_front_active']) ? sanitize_text_field(wp_unslash($_POST['staff_front_active'])) : ''));
                update_option(self::$name_prefix . '_settings_location_active', sanitize_text_field(isset($_POST['location_front_active']) ? sanitize_text_field(wp_unslash($_POST['location_front_active'])) : ''));
                update_option(self::$name_prefix . '_settings_customer_details_active', sanitize_text_field(isset($_POST['customer_details_front_active']) ? sanitize_text_field(wp_unslash($_POST['customer_details_front_active'])) : ''));
                update_option(self::$name_prefix . '_settings_customer_payment_active', sanitize_text_field(isset($_POST['customer_payment_front_active']) ? sanitize_text_field(wp_unslash($_POST['customer_payment_front_active'])) : ''));
                update_option(self::$name_prefix . '_settings_business_details_active', sanitize_text_field(wp_unslash($_POST['settings_business_details_active'] ?? '')));
                update_option(self::$name_prefix . '_settings_staff_required', sanitize_text_field(isset($_POST['settings_staff_required']) ? sanitize_text_field(wp_unslash($_POST['settings_staff_required'])) : ''));
                update_option(self::$name_prefix . '_settings_location_required', sanitize_text_field(isset($_POST['settings_location_required']) ? sanitize_text_field(wp_unslash($_POST['settings_location_required'])) : ''));
                update_option(self::$name_prefix . '_settings_staff_name', sanitize_text_field(wp_unslash($_POST['settings_staff_name'] ?? '')));
                update_option(self::$name_prefix . '_settings_time_name', sanitize_text_field(wp_unslash($_POST['settings_timing_name'] ?? '')));
                update_option(self::$name_prefix . '_settings_customer_book_name', sanitize_text_field(wp_unslash($_POST['settings_customer_book_name'] ?? '')));
                update_option(self::$name_prefix . '_settings_customer_payment_name', sanitize_text_field(wp_unslash($_POST['settings_customer_payment_name'] ?? '')));
                update_option(self::$name_prefix . '_settings_staff_position', sanitize_text_field(isset($_POST['settings_staff_set_position']) ? sanitize_text_field(wp_unslash($_POST['settings_staff_set_position'])) : ''));
                update_option(self::$name_prefix . '_settings_location_position', sanitize_text_field(isset($_POST['settings_location_set_position']) ? sanitize_text_field(wp_unslash($_POST['settings_location_set_position'])) : ''));
                update_option(self::$name_prefix . '_settings_repeat_position', sanitize_text_field(isset($_POST['settings_repeat_set_position']) ? sanitize_text_field(wp_unslash($_POST['settings_repeat_set_position'])) : ''));
                update_option(self::$name_prefix . '_settings_default_calendar', sanitize_text_field(isset($_POST['settings_default_set_calendar']) ? sanitize_text_field(wp_unslash($_POST['settings_default_set_calendar'])) : ''));            // service show
                // business
                update_option(self::$name_prefix . '_settings_repeat_book_name', sanitize_text_field(wp_unslash($_POST['settings_repeat_book_name'] ?? 'Repeat')));

                // colors
                update_option(self::$name_prefix . '_settings_color_sidebar', sanitize_text_field(wp_unslash($_POST['setting_color_sidebar'] ?? ''))); //setting_color_border
                update_option(self::$name_prefix . '_settings_color_sidebar_text', sanitize_text_field(wp_unslash($_POST['setting_color_sidebar_text'] ?? '')));
                update_option(self::$name_prefix . '_settings_color_label_text', sanitize_text_field(wp_unslash($_POST['setting_color_label_text'] ?? '')));
                update_option(self::$name_prefix . '_settings_color_sidebar_text_active', sanitize_text_field(wp_unslash($_POST['setting_color_sidebar_text_active'] ?? '')));
                update_option(self::$name_prefix . '_settings_color_border', sanitize_text_field(wp_unslash($_POST['setting_color_border'] ?? '')));
                update_option(self::$name_prefix . '_settings_color_continue_button_background', sanitize_text_field(wp_unslash($_POST['setting_color_continue_button_background'] ?? '')));
                update_option(self::$name_prefix . '_settings_color_back_button_background', sanitize_text_field(wp_unslash($_POST['setting_color_back_button_background'] ?? '')));
                update_option(self::$name_prefix . '_settings_color_back_button_text', sanitize_text_field(wp_unslash($_POST['setting_color_back_button_text'] ?? '')));
                update_option(self::$name_prefix . '_settings_continue_button_text', sanitize_text_field(wp_unslash($_POST['settings_continue_button_text'] ?? '')));
                update_option(self::$name_prefix . '_settings_book_button_text', sanitize_text_field(wp_unslash($_POST['settings_book_button_text'] ?? '')));
                update_option(self::$name_prefix . '_settings_back_button_text', sanitize_text_field(wp_unslash($_POST['settings_back_button_text'] ?? '')));
                update_option(self::$name_prefix . '_settings_fonts_headings', sanitize_text_field(wp_unslash($_POST['settings_headings_font_family'] ?? '')));
                update_option(self::$name_prefix . '_settings_fonts_all_other', sanitize_text_field(wp_unslash($_POST['settings_all_font_family'] ?? '')));

                update_option(self::$name_prefix . '_settings_customer_first_name_active', sanitize_text_field(wp_unslash($_POST['settings_customer_first_name_active'] ?? '')));
                update_option(self::$name_prefix . '_settings_customer_last_name_active', sanitize_text_field(wp_unslash($_POST['settings_customer_last_name_active'] ?? '')));
                update_option(self::$name_prefix . '_settings_customer_email_active', sanitize_text_field(wp_unslash($_POST['settings_customer_email_active'] ?? '')));
                update_option(self::$name_prefix . '_settings_customer_phone_active', sanitize_text_field(wp_unslash($_POST['settings_customer_phone_active'] ?? '')));

                update_option(self::$name_prefix . '_settings_customer_first_name_label', sanitize_text_field(wp_unslash($_POST['settings_customer_first_name_label'] ?? '')));
                update_option(self::$name_prefix . '_settings_customer_last_name_label', sanitize_text_field(wp_unslash($_POST['settings_customer_last_name_label'] ?? '')));
                update_option(self::$name_prefix . '_settings_customer_email_label', sanitize_text_field(wp_unslash($_POST['settings_customer_email_label'] ?? '')));
                update_option(self::$name_prefix . '_settings_customer_phone_label', sanitize_text_field(wp_unslash($_POST['settings_customer_phone_label'] ?? '')));

                update_option(self::$name_prefix . '_settings_customer_payment_required', sanitize_text_field(wp_unslash($_POST['settings_customer_payment_required'] ?? '')));
                update_option(self::$name_prefix . '_settings_customer_details_required', sanitize_text_field(wp_unslash($_POST['settings_customer_details_required'] ?? '')));
                update_option(self::$name_prefix . '_settings_cart_information_required', sanitize_text_field(wp_unslash($_POST['settings_cart_information_required'] ?? '')));
                update_option(self::$name_prefix . '_settings_background_border_color', sanitize_text_field(wp_unslash($_POST['settings_background_border_color'] ?? '')));
                update_option(self::$name_prefix . '_settings_buttons_border_active', sanitize_text_field(wp_unslash(isset($_POST['settings_buttons_border_active']) . 'px' ?? '')));
                update_option(self::$name_prefix . '_settings_buttons_border_color', sanitize_text_field(wp_unslash($_POST['settings_buttons_border_color'] ?? '')));
                update_option(self::$name_prefix . '_settings_buttons_radius', sanitize_text_field(wp_unslash(isset($_POST['settings_buttons_radius']) . 'px' ?? '')));

                update_option(self::$name_prefix . '_settings_pay_on_visit_name', sanitize_text_field(wp_unslash($_POST['settings_pay_on_visit_name'] ?? '')));

                update_option(self::$name_prefix . '_settings_booking_thank_you_text', sanitize_text_field(wp_unslash($_POST['settings_booking_thank_you_text'] ?? '')));
                update_option(self::$name_prefix . '_settings_booking_confirm_text', sanitize_text_field(wp_unslash($_POST['settings_booking_confirm_text'] ?? '')));

                // repeat
                update_option(self::$name_prefix . '_settings_repeat_book_name', sanitize_text_field(wp_unslash($_POST['settings_repeat_book_name'] ?? 'Repeat')));
                update_option(self::$name_prefix . '_settings_repeat_upcoming_booking_text', sanitize_text_field(wp_unslash($_POST['settings_repeat_upcoming_booking_text'] ?? 'Repeat')));
                update_option(self::$name_prefix . '_settings_repeat_every_text', sanitize_text_field(wp_unslash($_POST['settings_repeat_every_text'] ?? 'Repeat')));
                update_option(self::$name_prefix . '_settings_repeat_booking_end_text', sanitize_text_field(wp_unslash($_POST['settings_repeat_booking_end_text'] ?? 'Repeat')));
                update_option(self::$name_prefix . '_settings_repeat_pick_date_text', sanitize_text_field(wp_unslash($_POST['settings_repeat_pick_date_text'] ?? 'Repeat')));

                // location
                update_option(self::$name_prefix . '_settings_location_name', sanitize_text_field(wp_unslash($_POST['settings_location_name'] ?? '')));
                update_option(self::$name_prefix . '_settings_location_city', sanitize_text_field(wp_unslash($_POST['settings_location_city'] ?? '')));
                update_option(self::$name_prefix . '_settings_location_address', sanitize_text_field(wp_unslash($_POST['settings_location_address'] ?? '')));
                update_option(self::$name_prefix . '_settings_location_phone', sanitize_text_field(wp_unslash($_POST['settings_location_phone'] ?? '')));
            }

            $response = [
                'status' => htmlspecialchars('success'),
                'message' => htmlspecialchars('Settings updated successfully'),
            ];
            echo wp_json_encode($response);
            exit;
        }
    }

    public static function bp_settings_get_design_templates_data()
    {
        if (isset($_REQUEST['action'])) {
            //stripe


            if (isset($_POST['nonce'])) {
                if (!wp_verify_nonce(sanitize_text_field(wp_unslash($_POST['nonce'])), 'bookingor_ajax_nonce')) {
                    $response = [
                        'status' => htmlspecialchars('error'),
                        'message' => htmlspecialchars('Nonce verification failed.')
                    ];
                    echo wp_json_encode($response);
                }
            }
            if (!current_user_can('manage_options')) {
                $response = [
                    'status' => htmlspecialchars('error'),
                    'message' => htmlspecialchars('You do not have permission.')
                ];
                echo wp_json_encode($response);
                die();
            }

            $dcimal_point = get_option(self::$name_prefix . '_currency_decimal_point');


            $stripe_data = [
                'active_category' => get_option(self::$name_prefix . '_settings_category_active'),
                'active_staff' => get_option(self::$name_prefix . '_settings_staff_active'),
                'active_location' => get_option(self::$name_prefix . '_settings_location_active'),
                'category_required' => get_option(self::$name_prefix . '_settings_category_required'),
                'css_border_color' => get_option(self::$name_prefix . '_settings_color_border'),
                'boookingor_css' => [
                    'bookingor_color_border' => get_option(self::$name_prefix . '_settings_color_border'),
                    'sidebar_1' => get_option(self::$name_prefix . '_settings_color_sidebar'),
                    'full_day_selected' => get_option(self::$name_prefix . 'bkinz-day-full.selected'),
                    'sidebar_text' => get_option(self::$name_prefix . '_settings_color_sidebar_text'),
                    'label_text_color' => get_option(self::$name_prefix . '_settings_color_label_text'),
                    'sidebar_text_active' => get_option(self::$name_prefix . '_settings_color_sidebar_text_active'),
                    'search_bars' => get_option(self::$name_prefix . '_settings_color_continue_button_background'),
                    'background_border_color' => get_option(self::$name_prefix . '_settings_background_border_color'),
                    'button_border_active' => get_option(self::$name_prefix . '_settings_buttons_border_active'),
                    'button_border_color' => get_option(self::$name_prefix . '_settings_buttons_border_color'),
                    'button_border_radius' => get_option(self::$name_prefix . '_settings_buttons_radius'),
                    'heading_font_family' => get_option(self::$name_prefix . '_settings_fonts_headings'),
                    'all_other_font_family' => get_option(self::$name_prefix . '_settings_fonts_all_other'),
                    'category_text_color' => get_option(self::$name_prefix . '_settings_category_text_color', '#000000'),

                    // design 1
                    'background_border_active_design_1' => get_option(self::$name_prefix . '_settings_background_border_active_design_1'),
                    'background_border_color_design_1' => get_option(self::$name_prefix . '_settings_background_border_color_design_1'),
                    'background_border_radius_design_1' => get_option(self::$name_prefix . '_settings_background_radius_design_1'),

                    // design 2
                    'background_border_active_design_2' => get_option(self::$name_prefix . '_settings_background_border_active_design_2'),
                    'background_border_color_design_2' => get_option(self::$name_prefix . '_settings_background_border_color_design_2'),
                    'background_border_radius_design_2' => get_option(self::$name_prefix . '_settings_background_radius_design_2'),

                    // design 3
                    'status_active_text_color_design_3' => get_option(self::$name_prefix . '_settings_status_active_text_color'),
                    'status_completed_text_color_design_3' => get_option(self::$name_prefix . '_settings_status_completed_text_color'),
                    'status_progress_bar_color_design_3' => get_option(self::$name_prefix . '_settings_status_progress_bar_background_color'),
                    'background_border_active_design_3' => get_option(self::$name_prefix . '_settings_background_border_active_design_3'),
                    'background_border_color_design_3' => get_option(self::$name_prefix . '_settings_background_border_color_design_3'),
                    'background_border_radius_design_3' => get_option(self::$name_prefix . '_settings_background_radius_design_3'),

                    // design 4
                    'background_border_active_design_4' => get_option(self::$name_prefix . '_settings_background_border_active_design_4'),
                    'background_border_color_design_4' => get_option(self::$name_prefix . '_settings_background_border_color_design_4'),
                    'background_border_radius_design_4' => get_option(self::$name_prefix . '_settings_background_radius_design_4'),

                    // design 5
                    'background_border_active_design_5' => get_option(self::$name_prefix . '_settings_background_border_active_design_5'),
                    'background_border_color_design_5' => get_option(self::$name_prefix . '_settings_background_border_color_design_5'),

                    //design 6
                    'background_border_active_design_6' => get_option(self::$name_prefix . '_settings_background_border_active_design_6'),
                    'background_border_color_design_6' => get_option(self::$name_prefix . '_settings_background_border_color_design_6'),
                    'background_border_radius_design_6' => get_option(self::$name_prefix . '_settings_background_radius_design_6'),

                ],
                'bookingor_cont_btn' => [
                    'bg' => get_option(self::$name_prefix . '_settings_color_continue_button_background'),
                    'clr' => get_option(self::$name_prefix . '_settings_color_continue_button_text'),
                ],
                'bookingor_btn_back' => [
                    'bg' => get_option(self::$name_prefix . '_settings_color_back_button_background'),
                    'clr' => get_option(self::$name_prefix . '_settings_color_back_button_text'),
                ],
            ];
            echo wp_json_encode($stripe_data);
            die();
        }
    }
}
