<?if(!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED!==true)die();
/** @var array $arParams */
/** @var array $arResult */
/** @global CMain $APPLICATION */
/** @global CUser $USER */
/** @global CDatabase $DB */
/** @var CBitrixComponentTemplate $this */
/** @var string $templateName */
/** @var string $templateFile */
/** @var string $templateFolder */
/** @var string $componentPath */
/** @var CBitrixComponent $component */
$this->setFrameMode(true);

$description = [];

if(!empty($arParams['PROPERTIES']['YEAR']['VALUE'])) { array_push($description, $arParams['PROPERTIES']['YEAR']['VALUE']." г.в."); }
if($arParams['PROPERTIES']['MILEAGE']['VALUE'] > 0) { array_push($description, "пробег ".$arParams['PROPERTIES']['MILEAGE']['VALUE']." км"); }
if($arParams['PROPERTIES']['ENGINE_HOURS']['VALUE'] > 0) { array_push($description, $arParams['PROPERTIES']['ENGINE_HOURS']['VALUE']." м.ч."); }
if(!empty($arParams['PROPERTIES']['PARKING_CITY']['VALUE'])) { array_push($description, $arParams['PROPERTIES']['PARKING_CITY']['VALUE']); }

?>
<div class="catalog_item">
	<a href="/izt/<?= $arParams['CODE']; ?>/" class="item_link" area-label="<?= $arParams['PROPERTIES']['BRAND']['RELATED']['NAME']; ?> <?= $arParams['PROPERTIES']['MODEL']['RELATED']['NAME']; ?>"></a>

		<img class="used_item_img <?= $arParams['ACTIVE'] === "N" ? "car_used_sold" : ""; ?>" src="<?= !empty($arParams['PREVIEW_PICTURE']) ? $arParams['PREVIEW_PICTURE'] : "/images/no_image_500x300.png"; ?>" alt="<?= $arParams['PROPERTIES']['BRAND']['RELATED']['NAME']; ?> <?= $arParams['PROPERTIES']['MODEL']['RELATED']['NAME']; ?> <?= $arParams['PROPERTIES']['BODY']['VALUE']; ?>" />
		<? if(!isset($_GET['advertise']) && $arParams['PROPERTIES']['ADVERTISING_ERIR']['VALUE']): ?>
			<div class="advblock adv_button_news" style="padding: 6px; padding-top: 0px; padding-bottom: 0px;">Реклама
				<div class="adv_content">ООО "ЛК Эволюция"</div>
				<div class="adv_content">ИНН 9724016636</div>
				<div class="adv_content">erid: <?= $arParams['PROPERTIES']['ADVERTISING_ERIR']['VALUE']; ?></div>
			</div>
		<? endif; ?>
	
	<p class="item_class used_item_number">Артикул: <?= $arParams['PROPERTIES']['CONTRACT']['VALUE']; ?></p>
		<div class="used_item_tags <?= $arParams['ACTIVE'] === "N" ? "car_used_sold" : ""; ?>">
			<? if($arParams['PROPERTIES']['PRICE_WITH_DISCOUNT']['VALUE'] > 0): ?>
				<div class="used_item_tag used_item_discount">Скидка</div>
			<? endif; ?>
			<? if($arParams['PROPERTIES']['SPECIAL_OFFER']['VALUE_XML_ID'] === "YES"): ?>
				<div class="used_item_tag used_item_special_offer">Спецпредложение</div>
			<? endif; ?>
			<? if(!empty($arParams['PROPERTIES']['RESERVE_DATE']['VALUE'])): ?>
				<? if(strtotime($arParams['PROPERTIES']['RESERVE_DATE']['VALUE']) > time()): ?>
					<div class="used_item_tag used_item_reserve">Резерв до <?= date("d.m.Y", strtotime($arParams['PROPERTIES']['RESERVE_DATE']['VALUE'])); ?></div>
				<? endif; ?>
			<? endif; ?>
			<? if($arParams['PROPERTIES']['LEASING_AVAILABLE']['VALUE_XML_ID'] === "YES"): ?>
				<div class="used_item_tag used_item_leasing">Доступно в лизинг</div>
			<? endif; ?>
			<? if($arParams['PROPERTIES']['AFTER_ACCIDENT']['VALUE_XML_ID'] === "YES"): ?>
				<div class="used_item_tag used_item_accident">После ДТП</div>
			<? endif; ?>
		</div>
	<p class="item_class <?= $arParams['ACTIVE'] === "N" ? "car_used_sold" : ""; ?>"><?= $arParams['PROPERTIES']['BRAND']['RELATED']['NAME']; ?> <?= $arParams['PROPERTIES']['MODEL']['RELATED']['NAME']; ?> <?= $arParams['PROPERTIES']['BODY']['VALUE']; ?></p>
	<p class="item_model <?= $arParams['ACTIVE'] === "N" ? "car_used_sold" : ""; ?>">
		<b><?= $arParams['PROPERTIES']['MODIFICATION']['VALUE']; ?></b>
		<?= implode(", ", $description); ?>
	</p>
	<? if($arParams['ACTIVE'] === "N"): ?>
		<br/>
		<p class="item_model" style="font-weight: 600; color: #B7391A;">Автомобиль продан</p>
	<? else: ?>
	<ul>
		<? if($arParams['PROPERTIES']['LEASING_AVAILABLE']['VALUE_XML_ID'] === 'YES'): ?>
			<li class="pay">
				<p>Ежемесячный платёж (от)</p>
				<p><?= $arParams['CALCULATION']['MONTHLY']; ?> р.</p>
			</li>
		<? endif; ?>
		<li>
			<p>Стоимость автомобиля</p>
			<? if($arParams['PROPERTIES']['PRICE_WITH_DISCOUNT']['VALUE'] > 0): ?>
				<p style="text-decoration: line-through;"><?= number_format($arParams['PROPERTIES']['PRICE']['VALUE'], 0, ".", " "); ?> р.</p>
			<? else: ?>
				<p><?= number_format($arParams['PROPERTIES']['PRICE']['VALUE'], 0, ".", " "); ?> р.</p>
			<? endif; ?>
		</li>
		<? if($arParams['PROPERTIES']['PRICE_WITH_DISCOUNT']['VALUE'] > 0): ?>
			<li>
				<p>Стоимость со скидкой</p>
				<p><?= number_format($arParams['PROPERTIES']['PRICE_WITH_DISCOUNT']['VALUE'], 0, ".", " "); ?> р.</p>
			</li>
		<? endif; ?>
	</ul>
	<? endif; ?>
	<div class="item_footer">
		<? if($arParams['ACTIVE'] === "Y"): ?>
			<span class="button button-blue">Подробнее</span>
		<? endif; ?>
	</div>
	<p></p>
</div>