<?php

declare(strict_types=1);

use yii;
use yii\bootstrap\ActiveForm;

// Инициализация
$panel ?? $panel = 'profile_panel_supplies_input_import';

?>

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

<div id="page_profile" class="container mb-auto">
    <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"><i class="fas fa-truck my-auto mr-2"></i>Управление поставками</h4>
                <div id="profile_panel_supplies" class="profile_panel">
                    <div class="profile_panel_menu mb-3">
                        <label class="btn button_white mb-0 mr-2" for="profile_panel_supplies_input_settings">Настройки</label>
                        <label class="btn button_white mb-0 mr-2" for="profile_panel_supplies_input_import">Импорт</label>
                    </div>
                    <div class="profile_panel_content">

                        <input type="radio" id="profile_panel_supplies_input_settings" name="main_panel" <?= $panel === 'profile_panel_supplies_input_settings' ? 'checked' : null ?> />
                        <div class="col">
                            <p>В разработке</p>
                        </div>

                        <input type="radio" id="profile_panel_supplies_input_import" name="main_panel" <?= $panel === 'profile_panel_supplies_input_import' ? 'checked' : null ?> />
                        <div class="col">
                            <h5>Импорт из Excel-документа</h5>
                            <div class="dropdown-divider mb-3"></div>
                            <?php
                            $form = ActiveForm::begin([
                                'id' => 'form_product_import_excel',
                                'action' => false,
                                'fieldConfig' => [
                                    'template' => '{label}{input}',
                                    'options' => ['class' => '']
                                ],
                                'options' => [
                                    'class' => 'mb-3',
                                    'onsubmit' => 'return false;'
                                ]
                            ]);
                            ?>

                            <?= $form->field($model, 'file_excel', ['enableLabel' => false])->fileInput(['multiple' => true, 'class' => 'mb-2', 'onChange' => 'page_profile_supplies_import_excel(this.parentElement.parentElement, \'profile_panel_supplies_input_import\')']) ?>

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

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

<script src="/js/profile.js" defer></script>
<?php if (
    !yii::$app->user->isGuest
    && (yii::$app->user->identity->type === 'administrator'
        || yii::$app->user->identity->type === 'moderator')
) : ?>
    <script src="/js/profile_panel.js" defer></script>
<?php endif ?>