<?php
namespace Elementor;

/**
 * Elementor Widget
 * @package Geroz
 * @since 1.0.0
 */ 
 
class Home2_Price extends Widget_Base {

	/**
	 * Get widget name.
	 * Retrieve button widget name.
	 *
	 * @since  1.0.0
	 * @access public
	 * @return string Widget name.
	 */
	public function get_name() {
		return 'geroz-home2-price-widget';
	}

	/**
	 * Get widget title.
	 * Retrieve button widget title.
	 *
	 * @since  1.0.0
	 * @access public
	 * @return string Widget title.
	 */
	public function get_title() {
		return esc_html__( 'Home 2 Price', 'geroz-core' );
	}

	/**
	 * Get widget icon.
	 * Retrieve button widget icon.
	 *
	 * @since  1.0.0
	 * @access public
	 * @return string Widget icon.
	 */
	public function get_icon() {
		return 'eicon-flash';
	}

	/**
	 * Get widget categories.
	 * Retrieve the list of categories the button widget belongs to.
	 * Used to determine where to display the widget in the editor.
	 *
	 * @since  2.0.0
	 * @access public
	 * @return array Widget categories.
	 */
	public function get_categories()
    {
        return ['geroz_widgets'];
    }
	
	/**
	 * Register button widget controls.
	 * Adds different input fields to allow the user to change and customize the widget settings.
	 *
	 * @since  1.0.0
	 * @access protected
	 */
	protected function register_controls() {

		$this->start_controls_section(
			'home2-price-content',
			[
				'label' => esc_html__( 'Price Content', 'geroz-core' ),
			]
		);	

		$this->add_control(
			'title',
			[
				'label' => esc_html__( 'Title', 'geroz-core' ),
				'type' => Controls_Manager::TEXTAREA,
				'default' => esc_html__( 'We are here to help you', 'geroz-core' ),
				'placeholder' => esc_html__( 'Type your title here', 'geroz-core' ),
			]
		);

		$this->add_control(
			'subtitle',
			[
				'label' => esc_html__( 'Subtitle', 'geroz-core' ),
				'type' => Controls_Manager::TEXTAREA,
				'default' => esc_html__( 'We are here to help you', 'geroz-core' ),
				'placeholder' => esc_html__( 'Type your subtitle here', 'geroz-core' ),
			]
		);

		$this->end_controls_section();

		$this->start_controls_section(
			'home1-tab-content',
			[
				'label' => esc_html__( 'Tab Content', 'geroz-core' ),
			]
		);	

		$this->add_control(
			'tab_title',
			[
				'label' => esc_html__( 'Tab Title', 'geroz-core' ),
				'type' => Controls_Manager::TEXT,
				'default' => esc_html__( 'Tab 1', 'geroz-core' ),
				'placeholder' => esc_html__( 'Type your tab title here', 'geroz-core' ),
			]
		);

		$this->add_control(
			'tab_title2',
			[
				'label' => esc_html__( 'Tab Title 2', 'geroz-core' ),
				'type' => Controls_Manager::TEXT,
				'default' => esc_html__( 'Tab 2', 'geroz-core' ),
				'placeholder' => esc_html__( 'Type your tab title here', 'geroz-core' ),
			]
		);

		$this->add_control(
			'id_name',
			[
				'label' => esc_html__( 'Tab ID Name', 'geroz-core' ),
				'type' => Controls_Manager::TEXT,
				'default' => esc_html__( 'tab1', 'geroz-core' ),
				'placeholder' => esc_html__( 'Type your tab ID name here', 'geroz-core' ),
			]
		);

		$this->add_control(
			'id_name2',
			[
				'label' => esc_html__( 'Tab ID Name 2', 'geroz-core' ),
				'type' => Controls_Manager::TEXT,
				'default' => esc_html__( 'tab2', 'geroz-core' ),
				'placeholder' => esc_html__( 'Type your tab ID name here', 'geroz-core' ),
			]
		);

		$this->end_controls_section();

		// Tab Start - 3

		$this->start_controls_section(
			'content_section',
			[
				'label' => __( 'Block', 'geroz-core' ),
				'tab' => \Elementor\Controls_Manager::TAB_CONTENT,
			]
		);
		$this->add_control(
		  'repeat', 
			[
				'type' => Controls_Manager::REPEATER,
				'separator' => 'before',
				'default' => 
					[
						['section_title' => esc_html__('Hello World', 'geroz-core')],
					],
				'fields' => 
					[	
						
						[
							'name' => 'section_id',
							'label' => esc_html__( 'Section ID', 'geroz-core' ),
							'type' => Controls_Manager::TEXT,
							'default' => esc_html__( 'tab1', 'geroz-core' ),
							'placeholder' => esc_html__( 'Type your section ID here', 'geroz-core' ),
						],
						[
							'name' => 'section_title',
							'label' => esc_html__( 'Section Title', 'geroz-core' ),
							'type' => Controls_Manager::TEXTAREA,
							'default' => esc_html__( 'Basic Plan', 'geroz-core' ),
							'placeholder' => esc_html__( 'Type your section title here', 'geroz-core' ),
						],
						[
							'name' => 'section_subtitle',
							'label' => esc_html__( 'Section Subtitle', 'geroz-core' ),
							'type' => Controls_Manager::TEXTAREA,
							'default' => esc_html__( 'Basic Plan Subtitle', 'geroz-core' ),
							'placeholder' => esc_html__( 'Type your section subtitle here', 'geroz-core' ),
						],
						[
							'name' => 'section_text',
							'label' => esc_html__( 'Section Text', 'geroz-core' ),
							'type' => Controls_Manager::TEXTAREA,
							'default' => esc_html__( 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.', 'geroz-core' ),
							'placeholder' => esc_html__( 'Type your section text here', 'geroz-core' ),
						],
						[
							'name' => 'section_button',
							'label' => esc_html__( 'Section Button Text', 'geroz-core' ),
							'type' => Controls_Manager::TEXT,
							'default' => esc_html__( 'Get Started', 'geroz-core' ),
						],
						[
							'name' => 'section_button_link',
							'label' => esc_html__( 'Section Button Link', 'geroz-core'),
							'type'=> Controls_Manager::URL,
						],

						[
							'name' => 'section_list_text',
							'label' => esc_html__( 'Section List Text', 'geroz-core' ),
							'type' => Controls_Manager::TEXTAREA,
							'default' => esc_html__( 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.', 'geroz-core' ),
							'placeholder' => esc_html__( 'Type your section text here', 'geroz-core' ),
						],
						
						[
							'name' => 'section_title2',
							'label' => esc_html__( 'Section Title 2', 'geroz-core' ),
							'type' => Controls_Manager::TEXTAREA,
							'default' => esc_html__( 'Standard Plan', 'geroz-core' ),
							'placeholder' => esc_html__( 'Type your section title here', 'geroz-core' ),
						],
						[
							'name' => 'section_subtitle2',
							'label' => esc_html__( 'Section Subtitle 2', 'geroz-core' ),
							'type' => Controls_Manager::TEXTAREA,
							'default' => esc_html__( 'Standard Plan Subtitle', 'geroz-core' ),
							'placeholder' => esc_html__( 'Type your section subtitle here', 'geroz-core' ),
						],
						[
							'name' => 'section_text2',
							'label' => esc_html__( 'Section Text 2', 'geroz-core' ),
							'type' => Controls_Manager::TEXTAREA,
							'default' => esc_html__( 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.', 'geroz-core' ),
							'placeholder' => esc_html__( 'Type your section text here', 'geroz-core' ),
						],
						[
							'name' => 'section_button2',
							'label' => esc_html__( 'Section Button Text 2', 'geroz-core' ),
							'type' => Controls_Manager::TEXT,
							'default' => esc_html__( 'Get Started', 'geroz-core' ),
						],
						[
							'name' => 'section_button_link2',
							'label' => esc_html__( 'Section Button Link 2', 'geroz-core'),
							'type'=> Controls_Manager::URL,
						],
					
						[
							'name' => 'section_list_text2',
							'label' => esc_html__( 'Section List Text', 'geroz-core' ),
							'type' => Controls_Manager::TEXTAREA,
							'default' => esc_html__( 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.', 'geroz-core' ),
							'placeholder' => esc_html__( 'Type your section text here', 'geroz-core' ),
						],

						[
							'name' => 'section_title3',
							'label' => esc_html__( 'Section Title 3', 'geroz-core' ),
							'type' => Controls_Manager::TEXTAREA,
							'default' => esc_html__( 'Premium Plan', 'geroz-core' ),
							'placeholder' => esc_html__( 'Type your section title here', 'geroz-core' ),
						],
						[
							'name' => 'section_subtitle3',
							'label' => esc_html__( 'Section Subtitle 3', 'geroz-core' ),
							'type' => Controls_Manager::TEXTAREA,
							'default' => esc_html__( 'Premium Plan Subtitle', 'geroz-core' ),
							'placeholder' => esc_html__( 'Type your section subtitle here', 'geroz-core' ),
						],
						[
							'name' => 'section_text3',
							'label' => esc_html__( 'Section Text 3', 'geroz-core' ),
							'type' => Controls_Manager::TEXTAREA,
							'default' => esc_html__( 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.', 'geroz-core' ),
							'placeholder' => esc_html__( 'Type your section text here', 'geroz-core' ),
						],
						[
							'name' => 'section_button3',
							'label' => esc_html__( 'Section Button Text 3', 'geroz-core' ),
							'type' => Controls_Manager::TEXT,
							'default' => esc_html__( 'Get Started', 'geroz-core' ),
						],
						[
							'name' => 'section_button_link3',
							'label' => esc_html__( 'Section Button Link 3', 'geroz-core'),
							'type'=> Controls_Manager::URL,
						],
					
						[
							'name' => 'section_list_text3',
							'label' => esc_html__( 'Section List Text', 'geroz-core' ),
							'type' => Controls_Manager::TEXTAREA,
							'default' => esc_html__( 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.', 'geroz-core' ),
							'placeholder' => esc_html__( 'Type your section text here', 'geroz-core' ),
						],
						
					],
				'title_field' => '{{section_title}}',
			 ]
	);
		
		
	$this->end_controls_section();	

	
		}

	/**
	 * Render button widget output on the frontend.
	 * Written in PHP and used to generate the final HTML.
	 *
	 * @since  1.0.0
	 * @access protected
	 */
	protected function render() {
		$settings = $this->get_settings_for_display();
		$allowed_tags = wp_kses_allowed_html('post');
		?>


			<section class="pricing-wrapper pricing-2 section-padding section-bg-5">
                <div class="container">
					<?php if($settings['title']): ?>
                    <div class="section-title text-center">
                        <div class="sub-title">
                            <div class="dot"></div> <span><?php echo $settings['subtitle'];?></span>
                        </div>
                        <h2 class="text-white text-uppercase text_invert-2"><?php echo $settings['title'];?></h2>
                    </div>
					<?php endif; ?>
                    <div class="pricing-tab-btn text-center  wow fadeInUp" data-wow-delay=".4s">
                        <ul class="nav">
                            <li class="nav-item">
                                <a href="<?php echo esc_attr($settings['id_name']);?>" data-bs-toggle="tab" class="nav-link active">
                                    <?php echo $settings['tab_title'];?>	
                                </a>
                            </li>
                            <li class="nav-item">
                                <a href="<?php echo esc_attr($settings['id_name2']);?>" data-bs-toggle="tab" class="nav-link">
                                    <?php echo $settings['tab_title2'];?>
                                </a>
                            </li>
                        </ul>
                    </div>
                    <div class="tab-content">
						<?php foreach($settings['repeat'] as $key=>$item):?>
                        <div id="<?php echo esc_attr($item['section_id']);?>" class="tab-pane fade <?php if($key == 1) echo 'show active';?>">
                            <div class="row">
                                <div class="col-xxl-4 col-xl-6 col-lg-6 wow fadeInUp" data-wow-delay="200ms">
                                    <div class="single-pricing-item">
                                        <div class="border-shape">
                                            <span></span>
                                            <span></span>
                                            <span></span>
                                            <span></span>
                                        </div>
                                        <div class="header">
                                            <h4><?php echo wp_kses($item['section_subtitle'], $allowed_tags);?></h4>
                                        </div>
                                        <div class="price d-flex"><?php echo wp_kses($item['section_title'], $allowed_tags);?></div>
                                        <p><?php echo wp_kses($item['section_text'], $allowed_tags);?></p>
                                        <a href="<?php echo esc_url($item['section_button_link']['url']);?>" class="photo-theme-btn">
                                            <span></span>
                                            <span></span>
                                            <span></span>
                                            <span></span>
											<?php echo wp_kses($item['section_button'], $allowed_tags);?>
                                        </a>

                                        <?php echo wp_kses($item['section_list_text'], $allowed_tags);?>
										
                                    </div>
                                </div>
                                <div class="col-xxl-4 col-xl-6 col-lg-6 wow fadeInUp" data-wow-delay="200ms">
                                    <div class="single-pricing-item">
                                        <div class="border-shape">
                                            <span></span>
                                            <span></span>
                                            <span></span>
                                            <span></span>
                                        </div>
                                        <div class="header">
                                            <h4><?php echo wp_kses($item['section_subtitle2'], $allowed_tags);?></h4>
                                        </div>
                                        <div class="price d-flex"><?php echo wp_kses($item['section_title2'], $allowed_tags);?></div>
                                        <p><?php echo wp_kses($item['section_text2'], $allowed_tags);?></p>
                                        <a href="<?php echo esc_url($item['section_button_link2']['url']);?>" class="photo-theme-btn">
                                            <span></span>
                                            <span></span>
                                            <span></span>
                                            <span></span>
											<?php echo wp_kses($item['section_button2'], $allowed_tags);?>
                                        </a>

                                        <?php echo wp_kses($item['section_list_text2'], $allowed_tags);?>
										
                                    </div>
                                </div>
                                <div class="col-xxl-4 col-xl-6 col-lg-6 wow fadeInUp" data-wow-delay="200ms">
                                    <div class="single-pricing-item">
                                        <div class="border-shape">
                                            <span></span>
                                            <span></span>
                                            <span></span>
                                            <span></span>
                                        </div>
                                        <div class="header">
                                            <h4><?php echo wp_kses($item['section_subtitle3'], $allowed_tags);?></h4>
                                        </div>
                                        <div class="price d-flex"><?php echo wp_kses($item['section_title3'], $allowed_tags);?></div>
                                        <p><?php echo wp_kses($item['section_text3'], $allowed_tags);?></p>
                                        <a href="<?php echo esc_url($item['section_button_link3']['url']);?>" class="photo-theme-btn">
                                            <span></span>
                                            <span></span>
                                            <span></span>
                                            <span></span>
											<?php echo wp_kses($item['section_button3'], $allowed_tags);?>
                                        </a>

                                        <?php echo wp_kses($item['section_list_text3'], $allowed_tags);?>
										
                                    </div>
                                </div>
                            </div>
                        </div>
						<?php endforeach; ?>
                    </div>
                </div>
            </section>
             
		<?php 
	}


}

Plugin::instance()->widgets_manager->register_widget_type(new Home2_Price());