<?php

use yii\widgets\ActiveForm;
use yii\helpers\Html;
use yii\helpers\Url;
use home\modules\customer\models\Customer;
use common\components\Tool;
use yii\helpers\ArrayHelper;
use common\widgets\Tagit;
use home\assets\ModalAsset;
use common\assets\ArtDialogAsset;

$attrLabels = $model->attributeLabels();
$assetUrl = $this->getAssetManager()->getBundle(ModalAsset::className())->baseUrl;
$this->registerJsFile($assetUrl . '/js/district.link.js', ['depends' => [ModalAsset::className(), ArtDialogAsset::className()]]);
?>

<?php
$form = ActiveForm::begin([
        'id' => 'main-form',
        'options' => ['class' => 'informationform f14'],
        'action' => $action,
        'fieldConfig' => [
            'options' => ['tag' => 'td'],
            'template' => "{input}{hint}{error}",
            'errorOptions' => ["class" => "error"]
        ]
    ]);
?>

<table cellpadding="0" cellspacing="10" width="100%">
    <tbody>
        <tr>
            <td align="right"><?= $model->getAttributeLabel('name') ?>：</td>
                <?= $form->field($model, 'name')->textInput(['class' => 'form-control']) ?>
            <td><span class="redstar">*</span></td>

            <td align="right"><?= $model->getAttributeLabel('simple_name') ?>：</td>
                <?= $form->field($model, 'simple_name')->textInput(['class' => 'form-control']) ?>
            <td><span class="redstar">*</span></td>
        </tr>
        <tr>
            <td align="right"><?= $model->getAttributeLabel('category_id') ?>：</td>
            <td>
                <select class="form-control" name="Customer[category_id]" id="category-parent-id">
                    <?php echo home\modules\customer\models\Category::getDropDownTree($model->category_id, 0 , 'true', 'cat_id'); ?>
                </select>
                <div class="error"></div>
            </td>

            <td><span class="redstar"></span></td>
            <td align="right"><?= $model->getAttributeLabel('level_id') ?>：</td>
                <?= $form->field($model, 'level_id')->dropDownList(Customer::getLevelList(), ['class' => 'form-control']) ?>
            <td><span class="redstar"></span></td>
        </tr>
        <tr>
            <td align="right"><?= $model->getAttributeLabel('customer_no') ?>：</td>
                <?= $form->field($model, 'customer_no')->textInput(['class' => 'form-control', 'readonly' => ($model->isNewRecord) ? false : true]) ?>
            <td><span class="redstar">*</span></td>

            <td align="right"><?= $model->getAttributeLabel('organization_no') ?>：</td>
                <?= $form->field($model, 'organization_no')->textInput(['class' => 'form-control']) ?>
            <td><span class="redstar"></span></td>
        </tr>
        <tr>
            <td align="right"><?= $model->getAttributeLabel('leader_name') ?>：</td>
                <?= $form->field($model, 'leader_name')->textInput(['class' => 'form-control select-single-user', 'placeholder' => '请选择负责人', 'data-hidden-id' => 'leader-id', 'data-url' => Url::to(['/link/single-user']), 'data-title' => '选择负责人']) ?>
                <?= $form->field($model, 'leader_id', ['options' => ['tag' => 'div']])->hiddenInput(['id' => 'leader-id']) ?>
            <td><span class="redstar">*</span></td>

            <td align="right"><?= $model->getAttributeLabel('share_user_names') ?>：</td>
                <?= $form->field($model, 'share_user_names')->textInput(['class' => 'form-control select-multi-user', 'placeholder' => '请选择共享人', 'data-hidden-id' => 'joins-ids', 'data-url' => Url::to(['/link/multi-user']), 'data-title' => '选择共享人']) ?>
                <?= $form->field($model, 'share_user_ids', ['options' => ['tag' => 'div']])->hiddenInput(['id' => 'joins-ids']) ?>
            <td><span class="c6"><span class="redstar"></span></span></td>
        </tr>
        <tr>
            <td align="right"><?= $model->getAttributeLabel('department1') ?>：</td>
                <?= $form->field($model, 'department1')->textInput(['class' => 'form-control']) ?>
            <td><span class="redstar"></span></td>

            <td align="right"><?= $model->getAttributeLabel('dept_phone1') ?>：</td>
                <?= $form->field($model, 'dept_phone1')->textInput(['class' => 'form-control']) ?>
            <td><span class="redstar"></span></td>
        </tr>
        <tr>
            <td align="right"><?= $model->getAttributeLabel('department2') ?>：</td>
                <?= $form->field($model, 'department2')->textInput(['class' => 'form-control']) ?>
            <td><span class="redstar"></span></td>

            <td align="right"><?= $model->getAttributeLabel('dept_phone2') ?>：</td>
                <?= $form->field($model, 'dept_phone2')->textInput(['class' => 'form-control']) ?>
            <td><span class="redstar"></span></td>
        </tr>
        <tr>
            <td align="right" ><?= $model->getAttributeLabel('google_coordinate') ?>：</td>
                <?= $form->field($model, 'google_coordinate')->textInput(['class' => 'form-control', 'placeholder' => '经纬度坐标格式']) ?>
            <td><span class="redstar"></span></td>

            <td align="right"><?= $model->getAttributeLabel('baidu_coordinate') ?>：</td>
                <?= $form->field($model, 'baidu_coordinate')->textInput(['class' => 'form-control', 'placeholder' => '经纬度坐标格式']) ?>
            <td><span class="redstar"></span></td>
        </tr>
        <tr>
            <?php if (!$model->isNewRecord) : ?>
                <td id="only-0"  data-set-province="<?= $model['province_id'] ?>" data-set-city="<?= $model['city_id'] ?>"  data-set-area="<?= $model['area_id'] ?>" align="right"><?= $model->getAttributeLabel('address') ?>：</td>
            <?php else :?>
                <td align="right" id="only-0" ><?= $model->getAttributeLabel('address') ?>：</td>
            <?php endif; ?>
            <td><span class="redstar">*</span></td>

            <td align="right"><?= $model->getAttributeLabel('street') ?>：</td>
                <?= $form->field($model, 'street')->textInput(['class' => 'form-control', 'placeholder' => '请输入街道地址']) ?>
            <td><span class="redstar"></span></td>
        </tr>
        <tr>
            <td align="right"><?= $model->getAttributeLabel('attention') ?>：</td>
            <?= $form->field($model, 'attention', ['options' => ['width' => '250px']])->radioList(Customer::getAttentionList(), ['itemOptions' => ['labelOptions' => ['class' => 'radio-inline']]]) ?>
            <td></td>

            <td align="right"><?= $model->getAttributeLabel('status') ?>：</td>
            <?= $form->field($model, 'status', ['options' => ['width' => '250px']])->radioList(Customer::getStatusList(), ['itemOptions' => ['labelOptions' => ['class' => 'radio-inline']]]) ?>
            <td></td>
        </tr>
        <tr>
            <td align="right"><?= $model->getAttributeLabel('info') ?>：</td>
                <?= $form->field($model, 'info', ['options' => ['colspan' => '4']])->textarea(['class' => 'form-control', 'rows' => '3']) ?>
            <td></td>
        </tr>
        <tr>
            <td align="right"><?= $model->getAttributeLabel('remark') ?>：</td>
                <?= $form->field($model, 'remark', ['options' => ['colspan' => '4']])->textarea(['class' => 'form-control', 'rows' => '3']) ?>
            <td><span class="redstar"></span></td>
        </tr>
        <tr>
            <td align="right"><?= $model->getAttributeLabel('tag_names') ?>：</td>
            <td colspan='2'>
                <?= Tagit::widget(['attribute' => 'Customer[tag_names]', 'tag_value' => $model->tag_names]) ?>
            </td>
            <td align="right"><?= $model->getAttributeLabel('sort') ?>：</td>
                <?= $form->field($model, 'sort')->textInput(['class' => 'form-control', 'place']) ?>
            <td></td>
        </tr>
    </tbody>
</table>
<?= ($model->isNewRecord) ? '' : Html::hiddenInput('id', $model->customer_id); ?>
<?= ($model->isNewRecord) ? '' : '<span id="only-district" data-set-num="1" ></span>'; ?>
<?php ActiveForm::end(); ?>