<?php
/**
 * View: Global BBB module settings form.
 *
 * @var k7zz\humhub\bbb\models\forms\SettingsForm $model  The settings form model
 */

use humhub\modules\ui\form\widgets\ActiveForm;
use humhub\modules\ui\icon\widgets\Icon;
use yii\helpers\Url;
$url = Url::to('/bbb/sessions');
?>

<div class="card">
    <div class="card-header d-flex align-items-center">
        <span class="me-auto"><?= Yii::t('BbbModule.config', '<strong>Bigbluebutton</strong> Integration') ?></span>
        <a href="<?= $url ?>" class="btn btn-sm btn-outline-primary">
            <?= Icon::get('video-camera') ?> <?= Yii::t('BbbModule.config', 'Go to sessions') ?>
        </a>
    </div>

    <div class="card-body">
        <div class="clearfix">
            <h4><?= Yii::t('BbbModule.config', 'Settings') ?></h4>
            <div class="help-block">
                <?= Yii::t('BbbModule.config', 'On this page you can configure general settings of your Bigbluebutton integration.') ?>
            </div>
        </div>

        <hr>

        <?php $form = ActiveForm::begin() ?>
        <div class="card-body">
            <h3><?= Yii::t('BbbModule.config', 'API Settings') ?></h3>
            <div class="help-block">
                <?= Yii::t('BbbModule.config', 'To guarantee correct functionality, please use BigBlueButton >= 3.0.19 and make sure that the webhooks feature of your BigBlueButton Server is enabled.') ?>
            </div>

            <?= $form->field($model, 'bbbUrl')
                ->textInput(options: ['placeholder' => 'https://bbb.example.org/bigbluebutton/']); ?>

            <?= $form->field($model, 'bbbSecret')
                ->passwordInput(['autocomplete' => 'new-password']); ?>


            <h3><?= Yii::t('BbbModule.config', 'Chat Integration') ?></h3>
                <?= Yii::t('BbbModule.config', 'Will not work without functioning webhooks feature of your BigBlueButton Server.') ?>
            <?= $form->field($model, 'integrateBbbChat')
                ->checkbox()
                ->hint(Yii::t('BbbModule.config', 'Enables a persistent session chat on session pages. Messages can be written before, during and after meetings and are synchronised with BBB chat in real time.')) ?>

            <h3><?= Yii::t('BbbModule.config', 'Navigation') ?></h3>
            <?= $form->field($model, 'addNavItem')
                ->checkbox(); ?>

            <div id="bbb-nav-admin-hint" class="alert alert-info"
                style="display: <?= $model->addNavItem ? 'none' : '' ?>;">
                <?= Yii::t('BbbModule.config', 'When the navigation entry is disabled, administrators will still find a <strong>Sessions</strong> link in the administration menu.') ?>
            </div>

            <?= $form->field($model, 'navItemLabel')
                ->textInput() ?>
        </div>

        <button class="btn btn-primary" data-ui-loader><?= Yii::t('base', 'Save') ?></button>

        <?php ActiveForm::end() ?>

        <script>
            document.getElementById('settingsform-addnavitem').addEventListener('change', function () {
                document.getElementById('bbb-nav-admin-hint').style.display = this.checked ? 'none' : '';
            });
        </script>
    </div>



</div>