diff --git a/common/models/Job.php b/common/models/Job.php new file mode 100644 index 0000000..8fbff20 --- /dev/null +++ b/common/models/Job.php @@ -0,0 +1,62 @@ + 255] + ]; + } + + /** + * @inheritdoc + */ + public function attributeLabels() + { + return [ + 'job_id' => Yii::t('app', 'Job ID'), + 'name' => Yii::t('app', 'Name'), + 'link' => Yii::t('app', 'Link'), + 'date_start' => Yii::t('app', 'Date Start'), + 'date_end' => Yii::t('app', 'Date End'), + 'position' => Yii::t('app', 'Position'), + 'user_id' => Yii::t('app', 'User ID'), + 'total_count' => Yii::t('app', 'Total Count'), + 'complete_count' => Yii::t('app', 'Complete Count'), + 'current' => Yii::t('app', 'Current'), + ]; + } +} diff --git a/common/models/JobSearch.php b/common/models/JobSearch.php new file mode 100644 index 0000000..4e0c062 --- /dev/null +++ b/common/models/JobSearch.php @@ -0,0 +1,74 @@ + $query, + ]); + + $this->load($params); + + if (!$this->validate()) { + // uncomment the following line if you do not want to return any records when validation fails + // $query->where('0=1'); + return $dataProvider; + } + + $query->andFilterWhere([ + 'job_id' => $this->job_id, + 'date_start' => $this->date_start, + 'date_end' => $this->date_end, + 'user_id' => $this->user_id, + 'total_count' => $this->total_count, + 'complete_count' => $this->complete_count, + 'current' => $this->current, + ]); + + $query->andFilterWhere(['like', 'name', $this->name]) + ->andFilterWhere(['like', 'link', $this->link]) + ->andFilterWhere(['like', 'position', $this->position]); + + return $dataProvider; + } +} diff --git a/console/migrations/m160203_082111_jobs.php b/console/migrations/m160203_082111_jobs.php index 1f7ba8e..8ff295c 100644 --- a/console/migrations/m160203_082111_jobs.php +++ b/console/migrations/m160203_082111_jobs.php @@ -18,6 +18,7 @@ class m160203_082111_jobs extends Migration 'user_id' => $this->integer(), 'total_count' => $this->integer(), 'complete_count' => $this->integer(), + 'current' => $this->smallInteger(), ], $tableOptions); } diff --git a/frontend/controllers/AccountsController.php b/frontend/controllers/AccountsController.php index 80d629c..b3b1772 100755 --- a/frontend/controllers/AccountsController.php +++ b/frontend/controllers/AccountsController.php @@ -3,6 +3,7 @@ namespace frontend\controllers; use common\models\CompanyInfo; use common\models\Fields; +use common\models\Job; use common\models\Language; use Yii; use common\models\User; @@ -169,7 +170,18 @@ class AccountsController extends Controller public function actionEmployment() { - + $job = Job::find()->where(['user_id' => \Yii::$app->user->getId()])->orderBy(['current' => SORT_DESC])->all(); + if(empty($job)) { + $job[] = new Job(['user_id' => \Yii::$app->user->getId(), 'current' => 0]); + } + if(!$job[0]->current) { + array_unshift($job, new Job(['user_id' => \Yii::$app->user->getId(), 'current' => 1])); + } + if(!empty(\Yii::$app->request->post())) { + var_dump(\Yii::$app->request->post()); + die(); + } + return $this->render('employment', ['job' => $job]); } public function actionProjects() @@ -182,6 +194,11 @@ class AccountsController extends Controller } + public function actionGetForm($lastindex) + { + return $this->renderAjax('_job_form', ['index' => $lastindex+1]); + } + /** * @param $id * @return User diff --git a/frontend/controllers/JobController.php b/frontend/controllers/JobController.php new file mode 100644 index 0000000..1c88a22 --- /dev/null +++ b/frontend/controllers/JobController.php @@ -0,0 +1,121 @@ + [ + 'class' => VerbFilter::className(), + 'actions' => [ + 'delete' => ['post'], + ], + ], + ]; + } + + /** + * Lists all Job models. + * @return mixed + */ + public function actionIndex() + { + $searchModel = new JobSearch(); + $dataProvider = $searchModel->search(Yii::$app->request->queryParams); + + return $this->render('index', [ + 'searchModel' => $searchModel, + 'dataProvider' => $dataProvider, + ]); + } + + /** + * Displays a single Job model. + * @param integer $id + * @return mixed + */ + public function actionView($id) + { + return $this->render('view', [ + 'model' => $this->findModel($id), + ]); + } + + /** + * Creates a new Job model. + * If creation is successful, the browser will be redirected to the 'view' page. + * @return mixed + */ + public function actionCreate() + { + $model = new Job(); + + if ($model->load(Yii::$app->request->post()) && $model->save()) { + return $this->redirect(['view', 'id' => $model->job_id]); + } else { + return $this->render('create', [ + 'model' => $model, + ]); + } + } + + /** + * Updates an existing Job model. + * If update is successful, the browser will be redirected to the 'view' page. + * @param integer $id + * @return mixed + */ + public function actionUpdate($id) + { + $model = $this->findModel($id); + + if ($model->load(Yii::$app->request->post()) && $model->save()) { + return $this->redirect(['view', 'id' => $model->job_id]); + } else { + return $this->render('update', [ + 'model' => $model, + ]); + } + } + + /** + * Deletes an existing Job model. + * If deletion is successful, the browser will be redirected to the 'index' page. + * @param integer $id + * @return mixed + */ + public function actionDelete($id) + { + $this->findModel($id)->delete(); + + return $this->redirect(['index']); + } + + /** + * Finds the Job model based on its primary key value. + * If the model is not found, a 404 HTTP exception will be thrown. + * @param integer $id + * @return Job the loaded model + * @throws NotFoundHttpException if the model cannot be found + */ + protected function findModel($id) + { + if (($model = Job::findOne($id)) !== null) { + return $model; + } else { + throw new NotFoundHttpException('The requested page does not exist.'); + } + } +} diff --git a/frontend/views/accounts/_job_form.php b/frontend/views/accounts/_job_form.php new file mode 100644 index 0000000..7e26125 --- /dev/null +++ b/frontend/views/accounts/_job_form.php @@ -0,0 +1,35 @@ + \Yii::$app->user->getId (), 'current' => 0]); + $form = ActiveForm::begin (); + echo "
"; + echo $form->field ($model, '[' . $index . ']name') + ->label ('Название') + ->textInput (); + echo $form->field ($model, '[' . $index . ']link') + ->label ('Ссылка на компанию на сайте МФП') + ->textInput (); + echo $form->field ($model, '[' . $index . ']date_start') + ->label ('Дата начала работы') + ->widget (DatePicker::className (), ['language' => 'ru', 'dateFormat' => 'dd-MM-yyyy']); + echo $form->field ($model, '[' . $index . ']date_end') + ->label ('Дата окончания работы') + ->widget (DatePicker::className (), ['language' => 'ru', 'dateFormat' => 'dd-MM-yyyy']); + echo $form->field ($model, '[' . $index . ']position') + ->label ('Должность') + ->textInput (); + echo $form->field ($model, '[' . $index . ']total_count') + ->label ('Количество проектов, в которых принимали участие') + ->input ('number'); + echo $form->field ($model, '[' . $index . ']complete_count') + ->label ('из них реализовано') + ->input ('number'); + echo "
"; + $form->end (); +?> diff --git a/frontend/views/accounts/employment.php b/frontend/views/accounts/employment.php index 162a954..eae5d97 100644 --- a/frontend/views/accounts/employment.php +++ b/frontend/views/accounts/employment.php @@ -1,26 +1,94 @@ title = 'Мой профиль'; + $this->title = 'Трудовой стаж'; $this->params['breadcrumbs'][] = $this->title; ?> - -

title ?>

- - - +

title ?>

render('_form', [ - 'user' => $user, - 'user_info' => $user_info, -]); - -echo MultiLangForm::widget(['form'=>$form]); - + $form = ActiveForm::begin (); + $current = array_shift ($job); ?> - - +
+

Текущее место работы:

+
+ field ($current, '[0]current') + ->label (false) + ->hiddenInput (['value' => 1]); + echo $form->field ($current, '[0]name') + ->label ('Название') + ->textInput (); + echo $form->field ($current, '[0]link') + ->label ('Ссылка на компанию на сайте МФП') + ->textInput (); + echo $form->field ($current, '[0]date_start') + ->label ('Дата начала работы') + ->widget (DatePicker::className (), ['language' => 'ru', 'dateFormat' => 'dd-MM-yyyy']); + echo $form->field ($current, '[0]position') + ->label ('Должность') + ->textInput (); + echo $form->field ($current, '[0]total_count') + ->label ('Количество проектов, в которых принимали участие') + ->input ('number'); + echo $form->field ($current, '[0]complete_count') + ->label ('из них реализовано') + ->input ('number'); + ?> +
+
+
+

Предыдущие места работы

+ $job_model) + { + echo "
"; + echo $form->field ($job_model, '['. ($index + 1) .']name') + ->label ('Название') + ->textInput (); + echo $form->field ($job_model, '['. ($index + 1) .']link') + ->label ('Ссылка на компанию на сайте МФП') + ->textInput (); + echo $form->field ($job_model, '['. ($index + 1) .']date_start') + ->label ('Дата начала работы') + ->widget (DatePicker::className (), ['language' => 'ru', 'dateFormat' => 'dd-MM-yyyy']); + echo $form->field ($job_model, '['. ($index + 1) .']date_end') + ->label ('Дата окончания работы') + ->widget (DatePicker::className (), ['language' => 'ru', 'dateFormat' => 'dd-MM-yyyy']); + echo $form->field ($job_model, '['. ($index + 1) .']position') + ->label ('Должность') + ->textInput (); + echo $form->field ($job_model, '['. ($index + 1) .']total_count') + ->label ('Количество проектов, в которых принимали участие') + ->input ('number'); + echo $form->field ($job_model, '['. ($index + 1) .']complete_count') + ->label ('из них реализовано') + ->input ('number'); + echo "
"; + } + ?> +
+ 'add_job_button']); + $form->end (); +?> + diff --git a/frontend/views/job/_search.php b/frontend/views/job/_search.php new file mode 100644 index 0000000..0e4d755 --- /dev/null +++ b/frontend/views/job/_search.php @@ -0,0 +1,45 @@ + + + diff --git a/frontend/views/job/create.php b/frontend/views/job/create.php new file mode 100644 index 0000000..603190b --- /dev/null +++ b/frontend/views/job/create.php @@ -0,0 +1,21 @@ +title = Yii::t('app', 'Create Job'); +$this->params['breadcrumbs'][] = ['label' => Yii::t('app', 'Jobs'), 'url' => ['index']]; +$this->params['breadcrumbs'][] = $this->title; +?> +
+ +

