<?php
/**
 * Review List Widget - Content Controls
 *
 * @package GGM_Commerce
 */

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

// $this is the GGM_Commerce_Widget_Review_List instance.

$this->start_controls_section(
	'content_section',
	array(
		'label' => __( 'Content', 'ggm-commerce' ),
		'tab'   => \Elementor\Controls_Manager::TAB_CONTENT,
	)
);

$this->add_control(
	'product_source',
	array(
		'label'   => __( 'Product Source', 'ggm-commerce' ),
		'type'    => \Elementor\Controls_Manager::SELECT,
		'default' => 'current',
		'options' => array(
			'current' => __( 'Current Product (Auto-detect)', 'ggm-commerce' ),
			'custom'  => __( 'Select Product', 'ggm-commerce' ),
		),
	)
);

$this->add_control(
	'product_id',
	array(
		'label'       => __( 'Product', 'ggm-commerce' ),
		'type'        => \Elementor\Controls_Manager::NUMBER,
		'default'     => '',
		'condition'   => array(
			'product_source' => 'custom',
		),
		'description' => __( 'Start typing product name to search', 'ggm-commerce' ),
	)
);

$this->add_control(
	'reviews_per_page',
	array(
		'label'   => __( 'Reviews per Page', 'ggm-commerce' ),
		'type'    => \Elementor\Controls_Manager::NUMBER,
		'default' => 5,
		'min'     => 1,
		'max'     => 50,
	)
);

$this->add_control(
	'orderby',
	array(
		'label'   => __( 'Order By', 'ggm-commerce' ),
		'type'    => \Elementor\Controls_Manager::SELECT,
		'default' => 'created_at',
		'options' => array(
			'created_at'    => __( 'Date', 'ggm-commerce' ),
			'rating'        => __( 'Rating', 'ggm-commerce' ),
			'helpful_votes' => __( 'Most Helpful', 'ggm-commerce' ),
		),
	)
);

$this->add_control(
	'order',
	array(
		'label'   => __( 'Order', 'ggm-commerce' ),
		'type'    => \Elementor\Controls_Manager::SELECT,
		'default' => 'DESC',
		'options' => array(
			'DESC' => __( 'Descending', 'ggm-commerce' ),
			'ASC'  => __( 'Ascending', 'ggm-commerce' ),
		),
	)
);

$this->add_control(
	'show_title',
	array(
		'label'        => __( 'Show Section Title', 'ggm-commerce' ),
		'type'         => \Elementor\Controls_Manager::SWITCHER,
		'label_on'     => __( 'Yes', 'ggm-commerce' ),
		'label_off'    => __( 'No', 'ggm-commerce' ),
		'return_value' => 'yes',
		'default'      => 'yes',
	)
);

$this->add_control(
	'section_title',
	array(
		'label'     => __( 'Section Title', 'ggm-commerce' ),
		'type'      => \Elementor\Controls_Manager::TEXT,
		'default'   => 'Customer Reviews',
		'condition' => array(
			'show_title' => 'yes',
		),
	)
);

$this->add_control(
	'show_summary',
	array(
		'label'        => __( 'Show Rating Summary', 'ggm-commerce' ),
		'type'         => \Elementor\Controls_Manager::SWITCHER,
		'label_on'     => __( 'Yes', 'ggm-commerce' ),
		'label_off'    => __( 'No', 'ggm-commerce' ),
		'return_value' => 'yes',
		'default'      => 'yes',
		'description'  => __( 'Show average rating and distribution bars', 'ggm-commerce' ),
	)
);

$this->add_control(
	'show_review_title',
	array(
		'label'        => __( 'Show Review Title', 'ggm-commerce' ),
		'type'         => \Elementor\Controls_Manager::SWITCHER,
		'label_on'     => __( 'Yes', 'ggm-commerce' ),
		'label_off'    => __( 'No', 'ggm-commerce' ),
		'return_value' => 'yes',
		'default'      => 'yes',
	)
);

$this->add_control(
	'show_reviewer_name',
	array(
		'label'        => __( 'Show Reviewer Name', 'ggm-commerce' ),
		'type'         => \Elementor\Controls_Manager::SWITCHER,
		'label_on'     => __( 'Yes', 'ggm-commerce' ),
		'label_off'    => __( 'No', 'ggm-commerce' ),
		'return_value' => 'yes',
		'default'      => 'yes',
	)
);

$this->add_control(
	'show_date',
	array(
		'label'        => __( 'Show Review Date', 'ggm-commerce' ),
		'type'         => \Elementor\Controls_Manager::SWITCHER,
		'label_on'     => __( 'Yes', 'ggm-commerce' ),
		'label_off'    => __( 'No', 'ggm-commerce' ),
		'return_value' => 'yes',
		'default'      => 'yes',
	)
);

$this->add_control(
	'show_verified_badge',
	array(
		'label'        => __( 'Show Verified Badge', 'ggm-commerce' ),
		'type'         => \Elementor\Controls_Manager::SWITCHER,
		'label_on'     => __( 'Yes', 'ggm-commerce' ),
		'label_off'    => __( 'No', 'ggm-commerce' ),
		'return_value' => 'yes',
		'default'      => 'yes',
	)
);

$this->add_control(
	'show_helpful',
	array(
		'label'        => __( 'Show Helpful Button', 'ggm-commerce' ),
		'type'         => \Elementor\Controls_Manager::SWITCHER,
		'label_on'     => __( 'Yes', 'ggm-commerce' ),
		'label_off'    => __( 'No', 'ggm-commerce' ),
		'return_value' => 'yes',
		'default'      => 'yes',
	)
);

$this->add_control(
	'show_pagination',
	array(
		'label'        => __( 'Show Pagination', 'ggm-commerce' ),
		'type'         => \Elementor\Controls_Manager::SWITCHER,
		'label_on'     => __( 'Yes', 'ggm-commerce' ),
		'label_off'    => __( 'No', 'ggm-commerce' ),
		'return_value' => 'yes',
		'default'      => 'yes',
	)
);

$this->add_control(
	'no_reviews_text',
	array(
		'label'   => __( 'No Reviews Text', 'ggm-commerce' ),
		'type'    => \Elementor\Controls_Manager::TEXTAREA,
		'default' => 'No reviews yet. Be the first to review this product!',
	)
);

$this->end_controls_section();
