<?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_banner 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-banner';
	}

	/**
	 * 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 Banner', '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_banner_options',
            [
                'label' => __( 'Fintech Banner Options', 'ximsa' ),
                'tab' => Controls_Manager::TAB_CONTENT,
            ]
        );
        $this->add_control(
			'banner_bg',
			[
				'label' => esc_html__( 'Banner BG Image', 'ximsa' ),
				'type' => Controls_Manager::MEDIA,
                'label_block' => true,
			]
		);
        

        $this->add_control(
			'sub_title',
			[
				'label' => esc_html__( 'Sub Title', 'ximsa' ),
				'type' => Controls_Manager::TEXTAREA,
				'default' => esc_html__( 'Join with us today', '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::TEXTAREA,
				'placeholder' => esc_html__( 'Type Banner Title Here', 'ximsa' ),
                'label_block' => true,
			]
		);
        
        $this->add_control(
			'description',
			[
				'label' => esc_html__( 'Description', 'ximsa' ),
				'type' => Controls_Manager::TEXTAREA,
                'label_block' => true,
			]
		);
        
        $this->add_control(
			'newslater_form',
			[
				'label' => esc_html__( 'Newslater Form', 'ximsa' ),
				'type' => Controls_Manager::TEXT,
                'label_block' => true,
			]
		);

        $repeater = new \Elementor\Repeater();        
        
        $repeater->add_control(
			'app_icon',
			[
				'label' => esc_html__( 'App Store Image', 'ximsa' ),
				'type' => Controls_Manager::MEDIA,
                'label_block' => true,
			]
		);
        $repeater->add_control(
			'app_link',
			[
				'label' => esc_html__( 'App Link', 'ximsa' ),
				'type' => Controls_Manager::URL,
                'label_block' => true,
			]
		);
        $repeater->add_control(
			'rating',
			[
				'label' => esc_html__( 'Rating', 'ximsa' ),
				'type' => \Elementor\Controls_Manager::NUMBER,
				'min' => 0,
				'max' => 5,
			]
		);
        $repeater->add_control(
			'review_txt',
			[
				'label' => esc_html__( 'Review Text', 'ximsa' ),
				'type' => Controls_Manager::TEXT,
                'label_block' => true,
			]
		);
        
        $this->add_control(
			'ratinginfo',
			[
				'label' => esc_html__( 'Rating Info', 'ximsa' ),
				'type' => Controls_Manager::REPEATER,
				'fields' => $repeater->get_controls(),
				'title_field' => '{{{ review_txt }}}',
			]
		);
		$this->end_controls_section();
        $this->start_controls_section(
            'slider_settings_style',
            [
                'label' => __( 'Banner Settings', 'ximsa' ),
                'tab' => Controls_Manager::TAB_STYLE,
            ]
        );
        
        $this->add_control(
            'slider_sub_title',
            [
                'type'      => Controls_Manager::HEADING,
                'label'     => esc_html__( 'Slider Sub Style', 'ximsa' ),
                'separator' => 'before',
            ]
        );
        
        $this->add_control(
            'sl_sub_cl',
            [
                'label'     => esc_html__( 'Sub Title Color', 'ximsa' ),
                'type'      => Controls_Manager::COLOR,
                'selectors' => [
                    '{{WRAPPER}} .banner-section-three .title' => 'color: {{VALUE}} ',
                ],
            ]
        );
        $this->add_group_control(
            Group_Control_Typography::get_type(),
            [
                'name'           => 'sl_sub_title_typography',
                'label'          => esc_html__( 'Typography', 'ximsa' ),
                'selector'       => '{{WRAPPER}} .banner-section-three .title',
                '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_cl',
            [
                'label'     => esc_html__( 'Title Color', 'ximsa' ),
                'type'      => Controls_Manager::COLOR,
                'selectors' => [
                    '{{WRAPPER}} .banner-section-three h2' => 'color: {{VALUE}} ',
                ],
            ]
        );
        $this->add_group_control(
            Group_Control_Typography::get_type(),
            [
                'name'           => 'sl_title_typography',
                'label'          => esc_html__( 'Typography', 'ximsa' ),
                'selector'       => '{{WRAPPER}} .banner-section-three h2',
                'fields_options' => [
                    'typography' => [
                        'default' => 'custom',
                    ],
                ],
            ]
        );
        $this->add_control(
            'slider_txt_title',
            [
                'type'      => Controls_Manager::HEADING,
                'label'     => esc_html__( 'Text Style', 'ximsa' ),
                'separator' => 'before',
            ]
        );
        
        $this->add_control(
            'sl_txt_cl',
            [
                'label'     => esc_html__( 'Text Color', 'ximsa' ),
                'type'      => Controls_Manager::COLOR,
                'selectors' => [
                    '{{WRAPPER}} .banner-section-three .text' => 'color: {{VALUE}} ',
                ],
            ]
        );
        $this->add_group_control(
            Group_Control_Typography::get_type(),
            [
                'name'           => 'sl_txt_typography',
                'label'          => esc_html__( 'Typography', 'ximsa' ),
                'selector'       => '{{WRAPPER}} .banner-section-three .text',
                'fields_options' => [
                    'typography' => [
                        'default' => 'custom',
                    ],
                ],
            ]
        );

        $this->add_control(
            'slider_list_itm',
            [
                'type'      => Controls_Manager::HEADING,
                'label'     => esc_html__( 'List Item Style', 'ximsa' ),
                'separator' => 'before',
            ]
        );
        $this->add_control(
            'newslater_typography',
            [
                'label'     => esc_html__( 'Newslater Typography Color', 'ximsa' ),
                'type'      => Controls_Manager::COLOR,
                'selectors' => [
                    '{{WRAPPER}} .email-box-two .form-group input[type="text"], .email-box-two .form-group input[type="email"]' => 'border-color: {{VALUE}} ',
                ],
            ]
        );
        $this->add_group_control(
            Group_Control_Typography::get_type(),
            [
                'name'           => 'ns_typography',
                'label'          => esc_html__( 'Typography', 'ximsa' ),
                'selector'       => '
                    {{WRAPPER}} .email-box-two .form-group input[type="text"], .email-box-two .form-group input[type="email"]
                ',
                'fields_options' => [
                    'typography' => [
                        'default' => 'custom',
                    ],
                ],
            ]
        );
        $this->add_control(
            'review_title',
            [
                'type'      => Controls_Manager::HEADING,
                'label'     => esc_html__( 'Review Style', 'ximsa' ),
                'separator' => 'before',
            ]
        );
        $this->add_control(
            'ewview_cl',
            [
                'label'     => esc_html__( 'Review Color', 'ximsa' ),
                'type'      => Controls_Manager::COLOR,
                'selectors' => [
                    '{{WRAPPER}} .banner-section-three .reviews .total-review' => 'color: {{VALUE}} ',
                ],
            ]
        );
        $this->add_group_control(
            Group_Control_Typography::get_type(),
            [
                'name'           => 'rv_typography',
                'label'          => esc_html__( 'Typography', 'ximsa' ),
                'selector'       => '
                    {{WRAPPER}} .banner-section-three .reviews .total-review
                ',
                'fields_options' => [
                    'typography' => [
                        'default' => 'custom',
                    ],
                ],
            ]
        );
        $this->add_control(
            'dote_st',
            [
                'type'      => Controls_Manager::HEADING,
                'label'     => esc_html__( 'Dot Animation Style', 'ximsa' ),
                'separator' => 'before',
            ]
        );
        $this->add_control(
            'dot_anim_cl',
            [
                'label'     => esc_html__( 'Dot Animation Color', 'ximsa' ),
                'type'      => Controls_Manager::COLOR,
                'selectors' => [
                    '{{WRAPPER}} .bubble-dotted .dotted' => 'background-color: {{VALUE}} ',
                ],
            ]
        );
		$this->end_controls_section();
        
        $this->start_controls_section(
            'button__content',
            [
                'label' => __( 'Button Style', 'ximsa' ),
                'tab'   => \Elementor\Controls_Manager::TAB_STYLE,
            ]
        );
        
        $this->add_group_control(
            \Elementor\Group_Control_Typography::get_type(),
            [
                'name'           => 'btn_typography',
                'label'          => esc_html__( 'Typography', 'ximsa' ),
                'selector'       => '
                    {{WRAPPER}} .btn-style-nineteen .txt
                ',
                'fields_options' => [
                    'typography' => [
                        'default' => 'custom',
                    ],
                ],
            ]
        );
        
        $this->start_controls_tabs( '_banner_button_1' );
        $this->start_controls_tab(
            '_glow-extension_btn__banner_normal',
            [
                'label' => esc_html__( 'Normal', 'ximsa' ),
            ]
        );
        $this->add_control(
            'btn__color',
            [
                'label'     => esc_html__( 'Color', 'ximsa' ),
                'type'      => \Elementor\Controls_Manager::COLOR,
                'selectors' => [
                    '{{WRAPPER}} .btn-style-nineteen' => 'color: {{VALUE}}',
                ],
            ]
        );
        $this->add_group_control(
            \Elementor\Group_Control_Background::get_type(),
            [
                'name'     => 'btn_bg_color',
                'label'    => __( 'Background', 'ximsa' ),
                'types'    => ['classic', 'gradient'],
                'exclude'  => ['image'],
                'selector' => '
                    {{WRAPPER}} .btn-style-nineteen
                ',
            ]
        );
        $this->add_responsive_control(
            'btn_border_radious',
            [
                'label'      => esc_html__( 'Border Radius', 'ximsa' ),
                'type'       => \Elementor\Controls_Manager::DIMENSIONS,
                'size_units' => ['px', '%'],
                'selectors'  => [
                    '{{WRAPPER}} .btn-style-nineteen' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
                ],
            ]
        );
        
        $this->end_controls_tab();
        $this->start_controls_tab(
            '_glow-extension_btn_hover',
            [
                'label' => esc_html__( 'Hover', 'ximsa' ),
            ]
        );
        $this->add_control(
            'btn__hover_color',
            [
                'label'     => esc_html__( 'Color', 'ximsa' ),
                'type'      => \Elementor\Controls_Manager::COLOR,
                'selectors' => [
                    '{{WRAPPER}} .btn-style-nineteen:hover' => 'color: {{VALUE}}',
                ],
            ]
        );
        $this->add_group_control(
            \Elementor\Group_Control_Background::get_type(),
            [
                'name'     => 'btn_hover_bg_color',
                'label'    => __( 'Background', 'ximsa' ),
                'types'    => ['classic', 'gradient'],
                'exclude'  => ['image'],
                'selector' => '
                    {{WRAPPER}} .btn-style-nineteen:before
                ',
            ]
        );
        $this->add_responsive_control(
            'btn_hover_border_radious',
            [
                'label'      => esc_html__( 'Border Radius', 'ximsa' ),
                'type'       => \Elementor\Controls_Manager::DIMENSIONS,
                'size_units' => ['px', '%'],
                'selectors'  => [
                    '{{WRAPPER}} .btn-style-nineteen:hover' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',                    
                ],
            ]
        );
        $this->end_controls_tab();
        $this->end_controls_tabs();
        $this->end_controls_section();
	}
		


	protected function render() {	
	$settings = $this->get_settings_for_display();?>        
	<!-- Banner Section Three -->
	<section class="banner-section-three" style="background-image: url(<?php echo esc_url($settings['banner_bg']['url']);?>)">
		<div class="bubble-dotted">
            <span class="dotted dotted-1"></span>
            <span class="dotted dotted-2"></span>
            <span class="dotted dotted-3"></span>
            <span class="dotted dotted-4"></span>
            <span class="dotted dotted-5"></span>
            <span class="dotted dotted-6"></span>
            <span class="dotted dotted-7"></span>
            <span class="dotted dotted-8"></span>
            <span class="dotted dotted-9"></span>
            <span class="dotted dotted-10"></span>
        </div>
		<div class="auto-container">
			<div class="content">
				<div class="title"><?php echo wp_kses( $settings['sub_title'], true );?></div>
				<h2><?php echo wp_kses( $settings['title'], true );?></h2>
				<div class="text"><?php echo wp_kses( $settings['description'], true );?></div>
				
				<!-- Email Box Two -->
				<div class="email-box-two">
					<?php echo do_shortcode( $settings['newslater_form'] );?>
				</div>
				
				<!-- Reviews -->
				<div class="reviews">
					<div class="row clearfix">
						<!-- Column -->
                        <?php foreach($settings['ratinginfo'] as $item):?>
						<div class="column col-lg-6 col-md-6 col-sm-6">
							<div class="rating-info">
								<a href="<?php echo esc_url($item['app_link']['url']);?>"><img src="<?php echo esc_url($item['app_icon']['url']);?>" alt="<?php echo esc_url($item['app_icon']['alt']);?>" /></a>
								<div class="rating">
                                    <?php for($i = 0; $i < $item['rating']; $i++):?>
									    <span class="fa fa-star"></span>
                                    <?php endfor;?>
								</div>
								<div class="total-review"><?php echo esc_html($item['review_txt']);?></div>
							</div>
						</div>
						<?php endforeach;?>
					</div>
				</div>
				
			</div>
		</div>
	</section>
	<!-- End Banner Section Three -->
    <?php  
    }
	
}

