<?php

/**
 * Elementor daltech Team Details Widget.
 *
 * Elementor widget that inserts an embbedable content into the page, from any given URL.
 *
 * @since 1.0.0
 */
class Daltech_Team_Details extends \Elementor\Widget_Base
{

    /**
     * Get widget name.
     *
     * Retrieve Team Details widget name.
     *
     * @since 1.0.0
     * @access public
     *
     * @return string Widget name.
     */
    public function get_name()
    {
        return 'daltech_team_details';
    }

    /**
     * Get widget title.
     *
     * Retrieve Team Details Nav Tab widget title.
     *
     * @since 1.0.0
     * @access public
     *
     * @return string Widget title.
     */
    public function get_title()
    {
        return esc_html__('Team Details', 'daltech-core');
    }

    /**
     * Get widget icon.
     *
     * Retrieve Team Details Nav Tab widget icon.
     *
     * @since 1.0.0
     * @access public
     *
     * @return string Widget icon.
     */
    public function get_icon()
    {
        return 'eicon-code';
    }

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

    // Add The Input For User
    protected function register_controls()
    {

        $this->start_controls_section(
            'team_details_content_style',
            [
                'label'        => esc_html__('Team Details Style', 'daltech-core'),
                'tab'        => \Elementor\Controls_Manager::TAB_CONTENT,
            ]
        );

        $this->add_control(
            'style',
            [
                'label'     => esc_html__('Style', 'daltech-core'),
                'type'         => \Elementor\Controls_Manager::SELECT,
                'default'     => '1',
                'options'     => [
                    '1'      => esc_html__('Style One', 'daltech-core'),
                ],
            ]
        );

        $this->add_control(
            'name',
            [
                'label'         => esc_html__('Name', 'daltech-core'),
                'type'             => \Elementor\Controls_Manager::TEXTAREA,
                'placeholder'     => esc_html__('Name', 'daltech-core'),
                'default'         => esc_html__('Default Name', 'daltech-core'),
                'condition' => [
                    'style' => ['1']
                ]
            ]
        );

        $this->add_control(
            'designation',
            [
                'label'         => esc_html__('Designation', 'daltech-core'),
                'type'             => \Elementor\Controls_Manager::TEXTAREA,
                'placeholder'     => esc_html__('section Designation', 'daltech-core'),
                'default'         => esc_html__('Default Designation', 'daltech-core'),
                'condition' => [
                    'style' => ['1']
                ]
            ]
        );

        $this->add_control(
            'summary',
            [
                'label'         => esc_html__('Summary', 'daltech-core'),
                'type'             => \Elementor\Controls_Manager::TEXTAREA,
                'placeholder'     => esc_html__('Summary', 'daltech-core'),
                'default'         => esc_html__('Default Summary', 'daltech-core'),
                'condition' => [
                    'style' => ['1']
                ]
            ]
        );

        $this->add_control(
            'rating',
            [
                'label' => __('Rating', 'ploming-addon'),
                'type' => \Elementor\Controls_Manager::SLIDER,
                'size_units' => ['count'],
                'range' => [
                    'count' => [
                        'min' => 1,
                        'max' => 5,
                        'step' => 1,
                    ],
                ],
                'default' => [
                    'unit' => 'count',
                    'size' => 5,
                ],
                'condition' => [
                    'style' => ['1']
                ]
            ]
        );

        $this->add_control(
            'rating_text',
            [
                'label'         => esc_html__('Rating Text', 'daltech-core'),
                'type'             => \Elementor\Controls_Manager::TEXTAREA,
                'placeholder'     => esc_html__('Rating Text', 'daltech-core'),
                'default'         => esc_html__('Default Rating Text', 'daltech-core'),
                'condition' => [
                    'style' => ['1']
                ]
            ]
        );

        $this->add_control(
            'rating_url',
            [
                'label'         => __('Rating URL', 'daltech-core'),
                'type'             => \Elementor\Controls_Manager::URL,
                'placeholder'     => __('https://your-link.com', 'daltech-core'),
                'show_external' => true,
                'default'         => [
                    'url'             => '#',
                    'is_external'     => false,
                    'nofollow'         => false,
                ],
                'condition' => [
                    'style' => ['1']
                ]
            ]
        );

        $this->add_control(
            'team_social',
            [
                'label' => __('Team Social', 'insur-addon'),
                'type' => \Elementor\Controls_Manager::CODE,
                'label_block' => true,
                'default' => wp_kses('<a href="https://www.facebook.com"><i class="fab fa-facebook-f"></i></a>', 'daltech_kses_allowed_html')
            ]
        );

        $this->add_control(
            'image',
            [
                'label'     => esc_html__('Image', 'daltech-core'),
                'type'         => \Elementor\Controls_Manager::MEDIA,
                'default' => [
                    'url' => \Elementor\Utils::get_placeholder_image_src(),
                ],
                'condition' => [
                    'style' => ['1']
                ]
            ]
        );

        $this->add_control(
            'button_label',
            [
                'label'     => __('Button Label', 'daltech-core'),
                'type'         => \Elementor\Controls_Manager::TEXTAREA,
                'rows'         => 2,
                'default'      => __('Button Label', 'daltech-core'),
                'condition' => [
                    'style' => ['1']
                ]
            ]
        );

        $this->add_control(
            'url',
            [
                'label'         => __('URL', 'daltech-core'),
                'type'             => \Elementor\Controls_Manager::URL,
                'placeholder'     => __('https://your-link.com', 'daltech-core'),
                'show_external' => true,
                'default'         => [
                    'url'             => '#',
                    'is_external'     => false,
                    'nofollow'         => false,
                ],
                'condition' => [
                    'style' => ['1']
                ]
            ]
        );

        $this->end_controls_section();

        include DALTECH_PLUGIN_WIDGET_STYLE_PATH . 'team-details-style.php';
    }

