diff --git a/backend/config/main.php b/backend/config/main.php index d868264..4683bf1 100755 --- a/backend/config/main.php +++ b/backend/config/main.php @@ -53,6 +53,9 @@ return [ 'options' => [ 'class' => 'backend\modules\options\Options', ], + 'interview' => [ + 'class' => 'backend\modules\interview\Interview', + ], ], 'components' => [ 'request' => [ diff --git a/backend/modules/interview/Interview.php b/backend/modules/interview/Interview.php new file mode 100644 index 0000000..47ee710 --- /dev/null +++ b/backend/modules/interview/Interview.php @@ -0,0 +1,24 @@ +render('index'); + } +} diff --git a/backend/modules/interview/controllers/InterviewController.php b/backend/modules/interview/controllers/InterviewController.php new file mode 100644 index 0000000..01e1ab3 --- /dev/null +++ b/backend/modules/interview/controllers/InterviewController.php @@ -0,0 +1,133 @@ + [ + 'class' => VerbFilter::className(), + 'actions' => [ + 'delete' => ['POST'], + ], + ], + ]; + } + + /** + * Lists all InterviewRequest models. + * @return mixed + */ + public function actionIndex() + { + $searchModel = new InterviewRequestSearch(); + $dataProvider = $searchModel->search(Yii::$app->request->queryParams); + + return $this->render('index', [ + 'searchModel' => $searchModel, + 'dataProvider' => $dataProvider, + ]); + } + + /** + * Displays a single InterviewRequest model. + * @param integer $id + * @return mixed + * @throws NotFoundHttpException if the model cannot be found + */ + public function actionView($id) + { + $model = $this->findModel($id); + if($model){ + $model->new = 0; + $model->save(); + } + + return $this->render('view', [ + 'model' => $this->findModel($id), + ]); + } + + /** + * Creates a new InterviewRequest model. + * If creation is successful, the browser will be redirected to the 'view' page. + * @return mixed + */ + public function actionCreate() + { + $model = new InterviewRequest(); + + if ($model->load(Yii::$app->request->post()) && $model->save()) { + return $this->redirect(['view', 'id' => $model->id]); + } + + return $this->render('create', [ + 'model' => $model, + ]); + } + + /** + * Updates an existing InterviewRequest model. + * If update is successful, the browser will be redirected to the 'view' page. + * @param integer $id + * @return mixed + * @throws NotFoundHttpException if the model cannot be found + */ + public function actionUpdate($id) + { + $model = $this->findModel($id); + + if ($model->load(Yii::$app->request->post()) && $model->save()) { + return $this->redirect(['view', 'id' => $model->id]); + } + + return $this->render('update', [ + 'model' => $model, + ]); + } + + /** + * Deletes an existing InterviewRequest model. + * If deletion is successful, the browser will be redirected to the 'index' page. + * @param integer $id + * @return mixed + * @throws NotFoundHttpException if the model cannot be found + */ + public function actionDelete($id) + { + $this->findModel($id)->delete(); + + return $this->redirect(['index']); + } + + /** + * Finds the InterviewRequest model based on its primary key value. + * If the model is not found, a 404 HTTP exception will be thrown. + * @param integer $id + * @return InterviewRequest the loaded model + * @throws NotFoundHttpException if the model cannot be found + */ + protected function findModel($id) + { + if (($model = InterviewRequest::findOne($id)) !== null) { + return $model; + } + + throw new NotFoundHttpException('The requested page does not exist.'); + } +} diff --git a/backend/modules/interview/models/InterviewRequest.php b/backend/modules/interview/models/InterviewRequest.php new file mode 100644 index 0000000..46f2c4a --- /dev/null +++ b/backend/modules/interview/models/InterviewRequest.php @@ -0,0 +1,8 @@ + $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; + } + + // grid filtering conditions + $query->andFilterWhere([ + 'id' => $this->id, + 'profile_id' => $this->profile_id, + 'user_id' => $this->user_id, + 'created_at' => $this->created_at, + ]); + + $query->andFilterWhere(['like', 'email', $this->email]) + ->andFilterWhere(['like', 'phone', $this->phone]) + ->andFilterWhere(['like', 'comment', $this->comment]); + + $query->orderBy('id DESC'); + + return $dataProvider; + } +} diff --git a/backend/modules/interview/views/default/index.php b/backend/modules/interview/views/default/index.php new file mode 100644 index 0000000..b4b5646 --- /dev/null +++ b/backend/modules/interview/views/default/index.php @@ -0,0 +1,12 @@ +
+

context->action->uniqueId ?>

+

+ This is the view content for action "context->action->id ?>". + The action belongs to the controller "context) ?>" + in the "context->module->id ?>" module. +

+

+ You may customize this page by editing the following file:
+ +

