applicant-site/app/Services/DirectonHtmlBuilder.php

283 lines
14 KiB
PHP
Raw Normal View History

2024-03-12 12:47:12 +03:00
<?php
namespace App\Services;
2024-03-14 13:11:18 +03:00
use Illuminate\Support\Facades\URL;
2024-03-12 12:47:12 +03:00
2024-03-27 14:47:06 +03:00
// phpcs:disable
2024-03-12 12:47:12 +03:00
class DirectonHtmlBuilder
{
2024-03-15 10:38:26 +03:00
private array $direction;
2024-03-15 16:09:19 +03:00
2024-03-12 12:47:12 +03:00
public function __construct($direction)
{
$this->direction = $direction;
}
2024-03-21 14:48:08 +03:00
2024-03-12 12:47:12 +03:00
public function getHTML()
{
$direction = $this->direction;
2024-04-22 16:27:20 +03:00
$fon_3 = URL::to('img/front-page/bakalavr-special/fon2_blok.png');
2024-03-15 16:09:19 +03:00
$green_circle = URL::to('img/front-page/green-circle.png');
2024-03-21 16:29:10 +03:00
$education_form = '';
foreach ($direction['education_form'] as $el) {
$education_form .= $el . ', ';
2024-03-15 16:09:19 +03:00
}
2024-03-21 16:29:10 +03:00
$education_form = substr($education_form, 0, -2);
2024-03-15 16:09:19 +03:00
2024-03-21 16:29:10 +03:00
$period = '<br>';
foreach ($direction['period'] as $key => $el) {
2024-03-27 13:31:43 +03:00
$period .= '<span style="font-family: Geologica-ExtraLight">' . $key . '</span> - ' . '<strong>' . $el . '</strong><br>' ;
2024-03-15 16:09:19 +03:00
}
//dd($direction);
$paid_cost = '<div class="col-auto ">
<strong class="fs-3"> Стоимость обучения </strong>
<br>
2024-04-01 15:57:19 +03:00
<div class="fs-4 text-start">';
foreach ($direction['cost_paid_place'] as $key => $el) {
2024-03-27 13:31:43 +03:00
$paid_cost .= '<span style="font-family: Geologica-ExtraLight">' . $key . '</span> - ' . '<strong>' . $el . '</strong><br>' ;
2024-03-15 16:09:19 +03:00
}
$paid_cost .= '</div></div>';
2024-03-15 16:09:19 +03:00
2024-03-27 13:31:43 +03:00
$EGE = '<div class="col-auto ">
<strong> ЕГЭ </strong>
<br>
2024-04-01 15:57:19 +03:00
<div class=" d-inline-block p-2 text-start">';
2024-06-06 09:37:54 +03:00
if (array_key_exists('ЕГЭ', $direction['entrance_examinations'])){
foreach ($direction['entrance_examinations']['ЕГЭ']['Обязательные'] as $key => $el) {
$EGE .= '<span style="font-family: Geologica-ExtraLight">' . $key . '</span> - ' . '<strong>' . $el . '</strong><br>' ;
}
$EGE .= '</div></div>';
} else {
$EGE = '';
2024-03-15 16:09:19 +03:00
}
2024-06-06 09:37:54 +03:00
$po_viboru = '<div class="col-auto ">
<strong> Предметы по выбору </strong>
<br>
2024-04-01 15:57:19 +03:00
<div class=" d-inline-block p-2 text-start">';
2024-03-27 14:03:46 +03:00
if (array_key_exists('Предметы по выбору', $direction['entrance_examinations']['ЕГЭ'])) {
2024-03-21 16:29:10 +03:00
foreach ($direction['entrance_examinations']['ЕГЭ']['Предметы по выбору'] as $key => $el) {
2024-03-27 13:31:43 +03:00
$po_viboru .= '<span style="font-family: Geologica-ExtraLight">' . $key . '</span> - ' . '<strong>' . $el . '</strong><br>' ;
2024-03-21 16:29:10 +03:00
}
$po_viboru .= '</div></div>';
2024-03-27 14:03:46 +03:00
} else {
$po_viboru = '';
2024-03-21 16:29:10 +03:00
}
$SPO = '<div class="col-auto ">
<strong> СПО </strong>
<br>
2024-04-01 15:57:19 +03:00
<div class=" d-inline-block p-2 text-start">';
2024-03-27 14:03:46 +03:00
if (array_key_exists('СПО', $direction['entrance_examinations'])) {
2024-03-21 16:29:10 +03:00
foreach ($direction['entrance_examinations']['СПО']['Обязательные'] as $key => $el) {
2024-03-27 13:31:43 +03:00
$SPO .= '<span style="font-family: Geologica-ExtraLight">' . $key . '</span> - ' . '<strong>' . $el . '</strong><br>' ;
2024-03-21 16:29:10 +03:00
}
$SPO .= '</div></div>';
2024-03-27 14:03:46 +03:00
} else {
$SPO = '';
2024-03-15 16:09:19 +03:00
}
2024-03-21 16:29:10 +03:00
2024-03-22 16:33:16 +03:00
$mgtu = '';
2024-03-27 14:03:46 +03:00
if (array_key_exists('МГТУ', $direction['budget_places'])) {
2024-03-22 16:33:16 +03:00
foreach ($direction['budget_places']['МГТУ'] as $profile_name => $profile) {
2024-03-27 14:03:46 +03:00
$profile_content = '';
foreach ($profile as $forms => $budget_places) {
2024-03-27 13:31:43 +03:00
$profile_content .= "<strong> {$forms} </strong> - " . "<span style=\'font-family: Geologica-ExtraLight\'> {$budget_places} </span><br>";
2024-03-22 16:33:16 +03:00
}
$tmp = str_replace(' ', '', $profile_name);
$tmp = str_replace(',', '', $tmp);
2024-04-04 14:15:10 +03:00
$mgtu .= "<div class=\"accordion mb-3\" id=\"accordionExample\" >
2024-04-01 15:57:19 +03:00
<div class=\"accordion-item\" style='border-radius: 20px;'>
<h2 class=\"accordion-header\" style='border-radius: 20px;'>
<button class=\"accordion-button\" type=\"button\" data-bs-toggle=\"collapse\" data-bs-target=\"#collapse-{$tmp}\" aria-expanded=\"true\" aria-controls=\"collapse-{$tmp}\">
2024-03-22 16:33:16 +03:00
$profile_name
</button>
</h2>
<div id=\"collapse-{$tmp}\" class=\"accordion-collapse collapse show\" data-bs-parent=\"#accordionExample\">
2024-03-22 16:33:16 +03:00
<div class=\"accordion-body\">
$profile_content
</div>
</div>
</div>
</div>" ;
}
}
// if($direction['name'] == 'Нефтегазовое дело') {
// dd($direction);
// };
// dd($direction);
2024-03-22 16:33:16 +03:00
2024-03-21 16:29:10 +03:00
$filial = '';
2024-03-27 14:03:46 +03:00
if (array_key_exists('Филиал МГТУ (пос. Яблоновский)', $direction['budget_places'])) {
foreach ($direction['budget_places']['Филиал МГТУ (пос. Яблоновский)'] as $profile_name => $profile) {
2024-03-27 14:03:46 +03:00
$profile_content = '';
foreach ($profile as $forms => $budget_places) {
$profile_content .= "<strong> {$forms} </strong> - " . "<span style=\'font-family: Geologica-ExtraLight\'> {$budget_places} </span><br>";
}
$tmp = str_replace(' ', '', $profile_name);
$tmp = str_replace(',', '', $tmp);
2024-04-04 14:15:10 +03:00
$filial .= "<div class=\"accordion mb-3 \" id=\"accordionExample\">
2024-04-01 15:57:19 +03:00
<div class=\"accordion-item\" style='border-radius: 20px;'>
<h2 class=\"accordion-header\" style='border-radius: 20px;'>
<button class=\"accordion-button\" type=\"button\" data-bs-toggle=\"collapse\" data-bs-target=\"#collapse-{$tmp}\" aria-expanded=\"true\" aria-controls=\"collapse-{$tmp}\">
$profile_name
</button>
</h2>
<div id=\"collapse-{$tmp}\" class=\"accordion-collapse collapse show\" data-bs-parent=\"#accordionExample\">
<div class=\"accordion-body\">
$profile_content
</div>
</div>
</div>
2024-03-27 13:31:43 +03:00
</div>" ;
}
2024-03-27 14:03:46 +03:00
} else {
$filial = '<div class="w-100 h-100 d-flex justify-content-center align-items-center" >Этой специальности нет в филиалле</div>';
}
$paid_places_content = '';
foreach ($direction['paid_places'] as $institution) {
foreach ($institution as $profile_name => $profile) {
2024-03-27 13:31:43 +03:00
$profile_content = '';
2024-03-27 14:03:46 +03:00
foreach ($profile as $forms => $paid_places) {
$profile_content .= "<strong> {$forms} </strong> - " . "<span style=\'font-family: Geologica-ExtraLight\'> {$paid_places} </span><br>";
}
2024-03-27 13:31:43 +03:00
$tmp = str_replace(' ', '', $profile_name);
$tmp = str_replace(',', '', $tmp);
2024-04-04 14:15:10 +03:00
$paid_places_content .= "<div class=\"accordion mb-3 \" id=\"accordionExample\">
2024-04-01 15:57:19 +03:00
<div class=\"accordion-item\" style='border-radius: 20px;'>
<h2 class=\"accordion-header\" style='border-radius: 20px;'>
<button class=\"accordion-button\" type=\"button\" data-bs-toggle=\"collapse\" data-bs-target=\"#collapse-{$tmp}{$tmp}\" aria-expanded=\"true\" aria-controls=\"collapse-{$tmp}{$tmp}\">
$profile_name
</button>
</h2>
<div id=\"collapse-{$tmp}{$tmp}\" class=\"accordion-collapse collapse show\" data-bs-parent=\"#accordionExample\">
<div class=\"accordion-body\">
$profile_content
</div>
</div>
</div>
2024-03-27 13:31:43 +03:00
</div>" ;
}
}
2024-03-21 16:29:10 +03:00
2024-03-15 16:09:19 +03:00
2024-04-22 16:27:20 +03:00
return "<div class=\"offcanvas offcanvas-bottom visually_impaired_mode direction-card-text fon2_blok\" data-bs-scroll=\"true\" data-bs-backdrop=\"false\" tabindex=\"-1\" id=\"offcanvasScrolling-{$direction['id'] }\" aria-labelledby=\"offcanvasScrollingLabel-{$direction['id']}\" style=\"height: 100%; font-family: Geologica-Medium; overflow-y: auto ; \">
2024-03-14 13:11:18 +03:00
<div class=\"mx-5 pb-5\">
2024-03-21 14:48:08 +03:00
<div class=\"col-12 d-flex justify-content-end mt-4\">
<button type=\"button\" class=\"btn-close text-reset\" data-bs-dismiss=\"offcanvas\" aria-label=\"Close\"></button>
</div>
<div class='row'>
<div class='col-11 d-block'>
<div class='col ms-4'>
<div class=\"display-5 \" style=\"font-family: Geologica-Light\"> {$direction['code']} </div>
<div class=\"display-5 \" > {$direction['name']}</div>
2024-03-21 14:48:08 +03:00
</div>
<div class='col d-flex justify-content-end'>
2024-04-05 16:37:10 +03:00
<div class=\"fs-5 mb-3 d-flex\" style=\"font-family: Geologica-Light\">
<button type='button' class='button_chng_instit hover2 btn btn-outline-success' data-institut='mgtu' data-id='{$direction['id']}'>
2024-04-01 15:57:19 +03:00
<img style='width: 12px; height: auto;' id = 'id_mgtu_{$direction['id']}' src='img/front-page/green-circle.png'>
МГТУ
2024-04-05 16:37:10 +03:00
</button>
2024-04-05 16:37:10 +03:00
<button type='button' class='ms-2 button_chng_instit hover2 btn btn-outline-success' data-institut='filial' data-id='{$direction['id']}'>
2024-04-01 15:57:19 +03:00
<img style='display: none; width: 12px; height: auto;' id = 'id_filial_{$direction['id']}' src='img/front-page/green-circle.png'> Филиал МГТУ (пос. Яблоновский)
</button>
2024-03-21 14:48:08 +03:00
</div>
</div>
</div>
<hr class='col-11 '>
<div class=\"mt-4\">
<p style=\"text-align: justify;\">{$direction['description']}</p>
</div>
2024-03-21 14:48:08 +03:00
</div>
<div class='row'>
<div class='col-12 col-lg-4 h-100 '>
2024-04-05 16:37:10 +03:00
<div class=\"p-3 px-5 border-success fs-5 h-100 \" style='border-radius: 20px; border: 2px solid;'>
2024-03-21 14:48:08 +03:00
<div > Уровень образования:
2024-03-21 16:29:10 +03:00
<strong>{$direction['education_level']} </strong>
2024-03-21 14:48:08 +03:00
</div>
<div > Форма обучения:
2024-03-21 16:29:10 +03:00
<strong> {$education_form} </strong>
2024-03-21 14:48:08 +03:00
</div>
<div > Период обучения (в годах):
2024-03-21 16:29:10 +03:00
$period
2024-03-21 14:48:08 +03:00
</div>
</div>
</div>
<div class='col-12 col-lg-8 col-xl-7 '>
2024-04-05 16:37:10 +03:00
<div class=\"p-3 px-5 border-success fs-5 h-100 mt-xl-0 mt-3\" style='border-radius: 20px; border: 2px solid;'>
<strong class='d-flex justify-content-center fs-3'>Места для обучения:</strong><br>
2024-03-22 16:33:16 +03:00
<div class='content_budget'>
<br>
<div class='row'>
<div class='col'>
<p class='text-center'> Бюджет</p>
<div id='content_budget_filial_{$direction['id']}' style='display: none;' >{$filial}</div>
<div id='content_budget_mgtu_{$direction['id']}' >{$mgtu}</div>
</div>
2024-03-22 16:33:16 +03:00
<div class='col'>
<p class='text-center'> Коммерция</p>
<div> $paid_places_content </div>
</div>
</div>
2024-03-22 16:33:16 +03:00
</div>
2024-03-21 14:48:08 +03:00
</div>
</div>
</div>
<div class='row mt-3'>
<div class='col-12 col-lg-9 '>
2024-04-05 16:37:10 +03:00
<div class=\"p-3 px-5 border-success fs-5 h-100 mt-xl-0 mt-3\" style='border-radius: 20px; border: 2px solid;'>
<strong class='fs-3'> Проходные баллы:</strong>
2024-03-21 16:29:10 +03:00
<div class='row mt-3'>
$EGE $po_viboru $SPO
2024-03-21 16:29:10 +03:00
</div>
2024-03-21 14:48:08 +03:00
</div>
</div>
<div class='col-12 col-lg-3 col-xl-2 '>
2024-04-05 16:37:10 +03:00
<div class=\"p-3 border-success fs-5 h-100 col mt-xl-0 mt-5\" style='border-radius: 20px; border: 2px solid;'>
$paid_cost
2024-03-21 14:48:08 +03:00
</div>
</div>
</div>
</div>
</div>
</div>";
2024-03-12 12:47:12 +03:00
}
// phpcs:enable
2024-03-12 12:47:12 +03:00
}