<?php

namespace CarDealerPress\Includes\Functions;

use CarDealerPress\Includes\Database\Requests;
use CarDealerPress\Includes\Helpers\Option;
use CarDealerPress\Includes\Helpers\Remote_Requests;
use CarDealerPress\templates\partials\inventory\Vehicle_Attributes;


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

	private $fn_inventory;
	private $theme_options;
	private $admin_options;

	function __construct() {
		$this->fn_inventory = new Fn_Inventory();
		$this->set_option_variables();
	}

	private function set_option_variables() {
		$this->theme_options = Option::get_cdp_theme_options();
		$this->admin_options = Option::get_cdp_admin_options();
	}

	public function get_sc_detail_vehicles( $vehicle, $company, $options, $inv_options, $form_id ) {
		$vin                        = ( isset( $vehicle['vin'] ) ? array( 'vin' => $vehicle['vin'] ) : '' );
		$db_vehicle                 = ( $vin ? ( new Requests() )->cdp_db_init( 'inventory', $vin )[0] : array() );
		$fuel_economy               = array(
			'city'    => $db_vehicle['city'],
			'highway' => $db_vehicle['highway'],
		);
		$db_vehicle['fuel_economy'] = $fuel_economy;

		// get photos, standard_equipment, dealer_options from api and merge into db vehicle.
		$api_vehicle                       = Remote_Requests::api_vehicle_vdp_call( $db_vehicle['dealer_id'], $vin['vin'] );
		$vehicle                           = array_merge( $db_vehicle, $api_vehicle );

		$sc_content  = '';
		$fuel        = array();
		$sc_content .= '<div id="' . $vehicle['vin'] . '" class="sc-detail-item">';

		$sc_content .= '<div class="sc-detail-top-container"">';
		$sc_content .= '<div class="sc-detail-top-one">';
		$sc_content .= '<div class="sc-detail-title-wrapper">';
		$sc_content .= '<span class="sc-detail-saleclass form-value" data-name="saleclass"><small>' . $vehicle['saleclass'] . '</small></span>';
		$sc_content .= '<span class="sc-detail-year form-value" data-name="year">' . $vehicle['year'] . '</span>';
		$sc_content .= '<span class="sc-detail-make form-value" data-name="make">' . $vehicle['make'] . '</span>';
		$sc_content .= '<span class="sc-detail-model form-value" data-name="model">' . $vehicle['model'] . '</span>';
		$sc_content .= '</div>';
		$sc_content .= '</div>';
		$sc_content .= '<div class="sc-detail-top-two">';
		$sc_content .= '<div class="sc-img-wrapper">';
		$list_image  = $this->fn_inventory->no_photo_replace( $vehicle['thumbnail'] );
		$alt         = $vehicle['year'] . ' ' . $vehicle['make'] . ' ' . $vehicle['model'];
		// phpcs:ignore PluginCheck.CodeAnalysis.ImageFunctions.NonEnqueuedImage
		$sc_content .= '<img class="sc-detail-image" src="' . $list_image . '" alt="' . $alt . '"/>';
		$sc_content .= '</div>';
		$sc_content .= '</div>';
		$sc_content .= '<div class="sc-detail-top-three">';
		$price       = $this->fn_inventory->get_price_display(
			array(
				'company' => $company,
				'vehicle' => $vehicle,
				'theme'   => 'sc-detail',
			)
		);
		$sc_content .= '<div class="sc-detail-price-wrapper">';
		$sc_content .= $price['compare_price_text'] . $price['primary_text'] . $price['expire_text'] . $price['hidden_prices'];
		$sc_content .= '</div>';
		$sc_content .= '<div class="sc-detail-top-info">';
		$sc_content .= '<div class="top-info-value">Stock #: <span class="sc-detail-stock-number form-value" data-name="stock_number">' . $vehicle['stock'] . '</span></div>';
		$sc_content .= '<div class="top-info-value">Vin: <span class="sc-detail-vin form-value" data-name="vin">' . $vehicle['vin'] . '</span></div>';
		$sc_content .= '</div>';
		$sc_content .= '<div class="sc-detail-buttons">';
		$sc_content .= '<div class="sc-detail-button sc-action-button show-details" data-name="vehicle_info" data-key="' . $vehicle['vin'] . '">Show Details</div>';
		$make_offer_button = '';
		if ( function_exists( 'gravity_form_enqueue_scripts' ) ) {
			if ( $form_id ) {
				$sc_content .= "<div class='sc-detail-button sc-action-form' data-form-id='$form_id' data-name='vehicle_form' data-key='$vehicle[vin]'>Request Info</div>";
				$make_offer_button = "<div class='bottom-button vehicle_form-button'>";
				// phpcs:ignore PluginCheck.CodeAnalysis.ImageFunctions.NonEnqueuedImage
				$make_offer_button .= "<img class='sc-action-form inner-button' data-form-id='$form_id' data-name='vehicle_form' data-key='$vehicle[vin]' src='" . CDP_IMG . "templates/inventory/email_icon.png' alt='make-offer'/>";
				$make_offer_button .= "<small class='sc-detail-label label-offer''>Make Offer</small></div>";
			}
		}
		$sc_content .= '</div>';
		$sc_content .= '</div>';
		$sc_content .= '<div class="sc-detail-top-four">';
		$sc_content .= $this->fn_inventory->get_dealer_contact_info(
			array(
				'vehicle' => $vehicle,
				'company' => $company,
			)
		);
		$sc_content .= '</div>';
		$sc_content .= '</div>';

		$sc_content .= '<div class="sc-detail-bottom-container">';

		$sc_content .= '<div class="sc-detail-bottom-one">';
		$sc_content .= '<div class="sc-detail-bottom-buttons">';
		$sc_content .= '<div class="bottom-button vehicle_info-button"><img class="sc-action-button inner-button" data-name="vehicle_info" data-key="' . $vehicle['vin'] . '" src="' . CDP_IMG . 'templates/inventory/info_icon.png" alt="information"/><small class="sc-detail-label label-information">Information</small></div>';
		$sc_content .= '<div class="bottom-button vehicle_details-button"><img class="sc-action-ajax" data-name="vehicle_details" data-key="' . $vehicle['vin'] . '" data-tag="info" src="' . CDP_IMG . 'templates/inventory/detail_info_icon.png" alt="comments"/><small class="sc-detail-label label-details">Comments</small></div>';
		$sc_content .= '<div class="bottom-button vehicle_images-button"><img class="sc-action-ajax" data-name="vehicle_images" data-key="' . $vehicle['vin'] . '" data-tag="images" src="' . CDP_IMG . 'templates/inventory/image_icon.png" alt="images"/><small class="sc-detail-label lable-pictures">Pictures</small></div>';
		$sc_content .= $make_offer_button;
		$sc_content .= '</div>';
		$sc_content .= '</div>';

		$sc_content .= '<div class="sc-detail-bottom-two">';
		$sc_content .= '<div class="sc-detail-bottom-content">';

		$sc_content .= '<div class="bottom-content vehicle_info-content">';
		$sc_content .= '<div class="vehicle_info-data">';
		$sc_content .= '<div class="data-row"><span class="column-title">Year:</span><span class="column-value">' . $vehicle['year'] . '</span></div>';
		$sc_content .= '<div class="data-row"><span class="column-title">Make:</span><span class="column-value">' . $vehicle['make'] . '</span></div>';
		$sc_content .= '<div class="data-row"><span class="column-title">Model:</span><span class="column-value">' . $vehicle['model'] . '</span></div>';
		$sc_content .= $vehicle['trim'] ? '<div class="data-row"><span class="column-title">Trim:</span><span class="column-value sc-detail-trim form-value" data-name="trim">' . $vehicle['trim'] . '</span></div>' : '';
		$sc_content .= $vehicle['odometer'] ? '<div class="data-row"><span class="column-title">Odometer:</span><span class="column-value sc-detail-odometer form-value" data-name="odometer">' . $vehicle['odometer'] . '</span></div>' : '';
		$sc_content .= $vehicle['exterior'] ? '<div class="data-row"><span class="column-title">Exterior:</span><span class="column-value sc-detail-exterior form-value" data-name="exterior">' . $vehicle['exterior'] . '</span></div>' : '';
		$sc_content .= $vehicle['interior'] ? '<div class="data-row"><span class="column-title">Interior:</span><span class="column-value sc-detail-interior form-value" data-name="interior">' . $vehicle['interior'] . '</span></div>' : '';
		$sc_content .= $vehicle['body'] ? '<div class="data-row"><span class="column-title">Body:</span><span class="column-value sc-detail-body form-value" data-name="body">' . $vehicle['body'] . '</span></div>' : '';
		$sc_content .= $vehicle['engine'] ? '<div class="data-row"><span class="column-title">Engine:</span><span class="column-value sc-detail-engine form-value" data-name="engine">' . $vehicle['engine'] . '</span></div>' : '';
		$sc_content .= $vehicle['fuel_type'] ? '<div class="data-row"><span class="column-title">Fuel Type:</span><span class="column-value sc-detail-fuel-type form-value" data-name="fuel-type">' . $vehicle['fuel_type'] . '</span></div>' : '';
		$sc_content .= $vehicle['transmission'] ? '<div class="data-row"><span class="column-title">Trans:</span><span class="column-value sc-detail-transmission form-value" data-name="transmission">' . $vehicle['transmission'] . '</span></div>' : '';
		$sc_content .= $vehicle['drivetrain'] ? '<div class="data-row"><span class="column-title">Drive Train:</span><span class="column-value sc-detail-drive-train form-value" data-name="drivetrain">' . $vehicle['drivetrain'] . '</span></div>' : '';
		$sc_content .= $vehicle['doors'] ? '<div class="data-row"><span class="column-title">Doors:</span><span class="column-value sc-detail-doors form-value" data-name="doors">' . $vehicle['doors'] . '</span></div>' : '';

		if ( isset( $vehicle['fuel_economy'] ) ) {
			$fuel = $this->fn_inventory->get_fuel_economy_display( $vehicle['fuel_economy'], $company['country_code'], 0, true );
		}
		if ( $fuel && ( ! empty( $fuel['city'] ) || ! empty( $fuel['hwy'] ) ) ) {
			$sc_content .= '<div class="data-row"><span class="column-title">City:</span><span class="column-value form-value sc-detail-fuel-city" data-name="fuel_city">' . $fuel['city'] . '</span></div>';
			$sc_content .= '<div class="data-row"><span class="column-title">Highway:</span><span class="column-value form-value sc-detail-fuel-highway" data-name="fuel_highway">' . $fuel['hwy'] . '</span></div>';
		}
		$sc_content .= '</div>';
		$sc_content .= '</div>';

		$sc_content .= '<div class="bottom-content vehicle_details-content">';
		// populated with Ajax Call.
		$sc_content .= '</div>';

		$sc_content .= '<div class="bottom-content vehicle_images-content">';
		// populated with Ajax Call.
		$sc_content .= '</div>';

		$sc_content .= '<div class="bottom-content vehicle_form-content">';
		// populated with Ajax Call.
		$sc_content .= '</div>';

		$sc_content .= '</div>';
		$sc_content .= '</div>';

		$sc_content .= '</div>';

		$sc_content .= '</div>';

		return $sc_content;
	}

	public function get_sc_detail_razor_vehicles( $vehicle, $company, $options, $inv_options, $form ) {
		$sc_content = '';
		$fuel       = array();

		$price       = $this->fn_inventory->get_price_display(
			array(
				'company' => $company,
				'vehicle' => $vehicle,
				'theme'   => 'sc-detail',
			)
		);
		# for mileageFromOdometer
		$unitCode = 'SMI'; # miles
		if ('CA' === $company['country_code']){
			$unitCode = 'KMT'; # kilometers
		}
		$sc_content .= '<div id="' . $vehicle['vin'] . '" class="sc-detail-item" itemscope itemtype="http://schema.org/Vehicle">';

		$sc_content .= '<div class="sc-detail-top-container">';
		$sc_content .= '<div class="sc-detail-top-one">';
		$sc_content .= '<div class="sc-img-wrapper">';
		$list_image  = ( new Fn_Inventory() )->no_photo_replace( $vehicle['image_medium'] );
		$alt         = $vehicle['year'] . ' ' . $vehicle['make'] . ' ' . $vehicle['model'];
		// phpcs:ignore PluginCheck.CodeAnalysis.ImageFunctions.NonEnqueuedImage
		$sc_content .= '<img itemprop="image" class="sc-detail-image" src="' . $list_image . '" alt="' . $alt . '"/>';
		$sc_content .= '</div>';
		$sc_content .= '<div class="sc-detail-buttons">';
		$sc_content .= '<div class="sc-detail-button sc-action-button show-details" data-name="vehicle_info" data-key="' . $vehicle['vin'] . '">Show Details</div>';
		if ( function_exists( 'gravity_form' ) ) {
			if ( $form ) {
				$sc_content .= '<div class="sc-detail-button dialog-me" data-key="cdp-form-display" data-vin="' . $vehicle['vin'] . '" data-form="' . $form . '" >Request Info</div>';
			}
		}
		$sc_content .= '</div>';
		$sc_content .= '<div class="sc-detail-price-wrapper" itemprop="offers" itemscope="" itemtype="https://schema.org/Offer">';
				$sc_content .= '<div itemprop="availability" content="InStock" style="display:none;"></div>';
		$sc_content .= $price['primary_text'];
		$sc_content .= '</div>';
		$sc_content .= '</div>';
		$sc_content .= '<div class="sc-detail-top-two">';
		$sc_content .= '<div class="sc-detail-saleclass form-value" data-name="saleclass">' . $vehicle['saleclass'] . '</div>';
		$sc_content .= '<div class="sc-detail-title-wrapper" itemprop="name">';
		$sc_content .= '<span class="sc-detail-year form-value" data-name="year" itemprop="modelDate">' . $vehicle['year'] . '</span>';
		$sc_content .= '<span class="sc-detail-make form-value" data-name="make" itemprop="brand">' . $vehicle['make'] . '</span>';
		$sc_content .= '<span class="sc-detail-model form-value" data-name="model" itemprop="model">' . $vehicle['model'] . '</span>';
		$sc_content .= '</div>';
		$sc_content .= '<div class="sc-detail-top-info">';
		$sc_content .= '<div class="top-info-value stock"><span class="label">Stock #: </span><span class="sc-detail-stock-number form-value" data-name="stock_number" itemprop="sku">' . $vehicle['stock'] . '</span></div>';
		$sc_content .= '<div class="top-info-value vin"><span class="label">Vin: </span><span class="sc-detail-vin form-value" data-name="vin" itemprop="vehicleIdentificationNumber">' . $vehicle['vin'] . '</span></div>';
		$sc_content .= '</div>';
		$sc_content .= $this->fn_inventory->get_dealer_contact_info(
			array(
				'vehicle' => $vehicle,
				'company' => $company,
			)
		);
		$sc_content .= '</div>';
		$sc_content .= '</div>';

		$sc_content .= '<div class="sc-detail-bottom-container">';
		$sc_content .= '<div class="sc-detail-bottom-one">';
		$sc_content .= '<div class="sc-detail-bottom-buttons">';
		$sc_content .= '<div class="bottom-button vehicle_info-button"><span class="sc-action-button inner-button" data-name="vehicle_info" data-key="' . $vehicle['vin'] . '">Overview</span></div>';
		$sc_content .= '<div class="bottom-button vehicle_details-button"><span class="sc-action-ajax" data-name="vehicle_details" data-key="' . $vehicle['vin'] . '" data-tag="info" >Information</span></div>';
		$sc_content .= '<div class="bottom-button vehicle_images-button"><span class="sc-action-ajax" data-name="vehicle_images" data-key="' . $vehicle['vin'] . '" data-tag="images" >Photos</span></div>';
		if ( function_exists( 'gravity_form' ) ) {
			$sc_content .= $form ? '<div class="bottom-button vehicle_form-button"><span class="dialog-me" data-key="cdp-form-display" data-vin="' . $vehicle['vin'] . '" data-form="' . $form . '">Make Offer</span></div>' : '';
		}
		$sc_content .= '</div>';
		$sc_content .= '</div>';

		$sc_content .= '<div class="sc-detail-bottom-two">';
		$sc_content .= '<div class="sc-detail-bottom-content">';
		$sc_content .= '<div class="bottom-content vehicle_info-content">';
		$sc_content .= '<div class="vehicle_info-data">';
		$sc_content .= '<div class="data-row"><span class="column-title">Year:</span><span class="column-value">' . $vehicle['year'] . '</span></div>';
		$sc_content .= '<div class="data-row"><span class="column-title">Make:</span><span class="column-value" itemprop="manufacturer">' . $vehicle['make'] . '</span></div>';
		$sc_content .= '<div class="data-row"><span class="column-title">Model:</span><span class="column-value">' . $vehicle['model'] . '</span></div>';
		$sc_content .= $vehicle['trim'] ? '<div class="data-row"><span class="column-title">Trim:</span><span class="column-value sc-detail-trim form-value" data-name="trim">' . $vehicle['trim'] . '</span></div>' : '';
		$sc_content .= $vehicle['odometer'] ? '<div class="data-row"><span class="column-title">Odometer:</span><span class="column-value sc-detail-odometer form-value" data-name="odometer" itemprop="mileageFromOdometer">' . $vehicle['odometer'] . '</span></div>' : '';
		$sc_content .= $vehicle['odometer'] ? '<div class="data-row" style="display:none;"><span itemprop="unitCode">' . $unitCode . '</span></div>' : '';
		$sc_content .= $vehicle['exterior'] ? '<div class="data-row"><span class="column-title">Exterior:</span><span class="column-value sc-detail-exterior form-value" data-name="exterior" itemprop="color">' . $vehicle['exterior'] . '</span></div>' : '';
		$sc_content .= $vehicle['interior'] ? '<div class="data-row"><span class="column-title">Interior:</span><span class="column-value sc-detail-interior form-value" data-name="interior" itemprop="vehicleInteriorColor">' . $vehicle['interior'] . '</span></div>' : '';
		$sc_content .= $vehicle['body'] ? '<div class="data-row"><span class="column-title">Body:</span><span class="column-value sc-detail-body form-value" data-name="body" itemprop="bodyType">' . $vehicle['body'] . '</span></div>' : '';
		$sc_content .= $vehicle['engine'] ? '<div class="data-row"><span class="column-title">Engine:</span><span class="column-value sc-detail-engine form-value" data-name="engine" itemprop="vehicleEngine">' . $vehicle['engine'] . '</span></div>' : '';
		$sc_content .= $vehicle['fuel_type'] ? '<div class="data-row"><span class="column-title">Fuel Type:</span><span class="column-value sc-detail-fuel-type form-value" data-name="fuel-type" itemprop="fuelType">' . $vehicle['fuel_type'] . '</span></div>' : '';
		$sc_content .= $vehicle['transmission'] ? '<div class="data-row"><span class="column-title">Trans:</span><span class="column-value sc-detail-transmission form-value" data-name="transmission" itemprop="vehicleTransmission">' . $vehicle['transmission'] . '</span></div>' : '';
		$sc_content .= $vehicle['drivetrain'] ? '<div class="data-row"><span class="column-title">Drive Train:</span><span class="column-value sc-detail-drive-train form-value" data-name="drivetrain" itemprop="driveWheelConfiguration">' . $vehicle['drivetrain'] . '</span></div>' : '';
		$sc_content .= $vehicle['doors'] ? '<div class="data-row"><span class="column-title">Doors:</span><span class="column-value sc-detail-doors form-value" data-name="doors" itemprop="numberOfDoors">' . $vehicle['doors'] . '</span></div>' : '';
		if ( isset( $vehicle['fuel_economy'] ) ) {
			$fuel = ( new Fn_Inventory() )->get_fuel_economy_display( $vehicle['fuel_economy'], $company['country_code'], 0, true );
		}
		if ( $fuel && ( ! empty( $fuel['city'] ) || ! empty( $fuel['hwy'] ) ) ) {
			$sc_content .= '<div class="data-row"><span class="column-title">City:</span><span class="column-value form-value sc-detail-fuel-city" data-name="fuel_city">' . $fuel['city'] . '</span></div>';
			$sc_content .= '<div class="data-row"><span class="column-title">Highway:</span><span class="column-value form-value sc-detail-fuel-highway" data-name="fuel_highway">' . $fuel['hwy'] . '</span></div>';
		}
		$sc_content .= '</div>';
		$sc_content .= '</div>';
		$sc_content .= '<div class="bottom-content vehicle_details-content">';
		// populated with Ajax Call.
		$sc_content .= '</div>';

		$sc_content .= '<div class="bottom-content vehicle_images-content">';
		// populated with Ajax Call.
		$sc_content .= '</div>';
		$sc_content .= '</div>';
		$sc_content .= '</div>';
		$sc_content .= '</div>';

		$sc_content .= '</div>';

		return $sc_content;
	}
	public function get_sc_detail_razor_2_vehicles( $vehicle, $company, $options, $inv_options, $form ){
		$link_params = array( 'year' => $vehicle['year'], 'make' => $vehicle['make'],  'model' => $vehicle['model'],
		                      'state' => $company['state'], 'city' => $company['city'], 'vin' => $vehicle['vin'] );
		$link = $this->fn_inventory->generate_inventory_link(array('params' => $link_params, 'type' => 1));
		$sc_content = ''; $fuel = array();
		$price       = $this->fn_inventory->get_price_display(
			array(
				'company' => $company,
				'vehicle' => $vehicle,
				'theme'   => 'sc-detail',
			)
		);
		//wrapper
		$sc_content .= '<div id="'.$vehicle['vin'].'" class="sc-detail-item" itemscope itemtype="http://schema.org/Vehicle">';
		$sc_content .= '<div itemprop="modelDate" content="'.$vehicle['year'].'"></div>';
		$sc_content .= '<div itemprop="brand" content="'.$vehicle['make'].'"></div>';
		$sc_content .= '<div itemprop="mpn" content="'.$vehicle['vin'].'"></div>';
		$sc_content .= '<div itemprop="manufacturer" content="'.$vehicle['make'].'"></div>';
		$sc_content .= '<div itemprop="model" content="'.$vehicle['model'].'"></div>';
		$sc_content .= '<div itemprop="sku" content="'.$vehicle['stock'].'"></div>';
		$sc_content .= '<div itemprop="name" content="'.$vehicle['year'].' '.$vehicle['make'].' '.$vehicle['model'].'"></div>';

		$sc_content .= '<div class="sc-detail-top-container">';
		$sc_content .= '<div class="sc-detail-top-one">';
		$sc_content .= '<div class="sc-img-wrapper">';
		$list_image  = ( new Fn_Inventory() )->no_photo_replace( $vehicle['image_medium'] );
		// phpcs:ignore PluginCheck.CodeAnalysis.ImageFunctions.NonEnqueuedImage
		$sc_content .= '<img itemprop="image" id="vehicle-image" class="sc-detail-image" src="'.$list_image.'" alt="'.$vehicle['year'].' '.$vehicle['make'].' '.$vehicle['model'].'" title="'.$vehicle['year'].' '.$vehicle['make'].' '.$vehicle['model'].'" />';
		$sc_content .= '</div>';
		$sc_content .= '<div class="sc-detail-buttons">';
		$sc_content .= '<div class="sc-detail-button sc-action-button show-details" name="vehicle_info" data-key="'.$vehicle['vin'].'">';
		$sc_content .= '<span class="sc-action-ajax" data-name="vehicle_details" data-key="'.$vehicle['vin'].'" data-tag="info">Show Details</span></div>';
		$sc_content .= '</div>';
		$sc_content .= '<div class="sc-detail-price-wrapper" itemprop="offers" itemscope="" itemtype="https://schema.org/Offer">';
		$sc_content .= '<div itemprop="url" content="'.$link.'"></div>';
		$sc_content .= '<div itemprop="availability" content="InStock"></div>';
		$yearEnd = '12/31/'.gmdate('Y');
		$sc_content .= '<div itemprop="priceValidUntil" content="'.$yearEnd.'"></div>';
		$sc_content .= '<div itemprop="itemCondition" content="UsedCondition"></div>';
		$sc_content .= '<span>'.$price['primary_text'].'</span>';
		$sc_content .= '</div>';
		$sc_content .= '</div>';
		$sc_content .= '<div class="sc-detail-top-two">';
		$sc_content .= '<div class="sc-detail-title-wrapper">';
		$sc_content .= '<a class="link-to-detail" href="'.$link.'"><span id="vehicle-year" class="sc-detail-year form-value" name="year">'.$vehicle['year'].'</span>';
		$sc_content .= '<span id="vehicle-make" class="sc-detail-make form-value" name="make">'.$vehicle['make'].'</span>';
		$sc_content .= '<span id="vehicle-model" class="sc-detail-model form-value" name="model">'.$vehicle['model'].'</span></a>';
		$sc_content .= '</div>';
		$sc_content .= '<div class="sc-detail-top-info" itemprop="description">';
		$sc_content .= '<div class="top-info-value">Stock #: <span id="vehicle-stock" class="sc-detail-stock-number form-value" name="stock_number">'.$vehicle['stock'].'</span></div>';
		$sc_content .= '<div class="more">';
		$sc_content .= $vehicle['body'] ? '<div class="data-row"><span class="column-title">Body:</span><span itemprop="bodyType" class="column-value sc-detail-body form-value" name="body">'.$vehicle['body'].'</span></div>': '';
		$sc_content .= $vehicle['trim'] ? '<div class="data-row"><span class="column-title">Trim:</span><span class="column-value sc-detail-trim form-value" name="trim">'.$vehicle['trim'].'</span></div>': '';
		$sc_content .= $vehicle['exterior'] ? '<div class="data-row"><span class="column-title">Exterior:</span><span class="column-value sc-detail-exterior form-value" name="exterior" itemprop="color">'.$vehicle['exterior'].'</span></div>': '';
		$sc_content .= $vehicle['engine'] ? '<div class="data-row"><span class="column-title">Engine:</span><span class="column-value sc-detail-engine form-value" name="engine" itemprop="vehicleEngine">'.$vehicle['engine'].'</span></div>': '';
		$sc_content .= $vehicle['transmission'] ? '<div class="data-row"><span class="column-title">Trans:</span><span class="column-value sc-detail-transmission form-value" name="transmission" itemprop="vehicleTransmission">'.$vehicle['transmission'].'</span></div>': '';
		$sc_content .= '</div>';
		$sc_content .= '</div>';
		$sc_content .= '</div>';
		$sc_content .= '</div>';

		$sc_content .= '<div class="sc-detail-bottom-container">';
		$sc_content .= '<div class="sc-detail-bottom-one">';
		$sc_content .= '<div class="sc-detail-bottom-buttons">';
		$sc_content .= '<div class="bottom-button vehicle_details-button sc-action-ajax" data-name="vehicle_details" data-key="'.$vehicle['vin'].'" data-tag="info"><span style="pointer-events:none;">Vehicle Details</span></div>';
		$sc_content .= '<div class="bottom-button vehicle_images-button sc-action-ajax" data-name="vehicle_images" data-key="'.$vehicle['vin'].'" data-tag="images"><span style="pointer-events:none;">Photos</span></div>';
		if ( function_exists( 'gravity_form' ) ) {
			$sc_content .= $form ? '<div class="bottom-button vehicle_form-button"><span class="dialog-me" data-key="cdp-form-display" data-vin="' . $vehicle['vin'] . '" data-form="' . $form . '">Inquire Now</span></div>' : '';
		}
		$sc_content .= '</div>';

		$sc_content .= '</div>';

		$sc_content .= '<div class="sc-detail-bottom-two">';
		$sc_content .= '<div class="sc-detail-bottom-content">';
		$sc_content .= '<div class="bottom-content vehicle_info-content">';
		$sc_content .= '<div class="vehicle_info-data" itemprop="description">';
		$sc_content .= '</div>';
		$sc_content .= '</div>';
		$sc_content .= '<div class="bottom-content vehicle_details-content">';
		//populated with Ajax Call
		$sc_content .= '</div>';

		$sc_content .= '<div class="bottom-content vehicle_images-content">';
		//populated with Ajax Call
		$sc_content .= '</div>';
		$sc_content .= '</div>';
		$sc_content .= '</div>';
		$sc_content .= '</div>';

		$sc_content .= '</div>';
		return $sc_content;
	}

	public function get_sc_slider_view( $vehicle, $class, $company, $options, $url_rule, $params ) {
		$use_vehicle_url = $params['use_vehicle_url'] ?? false;
		$image_size = $params['image_size'] ?? 'small';
		$show_attributes = $params['show_attributes'] ?? '';
		$content = '';
		$target  = '';
		$link_params = array(
			'year'  => $vehicle['year'],
			'make'  => $vehicle['make'],
			'model' => $vehicle['model'],
			'state' => $company['state'],
			'city'  => $company['city'],
			'vin'   => $vehicle['vin'],
			'vms_id'    => $vehicle['vms_id'],
		);
		$link        = $this->fn_inventory->generate_inventory_link( array('params' => $link_params, 'type' => 1) );
		if ( ! empty( $vehicle['vehicle_url'] ) && $use_vehicle_url ) {
			$link   = $vehicle['vehicle_url'];
			$target = 'target="_blank"';
		}

		$content    .= '<li class="splide__slide sc-slides">';
		$content    .= '<div class="splide__slide__container">';
		$content .= '<div class="sc-slider-item-inner">';
		$content    .= '<a class="' . $class . '-item" href="' . $link . '" ' . $target . '>';

		$content    .= '<div class="' . $class . '-title-wrapper">';
		$content    .= '<span class="' . $class . '-year">' . $vehicle['year'] . '</span>';
		$content    .= '<span class="' . $class . '-make">' . $vehicle['make'] . '</span>';
		$content    .= '<span class="' . $class . '-model">' . $vehicle['model'] . '</span>';
		$content    .= '</div>';
		$image_column_size = 'thumbnail';
		if ('medium' === $image_size) {
			$image_column_size = 'image_medium';
		}
		$list_image = $this->fn_inventory->no_photo_replace( $vehicle[$image_column_size] );
		$alt        = $vehicle['year'] . ' ' . $vehicle['make'] . ' ' . $vehicle['model'];
		$content    .= '<div class="' . $class . '-img-wrapper">';
		// phpcs:ignore PluginCheck.CodeAnalysis.ImageFunctions.NonEnqueuedImage
		$content    .= '<img src="' . $list_image . '" alt="' . $alt . '"/>';
		$content    .= '</div>';
		$price      = $this->fn_inventory->get_price_display(
			array(
				'company' => $company,
				'vehicle' => $vehicle,
				'theme'   => 'short-code',
			)
		);
		$content    .= '<div class="' . $class . '-price-wrapper">';
		if ( $price['primary_price'] > 0 ) {
			$content .= '<div class="' . $class . '-price-value"><span class="sc-price-symbol">$</span>' . number_format( $price['primary_price'], 0, '.', ',' ) . '</div>';
		} else {
			$content .= '<div class="' . $class . '-price-value-text">' . $price['primary_text'] . '</div>';
		}
		$content .= '</div>';
		if ($show_attributes){
			$content .= '<div class="sc-attributes-wrapper">';
			$content .= '<div class="vehicle-information-attributes">';
			$content .= Vehicle_Attributes::call(
				array(
					'vehicle' => $vehicle,
					'layout'  => 'list',
					'page'    => 'inventory_slider',
					'option'  => 'cdp_shortcode_options',
				)
			);
			$content .= '</div>';
			$content .= '</div>';
		}
		$content .= '</a>';
		if ( $params['button'] ) {
			$content .= '<div class="sc-buttons-wrapper">';
			$content .= '<div class="vdp-button"><a href="' . $link . '">' . $params['button'] . '</a></div>';
			$content .= '</div>';
		}


		$content .= '</div>'; //sc-slider-item-inner
		$content    .= '</div>';
		$content    .= '</li>';

		return $content;
	}

	public static function get_sc_detail_images_display( $vehicle ) {
		$content = '';
		if ( $vehicle['video'] ) {
			$content .= '<div class="sc-detail-video" onclick=\'window.open("' . $vehicle['video'] . '","popup","width=640,height=500,scrollbars=no,resizable=yes,toolbar=no,directories=no,location=no,menubar=yes,status=no,left=50,top=125"); return false\'>Play Video ';
			// phpcs:ignore PluginCheck.CodeAnalysis.ImageFunctions.NonEnqueuedImage
			$content .= '<img class="sc-detail-video-img" src="' . CDP_IMG . 'templates/inventory/has_video.png" />';
			$content .= '</div>';
		}
		$content .= '<div class="sc-detail-photo-container">';
		$photos   = $vehicle['photos_raw'];
		foreach ( $photos as $photo ) {
			$image    = ( new Fn_Inventory() )->no_photo_replace( $photo->large );
			$alt      = $vehicle['year'] . ' ' . $vehicle['make'] . ' ' . $vehicle['model'];
			// phpcs:ignore PluginCheck.CodeAnalysis.ImageFunctions.NonEnqueuedImage
			$content .= '<a class="sc-lightbox" data-lightbox="vehicle-lightbox" rel="' . $vehicle['vin'] . '-slides" href="' . str_replace( '&', '&amp;', $image ) . '"><img src="' . str_replace( '&', '&amp;', $image ) . '" alt="' . $alt . '"/></a>';
		}
		$content .= '</div>';

		return $content;
	}

	public static function get_sc_detail_vehicle_info_display( $vehicle, $flags ) {
		$options     = '';
		$option_list = '';
		$tab_content = '';
		$tab_buttons = '';
		$content     = '';

		if ( $vehicle['dealer_options'] ) {
			sort( $vehicle['dealer_options'] );
			foreach ( $vehicle['dealer_options'] as $option ) {
				$option_list .= '<li>' . $option . '</li>';
			}
			$options .= '<div class="sc-detail-option-list"><ul>' . $option_list . '</ul></div>';
		}
		$equipment = $flags['show_eq'] ? ( new Fn_Inventory() )->display_equipment( $vehicle['standard_equipment'] ) : '';

		$tabs         = array(
			'Description'           => $vehicle['description'],
			'Equipment'     => $options,
			'Standard Equipment' => $equipment,
		);
		$active_class = 'active';
		$tab_buttons  = '';
		foreach ( $tabs as $tab => $data ) {
			if ( $data ) {
				$tab_id       = 'tab_' . strtolower( str_replace( ' ', '_', $tab ) );
				$tab_buttons .= '<div class="tab-button sc-action-button inner-tab-button ' . $tab_id . '-button ' . $active_class . '" data-name="' . $tab_id . '" data-key="' . $vehicle['vin'] . '">' . $tab . '</div>';
				$tab_content .= '<div class="tab-content ' . $tab_id . '-content ' . $active_class . '">' . $data . '</div>';
				$active_class = '';
			}
		}
		$content .= '<div class="bottom-tab-buttons-wrapper">' . $tab_buttons . '</div>';
		$content .= '<div class="bottom-tab-content-wrapper">' . $tab_content . '</div>';

		return $content;
	}

}
