src/Controller/AdmissionUserController.php line 932

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use App\Entity\ActionLog;
  4. use App\Entity\Addressing;
  5. use App\Entity\Admission;
  6. use App\Entity\AdmissionFile;
  7. use App\Entity\AdmissionUser;
  8. use App\Entity\AdmissionUserComment;
  9. use App\Entity\Payment;
  10. use App\Entity\User;
  11. use App\Entity\UserEducation;
  12. use App\Entity\UserFile;
  13. use App\Entity\UserInfo;
  14. use App\Entity\UserSat;
  15. use App\Entity\UserSatResult;
  16. use App\Filter\AdmissionUserFilter;
  17. use App\Filter\AdmissionUserFilterType;
  18. use App\Form\AdmissionUserFeType;
  19. use App\Form\AdmissionUserStateType;
  20. use App\Form\AdmissionUserType;
  21. use App\Services\AdmissionUserService;
  22. use App\Services\Payment\PaymentService;
  23. use App\Services\SatUserService;
  24. use Doctrine\ORM\EntityManagerInterface;
  25. use Doctrine\ORM\Query\Expr\Join;
  26. use Doctrine\ORM\QueryBuilder;
  27. use Knp\Component\Pager\PaginatorInterface;
  28. use PhpOffice\PhpSpreadsheet\Cell\Coordinate;
  29. use PhpOffice\PhpSpreadsheet\Spreadsheet;
  30. use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
  31. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  32. use Symfony\Component\HttpFoundation\Request;
  33. use Symfony\Component\HttpFoundation\Response;
  34. use Symfony\Component\HttpFoundation\ResponseHeaderBag;
  35. use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
  36. use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
  37. use Symfony\Component\Mailer\Exception\TransportExceptionInterface;
  38. use Symfony\Component\Mailer\MailerInterface;
  39. use Symfony\Component\Mime\Email;
  40. use Symfony\Component\Routing\Annotation\Route;
  41. use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
  42. #[Route('/admission')]
  43. class AdmissionUserController extends AbstractController implements AdminFilterController
  44. {
  45.     protected function exportResult(EntityManagerInterface $emQueryBuilder $qb$lessonCodes)
  46.     {
  47.         $admissionUsers $qb
  48.             ->getQuery()
  49.             ->getResult();
  50.         $spreadsheet = new Spreadsheet();
  51.         $sheet $spreadsheet->getActiveSheet();
  52.         $colIndex 0;
  53.         $colIndex++;
  54.         $col Coordinate::stringFromColumnIndex($colIndex);
  55.         $sheet->getCell($col "1")->setValue("БҮТ:");
  56.         $colIndex++;
  57.         $col Coordinate::stringFromColumnIndex($colIndex);
  58.         $sheet->getCell($col "1")->setValue("Ургийн овог:");
  59.         $colIndex++;
  60.         $col Coordinate::stringFromColumnIndex($colIndex);
  61.         $sheet->getCell($col "1")->setValue("Нэр:");
  62.         $colIndex++;
  63.         $col Coordinate::stringFromColumnIndex($colIndex);
  64.         $sheet->getCell($col "1")->setValue("Овог:");
  65.         $colIndex++;
  66.         $col Coordinate::stringFromColumnIndex($colIndex);
  67.         $sheet->getCell($col "1")->setValue("Нэр /англиар/:");
  68.         $colIndex++;
  69.         $col Coordinate::stringFromColumnIndex($colIndex);
  70.         $sheet->getCell($col "1")->setValue("Овог /англиар/:");
  71.         $colIndex++;
  72.         $col Coordinate::stringFromColumnIndex($colIndex);
  73.         $sheet->getCell($col "1")->setValue("Регистер:");
  74.         $colIndex++;
  75.         $col Coordinate::stringFromColumnIndex($colIndex);
  76.         $sheet->getCell($col "1")->setValue("Яс үндэс:");
  77.         $colIndex++;
  78.         $col Coordinate::stringFromColumnIndex($colIndex);
  79.         $sheet->getCell($col "1")->setValue("Хүйс :");
  80.         $colIndex++;
  81.         $col Coordinate::stringFromColumnIndex($colIndex);
  82.         $sheet->getCell($col "1")->setValue("Төрсөн огноо:");
  83.         $colIndex++;
  84.         $col Coordinate::stringFromColumnIndex($colIndex);
  85.         $sheet->getCell($col "1")->setValue("Мэйл:");
  86.         $colIndex++;
  87.         $col Coordinate::stringFromColumnIndex($colIndex);
  88.         $sheet->getCell($col "1")->setValue("Утас1:");
  89.         $colIndex++;
  90.         $col Coordinate::stringFromColumnIndex($colIndex);
  91.         $sheet->getCell($col "1")->setValue("Утас2:");
  92.         $colIndex++;
  93.         $col Coordinate::stringFromColumnIndex($colIndex);
  94.         $sheet->getCell($col "1")->setValue("Сонгосон мэргэжил:");
  95. // sat result
  96.         $colIndex++;
  97.         $col Coordinate::stringFromColumnIndex($colIndex);
  98.         $sheet->getCell($col "1")->setValue("ЭЕШ Математик:");
  99.         $colIndex++;
  100.         $col Coordinate::stringFromColumnIndex($colIndex);
  101.         $sheet->getCell($col "1")->setValue("ЭЕШ Нийгэм:");
  102.         $colIndex++;
  103.         $col Coordinate::stringFromColumnIndex($colIndex);
  104.         $sheet->getCell($col "1")->setValue("ЭЕШ Англи хэл:");
  105. // havsralt
  106.         $colIndex++;
  107.         $col Coordinate::stringFromColumnIndex($colIndex);
  108.         $sheet->getCell($col "1")->setValue("Иргэний үнэмлэхний хуулбар:");
  109.         $colIndex++;
  110.         $col Coordinate::stringFromColumnIndex($colIndex);
  111.         $sheet->getCell($col "1")->setValue("ЭЕШ-ийн батламж хуулбар:");
  112.         $colIndex++;
  113.         $col Coordinate::stringFromColumnIndex($colIndex);
  114.         $sheet->getCell($col "1")->setValue("Цээж зураг:");
  115. //tugsgul
  116.         $colIndex++;
  117.         $col Coordinate::stringFromColumnIndex($colIndex);
  118.         $sheet->getCell($col "1")->setValue("Бүртгэлийн хураамж");
  119.         $colIndex++;
  120.         $col Coordinate::stringFromColumnIndex($colIndex);
  121.         $sheet->getCell($col "1")->setValue("Кредитийн төлбөр");
  122.         $colIndex++;
  123.         $col Coordinate::stringFromColumnIndex($colIndex);
  124.         $sheet->getCell($col "1")->setValue("Хэлний мэдээлэл:Хэл");
  125.         $colIndex++;
  126.         $col Coordinate::stringFromColumnIndex($colIndex);
  127.         $sheet->getCell($col "1")->setValue("Хэлний мэдээлэл:Ярих");
  128.         $colIndex++;
  129.         $col Coordinate::stringFromColumnIndex($colIndex);
  130.         $sheet->getCell($col "1")->setValue("Хэлний мэдээлэл:Унших");
  131.         $colIndex++;
  132.         $col Coordinate::stringFromColumnIndex($colIndex);
  133.         $sheet->getCell($col "1")->setValue("Хэлний мэдээлэл:Бичих");
  134.         $colIndex++;
  135.         $col Coordinate::stringFromColumnIndex($colIndex);
  136.         $sheet->getCell($col "1")->setValue("Хэлний мэдээлэл:Сонсох");
  137.         $colIndex++;
  138.         $col Coordinate::stringFromColumnIndex($colIndex);
  139.         $sheet->getCell($col "1")->setValue("Ажил эрхлэлтийн мэдээлэл:Ажиллаж байгаа салбар");
  140.         $colIndex++;
  141.         $col Coordinate::stringFromColumnIndex($colIndex);
  142.         $sheet->getCell($col "1")->setValue("Ажил эрхлэлтийн :Байгуулгын нэр");
  143.         $colIndex++;
  144.         $col Coordinate::stringFromColumnIndex($colIndex);
  145.         $sheet->getCell($col "1")->setValue("Ажил эрхлэлтийн :Албан тушаал");
  146.         $colIndex++;
  147.         $col Coordinate::stringFromColumnIndex($colIndex);
  148.         $sheet->getCell($col "1")->setValue("Гэр бүлийн мэдээлэл:Хобоо хамаарал");
  149.         $colIndex++;
  150.         $col Coordinate::stringFromColumnIndex($colIndex);
  151.         $sheet->getCell($col "1")->setValue("Гэр бүлийн мэдээлэл:Овог");
  152.         $colIndex++;
  153.         $col Coordinate::stringFromColumnIndex($colIndex);
  154.         $sheet->getCell($col "1")->setValue("Гэр бүлийн мэдээлэл:Нэр");
  155.         $colIndex++;
  156.         $col Coordinate::stringFromColumnIndex($colIndex);
  157.         $sheet->getCell($col "1")->setValue("Гэр бүлийн мэдээлэл:РД");
  158.         $colIndex++;
  159.         $col Coordinate::stringFromColumnIndex($colIndex);
  160.         $sheet->getCell($col "1")->setValue("Гэр бүлийн мэдээлэл:Цахим шуудан");
  161.         $colIndex++;
  162.         $col Coordinate::stringFromColumnIndex($colIndex);
  163.         $sheet->getCell($col "1")->setValue("Гэр бүлийн мэдээлэл:Холбоо барих дугаар");
  164.         $colIndex++;
  165.         $col Coordinate::stringFromColumnIndex($colIndex);
  166.         $sheet->getCell($col "1")->setValue("Гэр бүлийн мэдээлэл:Байгуулгын нэр албан тушаал");
  167.         $colIndex++;
  168.         $col Coordinate::stringFromColumnIndex($colIndex);
  169.         $sheet->getCell($col "1")->setValue("Сургуулийн мэдээлэл:Улс");
  170.         $colIndex++;
  171.         $col Coordinate::stringFromColumnIndex($colIndex);
  172.         $sheet->getCell($col "1")->setValue("Сургуулийн мэдээлэл:Аймаг хот");
  173.         $colIndex++;
  174.         $col Coordinate::stringFromColumnIndex($colIndex);
  175.         $sheet->getCell($col "1")->setValue("Сургуулийн мэдээлэл:Сургууль");
  176.         $colIndex++;
  177.         $col Coordinate::stringFromColumnIndex($colIndex);
  178.         $sheet->getCell($col "1")->setValue("Сургуулийн мэдээлэл:Гэрчилгээний дугаар");
  179.         $colIndex++;
  180.         $col Coordinate::stringFromColumnIndex($colIndex);
  181.         $sheet->getCell($col "1")->setValue("Сургуулийн мэдээлэл:Зэрэг");
  182.         $colIndex++;
  183.         $col Coordinate::stringFromColumnIndex($colIndex);
  184.         $sheet->getCell($col "1")->setValue("Сургуулийн мэдээлэл:Мэргэжил");
  185.         $colIndex++;
  186.         $col Coordinate::stringFromColumnIndex($colIndex);
  187.         $sheet->getCell($col "1")->setValue("Сургуулийн мэдээлэл:Төгссөн он");
  188.         $colIndex++;
  189.         $col Coordinate::stringFromColumnIndex($colIndex);
  190.         $sheet->getCell($col "1")->setValue("Сургуулийн мэдээлэл:Голч дүн");
  191.         //hayg
  192.         $colIndex++;
  193.         $col Coordinate::stringFromColumnIndex($colIndex);
  194.         $sheet->getCell($col "1")->setValue("Хаяг:Үндсэн захиргаа");
  195.         $colIndex++;
  196.         $col Coordinate::stringFromColumnIndex($colIndex);
  197.         $sheet->getCell($col "1")->setValue("Хаяг:Сум, дүүрэг");
  198.         $colIndex++;
  199.         $col Coordinate::stringFromColumnIndex($colIndex);
  200.         $sheet->getCell($col "1")->setValue("Хаяг:Баг, хороо");
  201.         $colIndex++;
  202.         $col Coordinate::stringFromColumnIndex($colIndex);
  203.         $sheet->getCell($col "1")->setValue("Хаяг:Хороолол, байр тоот");
  204.         $colIndex++;
  205.         $col Coordinate::stringFromColumnIndex($colIndex);
  206.         $sheet->getCell($col "1")->setValue("Хаяг:Амьдарч буй газар");
  207.         foreach ($lessonCodes as $lessonCode) {
  208.             $colIndex++;
  209.             $col Coordinate::stringFromColumnIndex($colIndex);
  210.             $sheet->getCell($col "1")->setValue($lessonCode);
  211.         }
  212.         $curDate = new \DateTime('today');
  213.         $minSatYear = ((int)$curDate->format('Y')) - 2;
  214.         $row 2;
  215.         /** @var AdmissionUser $admissionUser */
  216.         $userEducations $em->getRepository(UserEducation::class)
  217.             ->createQueryBuilder('user_education')
  218.             ->getQuery()
  219.             ->getResult();
  220.         foreach ($admissionUsers as $admissionUser) {
  221.             $user $admissionUser->getUser();
  222.             $userInfo $user?->getUserInfo();
  223.             $check true;
  224.             $count 0;
  225.             $userEducation null;
  226.             foreach($userEducations as $userEducation1){
  227.                 if($userEducation1->getUserInfo()->getId() == $userInfo?->getId()){
  228.                     $userEducation $userEducation1;
  229.                     break;
  230.                 }
  231.             }
  232.             $colIndex 0;
  233.             $colIndex++;
  234.             $col Coordinate::stringFromColumnIndex($colIndex);
  235.             $sheet->getCell($col $row)->setValue($admissionUser->getSatCode());
  236.             $colIndex++;
  237.             $col Coordinate::stringFromColumnIndex($colIndex);
  238.             $sheet->getCell($col $row)->setValue($userInfo?->getFamilyName());
  239.             $colIndex++;
  240.             $col Coordinate::stringFromColumnIndex($colIndex);
  241.             $sheet->getCell($col $row)->setValue($userInfo?->getFirstnameMn());
  242.             $colIndex++;
  243.             $col Coordinate::stringFromColumnIndex($colIndex);
  244.             $sheet->getCell($col $row)->setValue($userInfo?->getLastnameMn());
  245.             $colIndex++;
  246.             $col Coordinate::stringFromColumnIndex($colIndex);
  247.             $sheet->getCell($col $row)->setValue($userInfo?->getFirstnameEn());
  248.             $colIndex++;
  249.             $col Coordinate::stringFromColumnIndex($colIndex);
  250.             $sheet->getCell($col $row)->setValue($userInfo?->getLastnameEn());
  251.             $colIndex++;
  252.             $col Coordinate::stringFromColumnIndex($colIndex);
  253.             $sheet->getCell($col $row)->setValue($userInfo?->getRegNum());
  254.             $colIndex++;
  255.             $col Coordinate::stringFromColumnIndex($colIndex);
  256.             $sheet->getCell($col $row)->setValue($userInfo?->getNationality()?->getName());
  257.             $colIndex++;
  258.             $col Coordinate::stringFromColumnIndex($colIndex);
  259.             $sheet->getCell($col $row)->setValue($userInfo?->getGender() ? "эр" "эм");
  260.             $colIndex++;
  261.             $col Coordinate::stringFromColumnIndex($colIndex);
  262.             $sheet->getCell($col $row)->setValue($userInfo?->getBirthDate());
  263.             $colIndex++;
  264.             $col Coordinate::stringFromColumnIndex($colIndex);
  265.             $sheet->getCell($col $row)->setValue($user?->getEmail());
  266.             $colIndex++;
  267.             $col Coordinate::stringFromColumnIndex($colIndex);
  268.             $sheet->getCell($col $row)->setValue($userInfo?->getMobile());
  269.             $colIndex++;
  270.             $col Coordinate::stringFromColumnIndex($colIndex);
  271.             $sheet->getCell($col $row)->setValue($userInfo?->getPhoneHome());
  272.             $colIndex++;
  273.             $col Coordinate::stringFromColumnIndex($colIndex);
  274.             if ($admissionUser->getState() != 'C') {
  275.                 $sheet->getCell($col $row)->setValue($admissionUser?->getAdmissionRegister()?->getStudyProgram()?->getDescription());
  276.             } else {
  277.                 $sheet->getCell($col $row)->setValue($admissionUser?->getAdmissionRegister()?->getStudyProgram()?->getDescription());
  278.             }
  279.             $userSat $em->getRepository(UserSat::class)->findOneBy([
  280.                 'userInfo' => $userInfo?->getId()
  281.             ]);
  282.             if ($userSat) {
  283.                 $matScore $em->getRepository(UserSatResult::class)->findOneBy([
  284.                     'userSat' => $userSat->getId(),
  285.                     'lessonName' => 'mat'
  286.                 ], [
  287.                     'lessonScore' => 'DESC'
  288.                 ]);
  289.                 $ngmScore $em->getRepository(UserSatResult::class)->findOneBy([
  290.                     'userSat' => $userSat->getId(),
  291.                     'lessonName' => 'ngm'
  292.                 ], [
  293.                     'lessonScore' => 'DESC'
  294.                 ]);
  295.                 $engScore $em->getRepository(UserSatResult::class)->findOneBy([
  296.                     'userSat' => $userSat->getId(),
  297.                     'lessonName' => 'eng'
  298.                 ], [
  299.                     'lessonScore' => 'DESC'
  300.                 ]);
  301.                 $colIndex++;
  302.                 $col Coordinate::stringFromColumnIndex($colIndex);
  303.                 $sheet->getCell($col $row)->setValue($matScore $matScore->getLessonScore() : 'ЭЕШ оноогүй');
  304.                 $colIndex++;
  305.                 $col Coordinate::stringFromColumnIndex($colIndex);
  306.                 $sheet->getCell($col $row)->setValue($ngmScore $ngmScore->getLessonScore() : 'ЭЕШ оноогүй');
  307.                 $colIndex++;
  308.                 $col Coordinate::stringFromColumnIndex($colIndex);
  309.                 $sheet->getCell($col $row)->setValue($engScore $engScore->getLessonScore() : 'ЭЕШ оноогүй');
  310.             } else {
  311.                 $colIndex++;
  312.                 $col Coordinate::stringFromColumnIndex($colIndex);
  313.                 $sheet->getCell($col $row)->setValue("ЭЕШ оноогүй");
  314.                 $colIndex++;
  315.                 $col Coordinate::stringFromColumnIndex($colIndex);
  316.                 $sheet->getCell($col $row)->setValue("ЭЕШ оноогүй");
  317.                 $colIndex++;
  318.                 $col Coordinate::stringFromColumnIndex($colIndex);
  319.                 $sheet->getCell($col $row)->setValue("ЭЕШ оноогүй");
  320.             }
  321.             $idFile $em->getRepository(UserFile::class)->findBy([
  322.                 'userInfo' => $userInfo
  323.             ]);
  324.             $irgen null;
  325.             $tseej null;
  326.             $eyesh null;
  327.             foreach ($idFile as $file) {
  328.                 if ($file->getFileType()->getId() == 36) {
  329.                     $irgen $file;
  330.                 } else if ($file->getFileType()->getId() == 45) {
  331.                     $tseej $file;
  332.                 } else {
  333.                     $eyesh $file;
  334.                 }
  335.             }
  336.             $prefix "https://infosys.ufe.edu.mn:9443";
  337. //ehlel
  338.             $colIndex++;
  339.             $col Coordinate::stringFromColumnIndex($colIndex);
  340.             $sheet->getCell($col $row)->setValue($prefix $irgen?->getFilePath());
  341.             $colIndex++;
  342.             $col Coordinate::stringFromColumnIndex($colIndex);
  343.             $sheet->getCell($col $row)->setValue($prefix $tseej?->getFilePath());
  344.             $colIndex++;
  345.             $col Coordinate::stringFromColumnIndex($colIndex);
  346.             $sheet->getCell($col $row)->setValue($prefix $eyesh?->getFilePath());
  347. //tugsgul
  348.             $colIndex++;
  349.             $col Coordinate::stringFromColumnIndex($colIndex);
  350.             if ($admissionUser?->getPaymentRegisterFee() != null) {
  351.                 $sheet->getCell($col $row)->setValue($admissionUser?->getPaymentRegisterFee()?->getState());
  352.             } else {
  353.                 $sheet->getCell($col $row)->setValue("");
  354.             }
  355.             $colIndex++;
  356.             $col Coordinate::stringFromColumnIndex($colIndex);
  357.             if ($admissionUser?->getPaymentCredit() != null) {
  358.                 $sheet->getCell($col $row)->setValue($admissionUser?->getPaymentCredit()?->getState());
  359.             } else {
  360.                 $sheet->getCell($col $row)->setValue("");
  361.             }
  362.             $colIndex++;
  363.             $col Coordinate::stringFromColumnIndex($colIndex);
  364.             if ($userInfo?->getUserLanguages()->get(0) != null) {
  365.                 $sheet->getCell($col $row)->setValue($userInfo?->getUserLanguages()->get(0)->getLanguage()->getName());
  366.             } else {
  367.                 $sheet->getCell($col $row)->setValue("");
  368.             }
  369.             $colIndex++;
  370.             $col Coordinate::stringFromColumnIndex($colIndex);
  371.             if ($userInfo?->getUserLanguages()->get(0) != null) {
  372.                 $sheet->getCell($col $row)->setValue($userInfo?->getUserLanguages()->get(0)->getSpeaking());
  373.             } else {
  374.                 $sheet->getCell($col $row)->setValue("");
  375.             }
  376.             $colIndex++;
  377.             $col Coordinate::stringFromColumnIndex($colIndex);
  378.             if ($userInfo?->getUserLanguages()->get(0) != null) {
  379.                 $sheet->getCell($col $row)->setValue($userInfo?->getUserLanguages()->get(0)->getReading());
  380.             } else {
  381.                 $sheet->getCell($col $row)->setValue("");
  382.             }
  383.             $colIndex++;
  384.             $col Coordinate::stringFromColumnIndex($colIndex);
  385.             if ($userInfo?->getUserLanguages()->get(0) != null) {
  386.                 $sheet->getCell($col $row)->setValue($userInfo?->getUserLanguages()->get(0)->getWriting());
  387.             } else {
  388.                 $sheet->getCell($col $row)->setValue("");
  389.             }
  390.             $colIndex++;
  391.             $col Coordinate::stringFromColumnIndex($colIndex);
  392.             if ($userInfo?->getUserLanguages()->get(0) != null) {
  393.                 $sheet->getCell($col $row)->setValue($userInfo?->getUserLanguages()->get(0)->getListening());
  394.             } else {
  395.                 $sheet->getCell($col $row)->setValue("");
  396.             }
  397.             $colIndex++;
  398.             $col Coordinate::stringFromColumnIndex($colIndex);
  399.             if ($userInfo?->getUserEmployment()->get(0) != null) {
  400.                 $sheet->getCell($col $row)->setValue($userInfo?->getUserEmployment()->get(0)->getWorkSection()->getName());
  401.             } else {
  402.                 $sheet->getCell($col $row)->setValue("");
  403.             }
  404.             $colIndex++;
  405.             $col Coordinate::stringFromColumnIndex($colIndex);
  406.             if ($userInfo?->getUserEmployment()->get(0) != null) {
  407.                 $sheet->getCell($col $row)->setValue($userInfo?->getUserEmployment()->get(0)->getOrganizationName());
  408.             } else {
  409.                 $sheet->getCell($col $row)->setValue("");
  410.             }
  411.             $colIndex++;
  412.             $col Coordinate::stringFromColumnIndex($colIndex);
  413.             if ($userInfo?->getUserEmployment()->get(0) != null) {
  414.                 $sheet->getCell($col $row)->setValue($userInfo?->getUserEmployment()->get(0)->getJobTitle());
  415.             } else {
  416.                 $sheet->getCell($col $row)->setValue("");
  417.             }
  418.             $colIndex++;
  419.             $col Coordinate::stringFromColumnIndex($colIndex);
  420.             if ($userInfo?->getUserFamilyInfo()->get(0) != null) {
  421.                 $sheet->getCell($col $row)->setValue($userInfo?->getUserFamilyInfo()->get(0)->getRelationType()->getName());
  422.             } else {
  423.                 $sheet->getCell($col $row)->setValue("");
  424.             }
  425.             $colIndex++;
  426.             $col Coordinate::stringFromColumnIndex($colIndex);
  427.             if ($userInfo?->getUserFamilyInfo()->get(0) != null) {
  428.                 $sheet->getCell($col $row)->setValue($userInfo?->getUserFamilyInfo()->get(0)->getLastname());
  429.             } else {
  430.                 $sheet->getCell($col $row)->setValue("");
  431.             }
  432.             $colIndex++;
  433.             $col Coordinate::stringFromColumnIndex($colIndex);
  434.             if ($userInfo?->getUserFamilyInfo()->get(0) != null) {
  435.                 $sheet->getCell($col $row)->setValue($userInfo?->getUserFamilyInfo()->get(0)->getFirstname());
  436.             } else {
  437.                 $sheet->getCell($col $row)->setValue("");
  438.             }
  439.             $colIndex++;
  440.             $col Coordinate::stringFromColumnIndex($colIndex);
  441.             if ($userInfo?->getUserFamilyInfo()->get(0) != null) {
  442.                 $sheet->getCell($col $row)->setValue($userInfo?->getUserFamilyInfo()->get(0)->getRegisterNumber());
  443.             } else {
  444.                 $sheet->getCell($col $row)->setValue("");
  445.             }
  446.             $colIndex++;
  447.             $col Coordinate::stringFromColumnIndex($colIndex);
  448.             if ($userInfo?->getUserFamilyInfo()->get(0) != null) {
  449.                 $sheet->getCell($col $row)->setValue($userInfo?->getUserFamilyInfo()->get(0)->getEmail());
  450.             } else {
  451.                 $sheet->getCell($col $row)->setValue("");
  452.             }
  453.             $colIndex++;
  454.             $col Coordinate::stringFromColumnIndex($colIndex);
  455.             if ($userInfo?->getUserFamilyInfo()->get(0) != null) {
  456.                 $sheet->getCell($col $row)->setValue($userInfo?->getUserFamilyInfo()->get(0)->getMobile());
  457.             } else {
  458.                 $sheet->getCell($col $row)->setValue("");
  459.             }
  460.             $colIndex++;
  461.             $col Coordinate::stringFromColumnIndex($colIndex);
  462.             if ($userInfo?->getUserFamilyInfo()->get(0) != null) {
  463.                 $sheet->getCell($col $row)->setValue($userInfo?->getUserFamilyInfo()->get(0)->getWorkState());
  464.             } else {
  465.                 $sheet->getCell($col $row)->setValue("");
  466.             }
  467.             $colIndex++;
  468.             $col Coordinate::stringFromColumnIndex($colIndex);
  469.             if ($userEducation != null) {
  470.                 $sheet->getCell($col $row)->setValue($userEducation->getCountry()->getName());
  471.             } else {
  472.                 $sheet->getCell($col $row)->setValue("");
  473.             }
  474.             $colIndex++;
  475.             $col Coordinate::stringFromColumnIndex($colIndex);
  476.             if ($userEducation != null || $userEducation != null) {
  477.                 $sheet->getCell($col $row)->setValue($userEducation->getAddressing()?->getName());
  478.             } else {
  479.                 $sheet->getCell($col $row)->setValue("");
  480.             }
  481.             $colIndex++;
  482.             $col Coordinate::stringFromColumnIndex($colIndex);
  483.             if ($userEducation != null) {
  484.                 $sheet->getCell($col $row)->setValue($userEducation->getEduOrgName());
  485.             } else {
  486.                 $sheet->getCell($col $row)->setValue("");
  487.             }
  488.             $colIndex++;
  489.             $col Coordinate::stringFromColumnIndex($colIndex);
  490.             if ($userEducation != null) {
  491.                 $sheet->getCell($col $row)->setValue($userEducation->getCertificateNumber());
  492.             } else {
  493.                 $sheet->getCell($col $row)->setValue("");
  494.             }
  495.             $colIndex++;
  496.             $col Coordinate::stringFromColumnIndex($colIndex);
  497.             if ($userEducation != null) {
  498.                 $sheet->getCell($col $row)->setValue($userEducation->getDegree()->getName());
  499.             } else {
  500.                 $sheet->getCell($col $row)->setValue("");
  501.             }
  502.             $colIndex++;
  503.             $col Coordinate::stringFromColumnIndex($colIndex);
  504.             if ($userEducation != null) {
  505.                 $sheet->getCell($col $row)->setValue($userEducation->getProfession());
  506.             } else {
  507.                 $sheet->getCell($col $row)->setValue("");
  508.             }
  509.             $colIndex++;
  510.             $col Coordinate::stringFromColumnIndex($colIndex);
  511.             if ($userEducation != null) {
  512.                 $sheet->getCell($col $row)->setValue($userEducation->getGraduatedYear());
  513.             } else {
  514.                 $sheet->getCell($col $row)->setValue("");
  515.             }
  516.             $colIndex++;
  517.             $col Coordinate::stringFromColumnIndex($colIndex);
  518.             if ($userEducation != null) {
  519.                 $sheet->getCell($col $row)->setValue($userEducation->getGradeAvg());
  520.             } else {
  521.                 $sheet->getCell($col $row)->setValue("");
  522.             }
  523. //hayg
  524.             $colIndex++;
  525.             $col Coordinate::stringFromColumnIndex($colIndex);
  526.             if ($userInfo?->getUserAdressing()->get(0) != null &&
  527.                 $administrationId $userInfo?->getUserAdressing()->get(0)->getAddressing()->getParentId()) {
  528.                 $administration $em->getRepository(Addressing::class)->findBy(['id'=> $administrationId]);
  529.                 $sheet->getCell($col $row)->setValue($administration[0]->getName());
  530.             } else {
  531.                 $sheet->getCell($col $row)->setValue("");
  532.             }
  533.             $colIndex++;
  534.             $col Coordinate::stringFromColumnIndex($colIndex);
  535.             if ($userInfo?->getUserAdressing()->get(0) != null) {
  536.                 $sheet->getCell($col $row)->setValue($userInfo?->getUserAdressing()->get(0)->getAddressing()->getName());
  537.             } else {
  538.                 $sheet->getCell($col $row)->setValue("");
  539.             }
  540.             $colIndex++;
  541.             $col Coordinate::stringFromColumnIndex($colIndex);
  542.             if ($userInfo?->getUserAdressing()->get(0) != null) {
  543.                 $sheet->getCell($col $row)->setValue($userInfo?->getUserAdressing()->get(0)->getMicroDistrict());
  544.             } else {
  545.                 $sheet->getCell($col $row)->setValue("");
  546.             }
  547.             $colIndex++;
  548.             $col Coordinate::stringFromColumnIndex($colIndex);
  549.             if ($userInfo?->getUserAdressing()->get(0) != null) {
  550.                 $sheet->getCell($col $row)->setValue($userInfo?->getUserAdressing()->get(0)->getDetail());
  551.             } else {
  552.                 $sheet->getCell($col $row)->setValue("");
  553.             }
  554.             $colIndex++;
  555.             $col Coordinate::stringFromColumnIndex($colIndex);
  556.             if ($userInfo?->getUserAdressing()->get(0) != null) {
  557.                 $sheet->getCell($col $row)->setValue($userInfo?->getUserAdressing()->get(0)->getState()?->getName());
  558.             } else {
  559.                 $sheet->getCell($col $row)->setValue("");
  560.             }
  561.             $uiScores $em->getRepository(UserSatResult::class)->getScoresByUserInfoIds([$userInfo?->getId()], $minSatYear$lessonCodes);
  562.             foreach ($lessonCodes as $lessonCode) {
  563.                 $colIndex++;
  564.                 $col Coordinate::stringFromColumnIndex($colIndex);
  565.                 foreach ($uiScores as $uiScore) {
  566.                     if ($uiScore['lessonCode'] === $lessonCode) {
  567.                         $sheet->getCell($col $row)->setValue(max($uiScore['score'], $uiScore['scoreCorr']));
  568.                     }
  569.                 }
  570.             }
  571.             $row++;
  572.         }
  573.         $currentTime = new \DateTime('now');
  574.         $writer = new Xlsx($spreadsheet);
  575.         $fileName 'admission_' $admissionUser->getAdmission()?->getId() . '_' $currentTime->format('Ymd') . '.xlsx';
  576.         $temp_file tempnam(sys_get_temp_dir(), $fileName);
  577.         $writer->save($temp_file);
  578.         return $this->file($temp_file$fileNameResponseHeaderBag::DISPOSITION_INLINE);
  579.     }
  580.     protected function exportResultNew(EntityManagerInterface $emQueryBuilder $qb)
  581.     {
  582.         $admissionUsers $qb
  583.             ->getQuery()
  584.             ->getResult();
  585.         $spreadsheet = new Spreadsheet();
  586.         $sheet $spreadsheet->getActiveSheet();
  587.         $colIndex 0;
  588.         $colIndex++;
  589.         $col Coordinate::stringFromColumnIndex($colIndex);
  590.         $sheet->getCell($col "1")->setValue("Нэр:");
  591.         $colIndex++;
  592.         $col Coordinate::stringFromColumnIndex($colIndex);
  593.         $sheet->getCell($col "1")->setValue("Овог:");
  594.         $colIndex++;
  595.         $col Coordinate::stringFromColumnIndex($colIndex);
  596.         $sheet->getCell($col "1")->setValue("Цол:");
  597.         $colIndex++;
  598.         $col Coordinate::stringFromColumnIndex($colIndex);
  599.         $sheet->getCell($col "1")->setValue("Эрдмийн зэрэг:");
  600.         $colIndex++;
  601.         $col Coordinate::stringFromColumnIndex($colIndex);
  602.         $sheet->getCell($col "1")->setValue("Хүйс :");
  603.         $colIndex++;
  604.         $col Coordinate::stringFromColumnIndex($colIndex);
  605.         $sheet->getCell($col "1")->setValue("Мэйл:");
  606.         $colIndex++;
  607.         $col Coordinate::stringFromColumnIndex($colIndex);
  608.         $sheet->getCell($col "1")->setValue("Утас:");
  609.         $colIndex++;
  610.         $col Coordinate::stringFromColumnIndex($colIndex);
  611.         $sheet->getCell($col "1")->setValue("Амьдран суугаа Хот, аймаг, дүүрэг:");
  612.         $colIndex++;
  613.         $col Coordinate::stringFromColumnIndex($colIndex);
  614.         $sheet->getCell($col "1")->setValue("Харьяалал:");
  615.         $colIndex++;
  616.         $col Coordinate::stringFromColumnIndex($colIndex);
  617.         $sheet->getCell($col "1")->setValue("Материал:");
  618.         $colIndex++;
  619.         $col Coordinate::stringFromColumnIndex($colIndex);
  620.         $sheet->getCell($col "1")->setValue("Ажил эрхлэлтийн мэдээлэл:Ажиллаж байгаа салбар");
  621.         $colIndex++;
  622.         $col Coordinate::stringFromColumnIndex($colIndex);
  623.         $sheet->getCell($col "1")->setValue("Ажил эрхлэлтийн :Байгуулгын нэр");
  624.         $colIndex++;
  625.         $col Coordinate::stringFromColumnIndex($colIndex);
  626.         $sheet->getCell($col "1")->setValue("Ажил эрхлэлтийн :Албан тушаал");
  627.         $colIndex++;
  628.         $col Coordinate::stringFromColumnIndex($colIndex);
  629.         $sheet->getCell($col "1")->setValue("Ажил эрхлэлтийн :Хот");
  630.         $colIndex++;
  631.         $col Coordinate::stringFromColumnIndex($colIndex);
  632.         $sheet->getCell($col "1")->setValue("Ажил эрхлэлтийн :Хаяг");
  633.         $curDate = new \DateTime('today');
  634.         $row 2;
  635.         /** @var AdmissionUser $admissionUser */
  636.         foreach ($admissionUsers as $admissionUser) {
  637.             $user $admissionUser->getUser();
  638.             $userInfo $user?->getUserInfo();
  639.             $colIndex 0;
  640.             $colIndex++;
  641.             $col Coordinate::stringFromColumnIndex($colIndex);
  642.             $sheet->getCell($col $row)->setValue($userInfo?->getFirstnameMn());
  643.             $colIndex++;
  644.             $col Coordinate::stringFromColumnIndex($colIndex);
  645.             $sheet->getCell($col $row)->setValue($userInfo?->getLastnameMn());
  646.             $colIndex++;
  647.             $col Coordinate::stringFromColumnIndex($colIndex);
  648.             $sheet->getCell($col $row)->setValue($userInfo?->getDegree());
  649.             $colIndex++;
  650.             $col Coordinate::stringFromColumnIndex($colIndex);
  651.             $sheet->getCell($col $row)->setValue($userInfo?->getTitle());
  652.             $colIndex++;
  653.             $col Coordinate::stringFromColumnIndex($colIndex);
  654.             $sheet->getCell($col $row)->setValue($userInfo?->getGender() ? "эр" "эм");
  655.             $colIndex++;
  656.             $col Coordinate::stringFromColumnIndex($colIndex);
  657.             $sheet->getCell($col $row)->setValue($user?->getEmail());
  658.             $colIndex++;
  659.             $col Coordinate::stringFromColumnIndex($colIndex);
  660.             $sheet->getCell($col $row)->setValue($userInfo?->getMobile());
  661.             $colIndex++;
  662.             $col Coordinate::stringFromColumnIndex($colIndex);
  663.             $sheet->getCell($col $row)->setValue($userInfo?->getProvince()->getName());
  664.             $colIndex++;
  665.             $col Coordinate::stringFromColumnIndex($colIndex);
  666.             $sheet->getCell($col $row)->setValue($userInfo?->getCountry()->getName());
  667.             $file $em->getRepository(AdmissionFile::class)->findOneBy([
  668.                 'userInfo' => $userInfo,
  669.                 'admission' => $admissionUser->getAdmission()
  670.             ]);
  671.             $prefix "http://research.ufe.mn:8000";
  672.             $colIndex++;
  673.             $col Coordinate::stringFromColumnIndex($colIndex);
  674.             $sheet->getCell($col $row)->setValue($prefix $file?->getFilePath());
  675.             $colIndex++;
  676.             $col Coordinate::stringFromColumnIndex($colIndex);
  677.             if ($userInfo?->getUserEmployment()->get(0) != null) {
  678.                 $sheet->getCell($col $row)->setValue($userInfo?->getUserEmployment()->get(0)->getWorkSection()->getName());
  679.             } else {
  680.                 $sheet->getCell($col $row)->setValue("");
  681.             }
  682.             $colIndex++;
  683.             $col Coordinate::stringFromColumnIndex($colIndex);
  684.             if ($userInfo?->getUserEmployment()->get(0) != null) {
  685.                 $sheet->getCell($col $row)->setValue($userInfo?->getUserEmployment()->get(0)->getOrganizationName());
  686.             } else {
  687.                 $sheet->getCell($col $row)->setValue("");
  688.             }
  689.             $colIndex++;
  690.             $col Coordinate::stringFromColumnIndex($colIndex);
  691.             if ($userInfo?->getUserEmployment()->get(0) != null) {
  692.                 $sheet->getCell($col $row)->setValue($userInfo?->getUserEmployment()->get(0)->getJobTitle());
  693.             } else {
  694.                 $sheet->getCell($col $row)->setValue("");
  695.             }
  696.             $colIndex++;
  697.             $col Coordinate::stringFromColumnIndex($colIndex);
  698.             if ($userInfo?->getUserEmployment()->get(0) != null) {
  699.                 $sheet->getCell($col $row)->setValue($userInfo?->getUserEmployment()->get(0)->getCity());
  700.             } else {
  701.                 $sheet->getCell($col $row)->setValue("");
  702.             }
  703.             $colIndex++;
  704.             $col Coordinate::stringFromColumnIndex($colIndex);
  705.             if ($userInfo?->getUserEmployment()->get(0) != null) {
  706.                 $sheet->getCell($col $row)->setValue($userInfo?->getUserEmployment()->get(0)->getAddress());
  707.             } else {
  708.                 $sheet->getCell($col $row)->setValue("");
  709.             }
  710.             $row++;
  711.         }
  712.         $currentTime = new \DateTime('now');
  713.         $writer = new Xlsx($spreadsheet);
  714.         $fileName 'research_' $admissionUser->getAdmission()?->getId() . '_' $currentTime->format('Ymd') . '.xlsx';
  715.         $temp_file tempnam(sys_get_temp_dir(), $fileName);
  716.         $writer->save($temp_file);
  717.         return $this->file($temp_file$fileNameResponseHeaderBag::DISPOSITION_INLINE);
  718.     }
  719.     #[Route('/{admissionId}/user/index/all'name'app_admission_user_index_all'methods: ['GET'])]
  720.     public function indexAll(
  721.         Request                $request,
  722.         EntityManagerInterface $em,
  723.     ): Response
  724.     {
  725.         $admissionId $request->attributes->getInt('admissionId'0);
  726.         $admission $em->getRepository(Admission::class)->find($admissionId);
  727.         $qb $em->getRepository(AdmissionUser::class)
  728.             ->createQueryBuilder('admission_user')
  729.             ->leftJoin('admission_user.user''user')
  730.             ->leftJoin('user.userInfo''user_info');
  731.         $qb
  732.             ->addSelect('user')
  733.             ->addSelect('user_info');
  734.         $qb
  735.             ->where($qb->expr()->eq('admission_user.admission'':admission'))
  736.             ->setParameter('admission'$admission);
  737.         $qb
  738.             ->orderBy('admission_user.timeCreated''DESC');
  739.         $admissionUsers $qb
  740.             ->getQuery()
  741.             ->getResult();
  742.         return $this->render('admission_user/index-all.html.twig', [
  743.             'admission' => $admission,
  744.             'admissionUsers' => $admissionUsers,
  745.         ]);
  746.     }
  747.     #[Route('/{admissionId}/user/index'name'app_admission_user_index'methods: ['GET''POST'])]
  748.     public function index(
  749.         Request                $request,
  750.         EntityManagerInterface $em,
  751.         PaginatorInterface     $paginator
  752.     ): Response
  753.     {
  754.         $page $request->query->getInt('page'0);
  755.         $admissionId $request->attributes->getInt('admissionId'0);
  756.         $admission $em->getRepository(Admission::class)->find($admissionId);
  757.         if (!$admission) {
  758.             throw new NotFoundHttpException("");
  759.         }
  760.         $lessonCodes $request->getSession()->get('sat_lesson_codes');
  761.         if (!$lessonCodes) {
  762.             $lessonCodes = [];
  763.         }
  764.         $qb $em->getRepository(AdmissionUser::class)
  765.             ->createQueryBuilder('admission_user')
  766.             ->leftJoin('admission_user.user''user')
  767.             ->leftJoin('user.userInfo''user_info')
  768.             ->leftJoin('admission_user.paymentRegisterFee''payment_register_fee')
  769.             ->leftJoin('admission_user.paymentCredit''payment_credit')
  770.             ->leftJoin('admission_user.lastComment''lastComment');
  771.         $qb
  772.             ->addSelect('user')
  773.             ->addSelect('user_info')
  774.             ->addSelect('payment_register_fee')
  775.             ->addSelect('payment_credit')
  776.             ->addSelect('lastComment');
  777.         $qb
  778.             ->where($qb->expr()->eq('admission_user.admission'':admission'))
  779.             ->setParameter('admission'$admission)
  780.             ->andWhere($qb->expr()->in('admission_user.state'':states'))
  781.             ->setParameter('states', [AdmissionUser::STATE_REGISTEREDAdmissionUser::STATE_FILE_UPLOADEDAdmissionUser::STATE_DECLINEAdmissionUser::STATE_POSTERAdmissionUser::STATE_SPEAKER]);
  782.         $filterForm $this->createForm(AdmissionUserFilterType::class, null, [
  783.             'em' => $em,
  784.             'admissionId' => $admissionId,
  785.             'action' => $this->generateUrl('app_admission_user_index', ['admissionId' => $admission->getId()]),
  786.         ]);
  787.         $filterForm->handleRequest($request);
  788.         $filtering false;
  789.         $filterName $request->attributes->get('_route') . "_filter";
  790.         if ($filterForm->isSubmitted()) {
  791.             $filtering true;
  792.             $request->getSession()->set($filterName$filterForm->getData());
  793.         } elseif ($page 0) {
  794.             $filterValues $request->getSession()->get($filterName);
  795.             if ($filterValues) {
  796.                 $filterForm->submit($filterValues);
  797.                 $filtering true;
  798.             }
  799.         }
  800.         if ($filtering && $filterForm->isValid()) {
  801.             $filter = new AdmissionUserFilter($filterForm);
  802.             $qb $filter->filterQuery($qb);
  803.         }
  804.         $submitType $request->request->get('_submit_type''filter');
  805.         if ($submitType === "export") {
  806.             return $this->exportResultNew($em$qb);
  807.         }
  808.         $qb
  809.             ->orderBy('admission_user.timeCreated''DESC');
  810.         $admissionUsersPaged $paginator->paginate($qb->getQuery(), $page === $page20);
  811.         $userInfoIds = [];
  812.         /** @var AdmissionUser $admissionUser */
  813.         foreach ($admissionUsersPaged as $admissionUser) {
  814.             $userInfoId $admissionUser->getUser()?->getUserInfo()?->getId();
  815.             if ($userInfoId 0) {
  816.                 $userInfoIds[] = $userInfoId;
  817.             }
  818.         }
  819.         $curDate = new \DateTime('today');
  820.         $minSatYear = ((int)$curDate->format('Y')) - 2;
  821.         $userInfoScores $em->getRepository(UserSatResult::class)->getScoresByUserInfoIds($userInfoIds$minSatYear);
  822.         $uiScores = [];
  823.         foreach ($userInfoScores as $uiScore) {
  824.             $uiKey 'user_info_' $uiScore['userInfoId'];
  825.             $lessonCode $uiScore['lessonCode'];
  826.             if (!isset($uiScores[$uiKey])) {
  827.                 $uiScores[$uiKey] = [];
  828.             }
  829.             $uiScores[$uiKey][$lessonCode] = max($uiScore['score'], $uiScore['scoreCorr']);
  830.         }
  831.         $admissionTotalRegFee $em->getRepository(Payment::class)->totalRegisterFee($admission->getCode());
  832.         $admissionTotalCreditFee $em->getRepository(Payment::class)->totalCreditFee($admission->getCode());
  833.         return $this->render('admission_user/index.html.twig', [
  834.             'admission' => $admission,
  835.             'admissionUsersPaged' => $admissionUsersPaged,
  836.             'filterForm' => $filterForm->createView(),
  837.             'uiScores' => $uiScores,
  838.             'lessonCodes' => $lessonCodes,
  839.             'pageId' => $page,
  840.             'admissionTotalRegFee' => $admissionTotalRegFee,
  841.             'admissionTotalCreditFee' => $admissionTotalCreditFee
  842.         ]);
  843.     }
  844.     #[Route('/{admissionId}/user/pub/index'name'app_admission_user_pub_index'methods: ['GET''POST'])]
  845.     public function indexPub(
  846.         Request                $request,
  847.         EntityManagerInterface $em,
  848.         PaginatorInterface     $paginator
  849.     ): Response
  850.     {
  851.         $page $request->query->getInt('page'0);
  852.         $admissionId $request->attributes->getInt('admissionId'0);
  853.         $admission $em->getRepository(Admission::class)->find($admissionId);
  854.         if (!$admission) {
  855.             throw new NotFoundHttpException("");
  856.         }
  857.         $qb $em->getRepository(AdmissionFile::class)
  858.             ->createQueryBuilder('af')
  859.             ->leftJoin('af.admissionUser''admission_user')
  860.             ->leftJoin('admission_user.user''user')
  861.             ->leftJoin('user.userInfo''user_info');
  862.         $qb
  863.             ->addSelect('admission_user')
  864.             ->addSelect('user')
  865.             ->addSelect('user_info');
  866.         $qb
  867.             ->where($qb->expr()->eq('admission_user.admission'':admission'))
  868.             ->setParameter('admission'$admission)
  869.             ->andWhere($qb->expr()->in('admission_user.state'':states'))
  870.             ->andWhere('admission_user.pubState is NULL')
  871.             ->andWhere($qb->expr()->in('admission_user.type'':types'))
  872.             ->setParameter('states', [AdmissionUser::STATE_FILE_UPLOADED])
  873.             ->setParameter('types', [2,3]);
  874.         $qb
  875.             ->orderBy('admission_user.timeCreated''DESC');
  876.         $admissionUsersPaged $paginator->paginate($qb->getQuery(), $page === $page20);
  877.         return $this->render('admission_user/index-pub.html.twig', [
  878.             'admission' => $admission,
  879.             'admissionUsersPaged' => $admissionUsersPaged,
  880.             'pageId' => $page
  881.         ]);
  882.     }
  883.     #[Route('/send/pub'name'app_admission_user_send_pub_index'methods: ['POST'])]
  884.     public function sendPub(
  885.         Request                $request,
  886.         EntityManagerInterface $em,
  887.     ): Response
  888.     {
  889.         $admissionUsers $request->request->all()['ids'];
  890.         foreach ($admissionUsers as $id){
  891.             /** @var AdmissionUser $admissionUser */
  892.             $admissionUser $em->getRepository(AdmissionUser::class)->find($id);
  893.             $admissionUser->setPubState('new');
  894.             $em->persist($admissionUser);
  895.             /** @var AdmissionFile $admissionFile */
  896.             $admissionFile $em->getRepository(AdmissionFile::class)->findOneBy(['admissionUser' => $admissionUser]);
  897.             $admissionFile->setState('new');
  898.             $em->persist($admissionFile);
  899.             $em->flush();
  900.         }
  901.         return $this->json([
  902.             'toast' => [
  903.                 'status' => 'success',
  904.                 'msg' => 'Амжилттай'
  905.             ],
  906.             'window_reload' => true,
  907.         ]);
  908.     }
  909.     #[Route('/{admissionId}/user/register'name'app_admission_user_register'methods: ['GET''POST'])]
  910.     public function register(
  911.         Request                $request,
  912.         EntityManagerInterface $em,
  913.         AdmissionUserService   $admissionUserService,
  914.         NormalizerInterface    $normalizer
  915.     ): Response
  916.     {
  917.         $admissionId $request->attributes->getInt('admissionId'0);
  918.         /** @var Admission $admission */
  919.         $admission $em->getRepository(Admission::class)->find($admissionId);
  920.         if (!$admission) {
  921.             throw new NotFoundHttpException("Admission not found");
  922.         }
  923.         $admissionUser = new AdmissionUser();
  924.         $admissionUser->setAdmission($admission);
  925.         $admissionUser->setTimeCreated(new \DateTime('now'));
  926.         $admissionUser->setState(AdmissionUser::STATE_REGISTERED);
  927.         $form $this->createForm(AdmissionUserType::class, $admissionUser);
  928.         $form->handleRequest($request);
  929.         if ($form->isSubmitted()) {
  930.             if ($form->isValid()) {
  931.                 $userId $form->get('userId')->getData();
  932.                 $user $em->getRepository(User::class)->find($userId);
  933.                 if (!$user) {
  934.                     throw new BadRequestHttpException();
  935.                 }
  936.                 $admissionUser->setUser($user);
  937.                 $admissionUser->setTimeUpdated(new \DateTime('now'));
  938.                 $result $admissionUserService->checkRegister($admissionUser);
  939.                 if ($result['created'] == true) {
  940.                     $log = new ActionLog();
  941.                     $log
  942.                         ->setRouteName($request->get('_route'))
  943.                         ->setActionName(ActionLog::ACTION_INSERT)
  944.                         ->setEntityName(AdmissionUser::class)
  945.                         ->setEntityId($admissionUser->getId())
  946.                         ->setEntityData($normalizer->normalize(
  947.                             $result['admissionUser'],
  948.                             'object',
  949.                             ['groups' => ['list']]
  950.                         ))
  951.                         ->setUserAct($this->getUser())
  952.                         ->setTimeCreated($admissionUser->getTimeCreated());
  953.                     $em->persist($log);
  954.                     $em->flush();
  955.                 }
  956.                 $em->persist($admissionUser);
  957.                 $em->flush();
  958.                 $this->addFlash($result['level'], $result['msg']);
  959.                 return $this->redirectToRoute('app_admission_user_index', ['admissionId' => $admission->getId()], Response::HTTP_SEE_OTHER);
  960.             }
  961.         }
  962.         return $this->renderForm('admission_user/new.html.twig', [
  963.             'admission' => $admission,
  964.             'admission_user' => $admissionUser,
  965.             'form' => $form,
  966.         ]);
  967.     }
  968.     #[Route('/{admissionId}/user/{id}/show'name'app_admission_user_show'methods: ['GET'])]
  969.     public function show(
  970.         Request                $request,
  971.         EntityManagerInterface $em,
  972.     ): Response
  973.     {
  974.         $id $request->attributes->getInt('id'0);
  975.         $qb $em->getRepository(AdmissionUser::class)
  976.             ->createQueryBuilder('admission_user')
  977.             ->leftJoin('admission_user.infoChannel''gc');
  978.         $admissionUser $qb
  979.             ->andWhere($qb->expr()->eq('admission_user.id'':id'))
  980.             ->setParameter('id'$id)
  981.             ->getQuery()
  982.             ->getSingleResult();
  983.         if (!$admissionUser) {
  984.             throw new NotFoundHttpException("AdmissionUser not found");
  985.         }
  986.         $admission $admissionUser->getAdmission();
  987.         $userInfo '';
  988.         $files '';
  989.         if($admissionUser->getUser()->getUserInfo()) {
  990.             $id $admissionUser->getUser()->getUserInfo()->getId();
  991.             $userInfo $em->getRepository(UserInfo::class)->find($id);
  992.             if (!$userInfo) {
  993.                 throw new NotFoundHttpException("Хэрэглэгчийн мэдээлэл олдсонгүй! Та хувийн мэдээллээ оруулна уу.");
  994.             }
  995.             $files $em->getRepository(AdmissionFile::class)->findBy([
  996.                 'userInfo' => $userInfo,
  997.                 'admission' => $admission
  998.             ]);
  999.         }
  1000.         return $this->render('admission_user/showC.html.twig', [
  1001.             'admission_user' => $admissionUser,
  1002.             'admission' => $admission,
  1003.             'files' => $files
  1004.         ]);
  1005.     }
  1006.     #[Route('/{admissionId}/user/{id}/payment/{paymentType}/create'name'app_admission_user_payment_create'methods: ['GET'])]
  1007.     public function userPaymentCreate(
  1008.         Request                $request,
  1009.         PaymentService         $paymentService,
  1010.         EntityManagerInterface $em
  1011.     ): Response
  1012.     {
  1013.         $paymentType $request->attributes->get('paymentType');
  1014.         if (!in_array($paymentType, [Payment::TYPE_ADMISSION_REGISTERPayment::TYPE_ADMISSION_CREDIT])) {
  1015.             throw new BadRequestHttpException("");
  1016.         }
  1017.         $admissionId $request->attributes->getInt('admissionId'0);
  1018.         /** @var Admission $admission */
  1019.         $admission $em->getRepository(Admission::class)->find($admissionId);
  1020.         if (!$admission) {
  1021.             throw new NotFoundHttpException("Admission not found");
  1022.         }
  1023.         $id $request->attributes->getInt('id'0);
  1024.         /** @var AdmissionUser $admissionUser */
  1025.         $admissionUser $em->getRepository(AdmissionUser::class)->find($id);
  1026.         if (!$admissionUser) {
  1027.             throw new NotFoundHttpException("AdmissionUser not found");
  1028.         }
  1029.         $payment $paymentService->getAdmissionUserPayment($admissionUser$paymentType);
  1030.         if ($payment) {
  1031.             return $this->json([
  1032.                 'toast' => [
  1033.                     'status' => 'success',
  1034.                     'msg' => 'Төлбөр үүслээ!'
  1035.                 ],
  1036.                 'window_reload' => true,
  1037.             ]);
  1038.         }
  1039.         return $this->json([
  1040.             'toast' => [
  1041.                 'status' => 'error',
  1042.                 'msg' => 'Амжилтгүй!'
  1043.             ],
  1044.             'window_reload' => true,
  1045.         ]);
  1046.     }
  1047.     #[Route('/{admissionId}/user/set/fix/sat/code'name'app_admission_user_set_fix_sat_code'methods: ['GET'])]
  1048.     public function setFixSatCode(
  1049.         Request                $request,
  1050.         EntityManagerInterface $em,
  1051.         SatUserService         $satUserService
  1052.     ): Response
  1053.     {
  1054.         $admissionId $request->attributes->getInt('admissionId'0);
  1055.         /** @var Admission $admission */
  1056.         $admission $em->getRepository(Admission::class)->find($admissionId);
  1057.         if (!$admission) {
  1058.             throw new NotFoundHttpException("Admission not found");
  1059.         }
  1060.         $qb $em->getRepository(AdmissionUser::class)
  1061.             ->createQueryBuilder('admission_user')
  1062.             ->leftJoin('admission_user.user''user')
  1063.             ->leftJoin('user.userInfo''user_info')
  1064.             ->leftJoin(UserSat::class, 'user_sat'Join::WITH'user_sat.userInfo = user_info');
  1065.         $qb->select('distinct admission_user');
  1066.         $qb
  1067.             ->where($qb->expr()->eq('admission_user.admission'':admission'))
  1068.             ->setParameter('admission'$admission)
  1069.             ->andWhere($qb->expr()->isNotNull('user_sat.id'))
  1070.             ->andWhere($qb->expr()->orX(
  1071.                 $qb->expr()->isNull('admission_user.satCode'),
  1072.                 $qb->expr()->neq('length(admission_user.satCode)'':satLength')
  1073.             ))
  1074.             ->setParameter('satLength'9);
  1075.         $admissionUsers $qb
  1076.             ->setMaxResults(100)
  1077.             ->getQuery()
  1078.             ->getResult();
  1079.         $counter 0;
  1080.         /** @var AdmissionUser $admissionUser */
  1081.         foreach ($admissionUsers as $admissionUser) {
  1082.             $userSat $em->getRepository(UserSat::class)->findOneConfirmedOrLast($admissionUser);
  1083.             if (!$userSat) {
  1084.                 continue;
  1085.             }
  1086.             $admissionUser->setSatCode($userSat->getSatCode());
  1087.             $counter++;
  1088.         }
  1089.         $em->flush();
  1090.         return $this->json([
  1091.             'toast' => [
  1092.                 'status' => 'success',
  1093.                 'msg' => 'success - ' $counter,
  1094.             ],
  1095.             'window_reload' => true,
  1096.         ]);
  1097.     }
  1098.     #[Route('/save/fe'name'app_admission_user_fe_save'methods: ['POST'])]
  1099.     public function saveFe(
  1100.         Request                $request,
  1101.         EntityManagerInterface $em,
  1102.     ): Response
  1103.     {
  1104.         $id $request->request->all()['admissionUserId'];
  1105.         $feId $request->request->all()['feId'];
  1106.         /** @var AdmissionUser $admissionUser */
  1107.         $admissionUser $em->getRepository(AdmissionUser::class)->find($id);
  1108.         $admissionUser->setFeId($feId);
  1109.         $admissionUser->setPubState(AdmissionUser::PUB_STATE_FE);
  1110.         $admissionUser->setTimeUpdated(new \DateTime('now'));
  1111.         $em->persist($admissionUser);
  1112.         $em->flush();
  1113.         return $this->json([
  1114.             'toast' => [
  1115.                 'status' => 'success',
  1116.                 'msg' => 'Амжилттай'
  1117.             ],
  1118.             'window_reload' => true,
  1119.         ]);
  1120.     }
  1121.     #[Route('/{admissionId}/user/{id}/edit'name'app_admission_user_edit'methods: ['GET''POST'])]
  1122.     public function edit(Request $requestAdmissionUser $admissionUserEntityManagerInterface $em,
  1123.                          MailerInterface $mailer): Response
  1124.     {
  1125.         $admissionId $request->attributes->getInt('admissionId'0);
  1126.         /** @var Admission $admission */
  1127.         $admission $em->getRepository(Admission::class)->find($admissionId);
  1128.         $subjectMail "Research.ufe.mn илгээсэн бүтээлийн тухай";
  1129.         $sub "Оюутны эрдэм шинжилгээний XVII хурал";
  1130.         $body "";
  1131.         if($admission->getDegree()->getId() == 1) {
  1132.             $subjectMail 'Research.ufe.mn илгээсэн бүтээлийн тухай';
  1133.             $sub "Нээлттэй шинжлэх ухаан ба Тогтвортой хөгжил";
  1134.         }
  1135.         $form $this->createForm(AdmissionUserStateType::class, $admissionUser);
  1136.         $form->handleRequest($request);
  1137.         if ($form->isSubmitted() && $form->isValid()) {
  1138.             $em->persist($admissionUser);
  1139.             $em->flush();
  1140.             if($admissionUser->getState() === AdmissionUser::STATE_SPEAKER){
  1141.                 $type 'Аман илтгэл';
  1142.                 $msg "Шалгарсан бүтээлийн танилцуулга (ppt) файлыг 2025 оны 4-р сарын 23-ны 15:00 цаг хүртэл салбар хариуцсан нарийн бичгийн имэйлээр хүлээн авна. Та бүхэн рүү салбар хариуцсан нарийн бичиг холбогдож, PPT загвар, бусад заавар мэдээлэл хүргэнэ. ";
  1143.                 $body $this->renderView('admission_user/_confirm.html.twig', [
  1144.                     'userInfo' => $admissionUser->getUser()->getUserInfo(),
  1145.                     'admission' => $admission,
  1146.                     'sub' => $sub,
  1147.                     'type' => $type,
  1148.                     'msg' => $msg
  1149.                 ]);
  1150.             }else if ($admissionUser->getState() === AdmissionUser::STATE_POSTER){
  1151.                 $type 'Постер илтгэл';
  1152.                 $msg "Хэвлэсэн постерийг 2025 оны 4 сарын 23-ны 15:00 цаг хүртэл СЭЗИС-ийн B байрны 502 тоотод хураалгана. /Холбогдох дугаар: 88301003/. Та бүхэн рүү салбар хариуцсан нарийн бичиг имэйлээр холбогдож, постерын загвар, бусад заавар мэдээлэл хүргэнэ. ";
  1153.                 $body $this->renderView('admission_user/_confirm.html.twig', [
  1154.                     'userInfo' => $admissionUser->getUser()->getUserInfo(),
  1155.                     'admission' => $admission,
  1156.                     'sub' => $sub,
  1157.                     'type' => $type,
  1158.                     'msg' => $msg
  1159.                 ]);
  1160.             } else if ($admissionUser->getState() === AdmissionUser::STATE_DECLINE){
  1161.                 $msg 'Дараагийн удаа дахин оролцоорой.';
  1162.                 $body $this->renderView('admission_user/_decline.html.twig', [
  1163.                     'userInfo' => $admissionUser->getUser()->getUserInfo(),
  1164.                     'admission' => $admission,
  1165.                     'subject' => $subjectMail,
  1166.                     'msg' => $msg
  1167.                 ]);
  1168.             }
  1169.             $mailFrom $_ENV['SYS_MAIL'];
  1170.             $email = (new Email())
  1171.                 ->from($mailFrom)
  1172.                 ->to($admissionUser->getUser()->getEmail())
  1173.                 ->subject($subjectMail)
  1174.                 ->html($body);
  1175.             try {
  1176.                 $mailer->send($email);
  1177.             } catch (TransportExceptionInterface $e) {
  1178.             }
  1179.             return $this->redirectToRoute('app_admission_user_show', ['admissionId' => $admissionId'id' => $admissionUser->getId()], Response::HTTP_SEE_OTHER);
  1180.         }
  1181.         return $this->renderForm('admission_user/edit.html.twig', [
  1182.             'admission_user' => $admissionUser,
  1183.             'form' => $form,
  1184.         ]);
  1185.     }
  1186. //
  1187. //    #[Route('/{id}', name: 'app_admission_user_delete', methods: ['POST'])]
  1188. //    public function delete(Request $request, AdmissionUser $admissionUser, AdmissionUserRepository $admissionUserRepository): Response
  1189. //    {
  1190. //        if ($this->isCsrfTokenValid('delete' . $admissionUser->getId(), $request->request->get('_token'))) {
  1191. //            $admissionUserRepository->remove($admissionUser);
  1192. //        }
  1193. //
  1194. //        return $this->redirectToRoute('app_admission_user_index', [], Response::HTTP_SEE_OTHER);
  1195. //    }
  1196. }