+
diff --git a/backend/modules/interview/views/interview/_form.php b/backend/modules/interview/views/interview/_form.php new file mode 100644 index 0000000..73f2f8c --- /dev/null +++ b/backend/modules/interview/views/interview/_form.php @@ -0,0 +1,33 @@ + + +
+ + + + field($model, 'email')->textInput(['maxlength' => true]) ?> + + field($model, 'phone')->textInput(['maxlength' => true]) ?> + + field($model, 'profile_id')->textInput() ?> + + field($model, 'user_id')->textInput() ?> + + field($model, 'comment')->textarea(['rows' => 6]) ?> + + field($model, 'created_at')->textInput() ?> + +
+ 'btn btn-success']) ?> +
+ + + +
diff --git a/backend/modules/interview/views/interview/_search.php b/backend/modules/interview/views/interview/_search.php new file mode 100644 index 0000000..9aa52c2 --- /dev/null +++ b/backend/modules/interview/views/interview/_search.php @@ -0,0 +1,39 @@ + + + diff --git a/backend/modules/interview/views/interview/create.php b/backend/modules/interview/views/interview/create.php new file mode 100644 index 0000000..cd6c4fc --- /dev/null +++ b/backend/modules/interview/views/interview/create.php @@ -0,0 +1,20 @@ +title = 'Create Interview Request'; +$this->params['breadcrumbs'][] = ['label' => 'Interview Requests', 'url' => ['index']]; +$this->params['breadcrumbs'][] = $this->title; +?> +
+ +

title) ?>

+ + render('_form', [ + 'model' => $model, + ]) ?> + +
diff --git a/backend/modules/interview/views/interview/index.php b/backend/modules/interview/views/interview/index.php new file mode 100644 index 0000000..8b86ce5 --- /dev/null +++ b/backend/modules/interview/views/interview/index.php @@ -0,0 +1,45 @@ +title = 'Запрос интервью'; +$this->params['breadcrumbs'][] = $this->title; +?> +
+ + render('_search', ['model' => $searchModel]); ?> + + $dataProvider, + 'filterModel' => $searchModel, + 'columns' => [ + ['class' => 'yii\grid\SerialColumn'], + + //'id', + 'email:email', + 'phone', + 'profile.fio', + 'user.email', + 'comment:ntext', + [ + 'attribute' => 'created_at', + 'value' => function($model){ + return date('Y-m-d H:i', $model->created_at); + } + ], + [ + 'attribute' => 'new', + 'value' => function($model){ + return $model->new ? 'Новое' : 'Просмотренно'; + } + ], + + ['class' => 'yii\grid\ActionColumn'], + ], + ]); ?> +
diff --git a/backend/modules/interview/views/interview/update.php b/backend/modules/interview/views/interview/update.php new file mode 100644 index 0000000..0c59eac --- /dev/null +++ b/backend/modules/interview/views/interview/update.php @@ -0,0 +1,21 @@ +title = 'Update Interview Request: ' . $model->id; +$this->params['breadcrumbs'][] = ['label' => 'Interview Requests', 'url' => ['index']]; +$this->params['breadcrumbs'][] = ['label' => $model->id, 'url' => ['view', 'id' => $model->id]]; +$this->params['breadcrumbs'][] = 'Update'; +?> +
+ +

title) ?>

+ + render('_form', [ + 'model' => $model, + ]) ?> + +
diff --git a/backend/modules/interview/views/interview/view.php b/backend/modules/interview/views/interview/view.php new file mode 100644 index 0000000..abf8e8d --- /dev/null +++ b/backend/modules/interview/views/interview/view.php @@ -0,0 +1,39 @@ +title = $model->phone; +$this->params['breadcrumbs'][] = ['label' => 'Interview Requests', 'url' => ['index']]; +$this->params['breadcrumbs'][] = $this->title; +\yii\web\YiiAsset::register($this); +?> +
+

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

