Skip to content

Commit

Permalink
Merge branch 'main' into portabilis-patch-2024-11-25
Browse files Browse the repository at this point in the history
  • Loading branch information
edineivaldameri committed Nov 25, 2024
2 parents 70850d7 + a92d953 commit 076675f
Show file tree
Hide file tree
Showing 54 changed files with 1,339 additions and 734 deletions.
20 changes: 20 additions & 0 deletions app/Events/EmployeeCreated.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

namespace App\Events;

use App\Models\Employee;
use App\Models\LegacyRegistration;
use Illuminate\Broadcasting\InteractsWithSockets;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Queue\SerializesModels;

class EmployeeCreated
{
use Dispatchable;
use InteractsWithSockets;
use SerializesModels;

public function __construct(
public Employee $employee,
) {}
}
19 changes: 19 additions & 0 deletions app/Events/StudentCreated.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

namespace App\Events;

use App\Models\LegacyStudent;
use Illuminate\Broadcasting\InteractsWithSockets;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Queue\SerializesModels;

class StudentCreated
{
use Dispatchable;
use InteractsWithSockets;
use SerializesModels;

public function __construct(
public LegacyStudent $student,
) {}
}
59 changes: 59 additions & 0 deletions app/Http/Controllers/BlockEnrollmentController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<?php

namespace App\Http\Controllers;

use App\Http\Requests\BlockEnrollmentRequest;
use App\Models\LegacySchoolGrade;
use App\Process;
use iEducar\Support\Exceptions\Exception;
use Illuminate\Support\Facades\DB;

class BlockEnrollmentController extends Controller
{
public function update(BlockEnrollmentRequest $request)
{
$query = LegacySchoolGrade::query()
->whereHas('school', fn ($q) => $q->whereInstitution($request->get('ref_cod_instituicao')))
->when($request->get('ref_cod_escola'), fn ($q, $school) => $q->where('ref_cod_escola', $school))
->when($request->get('ref_cod_curso'), function ($q, $course) {
$q->whereHas('grade', fn ($q) => $q->whereCourse($course));
})
->whereRaw("anos_letivos @> ?", ["{" . $request->get('ano') . "}"])
->where('ativo', 1);

$gradesCount = $query->count();

if ($gradesCount === 0) {
return redirect()->route('block-enrollment.edit')->withInput()->with('error', 'Nenhuma série da escola encontrada com os filtros selecionados');
}

if (empty($request->get('confirmation'))) {
return redirect()->route('block-enrollment.edit')->withInput()->with('show-confirmation', $gradesCount);
}

try {
DB::beginTransaction();
$query->update([
'bloquear_enturmacao_sem_vagas' => $request->get('bloquear_enturmacao_sem_vagas'),
'updated_at' => now()
]);
DB::commit();
session()->flash('success', 'Atualização em lote efetuada com sucesso.');
} catch (Exception) {
DB::rollBack();
session()->flash('error', 'Atualização em lote não realizada.');
}

return redirect()->route('block-enrollment.edit');
}

public function edit()
{
$this->menu(Process::BLOCK_ENROLLMENT);
$this->breadcrumb('Bloquear enturmação em lote', [
url('/intranet/educar_configuracoes_index.php') => 'Configurações',
]);

return view('block-enrollment.edit', ['user' => request()->user()]);
}
}
24 changes: 24 additions & 0 deletions app/Http/Requests/BlockEnrollmentRequest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php

namespace App\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;

class BlockEnrollmentRequest extends FormRequest
{
protected function prepareForValidation()
{
$this->merge([
'bloquear_enturmacao_sem_vagas' => $this->has('bloquear_enturmacao_sem_vagas') ? 1 : 0,
]);
}

public function rules()
{
return [
'ano' => ['required','integer'],
'ref_cod_instituicao' => ['required','integer'],
'bloquear_enturmacao_sem_vagas' => ['required','in:0,1'],
];
}
}
1 change: 1 addition & 0 deletions app/Models/Exporter/Teacher.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ public function getExportedColumnsByGroup()
'high_school_type' => 'Tipo de ensino médio cursado',
'employee_postgraduates_complete' => 'Pós-Graduações concluídas',
'continuing_education_course' => 'Outros cursos de formação continuada',
'complementacao_pedagogica' => 'Formação/Complementação pedagógica',
'employee_graduation_complete' => 'Curso(s) superior(es) concluído(s)',
'allocations.funcao_exercida' => 'Função exercida',
'allocations.tipo_vinculo' => 'Tipo de vínculo',
Expand Down
5 changes: 5 additions & 0 deletions app/Models/LegacyEvaluationRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,11 @@ public function isSpecificRetake(): bool
return $this->tipo_recuperacao_paralela == self::PARALLEL_REMEDIAL_PER_SPECIFIC_STAGE;
}

public function isByStage(): bool
{
return $this->tipo_recuperacao_paralela == self::PARALLEL_REMEDIAL_PER_STAGE;
}

public function isSumScoreCalculation(): bool
{
return $this->tipo_recuperacao_paralela == self::PARALLEL_REMEDIAL_PER_STAGE
Expand Down
5 changes: 5 additions & 0 deletions app/Models/LegacySchoolGrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,9 @@ public function grade(): BelongsTo
{
return $this->belongsTo(LegacyGrade::class, 'ref_cod_serie');
}

public function school(): BelongsTo
{
return $this->belongsTo(LegacySchool::class, 'ref_cod_escola');
}
}
2 changes: 2 additions & 0 deletions app/Process.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,4 +77,6 @@ class Process
public const ACTIVE_LOOKING = 9998921;

