<?php

namespace CarDealerPress\Templates\Admin\Theme;

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

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

function list_and_detail() {
	$content = '<section id="list-and-detail">';
	$content .= '<div><h3>Display options that have effect on both the List and Detail page</h3></div>';
	$content .= '<table id="list-and-detail-table" class="">';
	$content .= '<tbody>';

	if ( Display::theme_check() ) {
		$checked = Option::check_for_option(
			'cdp_theme_options',
			array(
				'theme',
				'inventory_display',
				'general',
				'saved_vehicles',
				'display',
			)
		);
		$content .= table_rows::tr_setting_checkbox(
			array(
				'id'      => 'saved_vehicles_display',
				'label'   => 'Allow Save Vehicles',
				'name'    => 'cdp_theme_options[theme][inventory_display][general][saved_vehicles][display]',
				'checked' => $checked,
			)
		);

		$value   = Option::check_for_option(
			'cdp_theme_options',
			array(
				'theme',
				'inventory_display',
				'general',
				'saved_vehicles',
				'form',
			)
		);
		$content .= table_rows::tr_setting_text(
			array(
				'label' => 'Saved Vehicle Form',
				'id'    => 'theme[inventory_display][saved_vehicles][form]',
				'name'  => 'cdp_theme_options[theme][inventory_display][general][saved_vehicles][form]',
				'value' => $value,
				'type'  => 'number',
				'min'   => 1,
			)
		);
	}
	$content .= '</tbody>';
	$content .= '</table>';
	$content .= '</section>';
	if ( Display::theme_check() ) {
		$content .= Inventory_Display\extra_boxes( array( 'location' => 'both' ) );
	}
	$content .= injector_style( array( 'location' => 'both' ) );

	return $content;
}
