public function actionFias() { $file = 'AS_ADDROBJ_20160609_c5080ba4-9f46-4b6e-aecc-72a630730b3a.XML'; $interestingNodes = array('AOGUID'); $xmlObject = new \XMLReader(); $xmlObject->open($file); header('Content-Type: text/html; charset=utf-8'); $i = 0; while ($xmlObject->read()) { if ($xmlObject->name == 'Object') { if ($xmlObject->getAttribute('IFNSFL') == '8603') { // if (($xmlObject->getAttribute('PARENTGUID') == '0bf0f4ed-13f8-446e-82f6-325498808076' && $xmlObject->getAttribute('AOLEVEL') == '7') || $xmlObject->getAttribute('AOGUID') == '0bf0f4ed-13f8-446e-82f6-325498808076') { $fias = new Fias(); $fias->AOGUID = $xmlObject->getAttribute('AOGUID'); $fias->OFFNAME = $xmlObject->getAttribute('OFFNAME'); $fias->SHORTNAME = $xmlObject->getAttribute('SHORTNAME'); $fias->IFNSFL = $xmlObject->getAttribute('IFNSFL'); $fias->AOLEVEL = $xmlObject->getAttribute('AOLEVEL'); $fias->PARENTGUID = $xmlObject->getAttribute('PARENTGUID'); if ($fias->validate()) { $fias->save(); } else { var_dump($fias->attributes); var_dump($fias->getErrors()); } // $i++; } } } echo 'ok'; $xmlObject->close(); }
protected function findModel($id) { if (($model = Fias::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
public function actionUpdate($id, $patienttype) { $dopparams = ['dopparams' => []]; $model = $this->findModel($id); $modelloaded = $model->load(Yii::$app->request->post()); $GlaukuchetIsNew = false; // Адрес $Fias = new Fias(); // отправлена форма if (isset($_POST['Fias']['AOGUID']) && Yii::$app->user->can('GlaukOperatorPermission')) { // город не заполнен if (empty($_POST['Fias']['AOGUID'])) { $model->id_fias = NULL; $model->patient_dom = NULL; $model->patient_korp = NULL; $model->patient_kvartira = NULL; } else { // город заполнен (Если улица есть, иначе Если улицы нет) $Fias->AOGUID = $_POST['Fias']['AOGUID']; // Если есть улицы $model->id_fias = Fias::Checkstreets($_POST['Fias']['AOGUID']) > 0 ? $_POST['Patient']['id_fias'] : Fias::findOne($_POST['Fias']['AOGUID'])->AOGUID; $model->scenario = 'streetrequired'; // Адрес обязателен } } elseif (!empty($model->id_fias)) { // просто загрузка страницы, если адрес заполнен $address = Fias::findOne($model->id_fias); // Если адрес Улица, иначе Если адрес поселок без улиц $Fias = $address->AOLEVEL == 7 ? Fias::findOne($address->PARENTGUID) : $address; } if ($patienttype === 'glauk' && Yii::$app->user->can('GlaukUserPermission')) { $dopparams['dopparams']['DisableElements'] = !Yii::$app->user->can('GlaukOperatorPermission'); $Glaukuchet = Glaukuchet::findOne(['id_patient' => $model->primaryKey]); if (empty($Glaukuchet)) { $Glaukuchet = new Glaukuchet(); $Glaukuchet->id_patient = $model->primaryKey; $GlaukuchetIsNew = true; } $dopparams['dopparams']['Glaukuchet'] = $Glaukuchet; if (!$Glaukuchet->isNewRecord && Yii::$app->user->can('GlaukOperatorPermission')) { $Glprep = new Glprep(); $Glprep->load(Yii::$app->request->get(), 'Glprep'); $Glprep->id_glaukuchet = $Glaukuchet->primaryKey; if ($Glprep->validate()) { $Glprep->save(false); } } $searchModelglprep = new GlprepSearch(); $dataProviderglprep = $searchModelglprep->search(Yii::$app->request->queryParams); $dopparams['dopparams']['Glprep'] = $Glprep; $dopparams['dopparams']['searchModelglprep'] = $searchModelglprep; $dopparams['dopparams']['dataProviderglprep'] = $dataProviderglprep; } $Fias->scenario = 'citychooserequired'; // Адрес обязателен if (Yii::$app->user->can('GlaukOperatorPermission')) { $transaction = Yii::$app->db->beginTransaction(); try { if ($patienttype === 'glauk' && $modelloaded && $Glaukuchet->load(Yii::$app->request->post()) && Model::validateMultiple([$model, $Glaukuchet, $Fias])) { $model->save(false); $Glaukuchet->save(false); $transaction->commit(); if ($GlaukuchetIsNew) { return $this->render('update', array_merge(['model' => $model, 'Fias' => $Fias, 'patienttype' => $patienttype], $dopparams)); } else { return $this->redirect(Proc::GetPreviousURLBreadcrumbsFromSession()); } } else { // Откатываем транзакцию $transaction->rollBack(); return $this->render('update', array_merge(['model' => $model, 'Fias' => $Fias, 'patienttype' => $patienttype], $dopparams)); } } catch (Exception $e) { $transaction->rollBack(); throw new Exception($e->getMessage()); } } elseif (Yii::$app->user->can('GlaukUserPermission')) { return $this->render('update', array_merge(['model' => $model, 'Fias' => $Fias, 'patienttype' => $patienttype], $dopparams)); } }
/** * @return \yii\db\ActiveQuery */ public function getIdFias() { return $this->hasOne(Fias::className(), ['AOGUID' => 'id_fias'])->from(['idFias' => Fias::tableName()]); }
public static function VariablesValues($attribute, $value = NULL) { $values = ['patient_pol' => Patient::VariablesValues($attribute), 'fias_city' => [$value => Fias::GetCityByAOGUID($value)], 'fias_street' => [$value => Fias::GetStreetByAOGUID($value)], 'glaukuchet_detect' => Glaukuchet::VariablesValues($attribute), 'glaukuchet_deregreason' => Glaukuchet::VariablesValues($attribute), 'glaukuchet_stage' => Glaukuchet::VariablesValues($attribute), 'glaukuchet_invalid' => Glaukuchet::VariablesValues($attribute), 'glaukuchet_id_employee' => [$value => Employee::getEmployeeByID($value)], 'employee_id_person' => [$value => Authuser::getAuthuserByID($value)], 'employee_id_dolzh' => [$value => Dolzh::getDolzhByID($value)], 'employee_id_podraz' => [$value => Podraz::getPodrazByID($value)], 'employee_id_build' => [$value => Build::getBuildByID($value)], 'glprep_id_preparat' => [$value => Preparat::getPreparatByID($value)], 'glprep_rlocat' => Glprep::VariablesValues($attribute)]; return isset($values[$attribute]) ? $values[$attribute] : NULL; }
public static function GetCityByAOGUID($AOGUID) { $result = ''; if (!empty($AOGUID)) { $Fias = self::findOne($AOGUID); if (!empty($Fias)) { $Fias2 = Fias::findOne($Fias->PARENTGUID); $part1 = !empty($Fias2->SHORTNAME) && !empty($Fias2->OFFNAME) ? $Fias2->SHORTNAME . '. ' . $Fias2->OFFNAME : ''; $result = $part1 . ($Fias->AOLEVEL != 7 ? (empty($part1) ? '' : ', ') . $Fias->SHORTNAME . '. ' . $Fias->OFFNAME : ''); } } return $result; }