예제 #1
0
 /**
  * Creates a new File model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new File();
     if ($model->load(Yii::$app->request->post()) && $model->validate()) {
         $dir = Yii::getAlias('@app/uf');
         foreach (UploadedFile::getInstances($model, 'files') as $file) {
             $file->saveAs($dir . '/' . $file->baseName . '.' . $file->extension);
             $new_file = new File();
             $new_file->setAttributes($model->attributes);
             $new_file->file_name = $file->baseName . '.' . $file->extension;
             $new_file->file_path = $dir . '/' . $file->baseName . '.' . $file->extension;
             $new_file->table_name = 'person';
             $new_file->class_name = Person::className();
             $new_file->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->setAttributes(Yii::$app->request->get());
         }
         return $this->render('create', ['model' => $model]);
     }
 }
예제 #2
0
 public function getPeople($list, $segment = NULL, $role = NULL)
 {
     return $this->hasMany(Person::className(), ['id' => 'user_id'])->joinWith(['list'])->viaTable('person_project', ['project_id' => 'id'], function ($query) use($list, $segment, $role) {
         $conditions = ['list' => $list];
         // Apply segment
         if ($segment) {
             $conditions['availability'] = $segment;
         }
         // Apply role
         if ($role) {
             $conditions['role'] = $role;
         }
         $query->onCondition($conditions);
     })->orderBy(['person_project.availability' => SORT_DESC]);
 }
예제 #3
0
파일: Section.php 프로젝트: mosedu/confprof
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getGuests()
 {
     return $this->hasMany(Person::className(), ['prs_sec_id' => 'sec_id'])->where(['prs_active' => Person::PERSON_STATE_ACTIVE, 'prs_type' => Person::PERSON_TYPE_GUEST]);
 }
예제 #4
0
파일: User.php 프로젝트: slavam/placement
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getPeople()
 {
     return $this->hasMany(Person::className(), ['user_id' => 'id']);
 }
예제 #5
0
 /**
  * @inheritdoc
  */
 public function rules()
 {
     return [[['type_id', 'person_id', 'education_type_id', 'profession_id', 'city_id', 'duration', 'rec_status_id', 'user_id'], 'integer'], [['date_start', 'date_end'], 'date', 'format' => 'dd.mm.yyyy'], [['education_type_id', 'person_id', 'firm', 'profession_id'], 'required'], [['firm'], 'string', 'max' => 128], [['type_id'], 'default', 'value' => 1], [['rec_status_id'], 'default', 'value' => 1], [['user_id'], 'default', 'value' => Yii::$app->user->id], [['note'], 'string'], [['dc'], 'safe'], ['person_id', 'exist', 'targetClass' => Person::className(), 'targetAttribute' => 'id']];
 }
예제 #6
0
파일: Company.php 프로젝트: stknight43/SHBB
 public function getPricipal()
 {
     return $this->hasOne(Person::className(), ['id' => 'pricipal_id']);
 }
예제 #7
0
 public function getOwners()
 {
     return $this->hasMany(Person::className(), ['id' => 'person_id'])->viaTable('person_vacancy_role', ['vacancy_id' => 'id'], function ($query) {
         $query->onCondition(['role_id' => VacancyRoleHelper::OWNER]);
     });
 }
예제 #8
0
 /**
  * Returns the receiving Person of this Review
  *
  * @return \yii\db\ActiveQuery Person
  */
 public function getReceiver()
 {
     return $this->hasOne(Person::className(), ['receiver_id' => 'id']);
 }
예제 #9
0
파일: Doclad.php 프로젝트: mosedu/confprof
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getPersons()
 {
     return $this->hasMany(Person::className(), ['prs_doc_id' => 'doc_id'])->where(['prs_type' => Person::PERSON_TYPE_CONSULTANT]);
 }
예제 #10
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getDebtPerson()
 {
     return $this->hasOne(Person::className(), ['person_id' => 'debt_person']);
 }
예제 #11
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getReserveStudent()
 {
     return $this->hasOne(Person::className(), ['person_id' => 'reserve_student_id']);
 }
예제 #12
0
 public function behaviors()
 {
     return ['validateConsultant' => ['class' => MultirowsBehavior::className(), 'model' => Person::className(), 'defaultattributes' => ['prs_type' => Person::PERSON_TYPE_CONSULTANT], 'scenario' => 'createconsultant'], 'validateMedals' => ['class' => MultirowsBehavior::className(), 'model' => Docmedal::className()], 'validateMembers' => ['class' => MultirowsBehavior::className(), 'model' => Member::className()], 'access' => ['class' => AccessControl::className(), 'rules' => [['allow' => true, 'actions' => ['list', 'create', 'view', 'update', 'logout', 'delete', 'deletefile'], 'roles' => ['@']], ['allow' => true, 'actions' => ['index', 'register', 'calendar', 'guest', 'login'], 'roles' => ['?', '@']], ['allow' => true, 'actions' => ['regthankyou', 'confirm'], 'roles' => ['?', '@']]]]];
 }
예제 #13
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getTransactionPerson()
 {
     return $this->hasOne(Person::className(), ['person_id' => 'transaction_person_id']);
 }
예제 #14
0
 /**
  * Returns all studentAssistants for this course
  *
  * @return \yii\db\ActiveQuery Person
  */
 public function getStudentAssistants()
 {
     return $this->hasMany(Person::className(), ['id' => 'person_id'])->viaTable('person_course_role', ['course_id' => 'id'], function ($query) {
         $query->onCondition(['role_id' => CourseRoleHelper::STUDENTASSISTANT]);
     });
 }
예제 #15
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getPeople()
 {
     return $this->hasMany(Person::className(), ['recommend_by' => 'person_id']);
 }
예제 #16
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getPerson()
 {
     return $this->hasOne(Person::className(), ['id' => 'person_id']);
 }
예제 #17
0
파일: Park.php 프로젝트: stknight43/SHBB
 public function getConnecter()
 {
     return $this->hasOne(Person::className(), ['id' => 'connecter_id']);
 }