Roman_applicant-site/app/Services/DirectonHtmlBuilder.php

190 lines
8.3 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
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-03-14 13:11:18 +03:00
$fon_3 = URL::to('img/front-page/bakalavr-special/fon3_blok.png');
2024-03-15 16:09:19 +03:00
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 09:47:12 +03:00
$period .= '<span style="font-family: Geologica-ExtraLight">' . $key . '</span> - ' . '<strong>' . $el .
'</strong><br>' ;
2024-03-15 16:09:19 +03:00
}
2024-03-21 16:29:10 +03:00
$EGE = '<br>';
foreach ($direction['entrance_examinations']['ЕГЭ']['Обязательные'] as $key => $el) {
2024-03-27 09:47:12 +03:00
$EGE .= '<span style="font-family: Geologica-ExtraLight">' . $key . '</span> - ' . '<strong>' . $el .
'</strong><br>' ;
2024-03-15 16:09:19 +03:00
}
2024-03-21 16:29:10 +03:00
//dd($direction);
$po_viboru = '<br>';
2024-03-27 09:47:12 +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 09:47:12 +03:00
$po_viboru .= '<span style="font-family: Geologica-ExtraLight">' . $key . '</span> - ' . '<strong>' .
$el . '</strong><br>' ;
2024-03-21 16:29:10 +03:00
}
}
$SPO = '<br>';
2024-03-27 09:47:12 +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 09:47:12 +03:00
$SPO .= '<span style="font-family: Geologica-ExtraLight">' . $key . '</span> - ' . '<strong>' . $el .
'</strong><br>' ;
2024-03-21 16:29:10 +03:00
}
2024-03-15 16:09:19 +03:00
}
2024-03-27 09:47:12 +03:00
// phpcs:disable
2024-03-21 16:29:10 +03:00
2024-03-22 16:33:16 +03:00
$mgtu = '';
2024-03-27 09:47:12 +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 09:47:12 +03:00
$profile_content = '';
foreach ($profile as $forms => $budget_places) {
2024-03-22 16:33:16 +03:00
$profile_content .= "<strong> {$forms} </strong> - " . "<span style='font-family: Geologica-ExtraLight'> {$budget_places} </span><br>";
}
$mgtu .= "<div class=\"accordion\" id=\"accordionExample\">
<div class=\"accordion-item\">
<h2 class=\"accordion-header\">
<button class=\"accordion-button\" type=\"button\" data-bs-toggle=\"collapse\" data-bs-target=\"#collapseOne\" aria-expanded=\"true\" aria-controls=\"collapseOne\">
$profile_name
</button>
</h2>
<div id=\"collapseOne\" class=\"accordion-collapse collapse show\" data-bs-parent=\"#accordionExample\">
<div class=\"accordion-body\">
$profile_content
</div>
</div>
</div>
</div>" ;
}
}
2024-03-21 16:29:10 +03:00
2024-03-22 16:33:16 +03:00
$filial = '222';
2024-03-21 16:29:10 +03:00
2024-03-15 16:09:19 +03:00
2024-03-15 10:38:26 +03:00
return "<div class=\"offcanvas offcanvas-bottom\" 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 ; background-image: url({$fon_3}); color: #004329\">
2024-03-14 13:11:18 +03:00
2024-03-21 14:48:08 +03:00
<div class=\"mx-5 \">
<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'>
<div class=\"display-6 \" style=\"font-family: Geologica-Light\"> {$direction['code']} </div>
<div class=\"display-6 \" > {$direction['name']}</div>
</div>
<div class='col d-flex justify-content-end'>
<div class=\"fs-5 \" style=\"font-family: Geologica-Light\">
2024-03-22 16:33:16 +03:00
<a href='#' role='button' class='button-mgtu'> МГТУ </a> |
<a href='#' role='button' class='button-filial' > Филиал МГТУ (пос. Яблоновский)</a>
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>
</div>
<div class='row'>
<div class='col-11 d-flex justify-content-end'> <a href='#' role='button'> Бюджет </a> | <a href='#' role='button' > Коммерция</a> </div>
<div class=' col-4 '>
<div class=\"p-3 px-5 border-success fs-5\" style='border-radius: 20px; border: 2px solid;'>
<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-7 '>
<div class=\"p-3 px-5 border-success fs-5 h-100\" style='border-radius: 20px; border: 2px solid;'>
2024-03-22 16:33:16 +03:00
<script>
$(\".button-mgtu\").click(function () {
$(\".content_budget\").html('{$mgtu}');
});
$(\".button-filial\").click(function () {
$(\".content_budget\").html('{$filial}');
});
</script>
<style>
</style>
<strong>Места для обучения:</strong><br>
<div class='content_budget'>
</div>
2024-03-21 14:48:08 +03:00
</div>
</div>
</div>
<div class='row mt-3'>
<div class=' col-9 '>
<div class=\"p-3 px-5 border-success fs-5 h-100\" style='border-radius: 20px; border: 2px solid;'>
2024-03-21 16:29:10 +03:00
<strong> Проходные баллы:</strong>
<div class='row mt-3'>
<div class='col '>
<strong> ЕГЭ </strong>
$EGE
</div>
<div class='col '>
<strong> Предметы по выбору </strong>
$po_viboru
</div>
<div class='col '>
<strong> СПО </strong>
$SPO
</div>
</div>
2024-03-21 14:48:08 +03:00
</div>
</div>
<div class=' col-2 '>
<div class=\"p-3 px-5 border-success fs-5 h-100\" style='border-radius: 20px; border: 2px solid;'>
</div>
</div>
</div>
</div>
</div>
</div>";
2024-03-12 12:47:12 +03:00
}
// phpcs:enable
2024-03-12 12:47:12 +03:00
}