<?php
namespace App\Controller;
use App\Entity\ActionLog;
use App\Entity\Addressing;
use App\Entity\Admission;
use App\Entity\AdmissionFile;
use App\Entity\AdmissionUser;
use App\Entity\AdmissionUserComment;
use App\Entity\Payment;
use App\Entity\User;
use App\Entity\UserEducation;
use App\Entity\UserFile;
use App\Entity\UserInfo;
use App\Entity\UserSat;
use App\Entity\UserSatResult;
use App\Filter\AdmissionUserFilter;
use App\Filter\AdmissionUserFilterType;
use App\Form\AdmissionUserFeType;
use App\Form\AdmissionUserStateType;
use App\Form\AdmissionUserType;
use App\Services\AdmissionUserService;
use App\Services\Payment\PaymentService;
use App\Services\SatUserService;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\Query\Expr\Join;
use Doctrine\ORM\QueryBuilder;
use Knp\Component\Pager\PaginatorInterface;
use PhpOffice\PhpSpreadsheet\Cell\Coordinate;
use PhpOffice\PhpSpreadsheet\Spreadsheet;
use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\ResponseHeaderBag;
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Symfony\Component\Mailer\Exception\TransportExceptionInterface;
use Symfony\Component\Mailer\MailerInterface;
use Symfony\Component\Mime\Email;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
#[Route('/admission')]
class AdmissionUserController extends AbstractController implements AdminFilterController
{
protected function exportResult(EntityManagerInterface $em, QueryBuilder $qb, $lessonCodes)
{
$admissionUsers = $qb
->getQuery()
->getResult();
$spreadsheet = new Spreadsheet();
$sheet = $spreadsheet->getActiveSheet();
$colIndex = 0;
$colIndex++;
$col = Coordinate::stringFromColumnIndex($colIndex);
$sheet->getCell($col . "1")->setValue("БҮТ:");
$colIndex++;
$col = Coordinate::stringFromColumnIndex($colIndex);
$sheet->getCell($col . "1")->setValue("Ургийн овог:");
$colIndex++;
$col = Coordinate::stringFromColumnIndex($colIndex);
$sheet->getCell($col . "1")->setValue("Нэр:");
$colIndex++;
$col = Coordinate::stringFromColumnIndex($colIndex);
$sheet->getCell($col . "1")->setValue("Овог:");
$colIndex++;
$col = Coordinate::stringFromColumnIndex($colIndex);
$sheet->getCell($col . "1")->setValue("Нэр /англиар/:");
$colIndex++;
$col = Coordinate::stringFromColumnIndex($colIndex);
$sheet->getCell($col . "1")->setValue("Овог /англиар/:");
$colIndex++;
$col = Coordinate::stringFromColumnIndex($colIndex);
$sheet->getCell($col . "1")->setValue("Регистер:");
$colIndex++;
$col = Coordinate::stringFromColumnIndex($colIndex);
$sheet->getCell($col . "1")->setValue("Яс үндэс:");
$colIndex++;
$col = Coordinate::stringFromColumnIndex($colIndex);
$sheet->getCell($col . "1")->setValue("Хүйс :");
$colIndex++;
$col = Coordinate::stringFromColumnIndex($colIndex);
$sheet->getCell($col . "1")->setValue("Төрсөн огноо:");
$colIndex++;
$col = Coordinate::stringFromColumnIndex($colIndex);
$sheet->getCell($col . "1")->setValue("Мэйл:");
$colIndex++;
$col = Coordinate::stringFromColumnIndex($colIndex);
$sheet->getCell($col . "1")->setValue("Утас1:");
$colIndex++;
$col = Coordinate::stringFromColumnIndex($colIndex);
$sheet->getCell($col . "1")->setValue("Утас2:");
$colIndex++;
$col = Coordinate::stringFromColumnIndex($colIndex);
$sheet->getCell($col . "1")->setValue("Сонгосон мэргэжил:");
// sat result
$colIndex++;
$col = Coordinate::stringFromColumnIndex($colIndex);
$sheet->getCell($col . "1")->setValue("ЭЕШ Математик:");
$colIndex++;
$col = Coordinate::stringFromColumnIndex($colIndex);
$sheet->getCell($col . "1")->setValue("ЭЕШ Нийгэм:");
$colIndex++;
$col = Coordinate::stringFromColumnIndex($colIndex);
$sheet->getCell($col . "1")->setValue("ЭЕШ Англи хэл:");
// havsralt
$colIndex++;
$col = Coordinate::stringFromColumnIndex($colIndex);
$sheet->getCell($col . "1")->setValue("Иргэний үнэмлэхний хуулбар:");
$colIndex++;
$col = Coordinate::stringFromColumnIndex($colIndex);
$sheet->getCell($col . "1")->setValue("ЭЕШ-ийн батламж хуулбар:");
$colIndex++;
$col = Coordinate::stringFromColumnIndex($colIndex);
$sheet->getCell($col . "1")->setValue("Цээж зураг:");
//tugsgul
$colIndex++;
$col = Coordinate::stringFromColumnIndex($colIndex);
$sheet->getCell($col . "1")->setValue("Бүртгэлийн хураамж");
$colIndex++;
$col = Coordinate::stringFromColumnIndex($colIndex);
$sheet->getCell($col . "1")->setValue("Кредитийн төлбөр");
$colIndex++;
$col = Coordinate::stringFromColumnIndex($colIndex);
$sheet->getCell($col . "1")->setValue("Хэлний мэдээлэл:Хэл");
$colIndex++;
$col = Coordinate::stringFromColumnIndex($colIndex);
$sheet->getCell($col . "1")->setValue("Хэлний мэдээлэл:Ярих");
$colIndex++;
$col = Coordinate::stringFromColumnIndex($colIndex);
$sheet->getCell($col . "1")->setValue("Хэлний мэдээлэл:Унших");
$colIndex++;
$col = Coordinate::stringFromColumnIndex($colIndex);
$sheet->getCell($col . "1")->setValue("Хэлний мэдээлэл:Бичих");
$colIndex++;
$col = Coordinate::stringFromColumnIndex($colIndex);
$sheet->getCell($col . "1")->setValue("Хэлний мэдээлэл:Сонсох");
$colIndex++;
$col = Coordinate::stringFromColumnIndex($colIndex);
$sheet->getCell($col . "1")->setValue("Ажил эрхлэлтийн мэдээлэл:Ажиллаж байгаа салбар");
$colIndex++;
$col = Coordinate::stringFromColumnIndex($colIndex);
$sheet->getCell($col . "1")->setValue("Ажил эрхлэлтийн :Байгуулгын нэр");
$colIndex++;
$col = Coordinate::stringFromColumnIndex($colIndex);
$sheet->getCell($col . "1")->setValue("Ажил эрхлэлтийн :Албан тушаал");
$colIndex++;
$col = Coordinate::stringFromColumnIndex($colIndex);
$sheet->getCell($col . "1")->setValue("Гэр бүлийн мэдээлэл:Хобоо хамаарал");
$colIndex++;
$col = Coordinate::stringFromColumnIndex($colIndex);
$sheet->getCell($col . "1")->setValue("Гэр бүлийн мэдээлэл:Овог");
$colIndex++;
$col = Coordinate::stringFromColumnIndex($colIndex);
$sheet->getCell($col . "1")->setValue("Гэр бүлийн мэдээлэл:Нэр");
$colIndex++;
$col = Coordinate::stringFromColumnIndex($colIndex);
$sheet->getCell($col . "1")->setValue("Гэр бүлийн мэдээлэл:РД");
$colIndex++;
$col = Coordinate::stringFromColumnIndex($colIndex);
$sheet->getCell($col . "1")->setValue("Гэр бүлийн мэдээлэл:Цахим шуудан");
$colIndex++;
$col = Coordinate::stringFromColumnIndex($colIndex);
$sheet->getCell($col . "1")->setValue("Гэр бүлийн мэдээлэл:Холбоо барих дугаар");
$colIndex++;
$col = Coordinate::stringFromColumnIndex($colIndex);
$sheet->getCell($col . "1")->setValue("Гэр бүлийн мэдээлэл:Байгуулгын нэр албан тушаал");
$colIndex++;
$col = Coordinate::stringFromColumnIndex($colIndex);
$sheet->getCell($col . "1")->setValue("Сургуулийн мэдээлэл:Улс");
$colIndex++;
$col = Coordinate::stringFromColumnIndex($colIndex);
$sheet->getCell($col . "1")->setValue("Сургуулийн мэдээлэл:Аймаг хот");
$colIndex++;
$col = Coordinate::stringFromColumnIndex($colIndex);
$sheet->getCell($col . "1")->setValue("Сургуулийн мэдээлэл:Сургууль");
$colIndex++;
$col = Coordinate::stringFromColumnIndex($colIndex);
$sheet->getCell($col . "1")->setValue("Сургуулийн мэдээлэл:Гэрчилгээний дугаар");
$colIndex++;
$col = Coordinate::stringFromColumnIndex($colIndex);
$sheet->getCell($col . "1")->setValue("Сургуулийн мэдээлэл:Зэрэг");
$colIndex++;
$col = Coordinate::stringFromColumnIndex($colIndex);
$sheet->getCell($col . "1")->setValue("Сургуулийн мэдээлэл:Мэргэжил");
$colIndex++;
$col = Coordinate::stringFromColumnIndex($colIndex);
$sheet->getCell($col . "1")->setValue("Сургуулийн мэдээлэл:Төгссөн он");
$colIndex++;
$col = Coordinate::stringFromColumnIndex($colIndex);
$sheet->getCell($col . "1")->setValue("Сургуулийн мэдээлэл:Голч дүн");
//hayg
$colIndex++;
$col = Coordinate::stringFromColumnIndex($colIndex);
$sheet->getCell($col . "1")->setValue("Хаяг:Үндсэн захиргаа");
$colIndex++;
$col = Coordinate::stringFromColumnIndex($colIndex);
$sheet->getCell($col . "1")->setValue("Хаяг:Сум, дүүрэг");
$colIndex++;
$col = Coordinate::stringFromColumnIndex($colIndex);
$sheet->getCell($col . "1")->setValue("Хаяг:Баг, хороо");
$colIndex++;
$col = Coordinate::stringFromColumnIndex($colIndex);
$sheet->getCell($col . "1")->setValue("Хаяг:Хороолол, байр тоот");
$colIndex++;
$col = Coordinate::stringFromColumnIndex($colIndex);
$sheet->getCell($col . "1")->setValue("Хаяг:Амьдарч буй газар");
foreach ($lessonCodes as $lessonCode) {
$colIndex++;
$col = Coordinate::stringFromColumnIndex($colIndex);
$sheet->getCell($col . "1")->setValue($lessonCode);
}
$curDate = new \DateTime('today');
$minSatYear = ((int)$curDate->format('Y')) - 2;
$row = 2;
/** @var AdmissionUser $admissionUser */
$userEducations = $em->getRepository(UserEducation::class)
->createQueryBuilder('user_education')
->getQuery()
->getResult();
foreach ($admissionUsers as $admissionUser) {
$user = $admissionUser->getUser();
$userInfo = $user?->getUserInfo();
$check = true;
$count = 0;
$userEducation = null;
foreach($userEducations as $userEducation1){
if($userEducation1->getUserInfo()->getId() == $userInfo?->getId()){
$userEducation = $userEducation1;
break;
}
}
$colIndex = 0;
$colIndex++;
$col = Coordinate::stringFromColumnIndex($colIndex);
$sheet->getCell($col . $row)->setValue($admissionUser->getSatCode());
$colIndex++;
$col = Coordinate::stringFromColumnIndex($colIndex);
$sheet->getCell($col . $row)->setValue($userInfo?->getFamilyName());
$colIndex++;
$col = Coordinate::stringFromColumnIndex($colIndex);
$sheet->getCell($col . $row)->setValue($userInfo?->getFirstnameMn());
$colIndex++;
$col = Coordinate::stringFromColumnIndex($colIndex);
$sheet->getCell($col . $row)->setValue($userInfo?->getLastnameMn());
$colIndex++;
$col = Coordinate::stringFromColumnIndex($colIndex);
$sheet->getCell($col . $row)->setValue($userInfo?->getFirstnameEn());
$colIndex++;
$col = Coordinate::stringFromColumnIndex($colIndex);
$sheet->getCell($col . $row)->setValue($userInfo?->getLastnameEn());
$colIndex++;
$col = Coordinate::stringFromColumnIndex($colIndex);
$sheet->getCell($col . $row)->setValue($userInfo?->getRegNum());
$colIndex++;
$col = Coordinate::stringFromColumnIndex($colIndex);
$sheet->getCell($col . $row)->setValue($userInfo?->getNationality()?->getName());
$colIndex++;
$col = Coordinate::stringFromColumnIndex($colIndex);
$sheet->getCell($col . $row)->setValue($userInfo?->getGender() ? "эр" : "эм");
$colIndex++;
$col = Coordinate::stringFromColumnIndex($colIndex);
$sheet->getCell($col . $row)->setValue($userInfo?->getBirthDate());
$colIndex++;
$col = Coordinate::stringFromColumnIndex($colIndex);
$sheet->getCell($col . $row)->setValue($user?->getEmail());
$colIndex++;
$col = Coordinate::stringFromColumnIndex($colIndex);
$sheet->getCell($col . $row)->setValue($userInfo?->getMobile());
$colIndex++;
$col = Coordinate::stringFromColumnIndex($colIndex);
$sheet->getCell($col . $row)->setValue($userInfo?->getPhoneHome());
$colIndex++;
$col = Coordinate::stringFromColumnIndex($colIndex);
if ($admissionUser->getState() != 'C') {
$sheet->getCell($col . $row)->setValue($admissionUser?->getAdmissionRegister()?->getStudyProgram()?->getDescription());
} else {
$sheet->getCell($col . $row)->setValue($admissionUser?->getAdmissionRegister()?->getStudyProgram()?->getDescription());
}
$userSat = $em->getRepository(UserSat::class)->findOneBy([
'userInfo' => $userInfo?->getId()
]);
if ($userSat) {
$matScore = $em->getRepository(UserSatResult::class)->findOneBy([
'userSat' => $userSat->getId(),
'lessonName' => 'mat'
], [
'lessonScore' => 'DESC'
]);
$ngmScore = $em->getRepository(UserSatResult::class)->findOneBy([
'userSat' => $userSat->getId(),
'lessonName' => 'ngm'
], [
'lessonScore' => 'DESC'
]);
$engScore = $em->getRepository(UserSatResult::class)->findOneBy([
'userSat' => $userSat->getId(),
'lessonName' => 'eng'
], [
'lessonScore' => 'DESC'
]);
$colIndex++;
$col = Coordinate::stringFromColumnIndex($colIndex);
$sheet->getCell($col . $row)->setValue($matScore ? $matScore->getLessonScore() : 'ЭЕШ оноогүй');
$colIndex++;
$col = Coordinate::stringFromColumnIndex($colIndex);
$sheet->getCell($col . $row)->setValue($ngmScore ? $ngmScore->getLessonScore() : 'ЭЕШ оноогүй');
$colIndex++;
$col = Coordinate::stringFromColumnIndex($colIndex);
$sheet->getCell($col . $row)->setValue($engScore ? $engScore->getLessonScore() : 'ЭЕШ оноогүй');
} else {
$colIndex++;
$col = Coordinate::stringFromColumnIndex($colIndex);
$sheet->getCell($col . $row)->setValue("ЭЕШ оноогүй");
$colIndex++;
$col = Coordinate::stringFromColumnIndex($colIndex);
$sheet->getCell($col . $row)->setValue("ЭЕШ оноогүй");
$colIndex++;
$col = Coordinate::stringFromColumnIndex($colIndex);
$sheet->getCell($col . $row)->setValue("ЭЕШ оноогүй");
}
$idFile = $em->getRepository(UserFile::class)->findBy([
'userInfo' => $userInfo
]);
$irgen = null;
$tseej = null;
$eyesh = null;
foreach ($idFile as $file) {
if ($file->getFileType()->getId() == 36) {
$irgen = $file;
} else if ($file->getFileType()->getId() == 45) {
$tseej = $file;
} else {
$eyesh = $file;
}
}
$prefix = "https://infosys.ufe.edu.mn:9443";
//ehlel
$colIndex++;
$col = Coordinate::stringFromColumnIndex($colIndex);
$sheet->getCell($col . $row)->setValue($prefix . $irgen?->getFilePath());
$colIndex++;
$col = Coordinate::stringFromColumnIndex($colIndex);
$sheet->getCell($col . $row)->setValue($prefix . $tseej?->getFilePath());
$colIndex++;
$col = Coordinate::stringFromColumnIndex($colIndex);
$sheet->getCell($col . $row)->setValue($prefix . $eyesh?->getFilePath());
//tugsgul
$colIndex++;
$col = Coordinate::stringFromColumnIndex($colIndex);
if ($admissionUser?->getPaymentRegisterFee() != null) {
$sheet->getCell($col . $row)->setValue($admissionUser?->getPaymentRegisterFee()?->getState());
} else {
$sheet->getCell($col . $row)->setValue("");
}
$colIndex++;
$col = Coordinate::stringFromColumnIndex($colIndex);
if ($admissionUser?->getPaymentCredit() != null) {
$sheet->getCell($col . $row)->setValue($admissionUser?->getPaymentCredit()?->getState());
} else {
$sheet->getCell($col . $row)->setValue("");
}
$colIndex++;
$col = Coordinate::stringFromColumnIndex($colIndex);
if ($userInfo?->getUserLanguages()->get(0) != null) {
$sheet->getCell($col . $row)->setValue($userInfo?->getUserLanguages()->get(0)->getLanguage()->getName());
} else {
$sheet->getCell($col . $row)->setValue("");
}
$colIndex++;
$col = Coordinate::stringFromColumnIndex($colIndex);
if ($userInfo?->getUserLanguages()->get(0) != null) {
$sheet->getCell($col . $row)->setValue($userInfo?->getUserLanguages()->get(0)->getSpeaking());
} else {
$sheet->getCell($col . $row)->setValue("");
}
$colIndex++;
$col = Coordinate::stringFromColumnIndex($colIndex);
if ($userInfo?->getUserLanguages()->get(0) != null) {
$sheet->getCell($col . $row)->setValue($userInfo?->getUserLanguages()->get(0)->getReading());
} else {
$sheet->getCell($col . $row)->setValue("");
}
$colIndex++;
$col = Coordinate::stringFromColumnIndex($colIndex);
if ($userInfo?->getUserLanguages()->get(0) != null) {
$sheet->getCell($col . $row)->setValue($userInfo?->getUserLanguages()->get(0)->getWriting());
} else {
$sheet->getCell($col . $row)->setValue("");
}
$colIndex++;
$col = Coordinate::stringFromColumnIndex($colIndex);
if ($userInfo?->getUserLanguages()->get(0) != null) {
$sheet->getCell($col . $row)->setValue($userInfo?->getUserLanguages()->get(0)->getListening());
} else {
$sheet->getCell($col . $row)->setValue("");
}
$colIndex++;
$col = Coordinate::stringFromColumnIndex($colIndex);
if ($userInfo?->getUserEmployment()->get(0) != null) {
$sheet->getCell($col . $row)->setValue($userInfo?->getUserEmployment()->get(0)->getWorkSection()->getName());
} else {
$sheet->getCell($col . $row)->setValue("");
}
$colIndex++;
$col = Coordinate::stringFromColumnIndex($colIndex);
if ($userInfo?->getUserEmployment()->get(0) != null) {
$sheet->getCell($col . $row)->setValue($userInfo?->getUserEmployment()->get(0)->getOrganizationName());
} else {
$sheet->getCell($col . $row)->setValue("");
}
$colIndex++;
$col = Coordinate::stringFromColumnIndex($colIndex);
if ($userInfo?->getUserEmployment()->get(0) != null) {
$sheet->getCell($col . $row)->setValue($userInfo?->getUserEmployment()->get(0)->getJobTitle());
} else {
$sheet->getCell($col . $row)->setValue("");
}
$colIndex++;
$col = Coordinate::stringFromColumnIndex($colIndex);
if ($userInfo?->getUserFamilyInfo()->get(0) != null) {
$sheet->getCell($col . $row)->setValue($userInfo?->getUserFamilyInfo()->get(0)->getRelationType()->getName());
} else {
$sheet->getCell($col . $row)->setValue("");
}
$colIndex++;
$col = Coordinate::stringFromColumnIndex($colIndex);
if ($userInfo?->getUserFamilyInfo()->get(0) != null) {
$sheet->getCell($col . $row)->setValue($userInfo?->getUserFamilyInfo()->get(0)->getLastname());
} else {
$sheet->getCell($col . $row)->setValue("");
}
$colIndex++;
$col = Coordinate::stringFromColumnIndex($colIndex);
if ($userInfo?->getUserFamilyInfo()->get(0) != null) {
$sheet->getCell($col . $row)->setValue($userInfo?->getUserFamilyInfo()->get(0)->getFirstname());
} else {
$sheet->getCell($col . $row)->setValue("");
}
$colIndex++;
$col = Coordinate::stringFromColumnIndex($colIndex);
if ($userInfo?->getUserFamilyInfo()->get(0) != null) {
$sheet->getCell($col . $row)->setValue($userInfo?->getUserFamilyInfo()->get(0)->getRegisterNumber());
} else {
$sheet->getCell($col . $row)->setValue("");
}
$colIndex++;
$col = Coordinate::stringFromColumnIndex($colIndex);
if ($userInfo?->getUserFamilyInfo()->get(0) != null) {
$sheet->getCell($col . $row)->setValue($userInfo?->getUserFamilyInfo()->get(0)->getEmail());
} else {
$sheet->getCell($col . $row)->setValue("");
}
$colIndex++;
$col = Coordinate::stringFromColumnIndex($colIndex);
if ($userInfo?->getUserFamilyInfo()->get(0) != null) {
$sheet->getCell($col . $row)->setValue($userInfo?->getUserFamilyInfo()->get(0)->getMobile());
} else {
$sheet->getCell($col . $row)->setValue("");
}
$colIndex++;
$col = Coordinate::stringFromColumnIndex($colIndex);
if ($userInfo?->getUserFamilyInfo()->get(0) != null) {
$sheet->getCell($col . $row)->setValue($userInfo?->getUserFamilyInfo()->get(0)->getWorkState());
} else {
$sheet->getCell($col . $row)->setValue("");
}
$colIndex++;
$col = Coordinate::stringFromColumnIndex($colIndex);
if ($userEducation != null) {
$sheet->getCell($col . $row)->setValue($userEducation->getCountry()->getName());
} else {
$sheet->getCell($col . $row)->setValue("");
}
$colIndex++;
$col = Coordinate::stringFromColumnIndex($colIndex);
if ($userEducation != null || $userEducation != null) {
$sheet->getCell($col . $row)->setValue($userEducation->getAddressing()?->getName());
} else {
$sheet->getCell($col . $row)->setValue("");
}
$colIndex++;
$col = Coordinate::stringFromColumnIndex($colIndex);
if ($userEducation != null) {
$sheet->getCell($col . $row)->setValue($userEducation->getEduOrgName());
} else {
$sheet->getCell($col . $row)->setValue("");
}
$colIndex++;
$col = Coordinate::stringFromColumnIndex($colIndex);
if ($userEducation != null) {
$sheet->getCell($col . $row)->setValue($userEducation->getCertificateNumber());
} else {
$sheet->getCell($col . $row)->setValue("");
}
$colIndex++;
$col = Coordinate::stringFromColumnIndex($colIndex);
if ($userEducation != null) {
$sheet->getCell($col . $row)->setValue($userEducation->getDegree()->getName());
} else {
$sheet->getCell($col . $row)->setValue("");
}
$colIndex++;
$col = Coordinate::stringFromColumnIndex($colIndex);
if ($userEducation != null) {
$sheet->getCell($col . $row)->setValue($userEducation->getProfession());
} else {
$sheet->getCell($col . $row)->setValue("");
}
$colIndex++;
$col = Coordinate::stringFromColumnIndex($colIndex);
if ($userEducation != null) {
$sheet->getCell($col . $row)->setValue($userEducation->getGraduatedYear());
} else {
$sheet->getCell($col . $row)->setValue("");
}
$colIndex++;
$col = Coordinate::stringFromColumnIndex($colIndex);
if ($userEducation != null) {
$sheet->getCell($col . $row)->setValue($userEducation->getGradeAvg());
} else {
$sheet->getCell($col . $row)->setValue("");
}
//hayg
$colIndex++;
$col = Coordinate::stringFromColumnIndex($colIndex);
if ($userInfo?->getUserAdressing()->get(0) != null &&
$administrationId = $userInfo?->getUserAdressing()->get(0)->getAddressing()->getParentId()) {
$administration = $em->getRepository(Addressing::class)->findBy(['id'=> $administrationId]);
$sheet->getCell($col . $row)->setValue($administration[0]->getName());
} else {
$sheet->getCell($col . $row)->setValue("");
}
$colIndex++;
$col = Coordinate::stringFromColumnIndex($colIndex);
if ($userInfo?->getUserAdressing()->get(0) != null) {
$sheet->getCell($col . $row)->setValue($userInfo?->getUserAdressing()->get(0)->getAddressing()->getName());
} else {
$sheet->getCell($col . $row)->setValue("");
}
$colIndex++;
$col = Coordinate::stringFromColumnIndex($colIndex);
if ($userInfo?->getUserAdressing()->get(0) != null) {
$sheet->getCell($col . $row)->setValue($userInfo?->getUserAdressing()->get(0)->getMicroDistrict());
} else {
$sheet->getCell($col . $row)->setValue("");
}
$colIndex++;
$col = Coordinate::stringFromColumnIndex($colIndex);
if ($userInfo?->getUserAdressing()->get(0) != null) {
$sheet->getCell($col . $row)->setValue($userInfo?->getUserAdressing()->get(0)->getDetail());
} else {
$sheet->getCell($col . $row)->setValue("");
}
$colIndex++;
$col = Coordinate::stringFromColumnIndex($colIndex);
if ($userInfo?->getUserAdressing()->get(0) != null) {
$sheet->getCell($col . $row)->setValue($userInfo?->getUserAdressing()->get(0)->getState()?->getName());
} else {
$sheet->getCell($col . $row)->setValue("");
}
$uiScores = $em->getRepository(UserSatResult::class)->getScoresByUserInfoIds([$userInfo?->getId()], $minSatYear, $lessonCodes);
foreach ($lessonCodes as $lessonCode) {
$colIndex++;
$col = Coordinate::stringFromColumnIndex($colIndex);
foreach ($uiScores as $uiScore) {
if ($uiScore['lessonCode'] === $lessonCode) {
$sheet->getCell($col . $row)->setValue(max($uiScore['score'], $uiScore['scoreCorr']));
}
}
}
$row++;
}
$currentTime = new \DateTime('now');
$writer = new Xlsx($spreadsheet);
$fileName = 'admission_' . $admissionUser->getAdmission()?->getId() . '_' . $currentTime->format('Ymd') . '.xlsx';
$temp_file = tempnam(sys_get_temp_dir(), $fileName);
$writer->save($temp_file);
return $this->file($temp_file, $fileName, ResponseHeaderBag::DISPOSITION_INLINE);
}
protected function exportResultNew(EntityManagerInterface $em, QueryBuilder $qb)
{
$admissionUsers = $qb
->getQuery()
->getResult();
$spreadsheet = new Spreadsheet();
$sheet = $spreadsheet->getActiveSheet();
$colIndex = 0;
$colIndex++;
$col = Coordinate::stringFromColumnIndex($colIndex);
$sheet->getCell($col . "1")->setValue("Нэр:");
$colIndex++;
$col = Coordinate::stringFromColumnIndex($colIndex);
$sheet->getCell($col . "1")->setValue("Овог:");
$colIndex++;
$col = Coordinate::stringFromColumnIndex($colIndex);
$sheet->getCell($col . "1")->setValue("Цол:");
$colIndex++;
$col = Coordinate::stringFromColumnIndex($colIndex);
$sheet->getCell($col . "1")->setValue("Эрдмийн зэрэг:");
$colIndex++;
$col = Coordinate::stringFromColumnIndex($colIndex);
$sheet->getCell($col . "1")->setValue("Хүйс :");
$colIndex++;
$col = Coordinate::stringFromColumnIndex($colIndex);
$sheet->getCell($col . "1")->setValue("Мэйл:");
$colIndex++;
$col = Coordinate::stringFromColumnIndex($colIndex);
$sheet->getCell($col . "1")->setValue("Утас:");
$colIndex++;
$col = Coordinate::stringFromColumnIndex($colIndex);
$sheet->getCell($col . "1")->setValue("Амьдран суугаа Хот, аймаг, дүүрэг:");
$colIndex++;
$col = Coordinate::stringFromColumnIndex($colIndex);
$sheet->getCell($col . "1")->setValue("Харьяалал:");
$colIndex++;
$col = Coordinate::stringFromColumnIndex($colIndex);
$sheet->getCell($col . "1")->setValue("Материал:");
$colIndex++;
$col = Coordinate::stringFromColumnIndex($colIndex);
$sheet->getCell($col . "1")->setValue("Ажил эрхлэлтийн мэдээлэл:Ажиллаж байгаа салбар");
$colIndex++;
$col = Coordinate::stringFromColumnIndex($colIndex);
$sheet->getCell($col . "1")->setValue("Ажил эрхлэлтийн :Байгуулгын нэр");
$colIndex++;
$col = Coordinate::stringFromColumnIndex($colIndex);
$sheet->getCell($col . "1")->setValue("Ажил эрхлэлтийн :Албан тушаал");
$colIndex++;
$col = Coordinate::stringFromColumnIndex($colIndex);
$sheet->getCell($col . "1")->setValue("Ажил эрхлэлтийн :Хот");
$colIndex++;
$col = Coordinate::stringFromColumnIndex($colIndex);
$sheet->getCell($col . "1")->setValue("Ажил эрхлэлтийн :Хаяг");
$curDate = new \DateTime('today');
$row = 2;
/** @var AdmissionUser $admissionUser */
foreach ($admissionUsers as $admissionUser) {
$user = $admissionUser->getUser();
$userInfo = $user?->getUserInfo();
$colIndex = 0;
$colIndex++;
$col = Coordinate::stringFromColumnIndex($colIndex);
$sheet->getCell($col . $row)->setValue($userInfo?->getFirstnameMn());
$colIndex++;
$col = Coordinate::stringFromColumnIndex($colIndex);
$sheet->getCell($col . $row)->setValue($userInfo?->getLastnameMn());
$colIndex++;
$col = Coordinate::stringFromColumnIndex($colIndex);
$sheet->getCell($col . $row)->setValue($userInfo?->getDegree());
$colIndex++;
$col = Coordinate::stringFromColumnIndex($colIndex);
$sheet->getCell($col . $row)->setValue($userInfo?->getTitle());
$colIndex++;
$col = Coordinate::stringFromColumnIndex($colIndex);
$sheet->getCell($col . $row)->setValue($userInfo?->getGender() ? "эр" : "эм");
$colIndex++;
$col = Coordinate::stringFromColumnIndex($colIndex);
$sheet->getCell($col . $row)->setValue($user?->getEmail());
$colIndex++;
$col = Coordinate::stringFromColumnIndex($colIndex);
$sheet->getCell($col . $row)->setValue($userInfo?->getMobile());
$colIndex++;
$col = Coordinate::stringFromColumnIndex($colIndex);
$sheet->getCell($col . $row)->setValue($userInfo?->getProvince()->getName());
$colIndex++;
$col = Coordinate::stringFromColumnIndex($colIndex);
$sheet->getCell($col . $row)->setValue($userInfo?->getCountry()->getName());
$file = $em->getRepository(AdmissionFile::class)->findOneBy([
'userInfo' => $userInfo,
'admission' => $admissionUser->getAdmission()
]);
$prefix = "http://research.ufe.mn:8000";
$colIndex++;
$col = Coordinate::stringFromColumnIndex($colIndex);
$sheet->getCell($col . $row)->setValue($prefix . $file?->getFilePath());
$colIndex++;
$col = Coordinate::stringFromColumnIndex($colIndex);
if ($userInfo?->getUserEmployment()->get(0) != null) {
$sheet->getCell($col . $row)->setValue($userInfo?->getUserEmployment()->get(0)->getWorkSection()->getName());
} else {
$sheet->getCell($col . $row)->setValue("");
}
$colIndex++;
$col = Coordinate::stringFromColumnIndex($colIndex);
if ($userInfo?->getUserEmployment()->get(0) != null) {
$sheet->getCell($col . $row)->setValue($userInfo?->getUserEmployment()->get(0)->getOrganizationName());
} else {
$sheet->getCell($col . $row)->setValue("");
}
$colIndex++;
$col = Coordinate::stringFromColumnIndex($colIndex);
if ($userInfo?->getUserEmployment()->get(0) != null) {
$sheet->getCell($col . $row)->setValue($userInfo?->getUserEmployment()->get(0)->getJobTitle());
} else {
$sheet->getCell($col . $row)->setValue("");
}
$colIndex++;
$col = Coordinate::stringFromColumnIndex($colIndex);
if ($userInfo?->getUserEmployment()->get(0) != null) {
$sheet->getCell($col . $row)->setValue($userInfo?->getUserEmployment()->get(0)->getCity());
} else {
$sheet->getCell($col . $row)->setValue("");
}
$colIndex++;
$col = Coordinate::stringFromColumnIndex($colIndex);
if ($userInfo?->getUserEmployment()->get(0) != null) {
$sheet->getCell($col . $row)->setValue($userInfo?->getUserEmployment()->get(0)->getAddress());
} else {
$sheet->getCell($col . $row)->setValue("");
}
$row++;
}
$currentTime = new \DateTime('now');
$writer = new Xlsx($spreadsheet);
$fileName = 'research_' . $admissionUser->getAdmission()?->getId() . '_' . $currentTime->format('Ymd') . '.xlsx';
$temp_file = tempnam(sys_get_temp_dir(), $fileName);
$writer->save($temp_file);
return $this->file($temp_file, $fileName, ResponseHeaderBag::DISPOSITION_INLINE);
}
#[Route('/{admissionId}/user/index/all', name: 'app_admission_user_index_all', methods: ['GET'])]
public function indexAll(
Request $request,
EntityManagerInterface $em,
): Response
{
$admissionId = $request->attributes->getInt('admissionId', 0);
$admission = $em->getRepository(Admission::class)->find($admissionId);
$qb = $em->getRepository(AdmissionUser::class)
->createQueryBuilder('admission_user')
->leftJoin('admission_user.user', 'user')
->leftJoin('user.userInfo', 'user_info');
$qb
->addSelect('user')
->addSelect('user_info');
$qb
->where($qb->expr()->eq('admission_user.admission', ':admission'))
->setParameter('admission', $admission);
$qb
->orderBy('admission_user.timeCreated', 'DESC');
$admissionUsers = $qb
->getQuery()
->getResult();
return $this->render('admission_user/index-all.html.twig', [
'admission' => $admission,
'admissionUsers' => $admissionUsers,
]);
}
#[Route('/{admissionId}/user/index', name: 'app_admission_user_index', methods: ['GET', 'POST'])]
public function index(
Request $request,
EntityManagerInterface $em,
PaginatorInterface $paginator
): Response
{
$page = $request->query->getInt('page', 0);
$admissionId = $request->attributes->getInt('admissionId', 0);
$admission = $em->getRepository(Admission::class)->find($admissionId);
if (!$admission) {
throw new NotFoundHttpException("");
}
$lessonCodes = $request->getSession()->get('sat_lesson_codes');
if (!$lessonCodes) {
$lessonCodes = [];
}
$qb = $em->getRepository(AdmissionUser::class)
->createQueryBuilder('admission_user')
->leftJoin('admission_user.user', 'user')
->leftJoin('user.userInfo', 'user_info')
->leftJoin('admission_user.paymentRegisterFee', 'payment_register_fee')
->leftJoin('admission_user.paymentCredit', 'payment_credit')
->leftJoin('admission_user.lastComment', 'lastComment');
$qb
->addSelect('user')
->addSelect('user_info')
->addSelect('payment_register_fee')
->addSelect('payment_credit')
->addSelect('lastComment');
$qb
->where($qb->expr()->eq('admission_user.admission', ':admission'))
->setParameter('admission', $admission)
->andWhere($qb->expr()->in('admission_user.state', ':states'))
->setParameter('states', [AdmissionUser::STATE_REGISTERED, AdmissionUser::STATE_FILE_UPLOADED, AdmissionUser::STATE_DECLINE, AdmissionUser::STATE_POSTER, AdmissionUser::STATE_SPEAKER]);
$filterForm = $this->createForm(AdmissionUserFilterType::class, null, [
'em' => $em,
'admissionId' => $admissionId,
'action' => $this->generateUrl('app_admission_user_index', ['admissionId' => $admission->getId()]),
]);
$filterForm->handleRequest($request);
$filtering = false;
$filterName = $request->attributes->get('_route') . "_filter";
if ($filterForm->isSubmitted()) {
$filtering = true;
$request->getSession()->set($filterName, $filterForm->getData());
} elseif ($page > 0) {
$filterValues = $request->getSession()->get($filterName);
if ($filterValues) {
$filterForm->submit($filterValues);
$filtering = true;
}
}
if ($filtering && $filterForm->isValid()) {
$filter = new AdmissionUserFilter($filterForm);
$qb = $filter->filterQuery($qb);
}
$submitType = $request->request->get('_submit_type', 'filter');
if ($submitType === "export") {
return $this->exportResultNew($em, $qb);
}
$qb
->orderBy('admission_user.timeCreated', 'DESC');
$admissionUsersPaged = $paginator->paginate($qb->getQuery(), $page === 0 ? 1 : $page, 20);
$userInfoIds = [];
/** @var AdmissionUser $admissionUser */
foreach ($admissionUsersPaged as $admissionUser) {
$userInfoId = $admissionUser->getUser()?->getUserInfo()?->getId();
if ($userInfoId > 0) {
$userInfoIds[] = $userInfoId;
}
}
$curDate = new \DateTime('today');
$minSatYear = ((int)$curDate->format('Y')) - 2;
$userInfoScores = $em->getRepository(UserSatResult::class)->getScoresByUserInfoIds($userInfoIds, $minSatYear);
$uiScores = [];
foreach ($userInfoScores as $uiScore) {
$uiKey = 'user_info_' . $uiScore['userInfoId'];
$lessonCode = $uiScore['lessonCode'];
if (!isset($uiScores[$uiKey])) {
$uiScores[$uiKey] = [];
}
$uiScores[$uiKey][$lessonCode] = max($uiScore['score'], $uiScore['scoreCorr']);
}
$admissionTotalRegFee = $em->getRepository(Payment::class)->totalRegisterFee($admission->getCode());
$admissionTotalCreditFee = $em->getRepository(Payment::class)->totalCreditFee($admission->getCode());
return $this->render('admission_user/index.html.twig', [
'admission' => $admission,
'admissionUsersPaged' => $admissionUsersPaged,
'filterForm' => $filterForm->createView(),
'uiScores' => $uiScores,
'lessonCodes' => $lessonCodes,
'pageId' => $page,
'admissionTotalRegFee' => $admissionTotalRegFee,
'admissionTotalCreditFee' => $admissionTotalCreditFee
]);
}
#[Route('/{admissionId}/user/pub/index', name: 'app_admission_user_pub_index', methods: ['GET', 'POST'])]
public function indexPub(
Request $request,
EntityManagerInterface $em,
PaginatorInterface $paginator
): Response
{
$page = $request->query->getInt('page', 0);
$admissionId = $request->attributes->getInt('admissionId', 0);
$admission = $em->getRepository(Admission::class)->find($admissionId);
if (!$admission) {
throw new NotFoundHttpException("");
}
$qb = $em->getRepository(AdmissionFile::class)
->createQueryBuilder('af')
->leftJoin('af.admissionUser', 'admission_user')
->leftJoin('admission_user.user', 'user')
->leftJoin('user.userInfo', 'user_info');
$qb
->addSelect('admission_user')
->addSelect('user')
->addSelect('user_info');
$qb
->where($qb->expr()->eq('admission_user.admission', ':admission'))
->setParameter('admission', $admission)
->andWhere($qb->expr()->in('admission_user.state', ':states'))
->andWhere('admission_user.pubState is NULL')
->andWhere($qb->expr()->in('admission_user.type', ':types'))
->setParameter('states', [AdmissionUser::STATE_FILE_UPLOADED])
->setParameter('types', [2,3]);
$qb
->orderBy('admission_user.timeCreated', 'DESC');
$admissionUsersPaged = $paginator->paginate($qb->getQuery(), $page === 0 ? 1 : $page, 20);
return $this->render('admission_user/index-pub.html.twig', [
'admission' => $admission,
'admissionUsersPaged' => $admissionUsersPaged,
'pageId' => $page
]);
}
#[Route('/send/pub', name: 'app_admission_user_send_pub_index', methods: ['POST'])]
public function sendPub(
Request $request,
EntityManagerInterface $em,
): Response
{
$admissionUsers = $request->request->all()['ids'];
foreach ($admissionUsers as $id){
/** @var AdmissionUser $admissionUser */
$admissionUser = $em->getRepository(AdmissionUser::class)->find($id);
$admissionUser->setPubState('new');
$em->persist($admissionUser);
/** @var AdmissionFile $admissionFile */
$admissionFile = $em->getRepository(AdmissionFile::class)->findOneBy(['admissionUser' => $admissionUser]);
$admissionFile->setState('new');
$em->persist($admissionFile);
$em->flush();
}
return $this->json([
'toast' => [
'status' => 'success',
'msg' => 'Амжилттай'
],
'window_reload' => true,
]);
}
#[Route('/{admissionId}/user/register', name: 'app_admission_user_register', methods: ['GET', 'POST'])]
public function register(
Request $request,
EntityManagerInterface $em,
AdmissionUserService $admissionUserService,
NormalizerInterface $normalizer
): Response
{
$admissionId = $request->attributes->getInt('admissionId', 0);
/** @var Admission $admission */
$admission = $em->getRepository(Admission::class)->find($admissionId);
if (!$admission) {
throw new NotFoundHttpException("Admission not found");
}
$admissionUser = new AdmissionUser();
$admissionUser->setAdmission($admission);
$admissionUser->setTimeCreated(new \DateTime('now'));
$admissionUser->setState(AdmissionUser::STATE_REGISTERED);
$form = $this->createForm(AdmissionUserType::class, $admissionUser);
$form->handleRequest($request);
if ($form->isSubmitted()) {
if ($form->isValid()) {
$userId = $form->get('userId')->getData();
$user = $em->getRepository(User::class)->find($userId);
if (!$user) {
throw new BadRequestHttpException();
}
$admissionUser->setUser($user);
$admissionUser->setTimeUpdated(new \DateTime('now'));
$result = $admissionUserService->checkRegister($admissionUser);
if ($result['created'] == true) {
$log = new ActionLog();
$log
->setRouteName($request->get('_route'))
->setActionName(ActionLog::ACTION_INSERT)
->setEntityName(AdmissionUser::class)
->setEntityId($admissionUser->getId())
->setEntityData($normalizer->normalize(
$result['admissionUser'],
'object',
['groups' => ['list']]
))
->setUserAct($this->getUser())
->setTimeCreated($admissionUser->getTimeCreated());
$em->persist($log);
$em->flush();
}
$em->persist($admissionUser);
$em->flush();
$this->addFlash($result['level'], $result['msg']);
return $this->redirectToRoute('app_admission_user_index', ['admissionId' => $admission->getId()], Response::HTTP_SEE_OTHER);
}
}
return $this->renderForm('admission_user/new.html.twig', [
'admission' => $admission,
'admission_user' => $admissionUser,
'form' => $form,
]);
}
#[Route('/{admissionId}/user/{id}/show', name: 'app_admission_user_show', methods: ['GET'])]
public function show(
Request $request,
EntityManagerInterface $em,
): Response
{
$id = $request->attributes->getInt('id', 0);
$qb = $em->getRepository(AdmissionUser::class)
->createQueryBuilder('admission_user')
->leftJoin('admission_user.infoChannel', 'gc');
$admissionUser = $qb
->andWhere($qb->expr()->eq('admission_user.id', ':id'))
->setParameter('id', $id)
->getQuery()
->getSingleResult();
if (!$admissionUser) {
throw new NotFoundHttpException("AdmissionUser not found");
}
$admission = $admissionUser->getAdmission();
$userInfo = '';
$files = '';
if($admissionUser->getUser()->getUserInfo()) {
$id = $admissionUser->getUser()->getUserInfo()->getId();
$userInfo = $em->getRepository(UserInfo::class)->find($id);
if (!$userInfo) {
throw new NotFoundHttpException("Хэрэглэгчийн мэдээлэл олдсонгүй! Та хувийн мэдээллээ оруулна уу.");
}
$files = $em->getRepository(AdmissionFile::class)->findBy([
'userInfo' => $userInfo,
'admission' => $admission
]);
}
return $this->render('admission_user/showC.html.twig', [
'admission_user' => $admissionUser,
'admission' => $admission,
'files' => $files
]);
}
#[Route('/{admissionId}/user/{id}/payment/{paymentType}/create', name: 'app_admission_user_payment_create', methods: ['GET'])]
public function userPaymentCreate(
Request $request,
PaymentService $paymentService,
EntityManagerInterface $em
): Response
{
$paymentType = $request->attributes->get('paymentType');
if (!in_array($paymentType, [Payment::TYPE_ADMISSION_REGISTER, Payment::TYPE_ADMISSION_CREDIT])) {
throw new BadRequestHttpException("");
}
$admissionId = $request->attributes->getInt('admissionId', 0);
/** @var Admission $admission */
$admission = $em->getRepository(Admission::class)->find($admissionId);
if (!$admission) {
throw new NotFoundHttpException("Admission not found");
}
$id = $request->attributes->getInt('id', 0);
/** @var AdmissionUser $admissionUser */
$admissionUser = $em->getRepository(AdmissionUser::class)->find($id);
if (!$admissionUser) {
throw new NotFoundHttpException("AdmissionUser not found");
}
$payment = $paymentService->getAdmissionUserPayment($admissionUser, $paymentType);
if ($payment) {
return $this->json([
'toast' => [
'status' => 'success',
'msg' => 'Төлбөр үүслээ!'
],
'window_reload' => true,
]);
}
return $this->json([
'toast' => [
'status' => 'error',
'msg' => 'Амжилтгүй!'
],
'window_reload' => true,
]);
}
#[Route('/{admissionId}/user/set/fix/sat/code', name: 'app_admission_user_set_fix_sat_code', methods: ['GET'])]
public function setFixSatCode(
Request $request,
EntityManagerInterface $em,
SatUserService $satUserService
): Response
{
$admissionId = $request->attributes->getInt('admissionId', 0);
/** @var Admission $admission */
$admission = $em->getRepository(Admission::class)->find($admissionId);
if (!$admission) {
throw new NotFoundHttpException("Admission not found");
}
$qb = $em->getRepository(AdmissionUser::class)
->createQueryBuilder('admission_user')
->leftJoin('admission_user.user', 'user')
->leftJoin('user.userInfo', 'user_info')
->leftJoin(UserSat::class, 'user_sat', Join::WITH, 'user_sat.userInfo = user_info');
$qb->select('distinct admission_user');
$qb
->where($qb->expr()->eq('admission_user.admission', ':admission'))
->setParameter('admission', $admission)
->andWhere($qb->expr()->isNotNull('user_sat.id'))
->andWhere($qb->expr()->orX(
$qb->expr()->isNull('admission_user.satCode'),
$qb->expr()->neq('length(admission_user.satCode)', ':satLength')
))
->setParameter('satLength', 9);
$admissionUsers = $qb
->setMaxResults(100)
->getQuery()
->getResult();
$counter = 0;
/** @var AdmissionUser $admissionUser */
foreach ($admissionUsers as $admissionUser) {
$userSat = $em->getRepository(UserSat::class)->findOneConfirmedOrLast($admissionUser);
if (!$userSat) {
continue;
}
$admissionUser->setSatCode($userSat->getSatCode());
$counter++;
}
$em->flush();
return $this->json([
'toast' => [
'status' => 'success',
'msg' => 'success - ' . $counter,
],
'window_reload' => true,
]);
}
#[Route('/save/fe', name: 'app_admission_user_fe_save', methods: ['POST'])]
public function saveFe(
Request $request,
EntityManagerInterface $em,
): Response
{
$id = $request->request->all()['admissionUserId'];
$feId = $request->request->all()['feId'];
/** @var AdmissionUser $admissionUser */
$admissionUser = $em->getRepository(AdmissionUser::class)->find($id);
$admissionUser->setFeId($feId);
$admissionUser->setPubState(AdmissionUser::PUB_STATE_FE);
$admissionUser->setTimeUpdated(new \DateTime('now'));
$em->persist($admissionUser);
$em->flush();
return $this->json([
'toast' => [
'status' => 'success',
'msg' => 'Амжилттай'
],
'window_reload' => true,
]);
}
#[Route('/{admissionId}/user/{id}/edit', name: 'app_admission_user_edit', methods: ['GET', 'POST'])]
public function edit(Request $request, AdmissionUser $admissionUser, EntityManagerInterface $em,
MailerInterface $mailer): Response
{
$admissionId = $request->attributes->getInt('admissionId', 0);
/** @var Admission $admission */
$admission = $em->getRepository(Admission::class)->find($admissionId);
$subjectMail = "Research.ufe.mn илгээсэн бүтээлийн тухай";
$sub = "Оюутны эрдэм шинжилгээний XVII хурал";
$body = "";
if($admission->getDegree()->getId() == 1) {
$subjectMail = 'Research.ufe.mn илгээсэн бүтээлийн тухай';
$sub = "Нээлттэй шинжлэх ухаан ба Тогтвортой хөгжил";
}
$form = $this->createForm(AdmissionUserStateType::class, $admissionUser);
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
$em->persist($admissionUser);
$em->flush();
if($admissionUser->getState() === AdmissionUser::STATE_SPEAKER){
$type = 'Аман илтгэл';
$msg = "Шалгарсан бүтээлийн танилцуулга (ppt) файлыг 2025 оны 4-р сарын 23-ны 15:00 цаг хүртэл салбар хариуцсан нарийн бичгийн имэйлээр хүлээн авна. Та бүхэн рүү салбар хариуцсан нарийн бичиг холбогдож, PPT загвар, бусад заавар мэдээлэл хүргэнэ. ";
$body = $this->renderView('admission_user/_confirm.html.twig', [
'userInfo' => $admissionUser->getUser()->getUserInfo(),
'admission' => $admission,
'sub' => $sub,
'type' => $type,
'msg' => $msg
]);
}else if ($admissionUser->getState() === AdmissionUser::STATE_POSTER){
$type = 'Постер илтгэл';
$msg = "Хэвлэсэн постерийг 2025 оны 4 сарын 23-ны 15:00 цаг хүртэл СЭЗИС-ийн B байрны 502 тоотод хураалгана. /Холбогдох дугаар: 88301003/. Та бүхэн рүү салбар хариуцсан нарийн бичиг имэйлээр холбогдож, постерын загвар, бусад заавар мэдээлэл хүргэнэ. ";
$body = $this->renderView('admission_user/_confirm.html.twig', [
'userInfo' => $admissionUser->getUser()->getUserInfo(),
'admission' => $admission,
'sub' => $sub,
'type' => $type,
'msg' => $msg
]);
} else if ($admissionUser->getState() === AdmissionUser::STATE_DECLINE){
$msg = 'Дараагийн удаа дахин оролцоорой.';
$body = $this->renderView('admission_user/_decline.html.twig', [
'userInfo' => $admissionUser->getUser()->getUserInfo(),
'admission' => $admission,
'subject' => $subjectMail,
'msg' => $msg
]);
}
$mailFrom = $_ENV['SYS_MAIL'];
$email = (new Email())
->from($mailFrom)
->to($admissionUser->getUser()->getEmail())
->subject($subjectMail)
->html($body);
try {
$mailer->send($email);
} catch (TransportExceptionInterface $e) {
}
return $this->redirectToRoute('app_admission_user_show', ['admissionId' => $admissionId, 'id' => $admissionUser->getId()], Response::HTTP_SEE_OTHER);
}
return $this->renderForm('admission_user/edit.html.twig', [
'admission_user' => $admissionUser,
'form' => $form,
]);
}
//
// #[Route('/{id}', name: 'app_admission_user_delete', methods: ['POST'])]
// public function delete(Request $request, AdmissionUser $admissionUser, AdmissionUserRepository $admissionUserRepository): Response
// {
// if ($this->isCsrfTokenValid('delete' . $admissionUser->getId(), $request->request->get('_token'))) {
// $admissionUserRepository->remove($admissionUser);
// }
//
// return $this->redirectToRoute('app_admission_user_index', [], Response::HTTP_SEE_OTHER);
// }
}