Ejemplo n.º 1
0
 /**
  * Finds the Vacancy model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Vacancy the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     $personId = \Yii::$app->user->identity->id;
     $vacancyId = $id;
     $vacancy = Vacancy::find()->innerJoin("person_vacancy_role", 'vacancy.id = person_vacancy_role.vacancy_id')->where(["person_vacancy_role.person_id" => $personId])->andWhere(["person_vacancy_role.role_id" => VacancyRoleHelper::OWNER])->andWhere(["vacancy.id" => $vacancyId])->one();
     if ($vacancy !== null) {
         return $vacancy;
     } else {
         throw new ForbiddenHttpException("You don't have access to this course");
     }
 }
Ejemplo n.º 2
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     //        $query = Vacancy::find()->joinWith(['firm', 'profession']);
     $query = Vacancy::find();
     $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;
     }
     $query->andFilterWhere(['id' => $this->id, 'firm_id' => $this->firm_id, 'profession_id' => $this->profession_id, 'salary' => $this->salary, 'workplace_id' => $this->workplace_id, 'rec_status_id' => $this->rec_status_id, 'user_id' => $this->user_id, 'dc' => $this->dc]);
     $query->andFilterWhere(['like', 'note', $this->note]);
     return $dataProvider;
 }
Ejemplo n.º 3
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Vacancy::find()->orderBy(['id' => SORT_DESC]);
     $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;
         //var_dump($dataProvider);
     }
     $query->andFilterWhere(['id' => $this->id, 'company_id' => $this->company_id, 'start_date' => $this->start_date, 'expired' => $this->expired]);
     $query->andFilterWhere(['like', 'position', $this->position])->andFilterWhere(['like', 'description', $this->description])->andFilterWhere(['like', 'location', $this->location])->andFilterWhere(['like', 'status', $this->status]);
     //->andFilterWhere(['like', 'name', $this->name]);
     return $dataProvider;
 }
Ejemplo n.º 4
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Vacancy::find();
     $query->joinWith(['workType']);
     $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;
     }
     $query->andFilterWhere(['hours_per_week' => $this->hours_per_week]);
     // Checkboxes
     $query->andFilterWhere(['like', 'contact_email', $this->contact_email])->andFilterWhere(['like', 'work_type.type', $this->workType])->andFilterWhere(['like', 'period_type.duration', $this->periodTypes]);
     // filter by country name
     return $dataProvider;
 }
Ejemplo n.º 5
0
 public function dataProvider()
 {
     $query = Vacancy::find();
     $dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => false]);
     if (!$this->validate()) {
         return $dataProvider;
     }
     //        $query->andFilterWhere([
     //            'hours_per_week' => $this->hours_per_week,
     //        ]);
     // Checkboxes
     $query->andFilterWhere(['type_work_id' => $this->workTypes])->andFilterWhere(['<=', 'hours_per_week', $this->max_hours]);
     // TODO: Multiple period types. Or/AND relation? Show all durations
     $query->joinWith(['periodTypes' => function ($q) {
         $q->andFilterWhere(['period_type.id' => $this->durations]);
     }]);
     $query->joinWith(['course' => function ($q) {
         $q->andFilterWhere(['course.id' => $this->courses]);
     }]);
     return $dataProvider;
 }
Ejemplo n.º 6
0
 private function _createReview($model, $student_id)
 {
     $model->writer_id = \Yii::$app->user->identity->getId();
     $model->receiver_id = $student_id;
     // TODO: fix date!
     $model->creation_date = "NOW()";
     $session = Yii::$app->session;
     $courseID = $session->get('create_review_session');
     // Get vacancy id from student Assistant for the course.
     // SELECT *
     // FROM vacancy
     // WHERE id IN
     //      (SELECT pcr.vancacy_id FROM person_vacancy_role as pcr WHERE pcr.person_id = $student_id)
     // AND id in
     //      (SELECT cvr.vacancy_id FROM course_vacancy as cvr WHERE cvr.course_id = $courseID)
     $pcrSubQuery = (new Query())->select("vacancy_id")->from("person_vacancy_role")->where(["person_id" => $student_id]);
     $cvSubQuery = (new Query())->select("vacancy_id")->from("course_vacancy")->where(["course_id" => $courseID]);
     $vacancy = Vacancy::find()->where(["in", "id", $pcrSubQuery])->andWhere(["in", "id", $cvSubQuery])->one();
     $model->vacancy_id = $vacancy->id;
     $this->getSession()['review_model'] = $model;
     return $this->render('writeReview', ['model' => $model]);
 }