Example #1
0
 /**
  * Activating vacancy form email link
  * @param $hash
  */
 public function actionActivate_vacancy($hash)
 {
     $hasError = true;
     $errorMessage = '';
     if (!empty($hash)) {
         $vacancy = Vacancy::model()->findByAttributes(['hash' => $hash]);
         if (!empty($vacancy)) {
             $vacancy->status = Vacancy::STATUS_OPEN;
             $vacancy->updated_by = $vacancy->user->id;
             $vacancy->close_time = new CDbExpression('NOW() + INTERVAL ' . Vacancy::INTERVAL_OPENED . ' DAY');
             $vacancy->hash = null;
             if ($vacancy->save()) {
                 $hasError = false;
                 Yii::app()->user->setFlash('success', Yii::t('main', 'vacancy.email.deactivate.message.success', [':date' => date("Y-m-d H:i:s", strtotime('+14day'))]));
             } else {
                 foreach ($vacancy->getErrors() as $err) {
                     $errorMessage .= " " . implode(";", $err);
                 }
             }
         }
     }
     if ($hasError) {
         Yii::app()->user->setFlash('error', Yii::t('main', 'vacancy.email.deactivate.message.error', [':message' => $errorMessage]));
     }
     if (Yii::app()->user->isGuest) {
         $this->redirect('/manage/login');
     } else {
         $this->redirect('/manage/employer/index');
     }
 }
Example #2
0
 /**
  * @param $id
  * @return Vacancy
  * @throws CHttpException
  */
 private function getVacancy($id)
 {
     $vacancy = Vacancy::model()->findByPk($id);
     if (empty($vacancy)) {
         throw new CHttpException(404, 'Vacancy not found');
     }
     return $vacancy;
 }
Example #3
0
 public static function getLastReview()
 {
     $criteria = new CDbCriteria();
     $criteria->condition = 'active = ' . self::STATUS_ACTIVE;
     $criteria->limit = 1;
     $criteria->order = 'date_created DESC';
     $lastReview = Vacancy::model()->find($criteria);
     return $lastReview;
 }
Example #4
0
 /**
  * Finds and deactivates out of date  vacancies
  */
 public function actionDeactivate()
 {
     echo "Start.." . PHP_EOL;
     $vacancies = Vacancy::model()->findAll('status=:status AND close_time < :close_time', [':status' => Vacancy::STATUS_OPEN, ':close_time' => date("Y-m-d H:i:s", time())]);
     foreach ($vacancies as $vacancy) {
         /* @var $vacancy Vacancy */
         echo $vacancy->id . PHP_EOL;
         $this->deactivateVacancy($vacancy);
         $this->sendMessage($vacancy);
     }
 }
Example #5
0
 public function actionIndex()
 {
     $criteria = new CDbCriteria();
     //$criteria->order = 'sorter';
     $criteria->order = 'date_created DESC';
     $criteria->condition = 'active=' . Vacancy::STATUS_ACTIVE;
     $pages = new CPagination(Vacancy::model()->count($criteria));
     $pages->pageSize = param('module_vacancy_itemsPerPage', 10);
     $pages->applyLimit($criteria);
     $vacancy = Vacancy::model()->cache(param('cachingTime', 1209600), Vacancy::getCacheDependency())->findAll($criteria);
     $this->render('index', array('vacancy' => $vacancy, 'pages' => $pages));
 }