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

	/**
	 * Get widget title.
	 *
	 * Retrieve Elementor widget title.
	 *
	 * @since 1.0.0
	 * @access public
	 *
	 * @return string Widget title.
	 */
	public function get_title() {
		return esc_html__( 'Digital Pay Footer', '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(
            'footer_news_later',
            [
                'label' => __('Footer Newslater Content', 'ximsa'),
                'tab' => \Elementor\Controls_Manager::TAB_CONTENT,
            ]
        );
        $this->add_control(
            'newslater_title',
            [
                'label' => __('Newslater Title', 'ximsa'),
                'type' => Controls_Manager::TEXTAREA,
            ]
        );
        $this->add_control(
            'newslater_form',
            [
                'label' => __('Form Shortcode', 'ximsa'),
                'type' => Controls_Manager::TEXTAREA,
            ]
        );
        $this->add_control(
            'newslater_img',
            [
                'label' => __('Newslater Img', 'ximsa'),
                'type' => Controls_Manager::MEDIA,
            ]
        );
        $this->end_controls_section();
        $this->start_controls_section(
            'footer_content',
            [
                'label' => __('Footer Content', 'ximsa'),
                'tab' => \Elementor\Controls_Manager::TAB_CONTENT,
            ]
        );
        $this->add_control(
            'logo',
            [
                'label' => __('Choose Custom Logo', 'ximsa'),
                'type' => Controls_Manager::MEDIA,
            ]
        );
        $this->add_control(
            'about_text',
            [
                'label' => __('About', 'ximsa'),
                'type' => Controls_Manager::TEXTAREA,
            ]
        );
        $this->add_control(
            'footer_link_title',
            [
                'label' => __('Footer Link Title', 'ximsa'),
                'type' => Controls_Manager::TEXT,
                'label_block' => true,
            ]
        );
        $this->add_control(
            'footer_nav',
            [
                'label' => __('Choose Link Menu', 'ximsa'),
                'type' => Controls_Manager::SELECT2,
                'options' =>  ximsa_menu_selector(),
                'multiple' => false,
                'label_block' => true,
            ]
        );
        $this->add_control(
            'service_title',
            [
                'label' => __('Service Title', 'ximsa'),
                'type' => Controls_Manager::TEXT,
            ]
        );
        $this->add_control(
            'footer_service_nav',
            [
                'label' => __('Choose Service Menu', 'ximsa'),
                'type' => Controls_Manager::SELECT2,
                'options' =>  ximsa_menu_selector(),
                'multiple' => false,
                'label_block' => true,
            ]
        );
        
        $this->add_control(
            'time_title',
            [
                'label' => __('Time Title', 'ximsa'),
                'type' => Controls_Manager::TEXT,
            ]
        );
        $this->add_control(
            'time_text',
            [
                'label' => __('Time Text', 'ximsa'),
                'type' => Controls_Manager::TEXTAREA,
            ]
        );
        $repeater = new \Elementor\Repeater();
        
        $repeater->add_control(
			'title',
			[
				'label' => esc_html__( 'Title', 'ximsa' ),
				'type' => Controls_Manager::TEXTAREA,
                'label_block' => true,
			]
		);
        
        $this->add_control(
			'contactinfos',
			[
				'label' => esc_html__( 'Add Contact Info', 'ximsa' ),
				'type' => Controls_Manager::REPEATER,
				'fields' => $repeater->get_controls(),
			]
		);
        $repeater = new \Elementor\Repeater();
        
        $repeater->add_control(
			'icons',
			[
				'label' => esc_html__( 'Icon', 'ximsa' ),
				'type' => Controls_Manager::ICONS,
                'label_block' => true,
			]
		);
        
        $repeater->add_control(
			'link_url',
			[
				'label' => esc_html__( 'Link URL', 'ximsa' ),
				'type' => Controls_Manager::URL,
                'label_block' => true,
			]
		);
        
        $this->add_control(
			'socialicons',
			[
				'label' => esc_html__( 'Social Icon', 'ximsa' ),
				'type' => Controls_Manager::REPEATER,
				'fields' => $repeater->get_controls(),
			]
		);
        
        
        $this->add_control(
            'footer_copyright',
            [
                'label' => __('Footer Copyright', 'ximsa'),
                'type' => Controls_Manager::WYSIWYG,
                'label_block' => true,
            ]
        );
        $this->add_control(
            'dev_quote',
            [
                'label' => __('Made By Text', 'ximsa'),
                'type' => Controls_Manager::WYSIWYG,
                'label_block' => true,
            ]
        );

        $this->end_controls_section();


        $this->start_controls_section(
            'Header_container_style',
            [
                'label' => __('Header Container Style', 'ximsa'),
                'tab' => \Elementor\Controls_Manager::TAB_STYLE,
            ]
        );
        $this->add_responsive_control(
            'logo_max_width',
            [
                'label' => esc_html__( 'Logo Width', 'ximsa' ),
                'type' => \Elementor\Controls_Manager::SLIDER,
                'size_units' => [ 'px', '%' ],
                'range' => [
                    'px' => [
                        'min' => 0,
                        'max' => 1920,
                        'step' => 1,
                    ],
                    '%' => [
                        'min' => 0,
                        'max' => 100,
                    ],
                ],
                'selectors' => [
                    '{{WRAPPER}} .footer-style-three .logo-widget .logo img' => 'max-width: {{SIZE}}{{UNIT}};',
                ],
            ]
        );
        $this->add_control(
            'section_bg_cl',
            [
                'label' => esc_html__( 'Footer Sction BG', 'ximsa' ),
                'type' => \Elementor\Controls_Manager::HEADING,
                'separator' => 'before',
            ]
        );
        $this->add_group_control(
			\Elementor\Group_Control_Background::get_type(),
			[
				'name' => 'ft-section-bgbackground',
				'label' => esc_html__( 'Background', 'plugin-name' ),
				'types' => [ 'classic', 'gradient' ],
				'selector' => '{{WRAPPER}} .footer-style-three',
			]
		);
        $this->add_control(
            'Header_bottom_border_color_heading',
            [
                'label' => esc_html__( 'Header Bottom Border Color', 'ximsa' ),
                'type' => \Elementor\Controls_Manager::HEADING,
                'separator' => 'before',
            ]
        );
        
        $this->add_control(
            'main_nav_color',
            [
                'label' => esc_html__( 'Link Color', 'ximsa' ),
                'type' => \Elementor\Controls_Manager::COLOR,
                'selectors' => [
                    '{{WRAPPER}} .footer-style-three .nav-list a' => 'color: {{VALUE}}',
                ],
            ]
        );
        $this->add_control(
            'main_nav_hover_color',
            [
                'label' => esc_html__( 'Nav link Hover Color', 'ximsa' ),
                'type' => \Elementor\Controls_Manager::COLOR,
                'selectors' => [
                    '{{WRAPPER}} .footer-style-three .nav-list a a:hover' => 'color: {{VALUE}}',
                ],
            ]
        );
        $this->add_group_control(
            \Elementor\Group_Control_Typography::get_type(),
            [
                'label' => esc_html__( 'Main Nav Typo', 'ximsa' ),
                'name' => 'main_nav_typography',
                'selector' => '{{WRAPPER}} .footer-style-three .nav-list a',
            ]
        );
        
        
        $this->add_control(
            'copyright_txt',
            [
                'label' => esc_html__( 'Copyright Text Color', 'ximsa' ),
                'type' => \Elementor\Controls_Manager::COLOR,
                'selectors' => [
                    '{{WRAPPER}} .footer-style-three .footer-bottom .copyright p' => 'color: {{VALUE}}',
                ],
            ]
        );
        $this->add_group_control(
            \Elementor\Group_Control_Typography::get_type(),
            [
                'label' => esc_html__( 'Copyright Title', 'ximsa' ),
                'name' => 'cpr_title_typography',
                'selector' => '{{WRAPPER}} .footer-style-three .footer-bottom .copyright p',
            ]
        );
        $this->add_control(
            'social_icon_clr',
            [
                'label' => esc_html__( 'Social Icon Color', 'ximsa' ),
                'type' => \Elementor\Controls_Manager::COLOR,
                'selectors' => [
                    '{{WRAPPER}} .footer-style-three .social-box li a' => 'color: {{VALUE}}',
                ],
            ]
        );
        $this->add_control(
            'social_icon_hv_clr',
            [
                'label' => esc_html__( 'Social Icon Hover Color', 'ximsa' ),
                'type' => \Elementor\Controls_Manager::COLOR,
                'selectors' => [
                    '{{WRAPPER}} .footer-style-three .social-box li a:hover' => 'color: {{VALUE}}',
                ],
            ]
        );

        
        $this->add_control(
			'heading_color',
			[
				'label' => esc_html__( 'Widget Title Options', 'ximsa' ),
				'type' => \Elementor\Controls_Manager::HEADING,
				'separator' => 'before',
			]
		);
        $this->add_control(
            'wid_title_cl',
            [
                'label' => esc_html__( 'Widget Title Color', 'ximsa' ),
                'type' => \Elementor\Controls_Manager::COLOR,
                'selectors' => [
                    '{{WRAPPER}} .footer-style-three .footer-widget h4' => 'color: {{VALUE}}',
                ],
            ]
        );
        $this->add_group_control(
            \Elementor\Group_Control_Typography::get_type(),
            [
                'label' => esc_html__( 'Widget Title', 'ximsa' ),
                'name' => 'contact_inf_typography',
                'selector' => '{{WRAPPER}} .footer-style-three .footer-widget h4',
            ]
        );
        $this->add_control(
			'contact_info_options',
			[
				'label' => esc_html__( 'Contact Info Options', 'ximsa' ),
				'type' => \Elementor\Controls_Manager::HEADING,
				'separator' => 'before',
			]
		);
        $this->add_control(
            'con_info_title',
            [
                'label' => esc_html__( 'Contact Info Title Color', 'ximsa' ),
                'type' => \Elementor\Controls_Manager::COLOR,
                'selectors' => [
                    '{{WRAPPER}} .footer-style-three .list-list li' => 'color: {{VALUE}}',
                ],
            ]
        );
        $this->add_group_control(
            \Elementor\Group_Control_Typography::get_type(),
            [
                'label' => esc_html__( 'Contact Info Content Typography', 'ximsa' ),
                'name' => 'contact_inf_typography',
                'selector' => '{{WRAPPER}} .footer-style-three .list-list li',
            ]
        );
        $this->add_control(
			'footer_txt_style',
			[
				'label' => esc_html__( 'Footer Text Options', 'ximsa' ),
				'type' => \Elementor\Controls_Manager::HEADING,
				'separator' => 'before',
			]
		);
        $this->add_control(
            'ft_txt_style',
            [
                'label' => esc_html__( 'Text Color', 'ximsa' ),
                'type' => \Elementor\Controls_Manager::COLOR,
                'selectors' => [
                    '{{WRAPPER}} .footer-style-three .logo-widget .text' => 'color: {{VALUE}}',
                ],
            ]
        );
        $this->add_group_control(
            \Elementor\Group_Control_Typography::get_type(),
            [
                'label' => esc_html__( 'Text Typography', 'ximsa' ),
                'name' => 'txt_styp_typography',
                'selector' => '{{WRAPPER}} .footer-style-three .logo-widget .text',
            ]
        );
        $this->add_control(
			'newslater_st',
			[
				'label' => esc_html__( 'Newslater Options', 'ximsa' ),
				'type' => \Elementor\Controls_Manager::HEADING,
				'separator' => 'before',
			]
		);
        $this->add_control(
            'newslater_title',
            [
                'label' => esc_html__( 'Newslater Title Color', 'ximsa' ),
                'type' => \Elementor\Controls_Manager::COLOR,
                'selectors' => [
                    '{{WRAPPER}} .footer-style-three .upper-box h2' => 'color: {{VALUE}}',
                ],
            ]
        );
        $this->add_group_control(
            \Elementor\Group_Control_Typography::get_type(),
            [
                'label' => esc_html__( 'Newslater Typography', 'ximsa' ),
                'name' => 'txt_ns_typography',
                'selector' => '{{WRAPPER}} .footer-style-three .upper-box h2',
            ]
        );
        $this->add_group_control(
			\Elementor\Group_Control_Background::get_type(),
			[
				'name' => 'elm-bgbackground',
				'label' => esc_html__( 'Background', 'plugin-name' ),
				'types' => [ 'classic', 'gradient', 'video' ],
				'selector' => '{{WRAPPER}} .btn-style-one',
			]
		);
        $this->add_group_control(
			\Elementor\Group_Control_Background::get_type(),
			[
				'name' => 'elm-hv-bgbackground',
				'label' => esc_html__( 'Background', 'plugin-name' ),
				'types' => [ 'classic', 'gradient', 'video' ],
				'selector' => '{{WRAPPER}} .btn-style-one:before',
			]
		);
       
        $this->add_group_control(
            \Elementor\Group_Control_Typography::get_type(),
            [
                'label' => esc_html__( 'Button Typography', 'ximsa' ),
                'name' => 'txt_btn_typography',
                'selector' => '{{WRAPPER}} .btn-style-one',
            ]
        );
        $this->end_controls_section();
	}
		


	protected function render() {
		
		
	$settings = $this->get_settings_for_display(); ?>

    <!-- Footer Style Three -->
    <footer class="footer-style-three">
    	<div class="auto-container">
			<!-- Upper Box -->
			<div class="upper-box">
				<div class="row clearfix">
					<!-- Title Column -->
					<div class="title-column col-lg-6 col-md-12 col-sm-12">
						<h2><?php echo __($settings['newslater_title']);?></h2>
					</div>
					<!-- Subscribe Column -->
					<div class="subscribe-column col-lg-6 col-md-12 col-sm-12">
						<!-- Subscribe Box -->
						<div class="subscribe-box">
							<div class="hand-icon">
								<img src="<?php echo esc_url($settings['newslater_img']['url']);?>" alt="" />
							</div>
                            <div class="form-group">
                                <?php echo do_shortcode( $settings['newslater_form'] );?>
                            </div>
						</div>
					</div>
				</div>
			</div>
        	<!-- Widgets Section -->
            <div class="widgets-section">
            	<div class="row clearfix">
                	
                    <!-- Column -->
                    <div class="big-column col-lg-6 col-md-12 col-sm-12">
						<div class="row clearfix">
						
                        	<!-- Footer Column -->
                            <div class="footer-column col-lg-8 col-md-6 col-sm-12">
                                <div class="footer-widget logo-widget">
									<div class="logo">
                                        <a href="<?php echo esc_url( home_url( '/' ) ); ?>"><img src="<?php echo esc_url($settings['logo']['url']);?>" alt=""></a>
									</div>
									<div class="text"><?php echo __($settings['about_text']);?></div>
									<ul class="list-list">
                                        <?php foreach($settings['contactinfos'] as $item):?>
										    <li><?php echo wp_kses( $item['title'], true );?></li>
                                        <?php endforeach;?>
									</ul>
								</div>
							</div>
							
							<!-- Footer Column -->
                            <div class="footer-column col-lg-4 col-md-6 col-sm-12">
                                <div class="footer-widget links-widget">
									<h4><?php echo __($settings['footer_link_title']);?></h4>
									<div class="nav-list">
                                        <?php
                                        wp_nav_menu( array(
                                            'menu' => $settings['footer_nav'],
                                        ) );
                                        ?>
									</div>
								</div>
							</div>
							
						</div>
					</div>
					
					<!-- Column -->
                    <div class="big-column col-lg-6 col-md-12 col-sm-12">
						<div class="row clearfix">
							
							<!-- Footer Column -->
                            <div class="footer-column col-lg- col-md-6 col-sm-12">
                                <div class="footer-widget links-widget">
									<h4><?php echo __($settings['service_title']);?></h4>
									<div class="nav-list">
                                        <?php
                                            wp_nav_menu( array(
                                                'menu' => $settings['footer_service_nav'],
                                            ) );
                                        ?>
									</div>
								</div>
							</div>
							
							<!-- Footer Column -->
                            <div class="footer-column col-lg-6 col-md-6 col-sm-12">
                                <div class="footer-widget info-widget">
									<h4><?php echo esc_html($settings['time_title']);?></h4>
									<div class="timing"><?php echo wp_kses( $settings['time_text'], true );?></div>
									<!-- Social Box -->
									<ul class="social-box">
                                        <?php foreach($settings['socialicons'] as $item):?>
										    <li><a href="<?php echo esc_url($item['link_url']['url']);?>"><?php \Elementor\Icons_Manager::render_icon( $item['icons'], [ 'aria-hidden' => 'true' ] ); ?></a></li>
                                        <?php endforeach;?>
									</ul>
								</div>
							</div>
							
						</div>
					</div>
					
				</div>
			</div>
			
			<!-- Footer Bottom -->
			<div class="footer-bottom">
				<div class="row clearfix">
					<div class="column col-lg-6 col-md-12 col-sm-12">
						<div class="copyright"><?php echo __($settings['footer_copyright']);?></div>
					</div>
					<div class="column col-lg-6 col-md-12 col-sm-12">
						<div class="profile"><?php echo wp_kses( $settings['dev_quote'], true );?></div>
					</div>
				</div>
			</div>
			
		</div>
	</footer>
	<!-- End Footer Style Two -->
        
    <?php  
    }
	
	

}

