public function index() { $vacancies = Vacancy::orderBy('vacancy_group_id', 'ASC')->orderBy('position', 'ASC')->get(); $vacancy = new Vacancy(); if (Request::isMethod('post')) { $validator = Validator::make(Request::all(), $this->rules); if ($validator->passes()) { $vacancy->vacancy_group_id = Request::input('vacancy_group_id'); $vacancy->agency_id = Request::input('agency_id'); $vacancy->title = Request::input('title'); $vacancy->announce = Request::input('announce'); $vacancy->position = Request::input('position'); $vacancy->enabled = Request::has('enabled'); $vacancy->city = Request::input('city'); $vacancy->text = Request::input('text'); $vacancy->duties = Request::input('duties'); $vacancy->requirements = Request::input('requirements'); $vacancy->circs = Request::input('circs'); $vacancy->office = Request::input('office'); $vacancy->save(); return redirect('admin/vacancy')->with('msg', 'Вакансия была успешно создана'); } else { return redirect('admin/vacancy')->withInput()->withErrors($validator); } } return view('admin.vacancy', ['vacancies' => $vacancies, 'vacancy' => $vacancy]); }
/** * Creates a new Vacancy model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $model = new Vacancy(); if ($model->load(Yii::$app->request->post()) && $model->save()) { return $this->redirect(['view', 'id' => $model->id]); } else { return $this->render('create', ['model' => $model]); } }
/** * 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) { if (($model = Vacancy::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
public function hr() { $email = trim(Request::input('email')); $text = trim(Request::input('text')); $name = trim(Request::input('name')); $vacancyId = intval(Request::input('vacancyId')); $traineeship = intval(Request::input('traineeship')) ? true : false; $text = nl2br(htmlspecialchars($text, ENT_COMPAT, 'UTF-8')); $fileUrl = null; if ($traineeship) { $title = $name . ' прислал(а) резюме на стажировку'; } else { $vacancy = Vacancy::findOrFail($vacancyId); $group = $vacancy->vacancyGroup; $title = "{$name} прислал(а) резюме на вакансию «{$vacancy}» раздела «{$group}»"; } $text = "<p>{$title}</p><p>Email: <a href=mailto:{$email}>{$email}</a></p>" . $text; $to = $traineeship ? '*****@*****.**' : '*****@*****.**'; //$to = '*****@*****.**'; if (empty($name) || mb_strlen($name, 'UTF-8') < 2) { return Response::json(['status' => 'SHORT_NAME']); } elseif (empty($email) || !filter_var($email, FILTER_VALIDATE_EMAIL)) { return Response::json(['status' => 'FAIL']); } elseif (empty($text) || mb_strlen($text, 'UTF-8') < 7) { return Response::json(['status' => 'SHORT']); } $hr = new Hr(); $hr->to = $to; $hr->from = $email; $hr->text = $text; $hr->name = $name; $hr->title = $title; $hr->traineeship = $traineeship; if ($vacancyId) { $hr->vacancy_id = $vacancyId; } $fileName = ""; if ($file = Request::file('resume')) { $file = Request::file('resume'); $fileName = sha1(uniqid() . md5(time() . rand(111, 999))) . "." . $file->getClientOriginalExtension(); if ($file->move(storage_path("resume"), $fileName) == false) { return Response::json(['status' => 'FILE']); } } if ($fileName != "") { $result = Mailer::send($to, ['emails.feedback', ['text' => $text]], $title, $email, storage_path("resume/" . $fileName), $fileName); $result = Mailer::send($email, ['emails.feedback_thanks', ['text' => $text]], "[TWIGA] Autoreply", "*****@*****.**"); unlink(storage_path("resume/" . $fileName)); return $result ? Response::json(['status' => 'OK']) : Response::json(['status' => 'FAIL']); } else { return Response::json(['status' => 'FILE']); } }
/** * Creates a new Review model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate($vacancyId) { $model = new Review(); $vacancy = Vacancy::findOne($vacancyId); if ($vacancy === null) { throw new HttpException(404, "This vacancy the Students Assistent is working for is not found"); } $model->vacancy_id = $vacancyId; if ($model->load(Yii::$app->request->post()) && $model->save()) { return $this->redirect(['view', 'id' => $model->id]); } else { return $this->render('create', ['model' => $model]); } }
/** * 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; }
/** * 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; }
/** * 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; }
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; }
public static function search($term) { $count = 0; $l = Session::get('locale'); $fields = "title_{$l},' ',content_{$l},' ',summary_{$l}"; $results['results']['news'] = News::select(DB::raw("*,concat('news/',slug) as link"))->where(DB::raw("concat({$fields})"), 'like', "%{$term}%")->get(); $count += count($results['results']['news']); $fields = "title_{$l},' ',content_{$l},' ',summary_{$l}"; $results['results']['pages'] = Page::select(DB::raw("*,concat('pages/',slug) as link"))->where(DB::raw("concat({$fields})"), 'like', "%{$term}%")->get(); $count += count($results['results']['pages']); $fields = "title_{$l}"; $results['results']['publications'] = Publication::select(DB::raw("*,file_{$l} as link"))->where(DB::raw("concat({$fields})"), 'like', "%{$term}%")->get(); $count += count($results['results']['publications']); $fields = "title_{$l},' ',content_{$l},' ',summary_{$l}"; $results['results']['trainings'] = Training::select(DB::raw("*,concat('trainings/',slug) as link"))->where(DB::raw("concat({$fields})"), 'like', "%{$term}%")->get(); $count += count($results['results']['trainings']); $fields = "title_{$l},' ',content_{$l},' ',summary_{$l}"; $results['results']['vacancies'] = Vacancy::select(DB::raw("*,concat('vacancies/',slug) as link"))->where(DB::raw("concat({$fields})"), 'like', "%{$term}%")->get(); $count += count($results['results']['vacancies']); $results['count'] = $count; return $results; }
/** * Store a newly created resource in storage. * * @return Response */ public function store(Business $business, Request $request) { $this->log->info(__METHOD__); $this->log->info(sprintf(" businessId:%s", $business->id)); /////////////////////////////// // TODO: AUTH GATE GOES HERE // /////////////////////////////// ////////////////// // FOR REFACTOR // ////////////////// $dates = $request->get('vacancy'); $changed = false; foreach ($dates as $date => $vacancy) { foreach ($vacancy as $serviceId => $capacity) { switch (trim($capacity)) { case '': // Dont update, leave as is $this->log->info("Blank vacancy capacity value"); break; default: $start_at = Carbon::parse($date . ' ' . $business->pref('start_at'))->timezone($business->timezone); $finish_at = Carbon::parse($date . ' ' . $business->pref('finish_at', '20:00:00'))->timezone($business->timezone); $vacancy = Vacancy::updateOrCreate(['business_id' => $business->id, 'service_id' => $serviceId, 'date' => $date], ['capacity' => intval($capacity), 'start_at' => $start_at, 'finish_at' => $finish_at]); $changed = true; break; } } } if (!$changed) { $this->log->warning("Nothing to update"); Flash::warning(trans('manager.vacancies.msg.store.nothing_changed')); return redirect()->back(); } $this->log->warning("Vacancies updated"); Flash::success(trans('manager.vacancies.msg.store.success')); return redirect()->route('manager.business.show', [$business]); }
protected function publishVacancy($business, $date, $service, $statement) { $date = $statement['date']; $startAt = $statement['startAt']; $finishAt = $statement['finishAt']; $startAt = Carbon::parse("{$date} {$startAt} {$business->timezone}")->timezone('UTC'); $finishAt = Carbon::parse("{$date} {$finishAt} {$business->timezone}")->timezone('UTC'); $vacancyValues = ['business_id' => $business->id, 'service_id' => $service->id, 'date' => $statement['date'], 'capacity' => intval($statement['capacity']), 'start_at' => $startAt, 'finish_at' => $finishAt]; $vacancy = Vacancy::create($vacancyValues); return $vacancy !== null; }
/** * @return \yii\db\ActiveQuery */ public function getVacancies() { return $this->hasMany(Vacancy::className(), ['company_id' => 'id']); }
/** * @return \yii\db\ActiveQuery */ public function getVacancy() { return $this->hasOne(Vacancy::className(), ['id' => 'vacancy_id']); }
/** * Show the form for editing the specified resource. * * @param int $id * @return Response */ public function publish($slug) { $vacancy = Vacancy::findBySlug($slug); $vacancy->update(['is_published' => $vacancy->is_published ? 0 : 1]); return Redirect::route('vacancies.admin'); }
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]); }
/** * @return \yii\db\ActiveQuery */ public function getVacancies() { return $this->hasMany(Vacancy::className(), ['rec_status_id' => 'id']); }
public function createnewstep3() { $model = new Vacancy(); $preferences = new Preferences(); $data = Yii::$app->request->post(); $model->load($data); $preferences->load($data); $transaction = \Yii::$app->db->beginTransaction(); try { //TODO check for errors and cancel transaction $model->save(); $model->savePreferences($preferences); $connection = \Yii::$app->db; // TODO Place this in preferences logic $connection->createCommand("INSERT INTO person_vacancy_role (person_id, vacancy_id, role_id) " . "VALUES (:person_id, :vacancy_id, :role_id)")->bindValues([":person_id" => \YII::$app->getUser()->getIdentity()->getId(), ":vacancy_id" => $model->getPrimaryKey(), ":role_id" => VacancyRoleHelper::OWNER])->execute(); // Vacanty - course_id $course_id = $this->getSession()['create-new-vacancy-course-id']; if (isset($course_id) && $course_id != "none") { $connection->createCommand("INSERT INTO course_vacancy (course_id, vacancy_id) VALUES (:course_id, :vacancy_id)")->bindValues([":course_id" => $course_id, ":vacancy_id" => $model->getPrimaryKey()])->execute(); } $transaction->commit(); } catch (\Exception $e) { $transaction->rollBack(); throw $e; } return $this->actionView($model->id); }
public static function latest($n = 4) { return Vacancy::orderBy('created_at', 'DESC')->limit($n)->get(); }
public function hasRoom(Appointment $appointment, Vacancy $vacancy) { return $vacancy->hasRoom(); }
/** * @return The vacancies this Course has available */ public function getVacancies() { return $this->hasMany(Vacancy::className(), ['id' => 'course_id'])->viaTable('course_vacancy', ['vacancy_id' => 'id']); }
/** * Returns all vacancies this person has * * @return \yii\db\ActiveQuery Vacancy */ public function getVacancies() { return $this->hasMany(Vacancy::className(), ['id' => 'vacancy_id'])->viaTable('person_vacancy_role', ['person_id' => 'id']); }
protected function chunkTimeslots(Vacancy $vacancy, $step = 30) { $times = []; $startTime = $vacancy->start_at->timezone($vacancy->business->timezone)->toTimeString(); $startKey = date('Y-m-d H:i', strtotime("{$vacancy->date} {$startTime}")) . ' ' . $vacancy->business->timezone; $finishTime = $vacancy->finish_at->timezone($vacancy->business->timezone)->toTimeString(); $endKey = date('Y-m-d H:i', strtotime("{$vacancy->date} {$finishTime}")) . ' ' . $vacancy->business->timezone; $fromTime = Carbon::parse($startKey); $toTime = $fromTime->copy()->addMinutes($step); $limit = Carbon::parse($endKey); while ($fromTime <= $limit) { $key = $fromTime->timezone($vacancy->business->timezone)->format('H:i'); $capacity = $vacancy->getAvailableCapacityBetween($fromTime, $toTime); if ($capacity > 0) { $times[$key] = $capacity; } $toTime->addMinutes($step); $fromTime->addMinutes($step); } return $times; }
/** * Update vacancies. * * @param Business $business * @param array $dates * * @return bool */ public function update(Business $business, $dates) { $changed = false; foreach ($dates as $date => $vacancy) { foreach ($vacancy as $serviceId => $capacity) { switch (trim($capacity)) { case '': // Dont update, leave as is logger()->info(sprintf('businessId:%s %s: Blank vacancy capacity value', $business->id, $date)); break; default: $startAt = Carbon::parse($date . ' ' . $business->pref('start_at') . ' ' . $business->timezone); $finishAt = Carbon::parse($date . ' ' . $business->pref('finish_at') . ' ' . $business->timezone); $vacancyKeys = ['business_id' => $business->id, 'service_id' => $serviceId, 'date' => $date]; $vacancyValues = ['capacity' => intval($capacity), 'start_at' => $startAt, 'finish_at' => $finishAt]; $vacancy = Vacancy::updateOrCreate($vacancyKeys, $vacancyValues); $changed = true; break; } } } return $changed; }