Пример #1
0
 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]);
 }
Пример #2
0
 /**
  * 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]);
     }
 }
Пример #3
0
 /**
  * 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();
     //Подставляем значения по умолчанию
     $model->firm_id = \app\models\User::findOne(Yii::$app->user->id)->firm_id;
     $model->workplace_id = \app\models\User::findOne(Yii::$app->user->id)->workplace_id;
     $model->date = Yii::$app->getFormatter()->asDate(time());
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         Yii::$app->getSession()->addFlash('success', "Запись #{$model->id} успешно добавлена.");
         return $this->redirect(Url::previous() != Yii::$app->homeUrl ? Url::previous() : ['view', 'id' => $model->id]);
     } else {
         if (Yii::$app->request->referrer != Yii::$app->request->absoluteUrl) {
             Url::remember(Yii::$app->request->referrer ? Yii::$app->request->referrer : null);
         }
         if (!Yii::$app->request->isPost) {
             $model->load(Yii::$app->request->get());
         }
         return $this->render('create', ['model' => $model]);
     }
 }
Пример #4
0
 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);
 }