Commit b16ed95f7aecff5c5edfa4ff9c0570c0240662ba
1 parent
02524a34
test
Showing
5 changed files
with
64 additions
and
12 deletions
Show diff stats
common/models/Team.php
@@ -13,7 +13,7 @@ | @@ -13,7 +13,7 @@ | ||
13 | * @property integer $user_id | 13 | * @property integer $user_id |
14 | * @property string $firstname | 14 | * @property string $firstname |
15 | * @property string $lastname | 15 | * @property string $lastname |
16 | - * @property string $midlename | 16 | + * @property string $middlename |
17 | * @property string $link | 17 | * @property string $link |
18 | * @property string $position | 18 | * @property string $position |
19 | * @property integer $department_id | 19 | * @property integer $department_id |
@@ -85,7 +85,7 @@ | @@ -85,7 +85,7 @@ | ||
85 | [ | 85 | [ |
86 | 'firstname', | 86 | 'firstname', |
87 | 'lastname', | 87 | 'lastname', |
88 | - 'midlename', | 88 | + 'middlename', |
89 | 'link', | 89 | 'link', |
90 | 'position', | 90 | 'position', |
91 | 'photo', | 91 | 'photo', |
@@ -107,7 +107,7 @@ | @@ -107,7 +107,7 @@ | ||
107 | 'user_id' => Yii::t('app', 'User ID'), | 107 | 'user_id' => Yii::t('app', 'User ID'), |
108 | 'firstname' => Yii::t('app', 'Имя'), | 108 | 'firstname' => Yii::t('app', 'Имя'), |
109 | 'lastname' => Yii::t('app', 'Фамилия'), | 109 | 'lastname' => Yii::t('app', 'Фамилия'), |
110 | - 'midlename' => Yii::t('app', 'Отчество'), | 110 | + 'middlename' => Yii::t('app', 'Отчество'), |
111 | 'link' => Yii::t('app', 'Ссылка на профиль МФП'), | 111 | 'link' => Yii::t('app', 'Ссылка на профиль МФП'), |
112 | 'position' => Yii::t('app', 'Должность'), | 112 | 'position' => Yii::t('app', 'Должность'), |
113 | 'department_id' => Yii::t('app', 'Отдел компании'), | 113 | 'department_id' => Yii::t('app', 'Отдел компании'), |
console/migrations/m160208_101449_team.php
@@ -17,7 +17,7 @@ class m160208_101449_team extends Migration | @@ -17,7 +17,7 @@ class m160208_101449_team extends Migration | ||
17 | 'link' => $this->string(255), | 17 | 'link' => $this->string(255), |
18 | 'position' => $this->string(255)->notNull(), | 18 | 'position' => $this->string(255)->notNull(), |
19 | 'department_id' => $this->integer()->notNull(), | 19 | 'department_id' => $this->integer()->notNull(), |
20 | - 'experience_from' => $this->timestamp(), | 20 | + 'experience_from' => $this->integer(), |
21 | 'date_add' => $this->timestamp()->notNull(), | 21 | 'date_add' => $this->timestamp()->notNull(), |
22 | 'user_add_id' => $this->integer(), | 22 | 'user_add_id' => $this->integer(), |
23 | 'photo' => $this->string(255), | 23 | 'photo' => $this->string(255), |
frontend/controllers/SiteController.php
@@ -2,6 +2,7 @@ | @@ -2,6 +2,7 @@ | ||
2 | namespace frontend\controllers; | 2 | namespace frontend\controllers; |
3 | 3 | ||
4 | use common\models\Cities; | 4 | use common\models\Cities; |
5 | +use common\models\Country; | ||
5 | use common\models\Specialization; | 6 | use common\models\Specialization; |
6 | use common\models\UserInfo; | 7 | use common\models\UserInfo; |
7 | use Yii; | 8 | use Yii; |
@@ -69,6 +70,24 @@ class SiteController extends Controller | @@ -69,6 +70,24 @@ class SiteController extends Controller | ||
69 | return $out; | 70 | return $out; |
70 | } | 71 | } |
71 | 72 | ||
73 | + public function actionCountry($q = null, $id = null) { | ||
74 | + \Yii::$app->response->format = \yii\web\Response::FORMAT_JSON; | ||
75 | + $out = ['results' => ['id' => '', 'text' => '']]; | ||
76 | + if (!is_null($q)) { | ||
77 | + $query = new Query; | ||
78 | + $query->select('country_name AS id, country_name AS text') | ||
79 | + ->from('country') | ||
80 | + ->where(['like', 'lower(country_name)', mb_strtolower($q) ]) | ||
81 | + ->limit(20); | ||
82 | + $command = $query->createCommand(); | ||
83 | + $data = $command->queryAll(); | ||
84 | + $out['results'] = array_values($data); | ||
85 | + } | ||
86 | + elseif ($id > 0) { | ||
87 | + $out['results'] = ['id' => $id, 'text' => Country::find($id)->country_name]; | ||
88 | + } | ||
89 | + return $out; | ||
90 | + } | ||
72 | 91 | ||
73 | public function actionFormsModal() | 92 | public function actionFormsModal() |
74 | { | 93 | { |
frontend/views/accounts/_projects_form.php
1 | <?php | 1 | <?php |
2 | /** | 2 | /** |
3 | - * @var Project $project | 3 | + * @var Project $project |
4 | * @var Specialization[] $specialization | 4 | * @var Specialization[] $specialization |
5 | - * @var Payment[] $payment | ||
6 | - * @var string[] $projects | 5 | + * @var Payment[] $payment |
6 | + * @var string[] $projects | ||
7 | */ | 7 | */ |
8 | use common\models\Payment; | 8 | use common\models\Payment; |
9 | use common\models\Project; | 9 | use common\models\Project; |
10 | use common\models\Specialization; | 10 | use common\models\Specialization; |
11 | use common\widgets\ImageUploader; | 11 | use common\widgets\ImageUploader; |
12 | + use kartik\select2\Select2; | ||
12 | use mihaildev\ckeditor\CKEditor; | 13 | use mihaildev\ckeditor\CKEditor; |
13 | use yii\helpers\Html; | 14 | use yii\helpers\Html; |
15 | + use yii\web\JsExpression; | ||
14 | use yii\widgets\ActiveForm; | 16 | use yii\widgets\ActiveForm; |
15 | 17 | ||
16 | $this->title = 'Мой профиль'; | 18 | $this->title = 'Мой профиль'; |
@@ -29,15 +31,29 @@ | @@ -29,15 +31,29 @@ | ||
29 | ->textInput() ?> | 31 | ->textInput() ?> |
30 | 32 | ||
31 | <?= $form->field($project, 'project_pid') | 33 | <?= $form->field($project, 'project_pid') |
32 | - ->dropDownList($projects, ['prompt' => 'Родительский проект']) ?> | 34 | + ->dropDownList($projects, [ 'prompt' => 'Родительский проект' ]) ?> |
33 | 35 | ||
34 | <?= $form->field($project, 'specializationInput') | 36 | <?= $form->field($project, 'specializationInput') |
35 | ->checkboxList($specialization) ?> | 37 | ->checkboxList($specialization) ?> |
36 | 38 | ||
37 | <div class="form-inline"> | 39 | <div class="form-inline"> |
38 | Адрес: | 40 | Адрес: |
39 | - <?= $form->field($project, 'city', [ 'template' => "{label}{input}{hint}{error}" ]) | ||
40 | - ->textInput() ?> | 41 | + <?= $form->field($project, 'city') |
42 | + ->widget(Select2::classname(), [ | ||
43 | + 'options' => [ 'placeholder' => 'Выбор города ...' ], | ||
44 | + 'pluginOptions' => [ | ||
45 | + 'allowClear' => true, | ||
46 | + 'minimumInputLength' => 3, | ||
47 | + 'ajax' => [ | ||
48 | + 'url' => \yii\helpers\Url::to([ 'site/city' ]), | ||
49 | + 'dataType' => 'json', | ||
50 | + 'data' => new JsExpression('function(params) { return {q:params.term}; }'), | ||
51 | + ], | ||
52 | + 'escapeMarkup' => new JsExpression('function (markup) { return markup; }'), | ||
53 | + 'templateResult' => new JsExpression('function(city) { return city.text; }'), | ||
54 | + 'templateSelection' => new JsExpression('function (city) { return city.text; }'), | ||
55 | + ], | ||
56 | + ]); ?> | ||
41 | <?= $form->field($project, 'street', [ 'template' => "{label}{input}{hint}{error}" ]) | 57 | <?= $form->field($project, 'street', [ 'template' => "{label}{input}{hint}{error}" ]) |
42 | ->textInput() ?> | 58 | ->textInput() ?> |
43 | <?= $form->field($project, 'house', [ 'template' => "{label}{input}{hint}{error}" ]) | 59 | <?= $form->field($project, 'house', [ 'template' => "{label}{input}{hint}{error}" ]) |
frontend/views/accounts/_team_form.php
@@ -6,9 +6,11 @@ | @@ -6,9 +6,11 @@ | ||
6 | */ | 6 | */ |
7 | use common\models\Team; | 7 | use common\models\Team; |
8 | use common\widgets\ImageUploader; | 8 | use common\widgets\ImageUploader; |
9 | + use kartik\select2\Select2; | ||
9 | use mihaildev\ckeditor\CKEditor; | 10 | use mihaildev\ckeditor\CKEditor; |
10 | use yii\helpers\Html; | 11 | use yii\helpers\Html; |
11 | use yii\jui\DatePicker; | 12 | use yii\jui\DatePicker; |
13 | + use yii\web\JsExpression; | ||
12 | use yii\widgets\ActiveForm; | 14 | use yii\widgets\ActiveForm; |
13 | 15 | ||
14 | $this->title = 'Мой профиль'; | 16 | $this->title = 'Мой профиль'; |
@@ -41,8 +43,23 @@ | @@ -41,8 +43,23 @@ | ||
41 | <?= $form->field($team, 'experience_from', [ 'template' => "{label}, с {input} года \n{hint}\n{error}" ]) | 43 | <?= $form->field($team, 'experience_from', [ 'template' => "{label}, с {input} года \n{hint}\n{error}" ]) |
42 | ->input('number') ?> | 44 | ->input('number') ?> |
43 | 45 | ||
44 | -<?= $form->field($team, 'country_id') | ||
45 | - ->dropDownList($country) ?> | 46 | +<?= |
47 | + $form->field($team, 'country_id')->widget(Select2::classname(), [ | ||
48 | + 'options' => ['placeholder' => 'Выбор страны ...'], | ||
49 | + 'pluginOptions' => [ | ||
50 | + 'allowClear' => true, | ||
51 | + 'minimumInputLength' => 3, | ||
52 | + 'ajax' => [ | ||
53 | + 'url' => \yii\helpers\Url::to(['site/country']), | ||
54 | + 'dataType' => 'json', | ||
55 | + 'data' => new JsExpression('function(params) { return {q:params.term}; }') | ||
56 | + ], | ||
57 | + 'escapeMarkup' => new JsExpression('function (markup) { return markup; }'), | ||
58 | + 'templateResult' => new JsExpression('function(country) { return country.text; }'), | ||
59 | + 'templateSelection' => new JsExpression('function (country) { return country.text; }'), | ||
60 | + ], | ||
61 | + ]); | ||
62 | +?> | ||
46 | 63 | ||
47 | <?= ImageUploader::widget([ | 64 | <?= ImageUploader::widget([ |
48 | 'model' => $team, | 65 | 'model' => $team, |