public function actionResume() { // Xu ly avatar $modelUser = User::findOne(Yii::$app->user->id); if ($modelUser == null) { throw new NotFoundHttpException('The requested page does not exist.'); } $modelUserJob = UserJob::findOne(Yii::$app->user->id); if ($modelUserJob == null) { throw new NotFoundHttpException('The requested page does not exist.'); } $model = UserJobSeekerResume::findOne(Yii::$app->user->id); if ($model == null) { $model = new UserJobSeekerResume(); $model->_id = Yii::$app->user->id; $model->nationality = $modelUserJob->seeker_nationality; $model->salary = $modelUserJob->seeker_salary; $model->candidate_id = UserJob::getNextSequence('seeker'); } $employments = UserJobSeekerEmployment::find()->where(['seeker_id' => Yii::$app->user->id])->indexBy('_id')->all(); if ($employments == null) { $employments = new UserJobSeekerEmployment(); $employments->seeker_id = $model->_id; } if ($model->load(Yii::$app->request->post()) && $modelUser->load(Yii::$app->request->post())) { // Sync data $model->phone_number = $modelUser->phone; // UserJobSeekerResume::search() có dùng đến phone_number nên cần đồng bộ chỗ này $modelValidate = $model->validate(); $modelUserValidate = $modelUser->validate(); if (!is_array($employments)) { $employments->load(Yii::$app->request->post()); $employmentsValidate = $employments->validate(); } else { $employmentsValidate = Model::loadMultiple($employments, Yii::$app->request->post()) && Model::validateMultiple($employments); } if ($employmentsValidate && $modelValidate && $modelUserValidate && $model->save(false) && $modelUser->save(false)) { $modelUserJob->seeker_nationality = $model->nationality; $modelUserJob->seeker_salary = $model->salary; $modelUserJob->save(); if (!is_array($employments)) { $employments->save(); //update latest company and position for seeker resume document $model->latest_company = $employments->company_name; $model->latest_position = $employments->position; $model->save(false); } else { if (isset($employmentsValidate) && $employmentsValidate == true) { $i = 1; $max = sizeof($employments); foreach ($employments as $employment) { $employment->save(false); if ($i == $max) { // is latest employment iformation //update latest company and position for seeker resume document $model->latest_company = $employment->company_name; $model->latest_position = $employment->position; $model->save(false); } $i++; } } } Yii::$app->getSession()->setFlash('flash', ['type' => 'success', 'title' => Yii::t('common', 'Message'), 'message' => Yii::t('common', 'Your information has been saved successfully.'), 'duration' => 10000]); return $this->refresh(); } } Yii::$app->view->title = Yii::t($this->module->id, 'Resume'); Yii::$app->view->params['breadcrumbs'][] = Yii::$app->view->title; return $this->render('resume', ['model' => $model, 'modelUser' => $modelUser, 'employments' => $employments]); }
public function actionEditProfile() { $jobModel = UserJob::findOne(['_id' => Yii::$app->user->identity->_id]); $jobModel->scenario = "edit_recruiter"; $model = User::findOne(['_id' => Yii::$app->user->identity->_id]); $model->scenario = "edit_recruiter"; if ($model->load(Yii::$app->request->post()) && $jobModel->load(Yii::$app->request->post())) { $modelValidate = $model->validate(); $jobModelValidate = $jobModel->validate(); if ($modelValidate && $jobModelValidate) { if ($model->save(false)) { if ($jobModel->save(false)) { Yii::$app->getSession()->setFlash('flash', ['type' => 'success', 'title' => Yii::t('account', 'Message'), 'message' => Yii::t('account', 'Updated succesfully.'), 'duration' => 10000]); return $this->redirect(['view-profile']); } } } } Yii::$app->view->title = Yii::t($this->module->id, 'Edit Profile'); Yii::$app->view->params['breadcrumbs'][] = Yii::$app->view->title; return $this->render('edit-profile', ['model' => $model, 'jobModel' => $jobModel]); }
public function getUserJobPosted() { return \app\modules\job\models\UserJob::findOne(['_id' => $this->created_by]); }
public static function getHighPotentialCandidate($agentId = null) { $dataProvider = null; //get agent functions $agent = UserJob::findOne(['role' => 'recruiter', '_id' => $agentId]); if ($agent) { //get seekers fit to agent $model = new UserJobSeekerResume(); $model->functions = $agent->agent_job_function; $model->industries = $agent->agent_job_industry; $dataProvider = $model->search(Yii::$app->request->getQueryParams()); } return $dataProvider; }
/** * Finds the UserJob model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $_id * @return UserJob the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = UserJob::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }