<?php

namespace CarDealerPress\templates\admin\theme\inventory_display\detail;

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

use CarDealerPress\Includes\Helpers\Option;
use CarDealerPress\templates\partials\admin\Table_Rows;

function similar_vehicles(): string {
	$content = '<section id="similar vehicles">';
	$content .= '<div><h3>Similar Vehicles</h3></div>';
	$content .= '<div><p>Similar Vehicles based on SaleClass, VehicleClass, and Price Range.</p></div>';
	$content .= '<table id="similar-vehicle-table" class="">';
	$content .= '<tbody>';

	$checked = Option::check_for_option(
		'cdp_theme_options',
		array(
			'theme',
			'inventory_display',
			'detail',
			'similar_vehicles',
			'display_similar',
		)
	);

	$content .= table_rows::tr_setting_checkbox(
		array(
			'id'      => 'display_similar',
			'label'   => 'Display Similar Vehicles',
			'name'    => 'cdp_theme_options[theme][inventory_display][detail][similar_vehicles][display_similar]',
			'checked' => $checked,
		)
	);

	$value   = Option::check_for_option(
		'cdp_theme_options',
		array(
			'theme',
			'inventory_display',
			'detail',
			'similar_vehicles',
			'price_subtract',
		)
	);
	$content .= table_rows::tr_setting_text(
		array(
			'label'       => 'Price Below:',
			'id'          => 'price_below',
			'name'        => 'cdp_theme_options[theme][inventory_display][detail][similar_vehicles][price_subtract]',
			'placeholder' => '3000',
			'value'       => $value,
			'class'       => 'input-medium',
			'type'        => 'number',
		)
	);
	$value   = Option::check_for_option(
		'cdp_theme_options',
		array(
			'theme',
			'inventory_display',
			'detail',
			'similar_vehicles',
			'price_add',
		)
	);
	$content .= table_rows::tr_setting_text(
		array(
			'label'       => 'Price Above:',
			'id'          => 'price_above',
			'name'        => 'cdp_theme_options[theme][inventory_display][detail][similar_vehicles][price_add]',
			'placeholder' => '1000',
			'value'       => $value,
			'class'       => 'input-medium',
			'type'        => 'number',
		)
	);
	$value   = Option::check_for_option(
		'cdp_theme_options',
		array(
			'theme',
			'inventory_display',
			'detail',
			'similar_vehicles',
			'link_text',
		)
	);
	$content .= table_rows::tr_setting_text(
		array(
			'label'       => 'Link Text:',
			'id'          => 'link_text',
			'name'        => 'cdp_theme_options[theme][inventory_display][detail][similar_vehicles][link_text]',
			'placeholder' => 'More Information',
			'value'       => $value,
			'class'       => 'input-long',
		)
	);
	$checked = Option::check_for_option(
		'cdp_theme_options',
		array(
			'theme',
			'inventory_display',
			'detail',
			'similar_vehicles',
			'display_price',
		)
	);

	$content .= table_rows::tr_setting_checkbox(
		array(
			'id'      => 'display_similar',
			'label'   => 'Display Similar Price',
			'name'    => 'cdp_theme_options[theme][inventory_display][detail][similar_vehicles][display_price]',
			'checked' => $checked,
		)
	);
	$content .= '</tbody>';
	$content .= '</table>';
	$content .= '</section>';

	return $content;
}
