<?php

use yii\widgets\ActiveForm;
use yii\bootstrap4\Tabs;
use yii\helpers\Html;

/* @var $this yii\web\View */
/* @var $model backend\models\Products */
/* @var $form yii\widgets\ActiveForm */

?>
<?php if ($this->context->action->id == 'update') {
    $items[] = ['label' => 'Details', 'content' => $this->render('_details_tab', ['model' => $model, 'extended' => $extended,]), 'active' => true];
    $items[] = ['label' => 'Branches','content' => $this->render('formtabs/_branches_tab', ['source' => 'Accounts', 'model' => $model,'branchsearchModel' => $branchsearchModel, 'branchProvider' => $branchProvider,]), 'active' => false];
    ?>
<div class="row">
    <div class="sidebar col-200 col-12 pr-lg-0">
        <?=Tabs::widget([
        'navType' => 'nav nav-pills nav-stacked',
        'id' => 'sidebara',
        'class' => 'nav-stacked',
        'items' => $items,
        'renderTabContent' => false,
    ]);?>
        <ul class="nav nav-pills nav-stacked mt-1">
            <li class="nav-item">
                <?=Html::submitButton('Save', ['class' => 'nav-link btn-submit btn btn-primary save', 'id' => 'submit-button'])?>
            </li>
            
            <li class="nav-item">
                <?= Html::a('View', ['view', 'id' => $model->id, 'language' => $model->language], ['class' => 'btn btn-primary nav-link view']) ?>
            </li>
        </ul>
    </div>
        <div class="col main">
        
        <div class="tab-content">
            <?php foreach ($items as $key => $pane) {?>
            <div class="tab-pane <?=$key == 0 ? 'active' : ''?> " id="sidebara-tab<?=$key?>">
                <?=$pane['content']?>
            </div>
            <?php }?>
        </div>
    </div>
</div>
<?php } else {?>
    <div class="col-12">
        <?=$this->render('_details_tab', ['model' => $model]);?>
    </div>
<?php }?>


<script>
$('#submit-button').on('click', function() {
    $('#account-form').submit();
})

</script>

