From 25e922cd377d118eddf124dbad4c239f5d150538 Mon Sep 17 00:00:00 2001 From: Kavalar Date: Fri, 23 Nov 2018 16:09:29 +0300 Subject: [PATCH] hh fix, profile fix --- .../card/controllers/UserCardController.php | 3 +++ .../modules/card/views/user-card/_form.php | 5 +--- .../modules/card/views/user-card/index.php | 16 +++++++++++- .../modules/hh/controllers/HhController.php | 12 ++++++++- backend/modules/hh/views/hh/view.php | 22 ++++++++++++++++ .../project/controllers/ProjectController.php | 15 ++++++++++- .../modules/project/views/project/view.php | 25 +++++++++++++++++++ common/models/Status.php | 9 +++++++ 8 files changed, 100 insertions(+), 7 deletions(-) diff --git a/backend/modules/card/controllers/UserCardController.php b/backend/modules/card/controllers/UserCardController.php index 65be193..2bad674 100644 --- a/backend/modules/card/controllers/UserCardController.php +++ b/backend/modules/card/controllers/UserCardController.php @@ -6,6 +6,7 @@ use common\classes\Debug; use common\models\AdditionalFields; use common\models\CardSkill; use common\models\FieldsValue; +use common\models\Status; use Yii; use backend\modules\card\models\UserCard; use backend\modules\card\models\UserCardSearch; @@ -41,6 +42,8 @@ class UserCardController extends Controller */ public function actionIndex() { + $status = new Status(); + //Debug::dd($status->getUseStatuses()); $searchModel = new UserCardSearch(); $dataProvider = $searchModel->search(Yii::$app->request->queryParams); diff --git a/backend/modules/card/views/user-card/_form.php b/backend/modules/card/views/user-card/_form.php index 4bb0359..c710dc8 100644 --- a/backend/modules/card/views/user-card/_form.php +++ b/backend/modules/card/views/user-card/_form.php @@ -91,10 +91,7 @@ use yii\widgets\ActiveForm;
field($model, 'status') - ->dropDownList(\yii\helpers\ArrayHelper::map( - \common\models\Status::find() - ->joinWith('useStatuses') - ->where(['`use_status`.`use`' => \common\models\UseStatus::USE_PROFILE])->all(), 'id', 'name'), + ->dropDownList(\common\models\Status::getStatusesArray(\common\models\UseStatus::USE_PROFILE), [ 'prompt' => 'Выберите' ] diff --git a/backend/modules/card/views/user-card/index.php b/backend/modules/card/views/user-card/index.php index 6cfdf3e..21030e6 100644 --- a/backend/modules/card/views/user-card/index.php +++ b/backend/modules/card/views/user-card/index.php @@ -38,7 +38,21 @@ $this->params['breadcrumbs'][] = $this->title; 'email:email', //'gender', //'dob', - //'status', + [ + 'attribute' => 'status', + 'value' => function($model){ + return $model->status0->name; + }, + 'filter' => kartik\select2\Select2::widget([ + 'model' => $searchModel, + 'attribute' => 'status', + 'data' => \common\models\Status::getStatusesArray(\common\models\UseStatus::USE_PROFILE), + 'options' => ['placeholder' => 'Начните вводить...','class' => 'form-control'], + 'pluginOptions' => [ + 'allowClear' => true + ], + ]), + ], //'created_at', //'updated_at', diff --git a/backend/modules/hh/controllers/HhController.php b/backend/modules/hh/controllers/HhController.php index b96c27c..971fd5e 100644 --- a/backend/modules/hh/controllers/HhController.php +++ b/backend/modules/hh/controllers/HhController.php @@ -8,6 +8,7 @@ use common\models\HhJob; use Yii; use backend\modules\hh\models\Hh; use backend\modules\hh\models\HhSearch; +use yii\data\ActiveDataProvider; use yii\web\Controller; use yii\web\NotFoundHttpException; use yii\filters\VerbFilter; @@ -55,8 +56,17 @@ class HhController extends Controller */ public function actionView($id) { + $model = $this->findModel($id); + $jobs = new ActiveDataProvider([ + 'query' => HhJob::find()->where(['employer_id' => $model->hh_id]), + 'pagination' => [ + 'pageSize' => 200, + ], + ]); + return $this->render('view', [ - 'model' => $this->findModel($id), + 'model' => $model, + 'jobs' => $jobs, ]); } diff --git a/backend/modules/hh/views/hh/view.php b/backend/modules/hh/views/hh/view.php index 33bf172..a8679b0 100644 --- a/backend/modules/hh/views/hh/view.php +++ b/backend/modules/hh/views/hh/view.php @@ -1,5 +1,6 @@ params['breadcrumbs'][] = $this->title; 'photo:image', ], ]) ?> +
+

Вакансии

+ $jobs, + 'columns' => [ + ['class' => 'yii\grid\SerialColumn'], + + 'title', + 'url:url', + 'salary_from', + 'salary_to', + 'salary_currency', + 'address', + 'dt_add:date', + + [ + 'class' => 'yii\grid\ActionColumn', + 'template' => '{view} {delete}' + ], + ], + ]); ?>
diff --git a/backend/modules/project/controllers/ProjectController.php b/backend/modules/project/controllers/ProjectController.php index d1c6351..6d0f26d 100644 --- a/backend/modules/project/controllers/ProjectController.php +++ b/backend/modules/project/controllers/ProjectController.php @@ -3,6 +3,8 @@ namespace backend\modules\project\controllers; use common\models\FieldsValue; +use common\models\Hh; +use common\models\HhJob; use common\models\ProjectUser; use Yii; use backend\modules\project\models\Project; @@ -55,6 +57,16 @@ class ProjectController extends Controller */ public function actionView($id) { + $model = $this->findModel($id); + $hh = Hh::findOne($model->hh_id); + + $jobsProvider = new ActiveDataProvider([ + 'query' => HhJob::find()->where(['employer_id' => $hh->hh_id]), + 'pagination' => [ + 'pageSize' => 200, + ], + ]); + $dataProvider = new ActiveDataProvider([ 'query' => FieldsValue::find()->where(['project_id' => $id])->orderBy('order'), 'pagination' => [ @@ -70,9 +82,10 @@ class ProjectController extends Controller ]); return $this->render('view', [ - 'model' => $this->findModel($id), + 'model' => $model, 'modelFildValue' => $dataProvider, 'modelUser' => $dataProviderUser, + 'jobsProvider' => $jobsProvider, ]); } diff --git a/backend/modules/project/views/project/view.php b/backend/modules/project/views/project/view.php index b9b5f5f..82607df 100644 --- a/backend/modules/project/views/project/view.php +++ b/backend/modules/project/views/project/view.php @@ -30,6 +30,10 @@ $this->params['breadcrumbs'][] = $this->title; 'attributes' => [ 'id', 'name', + [ + 'label' => 'Сраница на hh.ru', + 'attribute' => 'hh.url' + ], 'description:ntext', 'created_at', 'updated_at', @@ -76,4 +80,25 @@ $this->params['breadcrumbs'][] = $this->title; ], ], ]); ?> + +

Вакансии hh.ru

+ $jobsProvider, + 'columns' => [ + ['class' => 'yii\grid\SerialColumn'], + + 'title', + 'url:url', + 'salary_from', + 'salary_to', + 'salary_currency', + 'address', + 'dt_add:date', + + [ + 'class' => 'yii\grid\ActionColumn', + 'template' => '{view} {delete}' + ], + ], + ]); ?> diff --git a/common/models/Status.php b/common/models/Status.php index be8e6a2..c772852 100644 --- a/common/models/Status.php +++ b/common/models/Status.php @@ -3,6 +3,7 @@ namespace common\models; use Yii; +use yii\helpers\ArrayHelper; /** * This is the model class for table "status". @@ -56,6 +57,14 @@ class Status extends \yii\db\ActiveRecord return $this->hasMany(UseStatus::class, ['status_id' => 'id']); } + public static function getStatusesArray($type) + { + return ArrayHelper::map( + self::find() + ->joinWith('useStatuses') + ->where(['`use_status`.`use`' => $type])->all(), 'id', 'name'); + } + /** * @return \yii\db\ActiveQuery */