function updateData($data) { if (empty($data['pid']) || empty($data['sid']) || empty($data['value'])) { return false; } $auth = Zend_Auth::getInstance(); $identity = $auth->getIdentity(); if (!$identity) { return false; } $data['user_id'] = $identity->id; $this->addTechInfo($data, array('info' => true)); $res = $this->_updateData($data, array('notify' => false, 'upload' => false)); #, array('test' => 1) if ($res) { // update stat via TRIGGER! // http://www.wddx.ru/2010/07/count-vs.html $a = $this->countVotes($data); if ($a) { switch ($data['sid']) { case 3: $positions = new Positions(); $update = array('rating' => $a['avg'], 'votes' => $a['cnt']); #l($data); // UPDATE c_positions SET rating = '3.5000', votes = 2 WHERE id = 3; #$where = $this->getAdapter()->quoteInto('id = ?', $data['pid']); $res = $positions->update($update, 'id=' . $data['pid']); break; } } } return $res; }
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))); } }
public function getPositions() { $model = Positions::model()->findAllByAttributes(array('department_id' => $this->department_id)); $result = CHtml::listData($model, 'id', 'position'); return array_values($result); }
public function getPositions() { $positions = Positions::all(); return $positions->toJson(); }