service.php 11.2 KB
<?php
    /**
     * @var User               $user
     * @var UserInfo           $user_info
     * @var string[]           $specialization
     * @var string[]           $payment
     */
    use common\models\Currency;
    use common\models\Specialization;
    use common\models\User;
    use common\models\UserInfo;
    use kartik\select2\Select2;
    use yii\helpers\ArrayHelper;
    use yii\helpers\Html;
    use yii\web\JsExpression;
    use yii\widgets\ActiveForm;

    $this->title = 'Услуги';
    $this->params[ 'breadcrumbs' ][] = $this->title;
?>
<div class="login-left-column-title style">
    <table cellpadding="0" cellspacing="0" border="0">
        <tr>
            <td><?= $this->title ?></td>
            <td style="font-size: 13px; color: #b7b7b7;padding-left: 15px;">Рекомендуем детально заполнить для исполнителя. Это сильно влияет на количество заказов.</td>
        </tr>
    </table>
</div>
<div class="admin-service-wr style">
    <?php
        $form = ActiveForm::begin();
    ?>
    <div class="input-blocks-wrapper">
        <div class="input-blocks">
            <?=
                $form->field($user_info, 'salary_currency')->label(false)->dropDownList(Currency::getCurrencyDropdown());
            ?>
            <?= $form->field($user_info, 'salary', [
                'template' => "{label}<br /><span class='admn-input-txt'>от</span>{input}<span class='admn-input-txt'>за час</span>\n{hint}\n{error}",
                'options'  => [ 'class' => 'form-inline' ],
            ])
                ->label('Стоимость работ')
                ->textInput (['class'=> 'custom-input-2 custom-input-2-date','type'=>'number']);
            ?>
        </div>
    </div>

    <div class="input-blocks-wrapper">
        <ul class="content-menu-first">
            <?php foreach($specializations as $specialization):?>
                <li data-img="<?= $specialization->image?>">
                    <span data-menu-bg="<?= $specialization->background ?>"  style="background: <?= $specialization->background ?>"></span><a href="#"><?= $specialization->specialization_name?></a>
                    <ul>
                        <?php  foreach($specialization->children as $child_first):?>

                            <?php if($child_first instanceof Specialization):?>
                                <li>
                                    <a href="#"><?= $child_first->specialization_name?></a>
                                    <ul>
                                        <?php foreach($child_first->children as $child_second):?>
                                            <?php if($child_first instanceof Specialization): ?>
                                                <li>
                                                    <a href="#">
                                                        <?= $form->field($user, "specializationInput[{$child_second->specialization_id}]")->checkbox(['value' => $child_second->specialization_id, 'label' => $child_second->specialization_name, 'uncheck' => null, 'checked' => 'checked']) ?>
                                                    </a>
                                                </li>
                                            <?php endif;?>
                                        <?php endforeach; ?>
                                    </ul>
                                </li>
                            <?php endif; ?>
                        <?php endforeach; ?>

                    </ul>
                </li>
            <?php endforeach; ?>
        </ul>
    </div>
    <div class="input-blocks-wrapper">
        <div class="input-blocks">
            <?=
                $form->field($user_info, 'geographies')->widget(Select2::classname(), [
                    'options' => ['placeholder' => 'Выбор города ...', 'multiple' => true],
                    'pluginOptions' => [
                        'allowClear' => true,
                        'minimumInputLength' => 3,
                        'ajax' => [
                            'url' => \yii\helpers\Url::to(['site/city']),
                            'dataType' => 'json',
                            'data' => new JsExpression('function(params) { return {q:params.term}; }')
                        ],
                        'escapeMarkup' => new JsExpression('function (markup) { return markup; }'),
                        'templateResult' => new JsExpression('function(city) { return city.text; }'),
                        'templateSelection' => new JsExpression('function (city) { return city.text; }'),
                    ],
                ]);
            ?>
        </div>
    </div>
    <div class="input-blocks-wrapper">
        <div class="input-blocks">
            <?= $form->field($user_info, 'guarantee', [
                'template' => "{label}<br />{input}<span class='admn-input-txt'>лет</span>\n{hint}\n{error}",
                'options'  => [ 'class' => 'form-inline' ],
            ])
                ->label('Гарантия качества работ')
                ->textInput (['class'=> 'custom-input-2 custom-input-2-date custom-input-2-margin-r','type'=>'number']) ?>
        </div>
    </div>

    <div class="input-blocks-wrapper">
        <div class="input-blocks">
            <?= $form->field($user_info, 'contract', [ 'options' => [ 'class' => 'form-inline' ] ])
                ->label('Работа по договору')
                ->radioList([
                    1 => 'Да',
                    0 => 'Нет',
                ],
                    [
                    'item' => function($index, $label, $name, $checked, $value) {
                        $return = '<div class="admin-who-check">';
                        $return .= '<input class="custom-radio" id="select_admin_doc'.$value.'" type="radio" name="' . $name . '" value="' . $value . '" '.($checked ? "checked" :"").' >';
                        $return .= '<label for="select_admin_doc'.$value.'" >';
                        $return .= '<span></span>' . ucwords($label);
                        $return .= '</label>';
                        $return .= '</div>';
                        return $return;
                    }
                ]) ?>
        </div>
    </div>

    <div class="input-blocks-wrapper">
        <div class="input-blocks">
            <?= $form->field($user_info, 'estimate', [ 'options' => [ 'class' => 'form-inline' ] ])
                ->label('Предоставляете смету')
                ->radioList([
                    1 => 'Да',
                    0 => 'Нет',
                ], [
                    'item' => function($index, $label, $name, $checked, $value) {
                        $return = '<div class="admin-who-check">';
                        $return .= '<input class="custom-radio" id="select_admin_estimate'.$value.'" type="radio" name="' . $name . '" value="' . $value . '" '.($checked ? "checked" :"").' >';
                        $return .= '<label for="select_admin_estimate'.$value.'" >';
                        $return .= '<span></span>' . ucwords($label);
                        $return .= '</label>';
                        $return .= '</div>';
                        return $return;
                    }
                ]) ?>
        </div>
    </div>

    <div class="input-blocks-wrapper">
        <div class="input-blocks">
            <?= $form->field($user_info, 'purchase', [ 'options' => [ 'class' => 'form-inline' ] ])
                ->label('Делаете сами закупку материалов')
                ->radioList([
                    1 => 'Да',
                    0 => 'Нет',
                ], [
                    'item' => function($index, $label, $name, $checked, $value) {
                        $return = '<div class="admin-who-check">';
                        $return .= '<input class="custom-radio" id="select_admin_purchase'.$value.'" type="radio" name="' . $name . '" value="' . $value . '" '.($checked ? "checked" :"").' >';
                        $return .= '<label for="select_admin_purchase'.$value.'" >';
                        $return .= '<span></span>' . ucwords($label);
                        $return .= '</label>';
                        $return .= '</div>';
                        return $return;
                    }
                ]) ?>
        </div>
    </div>
    <div class="input-blocks-wrapper">
        <div class="input-blocks">
            <?= $form->field($user_info, 'delivery', [ 'options' => [ 'class' => 'form-inline' ] ])
                ->label('Занимаетесь сами доставкой материалов')
                ->radioList([
                    1 => 'Да',
                    0 => 'Нет',
                ], [
                    'item' => function($index, $label, $name, $checked, $value) {
                        $return = '<div class="admin-who-check">';
                        $return .= '<input class="custom-radio" id="select_admin_delivery'.$value.'" type="radio" name="' . $name . '" value="' . $value . '" '.($checked ? "checked" :"").' >';
                        $return .= '<label for="select_admin_delivery'.$value.'" >';
                        $return .= '<span></span>' . ucwords($label);
                        $return .= '</label>';
                        $return .= '</div>';
                        return $return;
                    }
                ]) ?>
        </div>
    </div>

    <div class="input-blocks-wrapper">
        <div class="input-blocks">
            <?= $form->field($user_info, 'prepayment', [
                'template' => "{label}<br />{input}<span class='admn-input-txt'>%</span>\n{hint}\n{error}",
                'options'  => [ 'class' => 'form-inline' ],
            ])
                ->label('Минимальная предоплата за работы')
                ->textInput (['class'=> 'custom-input-2 custom-input-2-date custom-input-2-margin-r','type'=>'number'])?>
        </div>
    </div>

    <div class="input-blocks-wrapper style border-general">
        <div class="input-blocks">
            <?= $form->field($user, 'paymentInput', [ 'template' => "{label}\n{input}\n{error}" ])
                ->label('Способы оплаты')
                ->checkboxList($payment,
                    [
                        'item' => function($index, $label, $name, $checked, $value) {
                            $return = '<div class="admin-who-check-payment">';
                            $return .= '<input class="custom-check" id="select_admin_payment'.$value.'" type="checkbox" name="' . $name . '" value="' . $value . '" '.($checked ? "checked" :"").' >';
                            $return .= '<label for="select_admin_payment'.$value.'" >';
                            $return .= '<span></span>' . ucwords($label);
                            $return .= '</label>';
                            $return .= '</div>';
                            return $return;
                        }
                    ]
                ) ?>
        </div>
    </div>

    <div class="input-blocks-wrapper">
        <div class="admin-save-btn style admin-save-btn-fix-line">
            <?= Html::submitButton('Сохранить') ?>
        </div>
    </div>

    <?php
        $form->end();
    ?>
</div>