+ + $model, + 'attributes' => [ + //'id', + 'email:email', + 'phone', + 'profile.fio', + 'user.email', + 'comment:ntext', + 'created_at', + ], + ]) ?> + +
diff --git a/backend/views/layouts/left.php b/backend/views/layouts/left.php index 9464d6c..c0772ca 100755 --- a/backend/views/layouts/left.php +++ b/backend/views/layouts/left.php @@ -42,17 +42,25 @@ 'label' => 'Hh.ru', 'icon' => 'user-circle', 'url' => '#', 'items' => [ ['label' => 'Компании', 'icon' => 'building', 'url' => ['/hh/hh'], 'active' => \Yii::$app->controller->id == 'hh'], - ['label' => 'Вакансии', 'icon' => 'user-md', 'url' => ['/hh/hh-job'], 'active' => \Yii::$app->controller->id == 'hh-job'], + ['label' => 'Вакансии', 'icon' => 'user-md', 'url' => ['/hh/hh-job'], 'active' => \Yii::$app->controller->id == 'hh-job'], ], 'visible' => Yii::$app->user->can('confidential_information') ], - ['label' => 'Баланс', 'icon' => 'dollar', 'url' => ['/balance/balance'], 'active' => \Yii::$app->controller->id == 'balance', 'visible' => Yii::$app->user->can('confidential_information')], + ['label' => 'Баланс', 'icon' => 'dollar', 'url' => ['/balan ce/balance'], 'active' => \Yii::$app->controller->id == 'balance', 'visible' => Yii::$app->user->can('confidential_information')], ['label' => 'Отпуска', 'icon' => 'plane', 'url' => ['/holiday/holiday'], 'active' => \Yii::$app->controller->id == 'holiday', 'visible' => Yii::$app->user->can('confidential_information')], ['label' => 'Доступы', 'icon' => 'key', 'url' => ['/accesses/accesses'], 'active' => \Yii::$app->controller->id == 'accesses', 'visible' => Yii::$app->user->can('confidential_information')], ['label' => 'Заметки', 'icon' => 'sticky-note', 'url' => ['/notes/notes'], 'active' => \Yii::$app->controller->id == 'notes', 'visible' => Yii::$app->user->can('confidential_information')], ['label' => 'Календарь ДР', 'icon' => 'calendar', 'url' => ['/calendar/calendar'], 'active' => \Yii::$app->controller->id == 'calendar', 'visible' => Yii::$app->user->can('confidential_information')], ['label' => 'Отчеты', 'icon' => 'list-alt', 'url' => ['/reports/reports'], 'active' => \Yii::$app->controller->id == 'reports', 'visible' => Yii::$app->user->can('confidential_information')], ['label' => 'Опции', 'icon' => 'list-alt', 'url' => ['/options/options'], 'active' => \Yii::$app->controller->id == 'options', 'visible' => Yii::$app->user->can('confidential_information')], + [ + 'label' => 'Запрос интервью (' . \common\models\InterviewRequest::getNewCount() . ')', + 'icon' => 'list-alt', + 'url' => ['/interview/interview'], + 'active' => \Yii::$app->controller->id == 'interview', + 'visible' => Yii::$app->user->can('confidential_information'), + 'badge' => '4' + ], /*['label' => 'Gii', 'icon' => 'file-code-o', 'url' => ['/gii']], ['label' => 'Debug', 'icon' => 'dashboard', 'url' => ['/debug']], diff --git a/common/models/InterviewRequest.php b/common/models/InterviewRequest.php index 8608cb8..9a58d21 100644 --- a/common/models/InterviewRequest.php +++ b/common/models/InterviewRequest.php @@ -13,6 +13,7 @@ use Yii; * @property int $profile_id * @property int $user_id * @property int $created_at + * @property int $new * @property string $comment */ class InterviewRequest extends \yii\db\ActiveRecord @@ -32,7 +33,7 @@ class InterviewRequest extends \yii\db\ActiveRecord { return [ [['email'], 'required'], - [['profile_id', 'user_id', 'created_at'], 'integer'], + [['profile_id', 'user_id', 'created_at', 'new'], 'integer'], [['email', 'phone'], 'string', 'max' => 255], [['comment'], 'string'], ]; @@ -53,4 +54,28 @@ class InterviewRequest extends \yii\db\ActiveRecord 'comment' => 'Комментарий', ]; } + + /** + * @return \yii\db\ActiveQuery + */ + public function getProfile() + { + return $this->hasOne(UserCard::class, ['id' => 'profile_id']); + } + + /** + * @return \yii\db\ActiveQuery + */ + public function getUser() + { + return $this->hasOne(User::class, ['id' => 'user_id']); + } + + /** + * @return bool|int|string|null + */ + public static function getNewCount() + { + return self::find()->where(['new' => 1])->count(); + } } diff --git a/console/migrations/m210816_100534_add_new_column_to_interview_request_table.php b/console/migrations/m210816_100534_add_new_column_to_interview_request_table.php new file mode 100644 index 0000000..2dc5836 --- /dev/null +++ b/console/migrations/m210816_100534_add_new_column_to_interview_request_table.php @@ -0,0 +1,25 @@ +addColumn('{{%interview_request}}', 'new', $this->integer(1)->defaultValue(1)); + } + + /** + * {@inheritdoc} + */ + public function safeDown() + { + $this->dropColumn('{{%interview_request}}', 'new'); + } +} diff --git a/frontend/modules/api/controllers/ProfileController.php b/frontend/modules/api/controllers/ProfileController.php index d840714..5b471fc 100644 --- a/frontend/modules/api/controllers/ProfileController.php +++ b/frontend/modules/api/controllers/ProfileController.php @@ -62,6 +62,7 @@ class ProfileController extends \yii\rest\Controller $model = new InterviewRequest(); $model->attributes = \Yii::$app->request->post(); $model->created_at = time(); + $model->user_id = \Yii::$app->user->id; if ($model->save()){ return ['status' => 'success']; }