Compare commits

..

No commits in common. "8e8b16d5400691cd088683a26329a2a5bff7ee67" and "c91ae889a3253626e92e69a4681ff2903eeb57bf" have entirely different histories.

8 changed files with 14 additions and 224 deletions

View File

@ -1,98 +0,0 @@
<?php
namespace App\Exports;
use App\Models\Direction;
use Maatwebsite\Excel\Concerns\FromQuery;
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
use Maatwebsite\Excel\Concerns\WithHeadings;
use Maatwebsite\Excel\Concerns\WithMapping;
class DirectionsExport implements WithMapping, FromQuery, WithHeadings, ShouldAutoSize
{
public function query()
{
return Direction::query();
}
public function headings(): array
{
return [
'Код',
'Имя',
'Кафедры',
'Ур-нь обр.',
'Форма обр.',
'бюджетные места',
'квота',
'платн. места',
'ст-ть платн. мест',
'период',
'Профиль подготовки',
'вступительные испытания ЕГЕ (Обязательное)',
'вступительные испытания ЕГЕ (По выбору)',
'вступительные испытания СПО',
'вступительные испытания Магистратура'
];
}
public function map($row): array
{
return [
[
$row->code,
$row->name,
$row->department->name,
$row->educationLevel->name,
$row->educationForm->name,
$row->budget_places,
$row->quota,
$row->paid_places,
$row->cost_paid_place,
$row->period,
implode("; ", $row->directionProfiles),
implode("; ", $row->egeCompulsory),
implode("; ", $row->egeOptional),
implode("; ", $row->spo),
implode("; ", $row->magistracy),
]
// $row->entranceExaminations->name,
];
}
public function prepareRows($rows)
{
return $rows->transform(function ($direction) {
$profilesNames = [];
foreach ($direction->directionProfiles as $profile) {
$profilesNames[] = $profile->name;
}
$direction->directionProfiles = $profilesNames;
$egeCompulsory = [];
$egeOptional = [];
$spo = [];
$magistracy = [];
foreach ($direction->entranceExaminations as $examination) {
$subject = $examination->subject->name;
$scores = $examination->scores;
if ($examination->examinationType->name === 'ЕГЭ') {
if ($examination->subjectType->name === 'Обязательные') {
$egeCompulsory[] = "{$subject} ({$scores})";
} elseif ($examination->subjectType->name === 'Предметы по выбору') {
$egeOptional[] = "{$subject} ({$scores})";
}
} elseif ($examination->examinationType->name === 'СПО') {
$spo[] = "{$subject} ({$scores})";
} elseif ($examination->examinationType->name === 'магитсратура') {
$magistracy[] = "{$subject} ({$scores})";
}
}
$direction->egeCompulsory = $egeCompulsory;
$direction->egeOptional = $egeOptional;
$direction->spo = $spo;
$direction->magistracy = $magistracy;
return $direction;
});
}
}

View File

@ -3,7 +3,6 @@
namespace App\Http\Controllers\admin\Catalog; namespace App\Http\Controllers\admin\Catalog;
use App\Enums\ExaminationTypeEnum; use App\Enums\ExaminationTypeEnum;
use App\Exports\DirectionsExport;
use App\Helpers\SlugHelper; use App\Helpers\SlugHelper;
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;
use App\Http\Requests\admin\Catalog\StoreDirectionRequest; use App\Http\Requests\admin\Catalog\StoreDirectionRequest;
@ -24,7 +23,6 @@ use Illuminate\Foundation\Application;
use Illuminate\Http\RedirectResponse; use Illuminate\Http\RedirectResponse;
use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Log;
use Maatwebsite\Excel\Facades\Excel;
class DirectionController extends Controller class DirectionController extends Controller
{ {
@ -305,9 +303,4 @@ class DirectionController extends Controller
return redirect()->route('directions.index'); return redirect()->route('directions.index');
} }
public function exportXls()
{
return Excel::download(new DirectionsExport(), 'directions.xlsx');
}
} }

View File

@ -20,11 +20,6 @@ class Direction extends Model
'position', 'position',
'slug', 'slug',
'code', 'code',
'budget_places',
'quota',
'paid_places',
'cost_paid_place',
'period',
]; ];
public function department(): BelongsTo public function department(): BelongsTo

View File

