<?php

use yii\helpers\Html;
use yii\widgets\ActiveForm;
use backend\models\{Attributesvalues, System};
/**
 * @var  yii\web\View $this
 * @var  backend\models\Accounts $model
 * @var  yii\widgets\ActiveForm $form
*/
?>
<?php  $exdata = $model->extended; ?>

<div class="accounts-form">

    <?php $form = ActiveForm::begin(['id' => 'account-form']); ?>
    <div class="card">

        <div class="card-header">
            Account Details
        </div>
        <div class="card-body">
            <div class="row">
                <div class="col-md-3">
                    <?= $form->field($model, 'accountcode')->textInput(['readonly' => 'true']) ?>
                    <?= $form->field($model, 'account_group')->textInput(['readonly' => 'true']) ?>
                </div>
                <div class="col-md-3">
                    <?= $form->field($model, 'intid')->textInput([]) ?>
                </div>
                <div class="col-md-3">
                    <?= $form->field($model, 'status')->dropdownlist(Attributesvalues::formArray('sys_status'), ['prompt' => 'Please Select']) ?>
                </div>
                <div class="col-md-3">
                    <?= $form->field($model, 'type')->dropdownlist(Attributesvalues::formArray('account_type'), ['prompt' => 'Please Select']) ?>
                </div>
            </div>
            <div class="row">
                <div class="col-md-6">
                    <?= $form->field($model, 'name')->textInput([]) ?>
                </div>
                <div class="col-md-3">
                    <?= $form->field($model, 'stop')->checkbox([]) ?>
                </div>
                <div class="col-md-3">
                    <?= $form->field($model, 'web_stop')->checkbox([]) ?>
                </div>
            </div>
            <div class="row">
                <div class="col-md-3">
                    <?= $form->field($model, 'price_number')->textInput(['type' => 'number', 'min' => 1, 'max' => 9]) ?>
                </div>
                <div class="col-md-3">
                    <?= $form->field($model, 'email')->textInput([]) ?>
                </div>
                <div class="col-md-3">
                    <?= $form->field($model, 'web_email')->textInput([]) ?>
                </div>
                <div class="col-md-3">
                    <?= $form->field($model, 'salesperson')->textInput([]) ?>
                </div>

            </div>
            <div class="row">
                <div class="col-md-3">
                    <?= $form->field($model, 'minfreedelivery')->textInput(['type' => 'number', 'min' => 0]) ?>
                </div>
                <div class="col-md-3">
                    <?= $form->field($model, 'account_group')->dropdownlist(AttributesValues::formarraytt('DF_Sales_Group')) ?>
                </div>
            </div>

        </div>
    </div>

    <div class="Card">
        <div class="card-header bg-info text-white">
            Addresses
        </div>
        <div class="card-body p-0">
            <?= $this->render('_addresses', ['model' => $model]); ?>
        </div>
    </div>
    
    <div class="card">
        <div class="card-header">
            Extended
        </div>
        <div class="card-body">
            <?php foreach ($exdata->attributes as $field => $value) { ?>
                    <?php
                    if (in_array('frontend', array_keys(System::getAliases()))) {
                        $fielddata = \frontend\models\Accounts_extended::fieldtypes($field);
                    } else {
                        $fielddata = \backend\models\Accounts_extended::fieldtypes($field);
                    }
                            $fieldinput = $fielddata['input'];
                            $fieldoptions = $fielddata['options'];
                            $label = $exdata->attributeLabels($field);
                    ?>

                    <?= $form->field($exdata, $field)->$fieldinput($fieldoptions)->label() ?>
                
            <?php } ?>
        </div>
    </div>

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