<?php

declare(strict_types=1);

use yii\helpers\Html;

use yii;
use yii\bootstrap\ActiveForm;

use app\assets\AppAsset;

use app\models\Request;

AppAsset::register($this);

?>

<?php $this->beginPage() ?>

<!DOCTYPE html>
<html lang="<?= yii::$app->language ?>">

<head>
    <meta charset="<?= yii::$app->charset ?>">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <link href="/css/pages/suppliers.css" rel="stylesheet">
    <link rel="apple-touch-icon" sizes="57x57" href="/favicons/apple-icon-57x57.png">
    <link rel="apple-touch-icon" sizes="60x60" href="/favicons/apple-icon-60x60.png">
    <link rel="apple-touch-icon" sizes="72x72" href="/favicons/apple-icon-72x72.png">
    <link rel="apple-touch-icon" sizes="76x76" href="/favicons/apple-icon-76x76.png">
    <link rel="apple-touch-icon" sizes="114x114" href="/favicons/apple-icon-114x114.png">
    <link rel="apple-touch-icon" sizes="120x120" href="/favicons/apple-icon-120x120.png">
    <link rel="apple-touch-icon" sizes="144x144" href="/favicons/apple-icon-144x144.png">
    <link rel="apple-touch-icon" sizes="152x152" href="/favicons/apple-icon-152x152.png">
    <link rel="apple-touch-icon" sizes="180x180" href="/favicons/apple-icon-180x180.png">
    <link rel="icon" type="image/png" sizes="192x192" href="/favicons/android-icon-192x192.png">
    <link rel="icon" type="image/png" sizes="32x32" href="/favicons/favicon-32x32.png">
    <link rel="icon" type="image/png" sizes="96x96" href="/favicons/favicon-96x96.png">
    <link rel="icon" type="image/png" sizes="16x16" href="/favicons/favicon-16x16.png">
    <link rel="manifest" href="/favicons/manifest.json">
    <meta name="msapplication-TileColor" content="#ffffff">
    <meta name="msapplication-TileImage" content="/favicons/ms-icon-144x144.png">
    <meta name="theme-color" content="#ffffff">

    <script type="text/javascript">
        var onloadCallback = function() {
            grecaptcha.render('form_suppliers_request_recaptcha', {
                'sitekey': '6LcTDSsbAAAAAF-KOY6azKzaIj6rOqyegJqNKRcc'
            });
        };
    </script>

    <?php $this->registerCsrfMetaTags() ?>

    <title><?= Html::encode($this->title ?? 'Поставщикам | SkillParts') ?></title>

    <?php $this->head() ?>
</head>

<body class="d-flex flex-column">
    <?php $this->beginBody() ?>

    <header class="container pt-2 mt-1 mb-2 mb-sm-4">
        <div class="row row h-100">
            <div id="logo" class="col-3 col-md-4 h-100">
                <a class="py-2 h-100 d-inline-flex" title="SkillParts" href="/">
                    <img class="img-fluid" src="/img/logos/skillparts.svg" alt="SkillParts">
                </a>
            </div>
        </div>
    </header>

    <main id="page_suppliers" class="container pb-5 flex-grow-1 d-flex justify-content-center">
        <article class="col my-auto p-3 px-5 rounded overflow-hidden">
            <h3 class="py-3 mt-2 mb-4 text-center"><b>Заявка на подключение</b></h3>
            <?php $form = ActiveForm::begin([
                'id' => 'form_suppliers_request',
                'action' => '/suppliers/request-send',
                'fieldConfig' => [
                    'template' => '{label}{input}',
                ],
                // 'options' => [
                //     'onsubmit' => 'return false;'
                // ]
            ]);

            // Инициализация
            $model_request ?? $model_request = new Request();
            ?>


            <div class="row mb-4">
                <div class="col-4 mx-auto">
                    <?= $form->field($model_request, 'name', ['options' => ['class' => "mb-3"]])->input('text', ['placeholder' => 'Иванов Иван Иванович']) ?>
                    <?= $form->field($model_request, 'phon', ['options' => ['class' => "mb-3"]])->input('tel', ['aria-invalid' => false, 'aria-required' => true, 'pattern' => '7[0-9]{3}[0-9]{3}[0-9]{2}[0-9]{2}', 'placeholder' => '79091112233', 'title' => '79091112233']); ?>
                    <?= $form->field($model_request, 'mail', ['options' => ['class' => "mb-3"]])->input('email', ['placeholder' => 'company@mail.ru']); ?>
                    <?= $form->field($model_request, 'file', ['options' => ['class' => "mb-3 d-flex flex-column justify-content-center"]])->fileInput(['multiple' => true, 'class' => 'my-auto px-0']) ?>
                    <div id="form_suppliers_request_recaptcha"></div>
                </div>
            </div>

            <div class="row">
                <?= Html::submitButton('Отправить', ['name' => 'submitRequest', 'id' => 'request-button-send', 'class' => 'col-auto mx-auto btn button_blue button_clean']) ?>
            </div>

            <?php ActiveForm::end(); ?>
        </article>
    </main>

    <?php $this->endBody() ?>
    <script src="https://www.google.com/recaptcha/api.js?onload=onloadCallback&render=explicit" async defer></script>

</body>

</html>

<?php $this->endPage() ?>
