interview back

This commit is contained in:
andrey 2021-08-16 14:32:54 +03:00
parent ec8b002838
commit 6f7c497d80
17 changed files with 534 additions and 3 deletions

View File

@ -53,6 +53,9 @@ return [
'options' => [
'class' => 'backend\modules\options\Options',
],
'interview' => [
'class' => 'backend\modules\interview\Interview',
],
],
'components' => [
'request' => [

View File

@ -0,0 +1,24 @@
<?php
namespace backend\modules\interview;
/**
* interview module definition class
*/
class Interview extends \yii\base\Module
{
/**
* {@inheritdoc}
*/
public $controllerNamespace = 'backend\modules\interview\controllers';
/**
* {@inheritdoc}
*/
public function init()
{
parent::init();
// custom initialization code goes here
}
}

View File

@ -0,0 +1,20 @@
<?php
namespace backend\modules\interview\controllers;
use yii\web\Controller;
/**
* Default controller for the `interview` module
*/
class DefaultController extends Controller
{
/**
* Renders the index view for the module
* @return string
*/
public function actionIndex()
{
return $this->render('index');
}
}

View File

@ -0,0 +1,133 @@
<?php
namespace backend\modules\interview\controllers;
use Yii;
use backend\modules\interview\models\InterviewRequest;
use backend\modules\interview\models\InterviewRequestSearch;
use yii\web\Controller;
use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter;
/**
* InterviewController implements the CRUD actions for InterviewRequest model.
*/
class InterviewController extends Controller
{
/**
* {@inheritdoc}
*/
public function behaviors()
{
return [
'verbs' => [
'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.');
}
}

View File

@ -0,0 +1,8 @@
<?php
namespace backend\modules\interview\models;
class InterviewRequest extends \common\models\InterviewRequest
{
}

View File

@ -0,0 +1,75 @@
<?php
namespace backend\modules\interview\models;
use yii\base\Model;
use yii\data\ActiveDataProvider;
use backend\modules\interview\models\InterviewRequest;
/**
* InterviewRequestSearch represents the model behind the search form of `backend\modules\interview\models\InterviewRequest`.
*/
class InterviewRequestSearch extends InterviewRequest
{
/**
* {@inheritdoc}
*/
public function rules()
{
return [
[['id', 'profile_id', 'user_id', 'created_at'], 'integer'],
[['email', 'phone', 'comment'], 'safe'],
];
}
/**
* {@inheritdoc}
*/
public function scenarios()
{
// bypass scenarios() implementation in the parent class
return Model::scenarios();
}
/**
* Creates data provider instance with search query applied
*
* @param array $params
*
* @return ActiveDataProvider
*/
public function search($params)
{
$query = InterviewRequest::find();
// add conditions that should always apply here
$dataProvider = new ActiveDataProvider([
'query' => $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;
}
}

View File

@ -0,0 +1,12 @@
<div class="interview-default-index">
<h1><?= $this->context->action->uniqueId ?></h1>
<p>
This is the view content for action "<?= $this->context->action->id ?>".
The action belongs to the controller "<?= get_class($this->context) ?>"
in the "<?= $this->context->module->id ?>" module.
</p>
<p>
You may customize this page by editing the following file:<br>
<code><?= __FILE__ ?></code>
</p>
</div>

View File

@ -0,0 +1,33 @@
<?php
use yii\helpers\Html;
use yii\widgets\ActiveForm;
/* @var $this yii\web\View */
/* @var $model backend\modules\interview\models\InterviewRequest */
/* @var $form yii\widgets\ActiveForm */
?>
<div class="interview-request-form">
<?php $form = ActiveForm::begin(); ?>
<?= $form->field($model, 'email')->textInput(['maxlength' => true]) ?>
<?= $form->field($model, 'phone')->textInput(['maxlength' => true]) ?>
<?= $form->field($model, 'profile_id')->textInput() ?>
<?= $form->field($model, 'user_id')->textInput() ?>
<?= $form->field($model, 'comment')->textarea(['rows' => 6]) ?>
<?= $form->field($model, 'created_at')->textInput() ?>
<div class="form-group">
<?= Html::submitButton('Save', ['class' => 'btn btn-success']) ?>
</div>
<?php ActiveForm::end(); ?>
</div>

View File

@ -0,0 +1,39 @@
<?php
use yii\helpers\Html;
use yii\widgets\ActiveForm;
/* @var $this yii\web\View */
/* @var $model backend\modules\interview\models\InterviewRequestSearch */
/* @var $form yii\widgets\ActiveForm */
?>
<div class="interview-request-search">
<?php $form = ActiveForm::begin([
'action' => ['index'],
'method' => 'get',
]); ?>
<?= $form->field($model, 'id') ?>
<?= $form->field($model, 'email') ?>
<?= $form->field($model, 'phone') ?>
<?= $form->field($model, 'profile_id') ?>
<?= $form->field($model, 'user_id') ?>
<?php // echo $form->field($model, 'comment') ?>
<?php // echo $form->field($model, 'created_at') ?>
<div class="form-group">
<?= Html::submitButton('Search', ['class' => 'btn btn-primary']) ?>
<?= Html::resetButton('Reset', ['class' => 'btn btn-default']) ?>
</div>
<?php ActiveForm::end(); ?>
</div>

View File

@ -0,0 +1,20 @@
<?php
use yii\helpers\Html;
/* @var $this yii\web\View */
/* @var $model backend\modules\interview\models\InterviewRequest */
$this->title = 'Create Interview Request';
$this->params['breadcrumbs'][] = ['label' => 'Interview Requests', 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="interview-request-create">
<h1><?= Html::encode($this->title) ?></h1>
<?= $this->render('_form', [
'model' => $model,
]) ?>
</div>

View File

@ -0,0 +1,45 @@
<?php
use yii\helpers\Html;
use yii\grid\GridView;
/* @var $this yii\web\View */
/* @var $searchModel backend\modules\interview\models\InterviewRequestSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */
$this->title = 'Запрос интервью';
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="interview-request-index">
<?php // echo $this->render('_search', ['model' => $searchModel]); ?>
<?= GridView::widget([
'dataProvider' => $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'],
],
]); ?>
</div>

View File

@ -0,0 +1,21 @@
<?php
use yii\helpers\Html;
/* @var $this yii\web\View */
/* @var $model backend\modules\interview\models\InterviewRequest */
$this->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';
?>
<div class="interview-request-update">
<h1><?= Html::encode($this->title) ?></h1>
<?= $this->render('_form', [
'model' => $model,
]) ?>
</div>

View File

@ -0,0 +1,39 @@
<?php
use yii\helpers\Html;
use yii\widgets\DetailView;
/* @var $this yii\web\View */
/* @var $model backend\modules\interview\models\InterviewRequest */
$this->title = $model->phone;
$this->params['breadcrumbs'][] = ['label' => 'Interview Requests', 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
\yii\web\YiiAsset::register($this);
?>
<div class="interview-request-view">
<p>
<?= Html::a('Удалить', ['delete', 'id' => $model->id], [
'class' => 'btn btn-danger',
'data' => [
'confirm' => 'Are you sure you want to delete this item?',
'method' => 'post',
],
]) ?>
<?= Html::a('Список', ['index'], ['class' => 'btn btn-primary',]) ?>
</p>
<?= DetailView::widget([
'model' => $model,
'attributes' => [
//'id',
'email:email',
'phone',
'profile.fio',
'user.email',
'comment:ntext',
'created_at',
],
]) ?>
</div>

View File

@ -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' => '<span class="badge badge-info right">4</span>'
],
/*['label' => 'Gii', 'icon' => 'file-code-o', 'url' => ['/gii']],
['label' => 'Debug', 'icon' => 'dashboard', 'url' => ['/debug']],

View File

@ -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();
}
}

View File

@ -0,0 +1,25 @@
<?php
use yii\db\Migration;
/**
* Handles adding columns to table `{{%interview_request}}`.
*/
class m210816_100534_add_new_column_to_interview_request_table extends Migration
{
/**
* {@inheritdoc}
*/
public function safeUp()
{
$this->addColumn('{{%interview_request}}', 'new', $this->integer(1)->defaultValue(1));
}
/**
* {@inheritdoc}
*/
public function safeDown()
{
$this->dropColumn('{{%interview_request}}', 'new');
}
}

View File

@ -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'];
}