public function search($request)
 {
     $query = ZayavlenieNaAttestaciyu::find()->joinWith('dolzhnostRel.dolzhnostAttestacionnoiKomissiiRel')->joinWith('attestacionnoeVariativnoeIspytanie2Rel')->joinWith('attestacionnoeVariativnoeIspytanie3Rel')->joinWith('vremyaProvedeniyaAttestaciiRel')->joinWith('organizaciyaRel')->joinWith('varIspytanie2FajlRel')->joinWith('varIspytanie3FajlRel')->joinWith('varIspytanie3FajlRel')->joinWith('portfolioFajlRel')->joinWith('prezentatsiyaFajlRel')->where(['!=', 'zayavlenie_na_attestaciyu.status', StatusZayavleniyaNaAttestaciyu::REDAKTIRUETSYA_PED_RABOTNIKOM])->orderBy('zayavlenie_na_attestaciyu.id');
     if ($this->load($request) && $this->validate()) {
         if ($this->fio) {
             $query->andWhere(['like', 'LOWER("familiya"||\' \'||"imya"||\' \'||"otchestvo")', mb_strtolower($this->fio)]);
         }
         if ($this->podtverzhdenieRegistracii) {
             $query->andWhere(['zayavlenie_na_attestaciyu.status' => StatusZayavleniyaNaAttestaciyu::PODPISANO_OTDELOM_ATTESTACII]);
         }
         if ($this->vreamyaProvedeniya) {
             $query->andWhere(['in', 'vremya_provedeniya_attestacii.id', $this->vreamyaProvedeniya]);
         }
         if ($this->dolzhnost) {
             $query->andWhere(['in', 'dolzhnost.id', $this->dolzhnost]);
         }
         if ($this->kategoriya) {
             $query->andWhere(['in', 'na_kategoriyu', $this->kategoriya]);
         }
         if ($this->varIspytanie2) {
             $query->andWhere(['in', 'var_ispytanie_2', $this->varIspytanie2]);
         }
         if ($this->varIspytanie3) {
             $query->andWhere(['in', 'var_ispytanie_3', $this->varIspytanie3]);
         }
         if ($this->zayavlenieId) {
             $query->andWhere(['zayavlenie_na_attestaciyu.id' => $this->zayavlenieId]);
         }
     }
     return new ActiveDataProvider(['query' => $query, 'sort' => false, 'pagination' => ['pageSize' => 20]]);
 }
 public function getZayavlenieNaAttestaciyuRel()
 {
     return $this->hasOne(ZayavlenieNaAttestaciyu::className(), ['id' => 'zayavlenie_na_attestaciyu'])->inverseOf('otraslevoeSoglashenieZayavleniyaRel');
 }
    public function actionPrintDostizheniya($id = false)
    {
        if (!$id) {
            throw new Exception('id parameter is required');
        }
        $zayavlenie = ZayavlenieNaAttestaciyu::find()->joinWith('fizLicoRel')->where(['zayavlenie_na_attestaciyu.id' => $id])->one();
        $content = $this->renderPartial('_printDostizheniya', compact('zayavlenie'));
        $indent = 3;
        $css = '
                body{
                   font-family:"Times New Roman","serif";
                }
                .paragraph{
                    text-align:justify;
                    margin-bottom: 5px;
                    margin-top: 5px;
                }
                .center{
                 text-align:center;
                }
                .tb {border-collapse: collapse}
                .tb td {padding: 5px;border: 1px solid #000}
                .inline-block{
                    display: inline-block;
                }
                .indent{padding-left: ' . $indent . 'em}

                .double-indent{padding-left: ' . 2 * $indent . 'em}

                .indent-block{
                    margin-left: ' . $indent . 'em;
                }
                .bold{
                    font-weight: bold;
                }
                ';
        $pdf = new Pdf(['mode' => Pdf::MODE_UTF8, 'format' => Pdf::FORMAT_A4, 'orientation' => Pdf::ORIENT_PORTRAIT, 'destination' => Pdf::DEST_BROWSER, 'content' => $content, 'cssFile' => '@vendor/kartik-v/yii2-mpdf/assets/kv-mpdf-bootstrap.min.css', 'cssInline' => $css, 'options' => ['title' => 'Личные достижения'], 'methods' => ['SetFooter' => ['']]]);
        // return the pdf output as per the destination setting
        return $pdf->render();
    }
Beispiel #4
0
 public function getZayavlenieNaAttestaciyuRel()
 {
     return $this->hasMany(ZayavlenieNaAttestaciyu::className(), ['fiz_lico' => 'id'])->inverseOf('fizLicoRel');
 }
Beispiel #5
0
 public function getZayavlenieNaAttestaciyuRel()
 {
     return $this->hasMany(ZayavlenieNaAttestaciyu::className(), ['rabota_organizaciya' => 'id'])->inverseOf('organizaciyaRel');
 }
Beispiel #6
0
 public function getZayavlenieNaAttestaciyuSvedeniyaOSebeRel()
 {
     return $this->hasOne(ZayavlenieNaAttestaciyu::className(), ['svedeniya_o_sebe_fajl' => 'id'])->inverseOf('svedeniyaOSebeFajlRel');
 }
Beispiel #7
0
 public function actionOtsenochnyjList()
 {
     $request = \Yii::$app->request;
     $type = $request->get('type', '');
     $id = $request->get('id', 0);
     $zid = $request->get('zid', 0);
     $zayavlenie = ZayavlenieNaAttestaciyu::findOne($zid);
     $query = OtsenochnyjListZayavleniya::find()->joinWith('strukturaOtsenochnogoListaZayvaleniyaRel')->joinWith('rabotnikKomissiiFizLicoRel')->orderBy('fiz_lico.familiya, fiz_lico.imya, fiz_lico.otchestvo')->where(['otsenochnyj_list_zayavleniya.zayavlenie_na_attestaciyu' => $zid]);
     $ispytanie = [];
     if ($type == 'postoyannoe') {
         $query = $query->andWhere(['otsenochnyj_list_zayavleniya.postoyannoe_ispytanie' => $id]);
         $ispytanie = PostoyannoeIspytanie::findOne($id);
     } elseif ($type == 'variativnoe') {
         $query = $query->andWhere(['otsenochnyj_list_zayavleniya.var_ispytanie_3' => $id]);
         $ispytanie = AttestacionnoeVariativnoeIspytanie_3::findOne($id);
     }
     $data = $query->all();
     $content = $this->renderPartial('otsenochnyj-list', compact('data', 'zayavlenie', 'ispytanie'));
     $pdf = new Pdf($this->getPdfSeetings($content));
     // return the pdf output as per the destination setting
     return $pdf->render();
 }
 public function actionGetZayavleniya()
 {
     \Yii::$app->response->format = Response::FORMAT_JSON;
     $response = new JsResponse();
     $fiz_lico = ApiGlobals::getFizLicoPolzovatelyaId();
     $districts = MunicipalnyjOtvestvennyj::find()->where(['fiz_lico' => $fiz_lico])->select('district_id')->column();
     //var_dump($districts);die();
     $periodId = $_REQUEST['period'];
     //\Yii::$app->request->post('period_id');
     $data = ZayavlenieNaAttestaciyu::find()->joinWith('organizaciyaRel.adresAdresnyjObjektRel')->where(['adresnyj_objekt.id' => $districts])->orWhere(['adresnyj_objekt.roditel' => $districts])->andWhere(['zayavlenie_na_attestaciyu.vremya_provedeniya' => $periodId])->asArray()->all();
     $response->data = $data;
     return $response;
 }
 public function actionOtsenki()
 {
     \Yii::$app->response->format = Response::FORMAT_JSON;
     $response = new JsResponse();
     $error = '';
     $fizLico = ApiGlobals::getFizLicoPolzovatelyaId();
     $zayavlenieId = $_REQUEST['zayavlenie_id'];
     $ajax = $_REQUEST['ajax'];
     $rabotnik = RabotnikAttestacionnojKomissii::find()->where(['fiz_lico' => $fizLico])->one();
     /**
      * @var ZayavlenieNaAttestaciyu $zayavlenie
      */
     $zayavlenie = ZayavlenieNaAttestaciyu::find()->joinWith('portfolioFajlRel')->joinWith('varIspytanie3FajlRel')->joinWith('prezentatsiyaFajlRel')->joinWith('otraslevoeSoglashenieZayavleniyaRel')->where(['zayavlenie_na_attestaciyu.id' => $zayavlenieId])->one();
     $raspredelenie = RaspredelenieZayavlenijNaAttestaciyu::find()->joinWith('rabotnikAttestacionnojKomissiiRel')->where(['rabotnik_attestacionnoj_komissii.fiz_lico' => $fizLico])->andWhere(['zayavlenie_na_attestaciyu' => $zayavlenieId])->exists();
     $r = RaspredelenieZayavlenijNaAttestaciyu::find()->joinWith('rabotnikAttestacionnojKomissiiRel')->where(['rabotnik_attestacionnoj_komissii.fiz_lico' => $fizLico])->andWhere(['zayavlenie_na_attestaciyu' => $zayavlenieId])->all();
     $first = function ($array) {
         if (count($array) > 0) {
             return $array[0];
         } else {
             return false;
         }
     };
     if ($raspredelenie) {
         $transaction = \Yii::$app->db->beginTransaction();
         try {
             $postoyannieIspyetaniya = [PostoyannoeIspytanie::getPortfolioId()];
             $variativnoeIspytanie = [];
             if ($zayavlenie->na_kategoriyu == KategoriyaPedRabotnika::VYSSHAYA_KATEGORIYA) {
                 if (count($zayavlenie->otraslevoeSoglashenieZayavleniyaRel) == 0) {
                     $variativnoeIspytanie[] = $zayavlenie->var_ispytanie_3;
                     $postoyannieIspyetaniya[] = PostoyannoeIspytanie::getSpdId();
                 }
             }
             $otsenochnieListy = OtsenochnyjList::find()->joinWith('ispytanieOtsenochnogoListaRel')->where(['in', 'ispytanie_otsenochnogo_lista.postoyannoe_ispytanie', $postoyannieIspyetaniya])->orWhere(['in', 'ispytanie_otsenochnogo_lista.var_ispytanie_3', $variativnoeIspytanie])->all();
             foreach ($otsenochnieListy as $list) {
                 /**
                  * @var OtsenochnyjList $list
                  */
                 if (!OtsenochnyjListZayavleniya::find()->where(['otsenochnij_list' => $list->id])->andWhere(['rabotnik_komissii' => $fizLico])->andWhere(['zayavlenie_na_attestaciyu' => $zayavlenieId])->exists()) {
                     $new_ol_zayvaleniya = new OtsenochnyjListZayavleniya();
                     $new_ol_zayvaleniya->otsenochnijList = $list->id;
                     $new_ol_zayvaleniya->rabotnikKomissii = $fizLico;
                     $new_ol_zayvaleniya->zayavlenieNaAttestaciyu = $zayavlenieId;
                     $ispytanie = $first($list->ispytanieOtsenochnogoListaRel);
                     if ($ispytanie && $ispytanie->postoyannoeIspytanie) {
                         $new_ol_zayvaleniya->postoyannoeIspytanie = $ispytanie->postoyannoeIspytanie;
                     }
                     if ($ispytanie && $ispytanie->var_ispytanie_3) {
                         $new_ol_zayvaleniya->var_ispytanie_3 = $ispytanie->var_ispytanie_3;
                     }
                     $new_ol_zayvaleniya->nazvanie = $list->nazvanie;
                     $new_ol_zayvaleniya->minBallPervayaKategoriya = $list->minBallPervayaKategoriya;
                     $new_ol_zayvaleniya->minBallVisshayaKategoriya = $list->minBallVisshayaKategoriya;
                     $new_ol_zayvaleniya->save();
                     $sql = '
                       INSERT INTO struktura_otsenochnogo_lista_zayvaleniya
                       (otsenochnyj_list_zayavleniya,nazvanie,max_bally, nomer, uroven, struktura_otsenochnogo_lista, roditel)
                       select :ol, sol.nazvanie, sol.bally,
                           case when sol.roditel is not null
                             then sol_roditel.nomer||\'.\'||sol.nomer
                             else cast(sol.nomer as varchar)
                           end as nomer,
                           case when sol.roditel is not null
                             then 2
                             else 1
                           end as uroven,
                           sol.id, sol.roditel
                       from otsenochnyj_list as ol
                       inner join struktura_otsenochnogo_lista as sol on ol.id = sol.otsenochnyj_list
                       left join struktura_otsenochnogo_lista as sol_roditel on sol.roditel = sol_roditel.id
                       inner join ispytanie_otsenochnogo_lista as iol on ol.id = iol.otsenochnyj_list
                       where ol.id = ' . $list->id . ' and ' . ($ispytanie->var_ispytanie_3 ? 'iol.var_ispytanie_3=:isp' : 'iol.postoyannoe_ispytanie=:isp') . '
                       order by nomer
                     ';
                     \Yii::$app->db->createCommand($sql)->bindValue(':ol', $new_ol_zayvaleniya->id)->bindValue(':isp', $ispytanie->var_ispytanie_3 ? $ispytanie->var_ispytanie_3 : $ispytanie->postoyannoeIspytanie)->execute();
                 }
             }
             $transaction->commit();
         } catch (Exception $e) {
             $transaction->rollBack();
             $error = 'Оценочный лист не сформирован' . $e->getMessage();
         }
     } else {
         $error = 'Недоступное действие для данного пользователя';
     }
     $listy = OtsenochnyjListZayavleniya::find()->joinWith(['strukturaOtsenochnogoListaZayvaleniyaRel' => function ($query) {
         /**
          * @var ActiveQuery $query
          */
         $query->orderBy(new Expression('cast(struktura_otsenochnogo_lista_zayvaleniya.nomer as FLOAT)'));
     }])->where(['otsenochnyj_list_zayavleniya.rabotnik_komissii' => $fizLico])->andWhere(['otsenochnyj_list_zayavleniya.zayavlenie_na_attestaciyu' => $zayavlenieId])->orderBy(new Expression('otsenochnyj_list_zayavleniya.id'))->all();
     $result = [];
     foreach ($listy as $list) {
         /**
          * @var OtsenochnyjListZayavleniya $list
          */
         if ($list->postoyannoeIspytanie == PostoyannoeIspytanie::getPortfolioId()) {
             //$result[] =$list->status;
             $portfolio = PostoyannoeIspytanie::find()->where(['id' => PostoyannoeIspytanie::getPortfolioId()])->one();
             $result[] = new \app\models\sotrudnik_att_komissii\OtsenochnyjList(['ispytanie_name' => $portfolio->nazvanie, 'file_name' => $zayavlenie->portfolioFajlRel ? $zayavlenie->portfolioFajlRel->vneshnee_imya_fajla : '', 'file_link' => $zayavlenie->portfolioFajlRel ? $zayavlenie->portfolioFajlRel->getUri() : '', 'list' => $list, 'struktura' => $list->strukturaOtsenochnogoListaZayvaleniyaRel]);
         } else {
             if ($list->postoyannoeIspytanie == PostoyannoeIspytanie::getSpdId()) {
                 //$result[] =$list->status;
                 $spd = PostoyannoeIspytanie::find()->where(['id' => PostoyannoeIspytanie::getSpdId()])->one();
                 $result[] = new \app\models\sotrudnik_att_komissii\OtsenochnyjList(['ispytanie_name' => $spd->nazvanie, 'file_name' => $zayavlenie->prezentatsiyaFajlRel ? $zayavlenie->prezentatsiyaFajlRel->vneshnee_imya_fajla : '', 'file_link' => $zayavlenie->prezentatsiyaFajlRel ? $zayavlenie->prezentatsiyaFajlRel->getUri() : '', 'list' => $list, 'struktura' => $list->strukturaOtsenochnogoListaZayvaleniyaRel]);
             } else {
                 if ($list->varIspytanie_3) {
                     //$result[] =$list->status;
                     $varIspytanie3 = AttestacionnoeVariativnoeIspytanie_3::find()->where(['id' => $list->varIspytanie_3])->one();
                     $result[] = new \app\models\sotrudnik_att_komissii\OtsenochnyjList(['ispytanie_name' => $varIspytanie3->nazvanie, 'file_name' => $zayavlenie->varIspytanie3FajlRel ? $zayavlenie->varIspytanie3FajlRel->vneshnee_imya_fajla : '', 'file_link' => $zayavlenie->varIspytanie3FajlRel ? $zayavlenie->varIspytanie3FajlRel->getUri() : '', 'list' => $list, 'struktura' => $list->strukturaOtsenochnogoListaZayvaleniyaRel]);
                 }
             }
         }
     }
     if ($error) {
         $response->type = JsResponse::ERROR;
         $response->msg = $error;
     } else {
         $response->data = $result;
     }
     return $response;
 }
Beispiel #10
0
 public function save()
 {
     $fizLicoFio = FizLico::getFioById($this->fizLicoId);
     $rabota = RabotaFizLica::find()->joinWith('dolzhnostiFizLicaNaRaboteRel')->where(['rabota_fiz_lica.id' => $this->dolzhnost])->one();
     $zayavlenie = ZayavlenieNaAttestaciyu::findOne($this->id ? $this->id : 0);
     $attestaciyaDates = $this->parseAttestaciyaDate();
     if (!$zayavlenie) {
         $zayavlenie = new ZayavlenieNaAttestaciyu();
     }
     $zayavlenie->fiz_lico = $this->fizLicoId;
     $zayavlenie->familiya = $fizLicoFio['familiya'];
     $zayavlenie->imya = $fizLicoFio['imya'];
     $zayavlenie->otchestvo = $fizLicoFio['otchestvo'];
     $zayavlenie->ped_stazh = $this->pedStazh;
     $zayavlenie->stazh_v_dolzhnosti = $this->pedStazhVDolzhnosti;
     $zayavlenie->rabota_organizaciya = $rabota->organizaciya;
     $zayavlenie->rabota_dolzhnost = $rabota->dolzhnostiFizLicaNaRaboteRel[0]->dolzhnost;
     $zayavlenie->rabota_stazh_v_dolzhnosti = $this->rabotaPedStazhVDolzhnosti;
     $zayavlenie->rabota_kopiya_trudovoj_knizhki = $this->trudovajya;
     $zayavlenie->attestaciya_kategoriya = $this->attestacionnyListKategoriya;
     $zayavlenie->attestaciya_kopiya_attestacionnogo_lista = $this->attestacionnyListPeriodFajl;
     $zayavlenie->attestaciya_data_prisvoeniya = date('Y-m-d', strtotime($attestaciyaDates['data_prisvoeniya']));
     $zayavlenie->attestaciya_data_okonchaniya_dejstviya = date('Y-m-d', strtotime($attestaciyaDates['data_okonchaniya_dejstviya']));
     $zayavlenie->na_kategoriyu = $this->kategoriya;
     $zayavlenie->attestaciya_data_okonchaniya_dejstviya = date('Y-m-d', strtotime($this->attestaciyaDataOkonchaniyaDejstviya));
     $zayavlenie->rabota_data_naznacheniya = date('Y-m-d', strtotime($this->rabotaDataNaznacheniya));
     $zayavlenie->rabota_data_naznacheniya_v_uchrezhdenii = date('Y-m-d', strtotime($this->rabotaDataNaznacheniyaVUchrezhdenii));
     $zayavlenie->data_rozhdeniya = date('Y-m-d', strtotime($this->dataRozhdeniya));
     if ($this->kategoriya == KategoriyaPedRabotnika::VYSSHAYA_KATEGORIYA) {
         $zayavlenie->svedeniya_o_sebe = $this->svedeniysOSebe ? $this->svedeniysOSebe : null;
         $zayavlenie->svedeniya_o_sebe_fajl = $this->svedeniysOSebeFajl;
     } else {
         $zayavlenie->svedeniya_o_sebe = null;
         $zayavlenie->svedeniya_o_sebe_fajl = null;
     }
     if ($this->kategoriya == KategoriyaPedRabotnika::BEZ_KATEGORII) {
         $zayavlenie->var_ispytanie_2 = null;
         $zayavlenie->var_ispytanie_3 = null;
     } else {
         $zayavlenie->var_ispytanie_2 = $this->kategoriya == KategoriyaPedRabotnika::VYSSHAYA_KATEGORIYA ? $this->varIspytanie2 : null;
         $zayavlenie->var_ispytanie_3 = $this->kategoriya == KategoriyaPedRabotnika::VYSSHAYA_KATEGORIYA ? $this->varIspytanie3 : null;
         if (count($this->otraslevoeSoglashenie) > 0) {
             $zayavlenie->var_ispytanie_3 = null;
         }
     }
     $zayavlenie->vremya_provedeniya = $this->vremyaProvedeniya;
     $this->status = $this->status ? $this->status : StatusZayavleniyaNaAttestaciyu::REDAKTIRUETSYA_PED_RABOTNIKOM;
     $zayavlenie->status = $this->status ? $this->status : StatusZayavleniyaNaAttestaciyu::REDAKTIRUETSYA_PED_RABOTNIKOM;
     $zayavlenie->vremya_smeny_statusa = date("Y-m-d H:i:s");
     $zayavlenie->domashnijTelefon = substr($this->domashnijTelefon, 1);
     $zayavlenie->provestiZasedanieBezPrisutstviya = $this->provestiZasedanieBezPrisutstviya;
     $zayavlenie->prilozhenie1 = $this->prilozhenie1;
     $zayavlenie->ld_olimpiady = $this->ldOlimpiady ? $this->ldOlimpiady : null;
     $zayavlenie->ld_posobiya = $this->ldPosobiya ? $this->ldPosobiya : null;
     $zayavlenie->ld_publikacii = $this->ldPublikacii ? $this->ldPublikacii : null;
     $zayavlenie->ld_prof_konkursy = $this->ldProfKonkursy ? $this->ldProfKonkursy : null;
     $zayavlenie->ld_obshestvennaya_aktivnost = $this->ldObshestvennayaAktivnost ? $this->ldObshestvennayaAktivnost : null;
     $zayavlenie->ld_elektronnye_resursy = $this->ldElektronnyeResursy ? $this->ldElektronnyeResursy : null;
     $zayavlenie->ld_otkrytoe_meropriyatie = $this->ldOtkrytoeMeropriyatie ? $this->ldOtkrytoeMeropriyatie : null;
     $zayavlenie->ld_nastavnik = $this->ldNastavnik ? $this->ldNastavnik : null;
     $zayavlenie->ld_deti_sns = $this->ldDetiSns ? $this->ldDetiSns : null;
     if (!$zayavlenie->validate()) {
         return false;
     }
     //создаем массив с высшими образованиями
     $Obrazovaniya = [];
     if ($this->visshieObrazovaniya) {
         foreach ($this->visshieObrazovaniya as $k => $v) {
             $object = ['tip' => 'vo', 'index' => $k];
             if ($v->udalit) {
                 $object['udalit'] = 1;
             } else {
                 $object['udalit'] = 0;
             }
             $dataVidachi = date('Y-m-d', strtotime($v->dataVidachi));
             $obrazovanieFizLica = ObrazovanieFizLica::findOne($v->obrazovanieFizLicaId ? $v->obrazovanieFizLicaId : 0);
             if (!$obrazovanieFizLica) {
                 $obrazovanieFizLica = new ObrazovanieFizLica();
             }
             $obrazovanieFizLica->fiz_lico = $this->fizLicoId;
             $obrazovanieFizLica->dokument_ob_obrazovanii_tip = $v->tipDokumenta;
             $obrazovanieFizLica->dokument_ob_obrazovanii_seriya = $v->seriya;
             $obrazovanieFizLica->dokument_ob_obrazovanii_nomer = $v->nomer;
             $obrazovanieFizLica->dokument_ob_obrazovanii_data = $dataVidachi;
             $obrazovanieFizLica->kvalifikaciya = $v->kvalifikaciyaId;
             $obrazovanieFizLica->organizaciya = $v->organizaciyaId;
             if (!$v->kvalifikaciyaId and $v->kvalifikaciyaNazvanie) {
                 $object['novayaKvalifikaciya'] = $v->kvalifikaciyaNazvanie;
             } else {
                 $object['novayaKvalifikaciya'] = '';
             }
             if (!$v->organizaciyaId and $v->organizaciyaNazvanie) {
                 $object['novayaOrganizaciya'] = $v->organizaciyaNazvanie;
             } else {
                 $object['novayaOrganizaciya'] = '';
             }
             $obrazovanieFizLica->dokument_ob_obrazovanii_kopiya = $v->documentKopiya;
             if (!$obrazovanieFizLica->validate()) {
                 return false;
             }
             $object['obrazovanieFizLica'] = $obrazovanieFizLica;
             $obrazovanieDlyaZayavleniya = ObrazovanieDlyaZayavleniyaNaAttestaciyu::findOne($v->obrazovanieDlyaZayavleniyaId ? $v->obrazovanieDlyaZayavleniyaId : 0);
             if (!$obrazovanieDlyaZayavleniya) {
                 $obrazovanieDlyaZayavleniya = new ObrazovanieDlyaZayavleniyaNaAttestaciyu();
             }
             $obrazovanieDlyaZayavleniya->zayavlenie_na_attestaciyu = $this->id;
             $obrazovanieDlyaZayavleniya->obrazovanie_istochnik = $v->obrazovanieFizLicaId;
             $obrazovanieDlyaZayavleniya->dokument_ob_obrazovanii_tip = $v->tipDokumenta;
             $obrazovanieDlyaZayavleniya->dokument_ob_obrazovanii_seriya = $v->seriya;
             $obrazovanieDlyaZayavleniya->dokument_ob_obrazovanii_nomer = $v->nomer;
             $obrazovanieDlyaZayavleniya->dokument_ob_obrazovanii_data = $dataVidachi;
             $obrazovanieDlyaZayavleniya->dokument_ob_obrazovanii_kopiya = $v->documentKopiya;
             $obrazovanieDlyaZayavleniya->kvalifikaciya = $v->kvalifikaciyaId;
             $obrazovanieDlyaZayavleniya->organizaciya = $v->organizaciyaId;
             $object['obrazovanieDlyaZayavlaniya'] = $obrazovanieDlyaZayavleniya;
             $Obrazovaniya[] = $object;
         }
     }
     if ($this->kursy) {
         foreach ($this->kursy as $k => $v) {
             $object = ['tip' => 'kurs', 'index' => $k];
             if ($v->udalit) {
                 $object['udalit'] = 1;
             } else {
                 $object['udalit'] = 0;
             }
             $dataVidachi = date('Y-m-d', strtotime($v->dataVidachi));
             $obrazovanieFizLica = ObrazovanieFizLica::findOne($v->obrazovanieFizLicaId ? $v->obrazovanieFizLicaId : 0);
             if (!$obrazovanieFizLica) {
                 $obrazovanieFizLica = new ObrazovanieFizLica();
             }
             $obrazovanieFizLica->fiz_lico = $this->fizLicoId;
             $obrazovanieFizLica->dokument_ob_obrazovanii_tip = $v->tipDokumenta;
             $obrazovanieFizLica->dokument_ob_obrazovanii_data = $dataVidachi;
             $obrazovanieFizLica->organizaciya = $v->organizaciyaId;
             $obrazovanieFizLica->kurs_nazvanie = $v->kursNazvanie;
             $obrazovanieFizLica->kurs_chasy = $v->kursChasy;
             $obrazovanieFizLica->kurs_tip = $v->kursTip;
             $obrazovanieFizLica->dokument_ob_obrazovanii_kopiya = $v->documentKopiya;
             $obrazovanieFizLica->dokument_ob_obrazovanii_seriya = null;
             $obrazovanieFizLica->dokument_ob_obrazovanii_nomer = null;
             if (!$v->organizaciyaId and $v->organizaciyaNazvanie) {
                 $object['novayaOrganizaciya'] = $v->organizaciyaNazvanie;
             } else {
                 $object['novayaOrganizaciya'] = '';
             }
             $object['novayaKvalifikaciya'] = '';
             if (!$obrazovanieFizLica->validate()) {
                 return false;
             }
             $object['obrazovanieFizLica'] = $obrazovanieFizLica;
             $obrazovanieDlyaZayavleniya = ObrazovanieDlyaZayavleniyaNaAttestaciyu::findOne($v->obrazovanieDlyaZayavleniyaId ? $v->obrazovanieDlyaZayavleniyaId : 0);
             if (!$obrazovanieDlyaZayavleniya) {
                 $obrazovanieDlyaZayavleniya = new ObrazovanieDlyaZayavleniyaNaAttestaciyu();
             }
             $obrazovanieDlyaZayavleniya->zayavlenie_na_attestaciyu = $this->id;
             $obrazovanieDlyaZayavleniya->obrazovanie_istochnik = $v->obrazovanieFizLicaId;
             $obrazovanieDlyaZayavleniya->dokument_ob_obrazovanii_tip = $v->tipDokumenta;
             $obrazovanieDlyaZayavleniya->dokument_ob_obrazovanii_data = $dataVidachi;
             $obrazovanieDlyaZayavleniya->dokument_ob_obrazovanii_kopiya = $v->documentKopiya;
             $obrazovanieDlyaZayavleniya->organizaciya = $v->organizaciyaId;
             $obrazovanieDlyaZayavleniya->kurs_nazvanie = $v->kursNazvanie;
             $obrazovanieDlyaZayavleniya->kurs_chasy = $v->kursChasy;
             $obrazovanieDlyaZayavleniya->kurs_tip = $v->kursTip;
             $obrazovanieDlyaZayavleniya->dokument_ob_obrazovanii_nomer = null;
             $obrazovanieDlyaZayavleniya->dokument_ob_obrazovanii_seriya = null;
             $object['obrazovanieDlyaZayavlaniya'] = $obrazovanieDlyaZayavleniya;
             $Obrazovaniya[] = $object;
         }
     }
     $saveTransaction = RabotaFizLica::getDb()->transaction(function () use($zayavlenie, $Obrazovaniya) {
         //var_dump($zayavlenie->save(false));
         if (!$zayavlenie->save(false)) {
             var_dump('zayavl_error');
             return false;
         }
         $this->id = $zayavlenie->id;
         foreach ($Obrazovaniya as $k => $v) {
             if ($v['udalit']) {
                 if (!$v['obrazovanieDlyaZayavlaniya']->delete()) {
                     return false;
                 }
                 if ($v['tip'] == 'kurs') {
                     if (!$v['obrazovanieFizLica']->delete()) {
                         return false;
                     }
                 }
                 if ($v['tip'] == 'vo') {
                     unset($this->visshieObrazovaniya[$v['index']]);
                 } else {
                     unset($this->kursy[$v['index']]);
                 }
             } else {
                 if ($v['novayaKvalifikaciya']) {
                     $kvalifikaciya = new Kvalifikaciya(['nazvanie' => $v['novayaKvalifikaciya'], 'obschij' => false]);
                     if (!$kvalifikaciya->save(false)) {
                         var_dump('kvalifik_error');
                         return false;
                     }
                     $v['obrazovanieFizLica']->kvalifikaciya = $kvalifikaciya->id;
                     $v['obrazovanieDlyaZayavlaniya']->kvalifikaciya = $kvalifikaciya->id;
                 }
                 if ($v['novayaOrganizaciya']) {
                     $organizaciya = new Organizaciya(['nazvanie' => $v['novayaOrganizaciya'], 'obschij' => false, 'etapy_obrazovaniya' => '{' . \app\enums\EtapObrazovaniya::VYSSHEE_PROFESSIONALNOE_OBRAZOVANIE . '}']);
                     if (!$organizaciya->save(false)) {
                         var_dump('orghanizac_error');
                         return false;
                     }
                     $v['obrazovanieFizLica']->organizaciya = $organizaciya->id;
                     $v['obrazovanieDlyaZayavlaniya']->organizaciya = $organizaciya->id;
                 }
                 if (!$v['obrazovanieFizLica']->validate()) {
                     return false;
                 }
                 if (!$v['obrazovanieFizLica']->save(false)) {
                     var_dump('obrfl_error');
                     return false;
                 }
                 if ($v['tip'] == 'vo') {
                     $this->visshieObrazovaniya[$v['index']]->obrazovanieFizLicaId = $v['obrazovanieFizLica']->id;
                 } else {
                     $this->kursy[$v['index']]->obrazovanieFizLicaId = $v['obrazovanieFizLica']->id;
                 }
                 $v['obrazovanieDlyaZayavlaniya']->obrazovanie_istochnik = $v['obrazovanieFizLica']->id;
                 $v['obrazovanieDlyaZayavlaniya']->zayavlenie_na_attestaciyu = $zayavlenie->id;
                 if (!$v['obrazovanieDlyaZayavlaniya']->validate()) {
                     return false;
                 }
                 if (!$v['obrazovanieDlyaZayavlaniya']->save(false)) {
                     var_dump('obrzZayavl_error');
                     return false;
                 }
                 if ($v['tip'] == 'vo') {
                     $this->visshieObrazovaniya[$v['index']]->obrazovanieDlyaZayavleniyaId = $v['obrazovanieDlyaZayavlaniya']->id;
                 } else {
                     $this->kursy[$v['index']]->obrazovanieDlyaZayavleniyaId = $v['obrazovanieDlyaZayavlaniya']->id;
                 }
             }
         }
         foreach ($this->otraslevoeSoglashenie as $key => $item) {
             /**
              * @var OtraslevoeSoglashenie $item
              */
             $item->zayavlenieNaAttestaciyu = $this->id;
             if ($savedItem = $item->save()) {
                 if ($item->udalit) {
                     unset($this->otraslevoeSoglashenie[$key]);
                 } else {
                     $item->id = $savedItem->id;
                 }
             } else {
                 var_dump('os_error');
                 return false;
             }
         }
         return true;
     });
     if (!$saveTransaction) {
         return false;
     }
     return true;
 }
Beispiel #11
0
 public function getZayavlenieNaAttestaciyuRel()
 {
     return $this->hasMany(ZayavlenieNaAttestaciyu::className(), ['rabota_dolzhnost' => 'id'])->inverseOf('dolzhnostRel');
 }