<?php

declare(strict_types=1);

use yii;
use yii\bootstrap\ActiveForm;

use app\controllers\ProfileController;
use app\models\Supply;

?>
<link href="/css/pages/profile.css" rel="stylesheet">

<div id="page_profile" class="container h-100">
    <div class="row h-100 py-3">
        <nav class="col-3">
            <?= $sidebar ?? yii::$app->controller->renderPartial('/profile/sidebar') ?>
        </nav>
        <article class="col-9">
            <div class="h-100 p-4 rounded">
                <h4 class="ml-4 mb-4">Управление поставками</h4>
                <?php
                $form = ActiveForm::begin([
                    'id' => 'form_product_import_excel',
                    'action' => false,
                    'fieldConfig' => [
                        'template' => '{label}{input}',
                        'options' => ['class' => '']
                    ],
                    'options' => [
                        'class' => 'mb-3',
                        'onsubmit' => 'return false;'
                    ]
                ]);

                $model = $model ?? new Supply;
                $groups = ProfileController::readGroups();

                ?>

                <?= $form->field($model, 'group', ['options' => ['class' => "mb-3"]])->dropDownList($groups ?? ['Нет данных']); ?>
                <?= $form->field($model, 'file', ['enableLabel' => false])->fileInput(['multiple' => true, 'onChange' => 'supply_import(this.parentElement.parentElement)']) ?>

                <?= $form->errorSummary($model, ['header' => 'В документе были допущены ошибки:' /*, 'footer' => 'Исправьте их и попробуйте снова'*/]); ?>

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

<script src="/js/profile.js" defer></script>