benefitsService = $benefitsService; $this->educationService = $educationService; $this->olympiadsService = $olympiadsService; $this->contractorService = $contractorService; $this->parentDataService = $parentDataService; $this->passportDataService = $passportDataService; $this->bindApplicationService = $bindApplicationService; $this->sandboxModerateService = $sandboxModerateService; $this->viewApplicationService = $viewApplicationService; $this->targetReceptionsService = $targetReceptionsService; $this->bachelorSpecialityService = $bachelorSpecialityService; $this->specialityPrioritiesService = $specialityPrioritiesService; $this->declineApplicationService = $declineApplicationService; $this->partialApplicationSavingService = $partialApplicationSavingService; $this->sandboxApplicationsTableService = $sandboxApplicationsTableService; $this->allApplicationAttachmentsService = $allApplicationAttachmentsService; parent::__construct($id, $module, $config); } public function getViewPath() { return Yii::getAlias('@common/modules/abiturient/views/sandbox'); } public function beforeAction($action) { $allowMasterSystemManager = Yii::$app->configurationManager->getMasterSystemManagerSetting('use_master_system_manager_interface'); if ($allowMasterSystemManager && $action->id !== 'informing') { $this->redirect(['sandbox/informing', 'name' => 'system_manager.manager_is_not_allowed']); return true; } return parent::beforeAction($action); } public function behaviors() { return [ 'access' => [ 'class' => AccessControl::class, 'rules' => [ [ 'controllers' => ['sandbox'], 'allow' => false, 'roles' => [User::ROLE_ADMINISTRATOR], ], [ 'actions' => [ 'bind-parent', 'bind', 'decline', 'delete-parent-data', 'delete-passport', 'full-package-xml', 'informing', 'is-blocked', 'moderate', 'parent-form', 'render-docs', 'reset-filters', 'return-to-moderate', 'save-address-data', 'save-exam-results', 'save-main-data', 'set-parent-data', 'set-passport', 'unblock', 'update-questionary', 'validate-application', 'save-application', 'want-delete', ], 'allow' => true, 'roles' => [User::ROLE_MANAGER] ], [ 'actions' => [ 'all', 'approved', 'declined', 'deleted', 'enlisted', 'get-all-attachments', 'index', 'preparing', 'questionaries', 'view-archive-application', 'view-questionary', 'view', 'want-delete', 'enrollment-rejection', ], 'allow' => true, 'roles' => [ User::ROLE_VIEWER, User::ROLE_MANAGER ] ], ], ], ]; } public function actions() { return ['error' => ['class' => \yii\web\ErrorAction::class]]; } public function actionUpdateQuestionary(int $id, int $questionary_id) { $questionary = AbiturientQuestionary::findOne((int)$questionary_id); if ($questionary) { $questionary->getFrom1CWithParents(); } return $this->redirect(Url::to(['sandbox/moderate', 'id' => $id]), 302); } public function actionIndex($old = null, $block = null) { $user = Yii::$app->user->identity; if ($old == '1') { Yii::$app->session->setFlash('alert', [ 'body' => 'Открытое вами заявление устарело и было актуализировано из ПК', 'options' => ['class' => 'alert-info'] ]); } if ($block == '1') { Yii::$app->session->setFlash('alert', [ 'body' => 'Заявление, которое вы пытались открыть, уже проверяется другим модератором', 'options' => ['class' => 'alert-danger'] ]); } return $this->render( 'index', $this->sandboxApplicationsTableService->buildAppicationsDataForSandbox($user, 'moderate') ); } public function actionAll() { $user = Yii::$app->user->identity; return $this->render( 'index', $this->sandboxApplicationsTableService->buildAppicationsDataForSandbox($user, 'all') ); } public function actionApproved() { $user = Yii::$app->user->identity; return $this->render( 'index', $this->sandboxApplicationsTableService->buildAppicationsDataForSandbox($user, 'approved') ); } public function actionEnlisted() { $user = Yii::$app->user->identity; return $this->render( 'index', $this->sandboxApplicationsTableService->buildAppicationsDataForSandbox($user, 'enlisted') ); } public function actionDeleted() { $user = Yii::$app->user->identity; return $this->render( 'index', $this->sandboxApplicationsTableService->buildAppicationsDataForSandbox($user, 'deleted') ); } public function actionWantDelete() { $user = Yii::$app->user->identity; return $this->render( 'index', $this->sandboxApplicationsTableService->buildAppicationsDataForSandbox($user, 'want-delete') ); } public function actionPreparing() { $user = Yii::$app->user->identity; return $this->render( 'index', $this->sandboxApplicationsTableService->buildAppicationsDataForSandbox($user, 'preparing') ); } public function actionDeclined() { $user = Yii::$app->user->identity; return $this->render( 'index', $this->sandboxApplicationsTableService->buildAppicationsDataForSandbox($user, 'declined') ); } public function actionQuestionaries() { $searchModel = new QuestionarySearch(); $questionariesDataProvider = $searchModel->search(Yii::$app->request->get()); return $this->render("questionaries", [ 'questionaries' => $questionariesDataProvider, 'searchModel' => $searchModel, 'type' => 'questionaries' ]); } public function actionResetFilters(string $type) { Yii::$app->session->remove('moderate_filters'); return $this->redirect(['sandbox/' . $type]); } public function actionModerate(int $id) { $user = Yii::$app->user->identity; $request = Yii::$app->request; $validation_errors = []; $passportErrors = []; $application = $this->sandboxModerateService->getApplicationById($id); if ($application->isArchive()) { Yii::$app->session->setFlash('alert', [ 'body' => Yii::t('sandbox/errors', "Сообщение модератору при работе с архивным заявлением: `Вы работаете с неактуальной версией заявления {fio}, необходимо открыть его повторно`", ['fio' => $application->fio]), 'options' => ['class' => 'alert-danger'] ]); return $this->redirect(['/sandbox/index']); } if ($moderatingAppId = $this->sandboxModerateService->checkDraftStatusToModerate($application)) { return $this->redirect(['/sandbox/moderate', 'id' => $moderatingAppId]); } if (!$application->moderationAllowedByStatus()) { return $this->redirect('/sandbox/index', 302); } $questionary = $application->abiturientQuestionary; [$blocked, $_] = $application->isApplicationBlocked(); if ($blocked) { return $this->redirect(Url::toRoute(['/sandbox/index', 'block' => 1]), 302); } $this->sandboxModerateService->startModeratingProcess($user, $application); $hasChangesIn1CWithNewerDate = false; $hasBlockedBy1C = false; if (!in_array($application->status, [BachelorApplication::STATUS_WANTS_TO_RETURN_ALL, BachelorApplication::STATUS_WANTS_TO_BE_REMOTE])) { [$hasChangesIn1CWithNewerDate, $hasBlockedBy1C] = NeedBlockAndUpdateProcessor::getProcessedNeedBlockAndUpdate($application); } $add_errors_json = Yii::$app->session->get('add_errors'); $add_errors = json_decode((string)$add_errors_json); Yii::$app->session->remove('add_errors'); $specialities = $this->bachelorSpecialityService->getSelectedSpecialityList($application); $canEdit = $application->type->moderator_allowed_to_edit && $questionary->canEditQuestionary() && $application->canEdit(); $haveValidationErrors = false; $forbiddenResultExists = $application->getEgeResults() ->andWhere(['cget_exam_form_id' => null]) ->exists(); [ 'egeResults' => $egeResults, 'validationErrors' => $validationEgeErrors, 'haveValidationEgeErrors' => $haveValidationEgeErrors, ] = $this->sandboxModerateService->getValidatedEgeResults($application); $validation_errors = array_merge($validation_errors, $validationEgeErrors); $pending_contractors = $this->contractorService->checkAllPendingContractors($application); $need_approve_contractor = $this->contractorService->hasAtLeastOnePendingContractor($pending_contractors); if ($request->isPost && $specialities && !$hasChangesIn1CWithNewerDate && !$hasBlockedBy1C && !$need_approve_contractor) { $application->load(Yii::$app->request->post()); $personal_data = $questionary->personalData; $address_data = $questionary->addressData; $actualAddressData = $questionary->getOrCreateActualAddressData(); $passports = $questionary->passportData; $passportErrors = $this->sandboxModerateService->validatePassports($passports); [ 'checkErrors' => $check_errors, 'haveValidationErrors' => $haveValidationErrors, ] = $this->sandboxModerateService->checkBalls($application, $specialities); if ($check_errors) { Yii::$app->session->setFlash('checkEgeErrorsAbit', json_encode($check_errors)); } $validateAgreementDate = $this->sandboxModerateService->validateAgreement($application, $specialities); if ( $application->validate() && $personal_data->validate() && empty($passportErrors) && $address_data->validate() && $actualAddressData->validate() && Model::validateMultiple($specialities) && $validateAgreementDate && $application->validateUnstagedDisciplineSets() && $application->validateUnstagedDisciplineResults() && !$haveValidationErrors && !$forbiddenResultExists && !$haveValidationEgeErrors ) { $approval_error = null; $transaction = Yii::$app->db->beginTransaction(); try { $application->save(true, ['moderator_comment']); gc_disable(); if ($application->getSandboxSendHandler()->send()) { $this->sandboxModerateService->afterSuccessFullApplicationApprovement($user, $application); $transaction->commit(); return $this->redirect('/sandbox/index'); } $application = $this->sandboxModerateService->afterFailureOnApplicationApprovement($application); $transaction->commit(); } catch (Throwable $e) { $transaction->rollBack(); $approval_error = $e->getMessage(); } $error_text = $this->sandboxModerateService->composeApplyingStepsErrors($application, $approval_error); Yii::$app->session->setFlash('appApprovingError', $error_text); if (!$approval_error && $this->failedPossibleOfDuplicate($application->applyingSteps)) { [ 'abiturientDoubles' => $abiturientDoubles, 'doublesForParents' => $doublesForParents, ] = $this->sandboxModerateService->checkPersonDuplicates($questionary); if ($abiturientDoubles || $doublesForParents) { Yii::$app->session->setFlash('abiturientDoubles', $abiturientDoubles); Yii::$app->session->setFlash('doublesForParents', $doublesForParents); return $this->redirect(Url::to([ 'sandbox/view', 'id' => $application->id, ])); } } return $this->redirect(['/sandbox/moderate', 'id' => $application->id]); } $modelsToValidate = [ $application, $personal_data, $address_data, $actualAddressData, ]; foreach ($modelsToValidate as $model) { if ($model && $model->errors) { $validation_errors[] = $model->errors; } } } if ($forbiddenResultExists) { $validation_errors[] = [[Yii::t( 'sandbox/moderate/all', 'Текст ошибки об отсутствии формы сдачи ВИ, на странице проверки заявления: `У поступающего присутствуют результаты вступительных испытаний с без выбранной формы сдачи. Отклоните заявление для выбора формы поступающим или выберите форму самостоятельно.`' )]]; } if (!$application->validateUnstagedDisciplineSets()) { $validation_errors[] = [[Yii::t( 'abiturient/bachelor/check-all-application/all', 'Текст ошибки для отсутствующего набора ВИ; при валидации данных анкеты или заявления: `Необходимо подтвердить набор вступительных испытаний`' )]]; } if (!$application->validateUnstagedDisciplineResults()) { $validation_errors[] = [[Yii::t( 'abiturient/bachelor/check-all-application/all', 'Текст ошибки при не сохранённых результатах ВИ; при валидации данных анкеты или заявления: `Необходимо сохранить результаты вступительных испытаний`' )]]; } if ($haveValidationErrors) { $validation_errors[] = [[Yii::t( 'abiturient/bachelor/check-all-application/all', 'Текст ошибки валидации результатов ВИ; при валидации данных анкеты или заявления: `Ошибка валидации результатов вступительных испытаний`' )]]; } if ($passportErrors) { $validation_errors = ArrayHelper::merge($validation_errors, $passportErrors); } $specErrors = $this->sandboxModerateService->validateSpecialities($specialities); $allowBenefitCategories = !ArrayHelper::getValue($application, 'type.hide_benefits_block', false); $available_specialities = SpecialityRepository::getCurrentAvailableSpecialities( $application, $allowBenefitCategories ) ->with('educationFormRef') ->with('educationFormRef') ->with('educationSourceRef') ->with('competitiveGroupRef') ->with('detailGroupRef') ->with('subdivisionRef') ->all(); $individualAchievements = new ActiveDataProvider([ 'query' => $application->getIndividualAchievements() ]); $regulations = UserRegulationRepository::GetAllUserRegulationsByRelatedEntity( $application->abiturientQuestionary, array_keys(RegulationRelationManager::GetRelatedList()), $application ); foreach ($regulations as $regulation) { if ($regulation->regulation->attachment_type !== null && $regulation->getAttachments()->exists()) { $newAttachment = new Attachment(); $newAttachment->owner_id = $application->user_id; $newAttachment->attachment_type_id = $regulation->regulation->attachment_type; $regulation->setRawAttachment($newAttachment); } } [ 'reallySentApplication' => $really_sent_app, 'reallySentQuestionary' => $really_sent_questionary, ] = $this->sandboxModerateService->getReallySentApplicationAndQuestionary($application); $resultTargets = $this->targetReceptionsService->getTargets($application->id); $resultBenefits = $this->benefitsService->getBenefits($application->id); $resultOlympiads = $this->olympiadsService->getOlympiads($application->id); $actual_application = DraftsManager::getActualApplication($application->user, $application->type); $actual_questionary = DraftsManager::getActualQuestionary($application->user); $application->setScenario(BachelorApplication::SCENARIO_APPLICATION_WITH_EDUCATION); return $this->render( 'moderate', ArrayHelper::merge( [ 'application_comparison_with_actual' => $actual_application && $actual_application->id != $application->id ? EntitiesComparator::compare($actual_application, $application) : null, 'questionary_comparison_with_actual' => $actual_questionary && $actual_questionary->id != $questionary->id ? EntitiesComparator::compare($actual_questionary, $questionary) : null, 'application_comparison_with_sent' => $really_sent_app && $really_sent_app->id != $application->id ? EntitiesComparator::compare($really_sent_app, $application) : null, 'questionary_comparison_with_sent' => $really_sent_questionary && $really_sent_questionary->id != $questionary->id ? EntitiesComparator::compare($really_sent_questionary, $questionary) : null, 'passports' => new ActiveDataProvider([ 'query' => $questionary->getPassportData() ]), 'egeResult' => new EgeResult(), 'competitiveGroupEntranceTest' => DictionaryCompetitiveGroupEntranceTest::getDataProviderByApplication($application), 'parents' => new ActiveDataProvider([ 'query' => $questionary->getParentData() ]), 'canEdit' => $canEdit, 'application' => $application, 'questionary' => $questionary, 'abitAvatar' => $questionary->getComputedAbiturientAvatar(), 'regulations' => $regulations, 'available_specialities' => $available_specialities, 'individualAchievements' => $individualAchievements, 'add_errors' => $add_errors, 'validation_errors' => $validation_errors, 'target_receptions' => ArrayHelper::map($application->bachelorTargetReceptions, 'id', 'name'), 'specialityErrors' => $specErrors, 'egeResults' => $egeResults, 'specialities' => $specialities, 'resultOlympiads' => $resultOlympiads, 'resultBenefits' => $resultBenefits, 'resultTargets' => $resultTargets, 'hasChangesIn1CWithNewerDate' => $hasChangesIn1CWithNewerDate, 'hasBlockedBy1C' => $hasBlockedBy1C, 'pending_contractors' => $pending_contractors, 'need_approve_contractor' => $need_approve_contractor, 'targetReceptionsService' => $this->targetReceptionsService, 'olympiadsService' => $this->olympiadsService, 'benefitsService' => $this->benefitsService, 'bachelorSpecialityService' => $this->bachelorSpecialityService, 'specialityPrioritiesService' => $this->specialityPrioritiesService, ], SpecialityRepository::getSpecialityFiltersData($application) ) ); } private function failedPossibleOfDuplicate(array $steps): bool { return (bool)array_filter($steps, function (ApplicationApplyingStep $step) { return $step->errors && array_filter($step->errors, function (string $error) { return ErrorMessageAnalyzer::isUserRefDuplicateError($error); }); }); } public function actionSaveMainData(int $quest_id) { $questionary = $this->partialApplicationSavingService->getAbiturientQuestionaryById($quest_id); $errorEmailValidate = $this->partialApplicationSavingService->validateEmail($questionary); if ($errorEmailValidate) { return $this->asJson([ 'status' => false, 'message' => $errorEmailValidate, ]); } $errorPersonalDataValidate = $this->partialApplicationSavingService->validatePersonalData($questionary); if ($errorPersonalDataValidate) { return $this->asJson([ 'status' => false, 'message' => $errorPersonalDataValidate ]); } return $this->asJson([ 'status' => true, 'message' => Yii::t( 'sandbox/moderate/all', 'Текст сообщения при успешном сохранении формы персональных данных: `Данные сохранены успешно`' ), ]); } public function actionSaveAddressData(string $type, int $questionary_id) { $questionary = $this->partialApplicationSavingService->getAbiturientQuestionaryById($questionary_id); $errorAddressDataValidate = $this->partialApplicationSavingService->validateAddressData( $questionary, $type ); if ($errorAddressDataValidate) { return $this->asJson([ 'status' => false, 'message' => $errorAddressDataValidate ]); } return $this->asJson([ 'status' => true, 'message' => Yii::t( 'sandbox/moderate/all', 'Текст сообщения при успешном сохранении формы адреса: `Данные сохранены успешно`' ), ]); } public function actionDecline(int $id) { if (!Yii::$app->request->isPost) { return $this->redirect('/sandbox/index', 302); } $application = BachelorApplication::findOne((int)$id); if ($application->isArchive()) { Yii::$app->session->setFlash('alert', [ 'body' => Yii::t('sandbox/errors', "Сообщение модератору при работе с архивным заявлением: `Вы работаете с неактуальной версией заявления {fio}, необходимо открыть его повторно`", ['fio' => $application->fio]), 'options' => ['class' => 'alert-danger'] ]); return $this->redirect(['/sandbox/index']); } if ($application->block_status != BachelorApplication::BLOCK_STATUS_ENABLED) { return $this->redirect(Url::to(['sandbox/moderate', 'id' => $application->id]), 302); } $sent_app = DraftsManager::getApplicationDraft($application->user, $application->type, IDraftable::DRAFT_STATUS_SENT); $transaction = Yii::$app->db->beginTransaction(); try { $declined_app = $this->declineApplicationService->decline(Yii::$app->user->identity, $sent_app); Yii::$app->notifier->notifyAboutDeclineApplication($declined_app->user_id, $declined_app->moderator_comment); $transaction->commit(); } catch (Throwable $e) { $transaction->rollBack(); throw $e; } return $this->redirect('/sandbox/index', 302); } public function actionSaveExamResults(int $id) { $application = BachelorApplication::findOne($id); if (empty($application)) { return $this->asJson([ 'status' => false, 'message' => 'Не удалось найти заявление.', ]); } $msgs = []; [ 'hasError' => $hasError, 'hasChanges' => $hasChanges, ] = EntrantTestManager::proceedEntrantTestFromPost(Yii::$app->request, $application, $msgs); return $this->asJson([ 'status' => !$hasError, 'message' => implode(', ', $msgs), ]); } public function actionSaveApplication(int $id) { if (!Yii::$app->request->isPost) { return $this->redirect(['/sandbox/moderate', 'id' => $id]); } $application = BachelorApplication::findOne($id); if (empty($application)) { return $this->asJson([ 'status' => false, 'message' => 'Не удалось найти заявление.', ]); } $application->setScenario(BachelorApplication::SCENARIO_APPLICATION_WITH_EDUCATION); $questionary = $application->abiturientQuestionary; $canEdit = $application->type->moderator_allowed_to_edit && $questionary->canEditQuestionary() && $application->canEdit(); if (!$canEdit) { return $this->redirect(['/sandbox/moderate', 'id' => $id]); } $specialities = $this->bachelorSpecialityService->getSelectedSpecialityList($application); [$spec_changed, $_] = $this->bachelorSpecialityService->processLoadedData( $application, $specialities, Yii::$app->request->post(), true ); if (!$spec_changed) { Yii::$app->session->setFlash('alert', [ 'body' => Yii::$app->configurationManager->getText('no_data_saved_text', $application->type ?? null), 'options' => ['class' => 'alert-warning'] ]); } return $this->redirect(['/sandbox/moderate', 'id' => $id]); } public function actionUnblock(int $id) { $application = BachelorApplication::findOne((int)$id); if ($application != null) { $application->fullyUnblockApplication(); } return $this->redirect('/sandbox/index', 302); } public function actionViewQuestionary(int $id) { $questionary = AbiturientQuestionary::findOne((int)$id); return $this->render("questionary_view", [ 'questionary' => $questionary, ]); } public function actionView(int $id) { $relationInfo = []; $code_message = ''; $parents_code_message = ''; if ($abiturientDoubles = Yii::$app->session->getFlash('abiturientDoubles')) { $code_message = Yii::t( 'sandbox/errors', 'Текст при сопоставлении поступающего: `Обнаружено совпадение персональных данных поступающего с данными физического лица в базе ПК. Следует ли сопоставить этого поступающего с существующим физическим лицом?`' ); $relationInfo['abit'] = $abiturientDoubles; } if ($doublesForParents = Yii::$app->session->getFlash('doublesForParents')) { $parents_code_message = Yii::t( 'sandbox/errors', 'Текст при сопоставлении родителя поступающего: `Обнаружено совпадение персональных данных родителя с данными физического лица в базе ПК. Следует ли сопоставить родителя с существующим физическим лицом?`' ); $relationInfo['parents'] = $doublesForParents; } [ 'application' => $application, 'questionary' => $questionary, 'regulations' => $regulations, 'moderatingAppId' => $moderatingAppId, 'individualAchievements' => $individualAchievements, ] = $this->viewApplicationService->getAllModelForView($id); $resultTargets = $this->targetReceptionsService->getTargets($id); $resultBenefits = $this->benefitsService->getBenefits($id); $resultOlympiads = $this->olympiadsService->getOlympiads($id); return $this->render( 'view', [ 'id' => $id, 'individualAchievements' => $individualAchievements, 'competitiveGroupEntranceTest' => DictionaryCompetitiveGroupEntranceTest::getDataProviderByApplication($application), 'questionary' => $questionary, 'regulations' => $regulations, 'application' => $application, 'relationInfo' => $relationInfo, 'code_message' => $code_message, 'parents_code_message' => $parents_code_message, 'moderate_app_id' => $moderatingAppId, 'resultOlympiads' => $resultOlympiads, 'resultBenefits' => $resultBenefits, 'resultTargets' => $resultTargets, 'benefitsService' => $this->benefitsService, 'targetReceptionsService' => $this->targetReceptionsService, 'olympiadsService' => $this->olympiadsService, ] ); } public function actionGetAllAttachments(int $id, string $type) { [ 'hasError' => $hasError, 'filename' => $filename, 'pathToZipArchive' => $pathToZipArchive, ] = $this->allApplicationAttachmentsService->getZipArchiveAttribute($id, $type); if ($hasError) { return false; } Yii::$app->response->sendFile($pathToZipArchive, $filename)->on( Response::EVENT_AFTER_SEND, function ($event) { unlink($event->data); }, $pathToZipArchive ); } public function actionBind() { $id = Yii::$app->request->post('application_id'); $url = Url::to(['sandbox/moderate', 'id' => $id]); if (!Yii::$app->request->isPost) { return $this->redirect($url, 302); } if ($this->bindApplicationService->bindUser(Yii::$app->user->identity, $id)) { Yii::$app->session->setFlash('bind', 'Поступающий успешно сопоставлен с Физ. лицом. Можно "Одобрить" заявление.'); } return $this->redirect($url, 302); } public function actionBindParent(int $id) { $url = Url::to(['sandbox/moderate', 'id' => $id]); if (!Yii::$app->request->isPost) { return $this->redirect($url); } if ($parentFullName = $this->bindApplicationService->bindParent()) { Yii::$app->session->setFlash('bind', "Родитель {$parentFullName} успешно сопоставлен с Физ. лицом. Можно \"Одобрить\" заявление."); } return $this->redirect($url); } private function renderPassports(AbiturientQuestionary $questionary) { $canEdit = $questionary->canEditQuestionary(); $passports = new ActiveDataProvider([ 'query' => $questionary->getPassportData() ]); return $this->renderAjax( "../abiturient/questionary_partial/_document_grid", [ 'passports' => $passports, 'canEdit' => $canEdit, ] ); } public function actionDeletePassport() { $app_id = Yii::$app->request->post('appId'); $application = BachelorApplication::findOne((int)$app_id); $user = Yii::$app->user->identity; $questionary = $application->abiturientQuestionary; $this->passportDataService->deletePassportData($user, $questionary); return $this->renderPassports($questionary); } public function actionSetPassport() { if (Yii::$app->request->isPost) { $app_id = Yii::$app->request->post('appId'); $application = BachelorApplication::findOne($app_id); $questionary = $application->abiturientQuestionary; $user = Yii::$app->user->identity; $this->passportDataService->setPassportData($user, $questionary); } if (!Yii::$app->request->isAjax) { return $this->redirect(Yii::$app->request->referrer ?? Yii::$app->homeUrl); } else { return $this->asJson(['status' => true, 'messages' => []]); } } public function actionReturnToModerate(int $id, bool $remove_from_one_s) { $bachelorApplication = BachelorApplication::findOne(['id' => $id]); if (!$bachelorApplication) { throw new NotFoundHttpException(); } if ($bachelorApplication->isArchive()) { Yii::$app->session->setFlash('alert', [ 'body' => Yii::t('sandbox/errors', "Сообщение модератору при возврате к модерации архивного заявления: `Вы работаете с неактуальной версией заявления {fio}`", ['fio' => $bachelorApplication->fio]), 'options' => ['class' => 'alert-danger'] ]); return $this->redirect(['/sandbox/index']); } if (!($bachelorApplication->status == ApplicationInterface::STATUS_NOT_APPROVED || ($bachelorApplication->status == ApplicationInterface::STATUS_APPROVED && Yii::$app->configurationManager->getAllowReturnApprovedApplicationToModerating()))) { return $this->redirect(Url::toRoute(['/sandbox/view', 'id' => $bachelorApplication->id])); } $transaction = Yii::$app->db->beginTransaction(); try { $bachelorApplication = $this->viewApplicationService->returnToModerate(Yii::$app->user->identity, $bachelorApplication, $remove_from_one_s); $transaction->commit(); } catch (Throwable $e) { $transaction->rollBack(); Yii::error("Ошибка при восстановлении статуса заявления\n" . print_r($bachelorApplication->errors, true)); throw $e; } return $this->redirect(Url::toRoute(['/sandbox/moderate', 'id' => $bachelorApplication->id])); } public function actionParentForm() { $app_id = Yii::$app->request->post('appId'); $application = BachelorApplication::findOne($app_id); $questionary = $application->abiturientQuestionary; $user = $questionary->user; $model = $this->parentDataService->getOrBuildParentData( $user, $questionary, 'parentDataId' ); $canEdit = $questionary->canEditQuestionary() && $application->type->moderator_allowed_to_edit && $application->canEdit(); $action = Url::to(array_merge( ['/abiturient/set-parent-data'], $model->id ? ['id' => $model->id] : [] )); return $this->renderAjax( '../abiturient/questionary_partial/parentData/_parentForm', [ 'model' => $model, 'familyTypes' => $this->parentDataService->getFamilyTypes(), 'passportTypes' => $this->parentDataService->getAllIdentityDocuments(), 'document_type' => $this->parentDataService->getDocumentTypeID(), 'keynum' => $model->id, 'action' => $action, 'canEdit' => $canEdit, 'isReadonly' => !$canEdit, 'application' => $application, ] ); } public function actionSetParentData() { if (!Yii::$app->request->isAjax) { throw new UserException('Is not ajax'); } $app_id = Yii::$app->request->post('appId'); $application = BachelorApplication::findOne($app_id); $questionary = $application->abiturientQuestionary; $user = $questionary->user; $parentData = $this->parentDataService->getOrBuildParentData( $user, $questionary, 'ParentData.id' ); [ 'parentData' => $parentData, 'addressData' => $addressData, 'passportData' => $passportData, 'personalData' => $personalData, ] = $this->parentDataService->loadParentData( $parentData ); $transaction = $parentData->getDb()->beginTransaction(); try { $success = $this->parentDataService->setParentData( $user, $parentData, $passportData, $personalData, $addressData ); if (!$success) { $transaction->rollBack(); Yii::$app->response->statusCode = 400; return Html::errorSummary([$personalData, $addressData, $passportData, $parentData], [ 'header' => '