public const ANNOUNCEMENT = 9999114;

public const BLOCK_ENROLLMENT = 9999115;
}
9 changes: 7 additions & 2 deletions app/Rules/IncompatibleDescriptiveOpinion.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,18 @@ public function passes($attribute, $value)
$schoolClass = $value[0]['turma_id'];
$schoolClass = LegacySchoolClass::find($schoolClass);
$grades = array_column($value, 'serie_id');
$utilizaRegraDiferenciada = $schoolClass->school->utiliza_regra_diferenciada;

$descriptiveOpinionType = LegacyEvaluationRuleGradeYear::query()
->whereIn('serie_id', $grades)
->where('ano_letivo', $schoolClass->ano)
->with('evaluationRule')
->with(['evaluationRule', 'differentiatedEvaluationRule'])
->get()
->map(function ($model) {
->map(function ($model) use ($utilizaRegraDiferenciada) {
if ($utilizaRegraDiferenciada && $model->differentiatedEvaluationRule) {
return $model->differentiatedEvaluationRule->parecer_descritivo;
}

return $model->evaluationRule->parecer_descritivo;
})
->toArray();
Expand Down
56 changes: 36 additions & 20 deletions app/Services/RegistrationService.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,14 @@

use App\Models\LegacyEnrollment;
use App\Models\LegacyRegistration;
use App\Models\LegacyRegistrationScore;
use App\Models\LegacySchoolClass;
use App\Models\LegacySchoolClassGrade;
use App\Models\LegacyTransferRequest;
use App\User;
use App_Model_MatriculaSituacao;
use Avaliacao_Model_NotaAlunoDataMapper;
use Avaliacao_Model_NotaComponenteMediaDataMapper;
use DateTime;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Collection;
Expand Down Expand Up @@ -95,29 +98,42 @@ private function checkUpdatedStatusAction($data, LegacyRegistration $registratio
{
$newStatus = $data['nova_situacao'];

if ($newStatus == App_Model_MatriculaSituacao::TRANSFERIDO) {
$this->markEnrollmentsAsTransferred($registration);
$this->createTransferRequest(
$data['transferencia_data'],
$data['transferencia_tipo'],
$data['transferencia_observacoes'],
$registration
);

$registration->data_cancel = DateTime::createFromFormat('d/m/Y', $data['transferencia_data']);
$registration->saveOrFail();
}

if ($newStatus == App_Model_MatriculaSituacao::RECLASSIFICADO) {
$this->markEnrollmentsAsReclassified($registration);
switch ($newStatus) {
case App_Model_MatriculaSituacao::TRANSFERIDO:
$this->markEnrollmentsAsTransferred($registration);
$this->createTransferRequest(
$data['transferencia_data'],
$data['transferencia_tipo'],
$data['transferencia_observacoes'],
$registration
);
$registration->data_cancel = DateTime::createFromFormat('d/m/Y', $data['transferencia_data']);
$registration->saveOrFail();
$this->processDisciplineScoreSituation($registration, $newStatus);
break;

case App_Model_MatriculaSituacao::RECLASSIFICADO:
$this->markEnrollmentsAsReclassified($registration);
break;

case App_Model_MatriculaSituacao::ABANDONO:
$this->markEnrollmentsAsAbandoned($registration);
$this->processDisciplineScoreSituation($registration, $newStatus);
break;

case App_Model_MatriculaSituacao::FALECIDO:
$this->markEnrollmentsAsDeceased($registration);
$this->processDisciplineScoreSituation($registration, $newStatus);
break;
}
}

if ($newStatus == App_Model_MatriculaSituacao::ABANDONO) {
$this->markEnrollmentsAsAbandoned($registration);
}
private function processDisciplineScoreSituation(LegacyRegistration $registration, $newStatus)
{
$registrationScoreId = $registration->registrationStores()->value('id');

if ($newStatus == App_Model_MatriculaSituacao::FALECIDO) {
$this->markEnrollmentsAsDeceased($registration);
if ($registrationScoreId) {
(new Avaliacao_Model_NotaComponenteMediaDataMapper())->updateSituation($registrationScoreId, $newStatus);
}
}

Expand Down
2 changes: 1 addition & 1 deletion app/Services/SchoolClass/AvailableTimeService.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function isAvailable(int $studentId, int $schoolClassId, ?int $turnoId =
{
$schoolClass = LegacySchoolClass::findOrFail($schoolClassId);

if ($schoolClass->tipo_mediacao_didatico_pedagogico != 1) {
if ($schoolClass->tipo_mediacao_didatico_pedagogico != 1 || ($this->onlySchoolClassesInformedOnCensus && $schoolClass->nao_informar_educacenso == 1)) {
return true;
}

Expand Down
2 changes: 1 addition & 1 deletion app/Support/Database/Connections.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ public function getConnections()
{
$connections = config('database.connections');

return array_diff(array_keys($connections), ['sqlite', 'mysql', 'pgsql', 'sqlsrv', 'bussolastaging', 'mariadb']);
return array_diff(array_keys($connections), ['sqlite', 'mysql', 'pgsql', 'sqlsrv', 'bussolastaging', 'mariadb', 'audit']);
}
}
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"aws/aws-sdk-php-laravel": "^3.7",
"composer/semver": "^3.2",
"dex/composer-plug-and-play": "^0.20",
"dex/frontier": "^0.12.0",
"dex/frontier": "^0.14.0",
"google/recaptcha": "^1.2",
"guzzlehttp/guzzle": "^7.3",
"honeybadger-io/honeybadger-laravel": "^4.0",
Expand Down
Loading

0 comments on commit 076675f

Please sign in to comment.