Commit b16ed95f7aecff5c5edfa4ff9c0570c0240662ba

Authored by Yarik
1 parent 02524a34

test

common/models/Team.php
... ... @@ -13,7 +13,7 @@
13 13 * @property integer $user_id
14 14 * @property string $firstname
15 15 * @property string $lastname
16   - * @property string $midlename
  16 + * @property string $middlename
17 17 * @property string $link
18 18 * @property string $position
19 19 * @property integer $department_id
... ... @@ -85,7 +85,7 @@
85 85 [
86 86 'firstname',
87 87 'lastname',
88   - 'midlename',
  88 + 'middlename',
89 89 'link',
90 90 'position',
91 91 'photo',
... ... @@ -107,7 +107,7 @@
107 107 'user_id' => Yii::t('app', 'User ID'),
108 108 'firstname' => Yii::t('app', 'Имя'),
109 109 'lastname' => Yii::t('app', 'Фамилия'),
110   - 'midlename' => Yii::t('app', 'Отчество'),
  110 + 'middlename' => Yii::t('app', 'Отчество'),
111 111 'link' => Yii::t('app', 'Ссылка на профиль МФП'),
112 112 'position' => Yii::t('app', 'Должность'),
113 113 'department_id' => Yii::t('app', 'Отдел компании'),
... ...
console/migrations/m160208_101449_team.php
... ... @@ -17,7 +17,7 @@ class m160208_101449_team extends Migration
17 17 'link' => $this->string(255),
18 18 'position' => $this->string(255)->notNull(),
19 19 'department_id' => $this->integer()->notNull(),
20   - 'experience_from' => $this->timestamp(),
  20 + 'experience_from' => $this->integer(),
21 21 'date_add' => $this->timestamp()->notNull(),
22 22 'user_add_id' => $this->integer(),
23 23 'photo' => $this->string(255),
... ...
frontend/controllers/SiteController.php
... ... @@ -2,6 +2,7 @@
2 2 namespace frontend\controllers;
3 3  
4 4 use common\models\Cities;
  5 +use common\models\Country;
5 6 use common\models\Specialization;
6 7 use common\models\UserInfo;
7 8 use Yii;
... ... @@ -69,6 +70,24 @@ class SiteController extends Controller
69 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 92 public function actionFormsModal()
74 93 {
... ...
frontend/views/accounts/_projects_form.php
1 1 <?php
2 2 /**
3   - * @var Project $project
  3 + * @var Project $project
4 4 * @var Specialization[] $specialization
5   - * @var Payment[] $payment
6   - * @var string[] $projects
  5 + * @var Payment[] $payment
  6 + * @var string[] $projects
7 7 */
8 8 use common\models\Payment;
9 9 use common\models\Project;
10 10 use common\models\Specialization;
11 11 use common\widgets\ImageUploader;
  12 + use kartik\select2\Select2;
12 13 use mihaildev\ckeditor\CKEditor;
13 14 use yii\helpers\Html;
  15 + use yii\web\JsExpression;
14 16 use yii\widgets\ActiveForm;
15 17  
16 18 $this->title = 'Мой профиль';
... ... @@ -29,15 +31,29 @@
29 31 ->textInput() ?>
30 32  
31 33 <?= $form->field($project, 'project_pid')
32   - ->dropDownList($projects, ['prompt' => 'Родительский проект']) ?>
  34 + ->dropDownList($projects, [ 'prompt' => 'Родительский проект' ]) ?>
33 35  
34 36 <?= $form->field($project, 'specializationInput')
35 37 ->checkboxList($specialization) ?>
36 38  
37 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 57 <?= $form->field($project, 'street', [ 'template' => "{label}{input}{hint}{error}" ])
42 58 ->textInput() ?>
43 59 <?= $form->field($project, 'house', [ 'template' => "{label}{input}{hint}{error}" ])
... ...
frontend/views/accounts/_team_form.php
... ... @@ -6,9 +6,11 @@
6 6 */
7 7 use common\models\Team;
8 8 use common\widgets\ImageUploader;
  9 + use kartik\select2\Select2;
9 10 use mihaildev\ckeditor\CKEditor;
10 11 use yii\helpers\Html;
11 12 use yii\jui\DatePicker;
  13 + use yii\web\JsExpression;
12 14 use yii\widgets\ActiveForm;
13 15  
14 16 $this->title = 'Мой профиль';
... ... @@ -41,8 +43,23 @@
41 43 <?= $form->field($team, 'experience_from', [ 'template' => "{label}, с {input} года \n{hint}\n{error}" ])
42 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 64 <?= ImageUploader::widget([
48 65 'model' => $team,
... ...