title) ?>

+ + render('_form', [ + 'model' => $model, + ]) ?> + +
diff --git a/frontend/views/job/index.php b/frontend/views/job/index.php new file mode 100644 index 0000000..f12029e --- /dev/null +++ b/frontend/views/job/index.php @@ -0,0 +1,43 @@ +title = Yii::t('app', 'Jobs'); +$this->params['breadcrumbs'][] = $this->title; +?> +
+ +

title) ?>

+ render('_search', ['model' => $searchModel]); ?> + +

+ 'btn btn-success']) ?> +

+ + $dataProvider, + 'filterModel' => $searchModel, + 'columns' => [ + ['class' => 'yii\grid\SerialColumn'], + + 'job_id', + 'name', + 'link', + 'date_start', + 'date_end', + // 'position', + // 'user_id', + // 'total_count', + // 'complete_count', + // 'current', + + ['class' => 'yii\grid\ActionColumn'], + ], + ]); ?> + +
diff --git a/frontend/views/job/update.php b/frontend/views/job/update.php new file mode 100644 index 0000000..3fe0ac8 --- /dev/null +++ b/frontend/views/job/update.php @@ -0,0 +1,23 @@ +title = Yii::t('app', 'Update {modelClass}: ', [ + 'modelClass' => 'Job', +]) . ' ' . $model->name; +$this->params['breadcrumbs'][] = ['label' => Yii::t('app', 'Jobs'), 'url' => ['index']]; +$this->params['breadcrumbs'][] = ['label' => $model->name, 'url' => ['view', 'id' => $model->job_id]]; +$this->params['breadcrumbs'][] = Yii::t('app', 'Update'); +?> +
+ +

title) ?>

+ + render('_form', [ + 'model' => $model, + ]) ?> + +
diff --git a/frontend/views/job/view.php b/frontend/views/job/view.php new file mode 100644 index 0000000..62e390b --- /dev/null +++ b/frontend/views/job/view.php @@ -0,0 +1,44 @@ +title = $model->name; +$this->params['breadcrumbs'][] = ['label' => Yii::t('app', 'Jobs'), 'url' => ['index']]; +$this->params['breadcrumbs'][] = $this->title; +?> +
+ +

title) ?>

+ +

+ $model->job_id], ['class' => 'btn btn-primary']) ?> + $model->job_id], [ + 'class' => 'btn btn-danger', + 'data' => [ + 'confirm' => Yii::t('app', 'Are you sure you want to delete this item?'), + 'method' => 'post', + ], + ]) ?> +

+ + $model, + 'attributes' => [ + 'job_id', + 'name', + 'link', + 'date_start', + 'date_end', + 'position', + 'user_id', + 'total_count', + 'complete_count', + 'current', + ], + ]) ?> + +
-- libgit2 0.21.4