<?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\Group_Control_Background;
use Elementor\Plugin;

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

class fintech_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 'fintech-testimonial';
	}

	/**
	 * Get widget title.
	 *
	 * Retrieve Elementor widget title.
	 *
	 * @since 1.0.0
	 * @access public
	 *
	 * @return string Widget title.
	 */
	public function get_title() {
		return esc_html__( 'Fintech 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(
            'fintech_testimonial_options',
            [
                'label' => __( 'Fintech Testimonial Options', 'ximsa' ),
                'tab' => Controls_Manager::TAB_CONTENT,
            ]
        );
        
        $this->add_control(
			'testimonial_bg',
			[
				'label' => esc_html__( 'Testimonial BG', 'ximsa' ),
				'type' => Controls_Manager::MEDIA,
                'label_block' => true,
			]
		);
        
        $this->add_control(
			'title',
			[
				'label' => esc_html__( 'Title', 'ximsa' ),
				'type' => Controls_Manager::TEXTAREA,
				'default' => esc_html__( 'Grow your Business
                Real, Organic & Automatic', 'ximsa' ),
				'placeholder' => esc_html__( 'Type Banner Title Here', 'ximsa' ),
                'label_block' => true,
			]
		);
        
        
        $repeater = new \Elementor\Repeater();        
        $repeater->add_control(
			'rating',
			[
				'label' => esc_html__( 'Rating', 'ximsa' ),
				'type' => Controls_Manager::NUMBER,
				'min' => 0,
				'max' => 5,
				'step' => 1,
			]
		);
        $repeater->add_control(
			'authore_img',
			[
				'label' => esc_html__( 'Authore Image', 'ximsa' ),
				'type' => Controls_Manager::MEDIA,
                'label_block' => true,
			]
		);
        $repeater->add_control(
			'feedback',
			[
				'label' => esc_html__( 'Authore Feedbacl', 'ximsa' ),
				'type' => Controls_Manager::TEXTAREA,
                'label_block' => true,
			]
		);
        $repeater->add_control(
			'name',
			[
				'label' => esc_html__( 'Authore Name', 'ximsa' ),
				'type' => Controls_Manager::TEXT,
                'label_block' => true,
			]
		);
        $repeater->add_control(
			'designation',
			[
				'label' => esc_html__( 'Authore Designation', 'ximsa' ),
				'type' => Controls_Manager::TEXT,
			]
		);
        
        $this->add_control(
			'testimonials',
			[
				'label' => esc_html__( 'Add List Item', 'ximsa' ),
				'type' => Controls_Manager::REPEATER,
				'fields' => $repeater->get_controls(),
				'title_field' => '{{{ name }}}',
			]
		);
		
		$this->end_controls_section();
        $this->start_controls_section(
            'slider_settings_style',
            [
                'label' => __( 'Banner Settings', 'ximsa' ),
                'tab' => Controls_Manager::TAB_STYLE,
            ]
        );
        
        $this->add_control(
            'slider_title',
            [
                'type'      => Controls_Manager::HEADING,
                'label'     => esc_html__( 'Title Style', 'ximsa' ),
                'separator' => 'before',
            ]
        );
        
        $this->add_control(
            'sl_title_cl',
            [
                'label'     => esc_html__( 'Title Color', 'ximsa' ),
                'type'      => Controls_Manager::COLOR,
                'selectors' => [
                    '{{WRAPPER}} .testimonial-section-seven .carousel-box h3' => 'color: {{VALUE}} ',
                ],
            ]
        );
        $this->add_group_control(
            Group_Control_Typography::get_type(),
            [
                'name'           => 'sl_title_typography',
                'label'          => esc_html__( 'Typography', 'ximsa' ),
                'selector'       => '{{WRAPPER}} .testimonial-section-seven .carousel-box h3',
                'fields_options' => [
                    'typography' => [
                        'default' => 'custom',
                    ],
                ],
            ]
        );
        $this->add_control(
            'rating_color',
            [
                'type'      => Controls_Manager::HEADING,
                'label'     => esc_html__( 'Rating Style', 'ximsa' ),
                'separator' => 'before',
            ]
        );
        
        $this->add_control(
            'rating_cl',
            [
                'label'     => esc_html__( 'Rating Color', 'ximsa' ),
                'type'      => Controls_Manager::COLOR,
                'selectors' => [
                    '{{WRAPPER}} .testimonial-block-six .rating' => 'color: {{VALUE}} ',
                ],
            ]
        );
        
        $this->add_control(
            'authore_name_st',
            [
                'type'      => Controls_Manager::HEADING,
                'label'     => esc_html__( 'Authore Name Style', 'ximsa' ),
                'separator' => 'before',
            ]
        );
        
        $this->add_control(
            'authore_name',
            [
                'label'     => esc_html__( 'Authore Name Color', 'ximsa' ),
                'type'      => Controls_Manager::COLOR,
                'selectors' => [
                    '{{WRAPPER}} .testimonial-block-six .author-info strong' => 'color: {{VALUE}} ',
                ],
            ]
        );
        $this->add_group_control(
            Group_Control_Typography::get_type(),
            [
                'name'           => 'authore_name_typography',
                'label'          => esc_html__( 'Typography', 'ximsa' ),
                'selector'       => '{{WRAPPER}} .testimonial-block-six .author-info strong',
                'fields_options' => [
                    'typography' => [
                        'default' => 'custom',
                    ],
                ],
            ]
        );
        $this->add_control(
            'authore_des_st',
            [
                'type'      => Controls_Manager::HEADING,
                'label'     => esc_html__( 'Authore Designation Style', 'ximsa' ),
                'separator' => 'before',
            ]
        );
        
        $this->add_control(
            'desig_name',
            [
                'label'     => esc_html__( 'Authore Designation Color', 'ximsa' ),
                'type'      => Controls_Manager::COLOR,
                'selectors' => [
                    '{{WRAPPER}} .testimonial-block-six .author-info .designation' => 'color: {{VALUE}} ',
                ],
            ]
        );
        $this->add_group_control(
            Group_Control_Typography::get_type(),
            [
                'name'           => 'authore_desig_typography',
                'label'          => esc_html__( 'Typography', 'ximsa' ),
                'selector'       => '{{WRAPPER}} .testimonial-block-six .author-info .designation',
                'fields_options' => [
                    'typography' => [
                        'default' => 'custom',
                    ],
                ],
            ]
        );
        $this->add_control(
            'authore_feedback_st',
            [
                'type'      => Controls_Manager::HEADING,
                'label'     => esc_html__( 'Authore Feedback Style', 'ximsa' ),
                'separator' => 'before',
            ]
        );
        
        $this->add_control(
            'fdb_name',
            [
                'label'     => esc_html__( 'Authore Feedback Color', 'ximsa' ),
                'type'      => Controls_Manager::COLOR,
                'selectors' => [
                    '{{WRAPPER}} .testimonial-block-six .inner-box .text' => 'color: {{VALUE}} ',
                ],
            ]
        );
        $this->add_group_control(
            Group_Control_Typography::get_type(),
            [
                'name'           => 'authore_feedback_typography',
                'label'          => esc_html__( 'Typography', 'ximsa' ),
                'selector'       => '{{WRAPPER}} .testimonial-block-six .inner-box .text',
                'fields_options' => [
                    'typography' => [
                        'default' => 'custom',
                    ],
                ],
            ]
        );
        $this->add_control(
            'nav_active_cl',
            [
                'type'      => Controls_Manager::HEADING,
                'label'     => esc_html__( 'Nav Active Style', 'ximsa' ),
                'separator' => 'before',
            ]
        );
        $this->add_control(
            'quote_cl',
            [
                'label'     => esc_html__( 'Quote Color', 'ximsa' ),
                'type'      => Controls_Manager::COLOR,
                'selectors' => [
                    '{{WRAPPER}} .testimonial-section-seven .carousel-box .quote-icon' => 'color: {{VALUE}} ',
                ],
            ]
        );
        
        $this->add_group_control(
			\Elementor\Group_Control_Background::get_type(),
			[
				'name' => 'nav_active_bg',
				'label' => esc_html__( 'Background', 'plugin-name' ),
				'types' => [ 'gradient' ],
				'selector' => '{{WRAPPER}} .testimonial-section-seven .carousel-box .owl-nav .owl-prev:hover, .testimonial-section-seven .carousel-box .owl-nav .owl-next:hover',
			]
		);
		$this->end_controls_section();
        
	}
		


	protected function render() {	
	$settings = $this->get_settings_for_display();?>        
	<!-- Testimonial Section Seven -->
	<section class="testimonial-section-seven">
		<div class="image-layer" style="background-image: url(<?php echo esc_url($settings['testimonial_bg']['url']);?>)"></div>
		<div class="auto-container">
			<!-- Carousel Box -->
			<div class="carousel-box">
				<span class="quote-icon flaticon-quote"></span>
				<h3><?php echo wp_kses( $settings['title'], true );?></h3>
				
				<div class="single-item-carousel owl-carousel owl-theme">
                    <?php foreach($settings['testimonials'] as $item):?>
					<!-- Testimonial Block Six -->
					<div class="testimonial-block-six">
						<div class="inner-box">
							<div class="text"><?php echo wp_kses( $item['feedback'], true );?></div>
							<div class="author-info">
								<div class="info-inner">
									<span class="author-image">
										<img src="<?php echo esc_url($item['authore_img']['url']);?>" alt="" />
									</span>
									<strong><?php echo wp_kses( $item['name'], true );?></strong>
									<div class="designation"><?php echo wp_kses( $item['designation'], true );?></div>
									<div class="rating">
                                        <?php for($i = 0; $i < $item['rating']; $i++):?>
										    <span class="fa fa-star"></span>
                                        <?php endfor;?>
									</div>
								</div>
							</div>
						</div>
					</div>
					<?php endforeach;?>
				</div>
			</div>
		</div>
	</section>
	<!-- End Testimonial Section Seven -->
    <?php  
    }
	
}

