<?php

namespace XIMSAPLUGIN\Element;

use Elementor\Controls_Manager;
use Elementor\Controls_Stack;
use Elementor\Group_Control_Typography;
use Elementor\Scheme_Typography;
use Elementor\Scheme_Color;
use Elementor\Group_Control_Border;
use Elementor\Repeater;
use Elementor\Widget_Base;
use Elementor\Utils;
use Elementor\Group_Control_Text_Shadow;
use Elementor\Plugin;

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

class banking_testimonial extends Widget_Base {

	/**
	 * Get widget name.
	 *
	 * Retrieve Elementor widget name.
	 *
	 * @since 1.0.0
	 * @access public
	 *
	 * @return string Widget name.
	 */
	public function get_name() {
		return 'banking-testimonial-item';
	}

	/**
	 * Get widget title.
	 *
	 * Retrieve Elementor widget title.
	 *
	 * @since 1.0.0
	 * @access public
	 *
	 * @return string Widget title.
	 */
	public function get_title() {
		return esc_html__( 'Banking Testimonial', 'ximsa' );
	}

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

	/**
	 * Get widget categories.
	 *
	 * Retrieve the list of categories the Elementor widget belongs to.
	 *
	 * @since 1.0.0
	 * @access public
	 *
	 * @return array Widget categories.
	 */
	public function get_categories() {
		return [ 'ximsa' ];
	}

