public function actionInformation($id) { if (isset($_POST['ajax']) && $_POST['ajax'] === 'info-form') { $talent_info = new TalentInfo(); echo CActiveForm::validate($talent_info); Yii::app()->end(); } if (isset($_POST['TalentInfo'])) { $model = TalentInfo::model()->findByPk($id); $model->attributes = $_POST['TalentInfo']; $create_user = User::model()->findByAttributes(array('user_name' => Yii::app()->user->name)); if (!empty($create_user)) { $model->create_user_id = $create_user->id; } else { $model->create_user_id = 0; } $type = $model->recruitment_type; $source = $model->recruitment_source; $department_id = $model->department_id; $position = $model->position; $department_position = Positions::model()->findByAttributes(array('department_id' => $department_id, 'position' => $position)); $type_source = RecruitmentSource::model()->findAllByAttributes(array('type' => $type, 'source' => $source)); if (empty($type_source) && !empty($source)) { $model_recruitment_source = new RecruitmentSource(); $model_recruitment_source->type = $type; $model_recruitment_source->source = $source; $model_recruitment_source->save(); } if (empty($department_position) && !empty($position)) { $model_department_position = new Positions(); $model_department_position->department_id = $department_id; $model_department_position->position = $position; $model_department_position->save(); } if (!empty($model->resume_file)) { $uploadPath = Yii::app()->params['uploadPath']; if (!is_dir($uploadPath)) { mkdir($uploadPath, 0777, true); } $file = CUploadedFile::getInstance($model, 'resume_file'); $filename = date('Y_m_d', time()) . $model->name; $filename .= "." . $file->getExtensionName(); $name = iconv("UTF-8", "gb2312", $uploadPath . '/' . $filename); $file->saveAs($name, true); chmod($name, 0777); $model->resume_file = $filename; } if ($model->save()) { Yii::app()->user->setFlash('success', '更改成功'); } else { } $this->render('information', array('model' => $model)); } else { $this->render('information', array('model' => TalentInfo::model()->findByPk($id))); } }
public function actionInformation($id) { if (isset($_POST['TalentInfo'])) { $model = TalentInfo::model()->findByPk($id); $model->attributes = $_POST['TalentInfo']; $create_user = User::model()->findByAttributes(array('user_name' => Yii::app()->user->name)); if (!empty($create_user)) { $model->create_user_id = $create_user->id; } else { $model->create_user_id = 0; } $type = $model->recruitment_type; $source = $model->recruitment_source; $department_id = $model->department_id; $position = $model->position; $department_position = Positions::model()->findByAttributes(array('department_id' => $department_id, 'position' => $position)); $type_source = RecruitmentSource::model()->findAllByAttributes(array('type' => $type, 'source' => $source)); if (empty($type_source) && !empty($source)) { $model_recruitment_source = new RecruitmentSource(); $model_recruitment_source->type = $type; $model_recruitment_source->source = $source; $model_recruitment_source->save(); } if (empty($department_position) && !empty($position)) { $model_department_position = new Positions(); $model_department_position->department_id = $department_id; $model_department_position->position = $position; $model_department_position->save(); } if ($model->save()) { Yii::app()->user->setFlash('success', '更改成功'); } else { } $this->render('information', array('model' => $model)); } else { $this->render('information', array('model' => TalentInfo::model()->findByPk($id))); } }