コード例 #1
0
ファイル: DolzhnostFizLica.php プロジェクト: tsyrya/mybriop
 public function addDolzhnost()
 {
     $organizaciya = $this->organizaciyaId ? Organizaciya::findOne($this->organizaciyaId) : new Organizaciya(['nazvanie' => $this->organizaciyaNazvanie, 'vedomstvo' => $this->organizaciyaVedomstvo, 'adresAdresnyjObjekt' => $this->organizaciyaVedomstvo, 'obschij' => false]);
     if (!$organizaciya->validate()) {
         return false;
     }
     if ($this->organizaciyaId) {
         $rabotaFizLica = RabotaFizLica::findOne(['fiz_lico' => $this->fizLicoId, 'organizaciya' => $this->organizaciyaId]);
     } else {
         $rabotaFizLica = null;
     }
     if (!$rabotaFizLica) {
         $rabotaFizLica = new RabotaFizLica(['fiz_lico' => $this->fizLicoId]);
     }
     if (!$rabotaFizLica->validate()) {
         return false;
     }
     $dolzhnost = $this->dolzhnostId ? Dolzhnost::findOne($this->dolzhnostId) : new Dolzhnost(['nazvanie' => $this->dolzhnostNazvanie, 'tip' => 'inaya', 'obschij' => false]);
     try {
         DolzhnostFizLicaNaRabote::getDb()->transaction(function () use($organizaciya, $rabotaFizLica, $dolzhnost) {
             $organizaciya->save(false);
             $dolzhnost->save(false);
             $rabotaFizLica->link('organizaciyaRel', $organizaciya);
             $dolzhnostFizLica = new DolzhnostFizLicaNaRabote(['dolzhnost' => $dolzhnost->id, 'etapObrazovaniya' => $this->etapObrazovaniya]);
             $dolzhnostFizLica->link('rabotaFizLicaRel', $rabotaFizLica);
         });
     } catch (Exception $e) {
         return false;
     }
     return ['rabota_fiz_lica_id' => $rabotaFizLica->id, 'dolhnost' => $dolzhnost->nazvanie . ', ' . $organizaciya->nazvanie];
 }
コード例 #2
0
 public function actionIndex($rabota)
 {
     $decodedRabota = Yii::$app->hashids->decode($rabota);
     if (!$decodedRabota) {
         throw new NotFoundHttpException();
     }
     $rabotaId = $decodedRabota[0];
     $query = DolzhnostFizLicaNaRabote::find()->joinWith('rabotaFizLicaRel')->with('dolzhnostRel')->where(['rabota_fiz_lica.id' => $rabotaId, 'rabota_fiz_lica.fiz_lico' => Yii::$app->user->fizLicoId]);
     $data = new ActiveDataProvider(['query' => $query, 'key' => 'hashids', 'pagination' => false, 'sort' => false]);
     return $this->render('index', ['data' => $data, 'rabota' => $rabota]);
 }
コード例 #3
0
ファイル: Registraciya.php プロジェクト: tsyrya/mybriop
 private function registerImpl()
 {
     if (!$this->validate()) {
         return false;
     }
     $fiz_lico = new FizLico(['familiya' => $this->familiya, 'imya' => $this->imya, 'otchestvo' => $this->otchestvo, 'email' => $this->email, 'formattedTelefon' => $this->telefon]);
     $polzovatel = new Polzovatel(['login' => $this->login, 'parol' => $this->parol, 'aktiven' => true, 'roliAsArray' => $this->roli]);
     $polzovatel->generateKlyuchAutentifikacii();
     $polzovatel->generateKodPodtverzhdeniyaEmail();
     list($organizaciya, $organizaciya_to_delete) = DirectoryHelper::getFromCombo(Organizaciya::className(), $this->rabotaOrgId, $this->rabotaOrgNazvanie, ['vedomstvo' => $this->rabotaOrgVedomstvo, 'adres_adresnyj_objekt' => $this->rabotaOrgAdres]);
     $rabota_fiz_lica = new RabotaFizLica(['formattedTelefon' => $this->rabotaTelefon]);
     list($dolzhnost, $dolzhnost_to_delete) = DirectoryHelper::getFromCombo(Dolzhnost::className(), $this->rabotaDolzhnostId, $this->rabotaDolzhnostNazvanie, null);
     $dolzhnost_fiz_lica_na_rabote = new DolzhnostFizLicaNaRabote(['etapObrazovaniyaAsEnum' => $this->rabotaEtapObrazovaniya]);
     $message = Yii::$app->mailer->compose('kadry/registraciya.php', ['model' => $this, 'polzovatel' => $polzovatel])->setTo($fiz_lico->email);
     if (!$message->send()) {
         $this->addError('email', 'Не удалось отправить E-Mail.');
         return false;
     }
     $transaction = Yii::$app->db->beginTransaction();
     try {
         $fiz_lico->save(false);
         $polzovatel->link('fizLicoRel', $fiz_lico);
         $polzovatel->save(false);
         if ($organizaciya) {
             $organizaciya->save(false);
         }
         $rabota_fiz_lica->fizLico = $fiz_lico->id;
         $rabota_fiz_lica->link('organizaciyaRel', $organizaciya);
         $rabota_fiz_lica->save(false);
         if ($dolzhnost) {
             $dolzhnost->save(false);
         }
         $dolzhnost_fiz_lica_na_rabote->dolzhnost = $dolzhnost->id;
         $dolzhnost_fiz_lica_na_rabote->link('rabotaFizLicaRel', $rabota_fiz_lica);
         $dolzhnost_fiz_lica_na_rabote->save(false);
         if ($organizaciya_to_delete) {
             $organizaciya_to_delete->delete();
         }
         if ($dolzhnost_to_delete) {
             $dolzhnost_to_delete->delete();
         }
         $transaction->commit();
     } catch (\Exception $e) {
         $transaction->rollBack();
         throw $e;
     }
     return true;
 }