	/**
	 * Register Elementor 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(
            'testimonial_options',
            [
                'label' => __( 'Testimonial Options', 'ximsa' ),
                'tab' => Controls_Manager::TAB_CONTENT,
            ]
        );
        $this->add_control(
			'shape',
			[
				'label' => esc_html__( 'Shape', 'ximsa' ),
				'type' => Controls_Manager::MEDIA,
                'label_block' => true,
			]
		);
        $this->add_control(
			'sub_title',
			[
				'label' => esc_html__( 'Sub Title', 'ximsa' ),
				'type' => Controls_Manager::TEXT,
				'default' => esc_html__( 'Online Payments', 'ximsa' ),
				'placeholder' => esc_html__( 'Type Banner Sub Title Here', 'ximsa' ),
                'label_block' => true,
			]
		);
        $this->add_control(
			'title',
			[
				'label' => esc_html__( 'Title', 'ximsa' ),
				'type' => Controls_Manager::TEXT,
				'default' => esc_html__( 'Looking to take online payments?', 'ximsa' ),
				'placeholder' => esc_html__( 'Type Banner Title Here', 'ximsa' ),
                'label_block' => true,
			]
		);
        $this->add_control(
			'description',
			[
				'label' => esc_html__( 'Description', 'ximsa' ),
				'type' => Controls_Manager::TEXTAREA,
				'default' => esc_html__( 'Take payments online with a scalable platform that grows with your perfect business.', 'ximsa' ),
				'placeholder' => esc_html__( 'Type Banner Short Info Here', 'ximsa' ),
                'label_block' => true,
			]
		);

        $repeater = new \Elementor\Repeater();
        $repeater->add_control(
			'title',
			[
				'label' => esc_html__( 'Title', 'ximsa' ),
				'type' => Controls_Manager::TEXT,
				'default' => esc_html__( 'Apply For Innsurance', 'ximsa' ),
				'placeholder' => esc_html__( 'Box Title Here', 'ximsa' ),
                'label_block' => true,
			]
		);
        $repeater->add_control(
			'description',
			[
				'label' => esc_html__( 'Description', 'ximsa' ),
				'type' => Controls_Manager::TEXTAREA,
				'default' => esc_html__( 'Box Short Description Here', 'ximsa' ),
                'label_block' => true,
			]
		);
       
        $this->add_control(
			'featuresitem',
			[
				'label' => esc_html__( 'Add Feature Item', 'ximsa' ),
				'type' => Controls_Manager::REPEATER,
				'fields' => $repeater->get_controls(),
				'title_field' => '{{{ title }}}',
			]
		);
        $repeater = new \Elementor\Repeater();
        $repeater->add_control(
			'authore_image',
			[
				'label' => esc_html__( 'Authore Image', 'ximsa' ),
				'type' => Controls_Manager::MEDIA,
                'label_block' => true,
			]
		);
        $repeater->add_control(
			'authore_name',
			[
				'label' => esc_html__( 'Authore Name', 'ximsa' ),
				'type' => Controls_Manager::TEXT,
                'label_block' => true,
			]
		);
        $repeater->add_control(
			'feedback',
			[
				'label' => esc_html__( 'Description', 'ximsa' ),
				'type' => Controls_Manager::TEXTAREA,
				'default' => esc_html__( 'Box Short Description Here', 'ximsa' ),
                'label_block' => true,
			]
		);
       
        $this->add_control(
			'testimonials',
			[
				'label' => esc_html__( 'Add Testimonial Item', 'ximsa' ),
				'type' => Controls_Manager::REPEATER,
				'fields' => $repeater->get_controls(),
				'title_field' => '{{{ authore_name }}}',
			]
		);
        
		$this->end_controls_section();
        
        $this->start_controls_section(
            'feature_style',
            [
                'label' => __( 'Feature Style Settings', 'ximsa' ),
                'tab' => Controls_Manager::TAB_STYLE,
            ]
        );
        $this->add_control(
            'slider_sub_title',
            [
                'type'      => Controls_Manager::HEADING,
                'label'     => esc_html__( 'Sub Heading Style', 'ximsa' ),
                'separator' => 'before',
            ]
        );
        $this->add_control(
            'sub_h_color',
            [
                'label'     => esc_html__( 'Sub Heading Color', 'ximsa' ),
                'type'      => Controls_Manager::COLOR,
                'selectors' => [
                    '{{WRAPPER}} .xis-section-title span' => 'color: {{VALUE}} ',
                ],
            ]
        );
        $this->add_group_control(
            Group_Control_Typography::get_type(),
            [
                'name'           => 'sl_h_typography',
                'label'          => esc_html__( 'Typography', 'ximsa' ),
                'selector'       => '
                    {{WRAPPER}} .xis-section-title span
                ',
                'fields_options' => [
                    'typography' => [
                        'default' => 'custom',
                    ],
                ],
            ]
        );
        $this->add_control(
            'slider_title',
            [
                'type'      => Controls_Manager::HEADING,
                'label'     => esc_html__( 'Title Style', 'ximsa' ),
                'separator' => 'before',
            ]
        );
        $this->add_control(
            'sl_title_color',
            [
                'label'     => esc_html__( 'Title Color', 'ximsa' ),
                'type'      => Controls_Manager::COLOR,
                'selectors' => [
                    '{{WRAPPER}} .xis-section-title h2' => 'color: {{VALUE}} ',
                ],
            ]
        );
        $this->add_group_control(
            Group_Control_Typography::get_type(),
            [
                'name'           => 'sl_title_typography',
                'label'          => esc_html__( 'Typography', 'ximsa' ),
                'selector'       => '{{WRAPPER}} .xis-section-title h2',
                'fields_options' => [
                    'typography' => [
                        'default' => 'custom',
                    ],
                ],
            ]
        );
        $this->add_control(
            'slider_desc',
            [
                'type'      => Controls_Manager::HEADING,
                'label'     => esc_html__( 'Description Style', 'ximsa' ),
                'separator' => 'before',
            ]
        );
        $this->add_control(
            'sl_desc_color',
            [
                'label'     => esc_html__( 'Description Color', 'ximsa' ),
                'type'      => Controls_Manager::COLOR,
                'selectors' => [
                    '{{WRAPPER}} .pera-content p' => 'color: {{VALUE}} ',
                ],
            ]
        );
        $this->add_group_control(
            Group_Control_Typography::get_type(),
            [
                'name'           => 'sl_desc_typography',
                'label'          => esc_html__( 'Typography', 'ximsa' ),
                'selector'       => '
                    {{WRAPPER}} .pera-content p
                ',
                'fields_options' => [
                    'typography' => [
                        'default' => 'custom',
                    ],
                ],
            ]
        );
        $this->add_control(
            'fs_title_st',
            [
                'type'      => Controls_Manager::HEADING,
                'label'     => esc_html__( 'Feature Title Style', 'ximsa' ),
                'separator' => 'before',
            ]
        );
        $this->add_control(
            'fs_title_cl',
            [
                'label'     => esc_html__( 'Authore Name Color', 'ximsa' ),
                'type'      => Controls_Manager::COLOR,
                'selectors' => [
                    '{{WRAPPER}} .xis-testimonial-feature-item h3' => 'color: {{VALUE}} ',
                ],
            ]
        );
        $this->add_group_control(
            Group_Control_Typography::get_type(),
            [
                'name'           => 'fs_fet_title_typography',
                'label'          => esc_html__( 'Typography', 'ximsa' ),
                'selector'       => '
                    {{WRAPPER}} .xis-testimonial-feature-item h3
                ',
                'fields_options' => [
                    'typography' => [
                        'default' => 'custom',
                    ],
                ],
            ]
        );
        $this->add_control(
            'test_title_st',
            [
                'type'      => Controls_Manager::HEADING,
                'label'     => esc_html__( 'Testimonial Title Style', 'ximsa' ),
                'separator' => 'before',
            ]
        );
        $this->add_control(
            'test_title_cl',
            [
                'label'     => esc_html__( 'Authore Name Color', 'ximsa' ),
                'type'      => Controls_Manager::COLOR,
                'selectors' => [
                    '{{WRAPPER}} .xis-testi-slide-item .xis-testi-text h3' => 'color: {{VALUE}} ',
                ],
            ]
        );
        $this->add_group_control(
            Group_Control_Typography::get_type(),
            [
                'name'           => 'tst_fet_title_typography',
                'label'          => esc_html__( 'Typography', 'ximsa' ),
                'selector'       => '
                    {{WRAPPER}} .xis-testi-slide-item .xis-testi-text h3
                ',
                'fields_options' => [
                    'typography' => [
                        'default' => 'custom',
                    ],
                ],
            ]
        );
        $this->add_control(
            'fedback_st',
            [
                'type'      => Controls_Manager::HEADING,
                'label'     => esc_html__( 'Feedback Style', 'ximsa' ),
                'separator' => 'before',
            ]
        );
        $this->add_control(
            'test_fdbk_cl',
            [
                'label'     => esc_html__( 'Authore Feedback Color', 'ximsa' ),
                'type'      => Controls_Manager::COLOR,
                'selectors' => [
                    '{{WRAPPER}} .xis-testi-text.pera-content p' => 'color: {{VALUE}} ',
                ],
            ]
        );
        $this->add_group_control(
            Group_Control_Typography::get_type(),
            [
                'name'           => 'tst_fedback_typography',
                'label'          => esc_html__( 'Typography', 'ximsa' ),
                'selector'       => '
                    {{WRAPPER}} .xis-testi-text.pera-content p
                ',
                'fields_options' => [
                    'typography' => [
                        'default' => 'custom',
                    ],
                ],
            ]
        );
        $this->add_control(
            'quote_st',
            [
                'type'      => Controls_Manager::HEADING,
                'label'     => esc_html__( 'Quote Style', 'ximsa' ),
                'separator' => 'before',
            ]
        );
        $this->add_control(
            'test_quote_cl',
            [
                'label'     => esc_html__( 'Authore Feedback Color', 'ximsa' ),
                'type'      => Controls_Manager::COLOR,
                'selectors' => [
                    '{{WRAPPER}} .xis-testimonial-slider .slick-center.xis-testi-slide-item:before' => 'color: {{VALUE}} ',
                ],
            ]
        );
        $this->add_control(
            'active_bar_cl',
            [
                'type'      => Controls_Manager::HEADING,
                'label'     => esc_html__( 'Active Bar Style', 'ximsa' ),
                'separator' => 'before',
            ]
        );
       
		$this->add_group_control(
			\Elementor\Group_Control_Background::get_type(),
			[
				'name' => 'act_test_background',
				'label' => esc_html__( 'Background', 'ximsa' ),
				'types' => [ 'gradient' ],
				'selector' => '{{WRAPPER}} .xis-testi-slide-item:after',
			]
		);
        
		$this->end_controls_section();
	}
		


	protected function render() {
		
		
	$settings = $this->get_settings_for_display(); ?>
		<!-- Start of Testimonial section
	============================================= -->
	<section id="xis-testimonial" class="xis-testimonial-section position-relative">
		<div class="xis-testimonial-shape position-absolute"><img src="<?php echo esc_url($settings['shape']['url']);?>" alt=""></div>
		<div class="container">
			<div class="xis-testimonial-content">
				<div class="row">
					<div class="col-lg-5">
						<div class="xis-testimonial-text">
							<div class="xis-section-title headline pera-content wow fadeInUp" data-wow-delay="0ms" data-wow-duration="1500ms">
								<span><?php echo esc_html($settings['sub_title']);?></span>
								<h2><?php echo __($settings['title']);?></h2>
								<p><?php echo __($settings['description']);?></p>
							</div>
							<div class="xis-testimonial-feature-wrapper d-flex justify-content-between">
								<?php foreach($settings['featuresitem'] as $item):?>
								<div class="xis-testimonial-feature-item headline pera-content wow fadeInUp" data-wow-delay="600ms" data-wow-duration="1500ms">
									<h3><?php echo esc_html($item['title']);?></h3>
									<p><?php echo esc_html($item['description']);?></p>
								</div>
                                <?php endforeach;?>
							</div> 
						</div>
					</div>
					<div class="col-lg-7">
						<div class="xis-testimonial-slider-wrapper">
							<div class="xis-testimonial-slider">
								<?php foreach($settings['testimonials'] as $test):?>
								<div class="xis-testi-slide-item d-flex align-items-center position-relative">
									<div class="xis-testi-img">
										<img src="<?php echo esc_url($test['authore_image']['url']);?>" alt="">
									</div>
									<div class="xis-testi-text headline pera-content">
										<h3><?php echo esc_html($test['authore_name']);?></h3>
										<p><?php echo esc_html($test['feedback']);?></p>
									</div>
								</div>
                                <?php endforeach;?>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
	</section>
<!-- End of Testimonial section
	============================================= -->
    <?php  
    }
	
	

}

