<?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);
?>
<script>
	$(function()
	{
		calculator(<?= CUtil::PhpToJSObject(array_merge($arParams, $arResult['CALCULATION'])); ?>);
	});
</script>
<section id="calc">
<input type="hidden" id="FORM_FIELD_PRICE" value=""/>
<input type="hidden" id="FORM_FIELD_PREPAID" value=""/>
<input type="hidden" id="FORM_FIELD_TERM" value=""/>
<input type="hidden" id="FORM_FIELD_REDEMPTION" value=""/>
	<div class="container wide">
		<h2 class="section_title">Калькулятор расчета лизинга</h2>
		<div class="calc_body">
			<div class="calc_settings">
				<div class="settings_box">
					<p>Стоимость авто</p>
					<?/*<output hidden></output>*/?>
					<p id="calculator_car_price_text"><output></output> ₽</p>
					<div class="price_custom" id="calculator_car_price_editor" style="display:none;">
						<input id="calculator_car_price_input" type="number" value="<?= $arParams['car_price']; ?>" min="<?= $arParams['CAR_PRICE_MIN']; ?>" max="<?= $arParams['CAR_PRICE_MAX']; ?>" />
						<button id="calculator_car_price_save">Сохранить</button>
					</div>
					<div class="line">
						<input id="calculation_car_price" data-slider-name="car_price" type="range" min="<?= $arParams['CAR_PRICE_MIN']; ?>" max="<?= $arParams['CAR_PRICE_MAX']; ?>" step="100000" data-rangeslider value="<?= $arParams['car_price']; ?>" />
					</div>
					<p class="min"><?= $arParams['CAR_PRICE_MIN'] / 1000000; ?> млн</p>
					<p class="max"><?= $arParams['CAR_PRICE_MAX'] / 1000000; ?> млн</p>
				</div>
				<div class="settings_box">
					<p>Первоначальный взнос</p>
					<p><output></output> %</p>
					<div class="line">
						<input data-slider-name="initial_payment" type="range" min="<?= $arParams['INITIAL_PAYMENT_MIN'];?>" max="<?= $arParams['INITIAL_PAYMENT_MAX']; ?>" data-rangeslider value="<?= $arParams['initial_payment']; ?>" />
					</div>
					<p class="min"><?= $arParams['INITIAL_PAYMENT_MIN']; ?>%</p>
					<p class="max"><?= $arParams['INITIAL_PAYMENT_MAX']; ?>%</p>
				</div>
				<div class="settings_box">
					<p>Срок договора</p>
					<p><output></output> мес.</p>
					<div class="line">
						<input data-slider-name="lease_period" type="range" min="<?= $arParams['LEASE_PERIOD_MIN']; ?>" max="<?= $arParams['LEASE_PERIOD_MAX']; ?>" data-rangeslider value="<?= $arParams['lease_period']; ?>" />
					</div>
					<p class="min"><?= $arParams['LEASE_PERIOD_MIN']; ?> мес.</p>
					<p class="max"><?= $arParams['LEASE_PERIOD_MAX']; ?> мес.</p>
				</div>
				<div class="settings_box">
					<p>Выкупной платеж</p>
					<p><output></output> %</p>
					<div class="line">
						<input data-slider-name="redemption_payment" type="range" min="<?= $arParams['REDEMPTION_PAYMENT_MIN']; ?>" max="<?= $arParams['REDEMPTION_PAYMENT_MAX']; ?>" data-rangeslider value="<?= $arParams['redemption_payment']; ?>" />
					</div>
					<p class="min"><?= $arParams['REDEMPTION_PAYMENT_MIN']; ?>%</p>
					<p class="max"><?= $arParams['REDEMPTION_PAYMENT_MAX']; ?>%</p>
				</div>
			</div>
			<div class="calc_result">
				<div class="result_box">
					<p>Налоговая экономия (до)*</p>
					<p class="price primary"><span id="calculator_tax_savings_value"><?= number_format($arResult['CALCULATION']['tax_savings'] + $arResult['CALCULATION']['vat_reimbursement'], 0, '.', ' '); ?></span>₽ <sup><span id="calculator_tax_savings_percent"><?= round($arResult['CALCULATION']['tax_savings'] / ($arParams['car_price'] / 100)) ?></span>%</sup></p>
				</div>
				<div class="result_box">
					<p>Ежемесячный платеж (от)*</p>
					<p class="price"><span id="calculator_monthly_payment_value"><?= number_format($arResult['CALCULATION']['monthly_payment'], 0, '.', ' '); ?></span>₽</p>
				</div>
				<a href="#order" class="button button-blue">Отправить заявку</a>
				<p class="secondary not_active">** Все расчеты приведены в рублях с учетом НДС. Данный расчет не является
					окончательным
					и носит справочный характер. Итоговый расчет предоставляется лизингополучателю после выяснений всех
					аспектов сделки.
				</p>
			</div>
		</div>
	</div>
</section>