コード例 #4
0
ファイル: ZapisNaKursForm.php プロジェクト: tsyrya/mybriop
 private function populateByudzhetImpl()
 {
     $fiz_lico = FizLico::findOne($this->fizLico);
     if ($fiz_lico) {
         $this->pedStazh = $fiz_lico->pedStazh;
     }
     $rabota_fiz_lica = RabotaFizLica::find()->where(['fiz_lico' => $this->fizLico])->orderBy('id')->one();
     $dolzhnost_fiz_lica_na_rabote = $rabota_fiz_lica ? DolzhnostFizLicaNaRabote::find()->where(['rabota_fiz_lica' => $rabota_fiz_lica->id])->orderBy('id')->one() : null;
     if ($dolzhnost_fiz_lica_na_rabote) {
         list($this->dolzhnostId, $this->dolzhnostNazvanie) = DirectoryHelper::getForCombo(Dolzhnost::findOne($dolzhnost_fiz_lica_na_rabote->dolzhnost));
     }
     if ($dolzhnost_fiz_lica_na_rabote && ($stazh_v_dolzhnosti = StazhFizLica::findOne(['fiz_lico' => $this->fizLico, 'dolzhnost' => Val::of($dolzhnost_fiz_lica_na_rabote, 'dolzhnost')]))) {
         $this->stazhVDolzhnosti = $stazh_v_dolzhnosti->stazh;
     }
     if ($attestaciya_fiz_lica = $fiz_lico->attestaciyaFizLicaRel) {
         $this->kategoriya = $attestaciya_fiz_lica->kategoriya;
     }
     if ($obrazovanie_fiz_lica = ObrazovanieFizLica::find()->where(['fiz_lico' => $this->fizLico])->orderBy('id')->one()) {
         list($this->obrOrgId, $this->obrOrgNazvanie) = DirectoryHelper::getForCombo(Organizaciya::findOne($obrazovanie_fiz_lica->organizaciya));
         list($this->obrKvalifikaciyaId, $this->obrKvalifikaciyaNazvanie) = DirectoryHelper::getForCombo(Kvalifikaciya::findOne($obrazovanie_fiz_lica->kvalifikaciya));
         $this->obrDocTip = $obrazovanie_fiz_lica->dokumentObObrazovaniiTip;
         $this->obrDocSeriya = $obrazovanie_fiz_lica->dokumentObObrazovaniiSeriya;
         $this->obrDocNomer = $obrazovanie_fiz_lica->dokumentObObrazovaniiNomer;
         $this->obrDocData = DeprecatedDatePicker::fromDatetime($obrazovanie_fiz_lica->dokumentObObrazovaniiDataAsDate);
     }
     return $fiz_lico;
 }
コード例 #5
0
ファイル: RabotaFizLica.php プロジェクト: tsyrya/mybriop
 /**
  * @return ActiveQuery
  */
 public function getDolzhnostiFizLicaNaRaboteRel()
 {
     return $this->hasMany(DolzhnostFizLicaNaRabote::className(), ['rabota_fiz_lica' => 'id'])->inverseOf('rabotaFizLicaRel');
 }
コード例 #6
0
ファイル: DolzhnostForm.php プロジェクト: tsyrya/mybriop
 public static function tableName()
 {
     return DolzhnostFizLicaNaRabote::tableName();
 }
コード例 #7
0
ファイル: Dolzhnost.php プロジェクト: tsyrya/mybriop
 public function getDolzhnostiFizLicNaRabotahRel()
 {
     return $this->hasMany(DolzhnostFizLicaNaRabote::className(), ['dolzhnost' => 'id'])->inverseOf('dolzhnostRel');
 }