@ -9,87 +9,17 @@ use PhpParser\Node\Expr\Array_;
class DirectonHtmlBuilder class DirectonHtmlBuilder
{ {
private array $direction; private array $direction;
public function __construct($direction) public function __construct($direction)
{ {
$this->direction = $direction; $this->direction = $direction;
} }
public function getHTML() public function getHTML()
{ {
$direction = $this->direction; $direction = $this->direction;
$fon_3 = URL::to('img/front-page/bakalavr-special/fon3_blok.png'); $fon_3 = URL::to('img/front-page/bakalavr-special/fon3_blok.png');
$educationForm = implode(", ", $direction['educationForm']);
$educationForms = '';
foreach ($direction['educationForms'] as $key => $educationForm) {
$educationForms .= $key . ', ';
}
$educationForms = substr($educationForms, 0, -2);
$budget_places_array = array();
foreach ($direction['educationForms'] as $key => $educationForm){
$budget_places_array[$key] = $educationForm['budget_places'];
}
$budget_places = '<br>';
foreach ($budget_places_array as $key => $item){
$budget_places .= "<span style='font-family: Geologica-ExtraLight'>$key</span> - <strong> $item </strong><br>";
}
$period_array = array();
foreach ($direction['educationForms'] as $key => $period) {
$period_array[$key] = $period['period'];
}
$period = '<br>';
foreach ($period_array as $key => $item) {
$period .= "<span style='font-family: Geologica-ExtraLight'>$key</span> - <strong> $item </strong><br>";
}
$profiles = '';
//if (array_key_exists('educationalInstitution',$direction)) echo '+++++'; else echo '----';
//exit();
if (array_key_exists('educationalInstitution',$direction)) {
foreach ($direction['educationalInstitution'] as $educationalInstitution_name => $educationalInstitution) {
$profile_out = '<br>';
$profiles .= "<p> {$educationalInstitution_name}</p>";
foreach ($educationalInstitution as $profile_name => $profile) {
foreach ($profile as $key => $value) {
$profile_out .= "<span style='font-family: Geologica-ExtraLight'>{$key}</span> - <strong> {$value['budget_places']} </strong><br>";
}
$tmp = str_replace(' ', '', $profile_name);
$profiles .= "
<div class=\"accordion \" id=\"accordionPanelsStayOpenExample\">
<div class=\"accordion-item\">
<h2 class=\"accordion-header\">
<button class=\"accordion-button\" type=\"button\" data-bs-toggle=\"collapse\" data-bs-target=\"#panelsStayOpen-{$tmp}\" aria-expanded=\"true\" aria-controls=\"panelsStayOpen-{$tmp}\">
{$profile_name}
</button>
</h2>
<div id=\"panelsStayOpen-{$tmp}\" class=\"accordion-collapse collapse show\">
<div class=\"accordion-body\">
$profile_out
</div>
</div>
</div>
</div>
";
}
};
}
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\"> 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\">
@ -109,13 +39,8 @@ class DirectonHtmlBuilder
</div> </div>
<div class=\"mt-4\"> <div class=\"mt-4\">
<p style=\"text-align: justify;\">{$direction['description']}</p> <p style=\"text-align: justify;\">{$direction['description']}</p>
<div class='row'> <p class='fs-5'> Бюджетные места: </p> {$profiles} </div>
</div> </div>
</div> </div>
@ -127,12 +52,12 @@ class DirectonHtmlBuilder
</div> </div>
<hr class='d-block d-md-none'><br> <hr class='d-block d-md-none'><br>
<div > Форма обучения: <div > Форма обучения:
<strong> $educationForms <strong> {$educationForm}
</strong> </strong>
</div> </div>
<hr class='d-block d-md-none'><br> <hr class='d-block d-md-none'><br>
<div > Бюджетные места: <div > Бюджетные места:
{$budget_places} <strong >{$direction['budget_places']} </strong>
</div> </div>
<hr class='d-block d-md-none'><br> <hr class='d-block d-md-none'><br>
<div > Квота: <div > Квота:
@ -144,11 +69,11 @@ class DirectonHtmlBuilder
</div> </div>
<hr class='d-block d-md-none'><br> <hr class='d-block d-md-none'><br>
<div > Стоимость платного обучения: <div > Стоимость платного обучения:
<strong >{$direction['cost_paid_place']} </strong>
</div> </div>
<hr class='d-block d-md-none'><br> <hr class='d-block d-md-none'><br>
<div > Период обучения (в годах): <div > Период обучения (в годах):
{$period} <strong>{$direction['period']} </span>
</div> </div>
</div> </div>
</div> </div>

View File

@ -3,10 +3,7 @@
<div class="container"> <div class="container">
<h2>Направления</h2> <h2>Направления</h2>
<br> <br>
<div class="d-grid gap-2 d-md-flex justify-content-between">
<a href="{{ route('directions.create') }}" class="btn btn-primary">Создать Направление</a> <a href="{{ route('directions.create') }}" class="btn btn-primary">Создать Направление</a>
<a href="{{ route('export_excel') }}" class="btn btn-info">Импорт xls</a>
</div>
<br> <br>
<br> <br>
<table class="table"> <table class="table">
@ -31,7 +28,7 @@
<br> <br>
<p @style(['font-size: 0.7em', 'color: grey'])> <p @style(['font-size: 0.7em', 'color: grey'])>
@foreach($direction->directionProfiles as $directionProfile) @foreach($direction->directionProfiles as $directionProfile)
{{ $directionProfile->name }} <br> {{ $directionProfile->name }}
@endforeach @endforeach
</p> </p>
</td> </td>

View File

@ -362,20 +362,7 @@
@php @php
$napr = array(); $napr = array();
foreach ($department->directions as $direction){ foreach ($department->directions as $direction){
$napr[$direction->name]['educationForm'][$direction->name . ' ' . $direction->id] = $direction->educationForm->name;
$napr[$direction->name]['educationForms'][$direction->educationForm->name]['budget_places'] = $direction->budget_places;
foreach($direction->directionProfiles as $profile) {$napr[$direction->name]['educationalInstitution'][$faculty->educationalInstitution->name][$profile->name][$direction->educationForm->name]['budget_places'] = $direction->budget_places;
}
$napr[$direction->name]['educationForms'][$direction->educationForm->name]['period'] = $direction->period;
$napr[$direction->name]['id'] = $direction->id; $napr[$direction->name]['id'] = $direction->id;
$napr[$direction->name]['code'] = $direction->code; $napr[$direction->name]['code'] = $direction->code;
$napr[$direction->name]['educationLevel'] = $direction->educationLevel->name; $napr[$direction->name]['educationLevel'] = $direction->educationLevel->name;
@ -391,13 +378,12 @@
@endphp @endphp
{{-- @dd($napr)--}}
@foreach($napr as $el) @foreach($napr as $el)
<tr> <tr>
<td> <td>
<a class=" border border-dark rounded-3 p-2 hover1" type="button" data-bs-toggle="offcanvas" data-bs-target="#offcanvasScrolling-{{ $el['id'] }}" aria-controls="offcanvasScrolling" role="button">{{ $el['name'] }}</a> <a class=" border border-dark rounded-3 p-2 hover1" type="button" data-bs-toggle="offcanvas" data-bs-target="#offcanvasScrolling-{{ $el['id'] }}" aria-controls="offcanvasScrolling" role="button">{{ $el['name'] }}</a>
{{-- @dd($el)--}}
@php @php
$DirectonHtmlBuilder = new DirectonHtmlBuilder($el); $DirectonHtmlBuilder = new DirectonHtmlBuilder($el);
echo $DirectonHtmlBuilder->getHTML(); echo $DirectonHtmlBuilder->getHTML();
@ -406,15 +392,7 @@
<td> {{ $el['code'] }} </td> <td> {{ $el['code'] }} </td>
<td> {{ $el['educationLevel'] }} </td> <td> {{ $el['educationLevel'] }} </td>
@php <td> <?php foreach($el['educationForm'] as $form) { echo $form . '<br>'; } ?> </td>
$educationForms = '';
foreach ($el['educationForms'] as $key => $educationForm) {
$educationForms .= $key . ', ';
}
$educationForms = substr($educationForms, 0, -2);
@endphp
<td> {{$educationForms}} </td>
</tr> </tr>
@endforeach @endforeach
@endforeach @endforeach

View File

@ -18,7 +18,7 @@ use Rap2hpoutre\LaravelLogViewer\LogViewerController;
Route::middleware(['auth', 'verified'])->prefix('admin')->group(function () { Route::middleware(['auth', 'verified'])->prefix('admin')->group(function () {
Route::get('/logs', [LogViewerController::class, 'index']); Route::get('/logs', [LogViewerController::class, 'index']);
Route::get('/export_excel', [DirectionController::class, 'exportXls'])->name('export_excel'); Route::get('/exportExcel', [LogViewerController::class, 'index']);
Route::get('/dashboard', function () { Route::get('/dashboard', function () {
return view('admin'); return view('admin');