    // Output For User
    protected function render()
    {
        $settings = $this->get_settings_for_display();
        if ($settings['style'] == '1') :
?>
            <!--<< Team Details Section Start >>-->
            <section class="team-details-section fix section-padding">
                <div class="container">
                    <div class="team-details-wrapper">
                        <div class="row justify-content-between align-items-center">
                            <div class="col-lg-6 wow fadeInUp" data-wow-delay=".3s">
                                <div class="team-image bg-cover" style="background-image: url(<?php echo esc_url($settings['image']['url']); ?>);">
                                </div>
                            </div>
                            <div class="col-lg-5 mt-5 mt-lg-0 wow fadeInUp" data-wow-delay=".5s">
                                <div class="team-details-content">
                                    <div class="star pb-3">
                                        <?php for ($i = 0; $i < $settings['rating']['size']; $i++) : ?>
                                            <a href=""><i class="fas fa-star"></i></a>
                                        <?php endfor; ?>

                                        <a href="<?php echo esc_url($settings['rating_url']['url']); ?>">
                                            <?php echo wp_kses($settings['rating_text'], 'daltech_allowed_tags'); ?>
                                        </a>
                                    </div>
                                    <h3><?php echo wp_kses($settings['name'], 'daltech_allowed_tags'); ?></h3>
                                    <span><?php echo wp_kses($settings['designation'], 'daltech_allowed_tags'); ?></span>
                                    <p>
                                        <?php echo wp_kses($settings['summary'], 'daltech_allowed_tags'); ?>
                                    </p>
                                    <div class="social-icon d-flex align-items-center">
                                        <?php echo wp_kses($settings['team_social'], 'daltech_allowed_tags'); ?>
                                    </div>

                                    <?php if (!empty($settings['button_label'])) : ?>
                                        <a href="<?php echo esc_url($settings['url']['url']); ?>" class="theme-btn mt-5">
                                            <span class="mb-0">
                                                <?php echo wp_kses($settings['button_label'], 'daltech_allowed_tags'); ?>
                                                <i class="fas fa-chevron-right"></i>
                                            </span>
                                        </a>
                                    <?php endif; ?>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </section>
            <!-- End  Team Details Style One -->


<?php
        endif;
    }
}
