<?php if (!defined('B_PROLOG_INCLUDED') || B_PROLOG_INCLUDED !== true) die();

use Bitrix\Main\Localization\Loc;
use intec\core\helpers\Html;
use intec\core\platform\main\Component;

/**
 * @var array $arResult
 * @var CBitrixComponentTemplate $this
 * @var IntecReviewsAddComponent $component
 */

$this->setFrameMode(true);
$templateId = Html::getUniqueId(null, Component::getUniqueId($this));
$visual = &$arResult['VISUAL'];

?>
<div class="intec-reviews-add standard" id="<?= $templateId ?>">
    <?php if ($arResult['ACCESS']) { ?>
        <?php if ($arResult['STATUS'] === $component::STATUS_ACCEPTED) {
            include 'parts/form.accepted.php';
        } elseif ($arResult['STATUS'] === $component::STATUS_CLOSED) {
            include 'parts/form.closed.php';
        } else { ?>
            <form enctype="multipart/form-data" method="post" action="<?= $APPLICATION->GetCurPageParam() ?>">
                <?= bitrix_sessid_post() ?>
                <?php include 'parts/form.fields.php'; ?>
                <?php $disableSubmit = false;

                    if ($arResult['CONSENT']['SHOW'] && !is_null($arResult['CONSENT']['ID']) && $arResult['CONSENT']['REQUIRED']) {
                        $disableSubmit = true;
                    }

                    if ($arResult['MAILING']['SHOW'] && !is_null($arResult['MAILING']['ID']) && $arResult['MAILING']['REQUIRED']) {
                        $disableSubmit = true;
                    }
                ?>
                <?= Html::submitButton(Loc::getMessage('IC_REVIEWS_ADD_STANDARD_TEMPLATE_SUBMIT'), [
                    'class' => [
                        'ui-button',
                        'ind-m-t-40'
                    ],
                    'data-role' => 'submit',
                    'disabled' => $disableSubmit ? 'disabled' : null,
                    'name' => 'review',
                    'value' => Loc::getMessage('IC_REVIEWS_ADD_STANDARD_TEMPLATE_SUBMIT')
                ]) ?>
            </form>
            <?php include('parts/script.php') ?>
        <?php } ?>
    <?php } else {
        include 'parts/access.denied.php';
    } ?>
</div>
