<?php

namespace CarDealerPress\Templates\Admin\Theme;

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

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

function color_mapping() {
	$options = Option::get_cdp_theme_options()['theme']['inventory_display']['list']['search_filters']['color_mapping'];
	$content = '<table>';
	$content .= '<tbody>';
	$content .= '<tr><h4>Exterior Color Mapping</h4></tr>';

	$value   = ( $options['default_text'] ?? 'Unknown' );
	$content .= table_rows::tr_setting_text(
		array(
			'label' => 'Default Color Text:',
			'id'    => 'color_mapping-default_text',
			'name'  => 'cdp_theme_options[theme][search_filters][color_mapping][default_text]',
			'value' => $value,
			'class' => 'input-long',
		)
	);

	foreach ( $options['exterior'] as $key => $values ) {
		$content .= table_rows::tr_setting_text(
			array(
				'label' => ucfirst( $key ),
				'id'    => 'theme[color_mapping][exterior][' . $key . ']',
				'name'  => 'cdp_theme_options[theme][inventory_display][list][search_filters][color_mapping][exterior][' . $key . ']',
				'value' => $values,
				'class' => 'input-long',
			)
		);
	}
	$content .= '</tbody></table>';

	return $content;
}
