<?php
namespace dexen\Widget;
  use Elementor\Utils;
  use SmartDataSoft\Owl\SliderSettings\sliderSettings;


class PricingList extends \Elementor\Widget_Base {

	public function get_name() {
		return 'dexen_pricing_list';
	}

	public function get_title() {
		return esc_html__( 'Dexen Pricing List', 'dexen-core' );
	}

	public function get_icon() {
		return 'fa fa-object-ungroup';
	}

	public function get_categories() {
		return [ 'dexencore' ];
	}

	protected function _register_controls() {

		
		$this->start_controls_section(
			'title_settings',
			[
				'label' => __( 'Header Settings', 'dexen-core' ),
			]
		);

		$this->add_control(
			'title',
			[
				'label'   => __( 'Titile', 'dexen-core' ),
				'type'    => \Elementor\Controls_Manager::TEXT,
				'default' => __( 'Title', 'dexen-core' ),

			]
		);
		$this->add_control(
			'tag_line',
			[
				'label'   => __( 'Tag Line', 'dexen-core' ),
				'type'    => \Elementor\Controls_Manager::TEXT,
				'default' => __( 'Tag Line', 'dexen-core' ),

			]
		);
		$this->add_control(
			'link_content',
			[
				'label'   => __( 'Link Content', 'dexen-core' ),
				'type'    => \Elementor\Controls_Manager::TEXTAREA,
				'default' => __( 'For more quantities and pricing visit our <a href="#">Shipping and Cost Calculator</a>', 'dexen-core' ),

			]
		);


		$this->end_controls_section();

		$this->start_controls_section(
			'pricing_settings',
			[
				'label' => __( 'Pricing Settings', 'dexen-core' ),
			]
		);

	

		$repeater = new \Elementor\Repeater();
	
		$repeater->add_control(
			'pricing_titile',
			[
				'label'   => __( 'Pricing Titile', 'dexen-core' ),
				'type'    => \Elementor\Controls_Manager::TEXT,
				'default' => __( 'Standerd Plan', 'dexen-core' ),

			]
		);

		$repeater->add_control(
			'price',
			[
				'label'   => __( 'Price', 'dexen-core' ),
				'type'    => \Elementor\Controls_Manager::TEXT,
				'default' => __( '$39', 'dexen-core' ),

			]
		);
		$repeater->add_control(
			'content',
			[
				'label'   => __( 'Content', 'dexen-core' ),
				'type'    => \Elementor\Controls_Manager::TEXTAREA,
				'default' => __( 'Rounded & Colored', 'dexen-core' ),

			]
		);

		$this->add_control(
			'items1',
			[
				'label'   => __( 'Repeater List', 'dexen-core' ),
				'type'    => \Elementor\Controls_Manager::REPEATER,
				'fields'  => $repeater->get_controls(),
				'default' => [
					[
						'list_title'   => __( 'Title #1', 'dexen-core' ),
						'list_content' => __( 'Item content. Click the edit button to change this text.', 'dexen-core' ),
					],
					[
						'list_title'   => __( 'Title #2', 'dexen-core' ),
						'list_content' => __( 'Item content. Click the edit button to change this text.', 'dexen-core' ),
					],
				],
				'title_field' => '{{pricing_titile}}',
			]
		);
		$this->end_controls_section();


	}

	protected function render() {
		$settings             = $this->get_settings_for_display();
	
		$title       = $settings['title'];
		$tag_line       = $settings['tag_line'];
		$link_content       = $settings['link_content'];
	
		$layout_class  = '';
		$premium_class = '';


		?> 
		<section class="price-two sec-pad">
		<div class="container">
			<div class="block-title text-center">
				<p class="block-title__tag-line"><?php echo wp_kses_post($tag_line); ?></p>
				<h2 class="block-title__title block-title__light-color"><?php echo wp_kses_post($title); ?></h2>
			</div>
			<!-- /.block-title -->
		</div>
		<!-- /.container -->

    <div class="container">
        <div class="row-5-col">
		<?php
								foreach ( $settings['items1'] as $item ) {
									$pricing_titile       = $item['pricing_titile'];

									$price                = $item['price'];

				?>
            <div class="col-5-col">
                <div class="price-two__single hvr-bounce-to-bottom content-margin-60">
				<?php if(!empty($item['button_text_link']['url'])) :?>
                                    <a 
                                                    href="<?php echo esc_url($item['button_text_link']['url']); ?>"
                                                    <?php
                                                        $target = $item['button_text_link']['is_external'] ? ' target=_blank' : '';
                                                        $nofollow = $item['button_text_link']['nofollow'] ? ' rel=nofollow' : '';
                                                        echo esc_attr($target . $nofollow);
                                                    ?>> <?php endif;?>
                    <span class="price-two__average"><?php echo $pricing_titile; ?></span>
                    <h3 class="price-two__price"><?php echo $price; ?></h3>
                    <!-- /.price-two__price -->
                    <p class="price-two__count"><?php echo wp_kses_post($item['content']); ?></p>
                    <!-- /.price-two__count -->
					<?php if(!empty($item['button_text_link']['url'])) :?>	</a> <?php endif;?>
                </div>
                <!-- /.price-two__single -->
            </div>
            <!-- /.col-5-col -->
			<?php } ?>  
        </div>
        <!-- /.row-5-col -->

        <p class="text-center price-two__link-text"><?php echo wp_kses_post($link_content); ?></p>
    </div>
    <!-- /.container -->
</section>

		<?php
	}

	protected function _content_template() {

	}
}

  \Elementor\Plugin::instance()->widgets_manager->register_widget_type( new PricingList() );

