Esempio n. 1
0
 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;
 }
Esempio n. 2
0
 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;
 }