コード例 #1
0
 public function save($userId, $cvFileName, $pfFileName)
 {
     if ($userId !== null) {
         $transaction = Yii::app()->db->beginTransaction();
         try {
             foreach ($this->jobTitles as $jobTitle) {
                 $studentJobTitle = new StudentJobTitle();
                 $studentJobTitle->user_id = $userId;
                 $studentJobTitle->job_title_id = $jobTitle;
                 $studentJobTitle->job_type_id = $this->jobType;
                 $studentJobTitle->resume_file = $cvFileName;
                 //if($pfFileName != NULL)
                 //{
                 $studentJobTitle->portfolio_file = $pfFileName;
                 //}
                 $studentJobTitle->ECWS_id = $this->ecwsCourse;
                 $studentJobTitle->skills = $this->skills;
                 $studentJobTitle->date_created = new CDbExpression('NOW()');
                 $studentJobTitle->expiry_date = new CDbExpression('DATE(NOW()+INTERVAL 3 MONTH)');
                 if (!$studentJobTitle->save()) {
                     throw new CException(json_encode($studentJobTitle->errors));
                 }
             }
             $transaction->commit();
             return true;
         } catch (Exception $e) {
             $transaction->rollback();
             throw new CException($e->getMessage());
         }
     } else {
         throw new CException('User not found!');
     }
 }
コード例 #2
0
 public function actionUnhireSelected()
 {
     if (isset($_GET['ajax'])) {
         if (isset($_POST) && isset($_POST['stu_job_id']) && !empty($_POST['stu_job_id'])) {
             try {
                 if (StudentJobTitle::unhireResumes($_POST['stu_job_id'], Yii::app()->user->id)) {
                     $this->renderPartial('/common/_alerts', array('type' => 'success', 'msg' => Yii::t('app', 'msg.success.unhire_resumes')));
                 }
             } catch (Exception $e) {
                 $this->renderPartial('/common/_alerts', array('type' => 'danger', 'msg' => Yii::t('app', 'msg.error.unhire_resume')));
             }
             return;
         }
         $this->renderPartial('/common/_alerts', array('type' => 'danger', 'msg' => Yii::t('app', 'msg.error.resumes_not_found')));
     }
 }
コード例 #3
0
 public function actionFav($stu_job_id)
 {
     if (isset($stu_job_id)) {
         if (StudentJobTitle::model()->exists('stu_job_id=:stu_job_id', array(':stu_job_id' => $stu_job_id))) {
             $favJobTitle = new FavoriteStudentJobTitle();
             $favJobTitle->stu_job_id = $stu_job_id;
             $favJobTitle->employer_id = Yii::app()->user->id;
             try {
                 if ($favJobTitle->save()) {
                     $this->renderPartial('//common/_alerts', array('type' => 'success', 'msg' => Yii::t('app', 'msg.success.fav_resume')));
                 }
             } catch (CDbException $e) {
                 $this->renderPartial('//common/_alerts', array('type' => 'danger', 'msg' => Yii::t('app', 'msg.error.fav_resume')));
             }
         } else {
             $this->renderPartial('//common/_alerts', array('type' => 'danger', 'msg' => Yii::t('app', 'msg.error.resume_not_found')));
         }
     }
 }
コード例 #4
0
 public function actionDeleteJob($stuJobID)
 {
     if ($stuJobID !== null) {
         $jobTitleModel = StudentJobTitle::model()->with('jobTitle')->findByAttributes(array('stu_job_id' => $stuJobID, 'user_id' => Yii::app()->user->id));
         if ($jobTitleModel != null) {
             try {
                 if ($jobTitleModel->delete()) {
                     Yii::app()->user->setFlash('success', sprintf(Yii::t('app', 'msg.success.delete_job_title'), $jobTitleModel->jobTitle->job_title_name));
                     $this->redirect($this->createUrl('viewCat', array('jobCat' => $jobTitleModel->jobTitle->job_cat_id)), true);
                 } else {
                     throw new CHttpException(404, "Student Job Title {$stuJobID} cannot be deleted.");
                 }
             } catch (Exception $e) {
                 throw new CHttpException(404, "Student Job Title {$stuJobID} cannot be deleted.");
             }
         } else {
             throw new CHttpException(404, "Student Job Title {$stuJobID} is not found.");
         }
     } else {
         throw new CHttpException(404, "Student Job Title is not found.");
     }
 }
コード例 #5
0
 public static function unhireResumes($resumes, $empId)
 {
     if (!isset($resumes) || !is_array($resumes) || !isset($empId)) {
         throw new CException('Resumes and Employer Id are required');
     }
     $resCount = count($resumes);
     if ($resCount === 0) {
         return true;
     }
     $transaction = Yii::app()->db->beginTransaction();
     try {
         $hiredResumes = StudentJobTitle::model()->FindAllByAttributes(array('stu_job_id' => $resumes, 'employer_id' => $empId, 'is_current_hired' => '1', 'is_hired' => '1'));
         $deletedCount = 0;
         foreach ($hiredResumes as $hired) {
             if ($hired->unhire($empId)) {
                 $deletedCount++;
             }
         }
         if ($deletedCount !== $resCount) {
             throw new CException("Only {$deletedCount} records deleted, while deleting {$resCount} records.");
         }
         $transaction->commit();
         return true;
     } catch (Exception $e) {
         $transaction->rollback();
         throw $e;
     }
 }