Skip to content

Commit

Permalink
Merge pull request #926 from portabilis/portabilis-patch-2023-11-23
Browse files Browse the repository at this point in the history
Portabilis patch 23/11/2023
  • Loading branch information
edersoares authored Nov 23, 2023
2 parents 5c847e5 + 9ff4d9b commit 7918ee8
Show file tree
Hide file tree
Showing 209 changed files with 2,885 additions and 1,651 deletions.
3 changes: 3 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ REDIS_HOST=localhost
REDIS_PASSWORD=null
REDIS_PORT=6379

SENTINEL_HOSTS=localhost
SENTINEL_PORT=26379

MAIL_MAILER=smtp
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525
Expand Down
2 changes: 0 additions & 2 deletions app/Console/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ protected function schedule(Schedule $schedule)
{
$schedule->job(new TenantsJob(CheckInstitutionConfigurationsJob::class))->cron('0 8 1 1 *');

$schedule->command('horizon:snapshot')->everyFiveMinutes();

$schedule->command('notifications:delete')->saturdays()->dailyAt('04:00');
}

Expand Down
21 changes: 13 additions & 8 deletions app/Events/ReportIssued.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,25 @@

namespace App\Events;

use Illuminate\Broadcasting\InteractsWithSockets;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Queue\SerializesModels;

class ReportIssued
{
use Dispatchable;
use InteractsWithSockets;
use SerializesModels;
private string $content;

public function __construct(
public string $render,
public string $template,
public bool $success
public bool $success,
public bool $authenticate = false,
) {
}

public function replace(string $content): void
{
$this->content = $content;
}

public function content(): string
{
return $this->content;
}
}
1 change: 1 addition & 0 deletions app/Http/Controllers/AccessLevelController.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ private function store(Request $request, LegacyUserType $userType)
'descricao' => $request->input('description'),
'ref_funcionario_cad' => $request->user()->getKey(),
'data_cadastro' => now(),
'updated_at' => now(),
]);

$processes = collect($request->input('processes'))->mapWithKeys(function ($level, $process) {
Expand Down
30 changes: 30 additions & 0 deletions app/Http/Controllers/Api/PeriodController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

namespace App\Http\Controllers\Api;

use App\Http\Controllers\ResourceController;
use App\Models\LegacySchoolClass;
use iEducar\Modules\Educacenso\Model\ModalidadeCurso;
use iEducar\Modules\SchoolClass\Period;
use Illuminate\Http\Request;

class PeriodController extends ResourceController
{
public function index(Request $request): array
{
$periods = collect((new Period)->getDescriptiveValues())->except(Period::FULLTIME);
if (is_numeric($schoolClass = $request->get('schoolclass'))) {
$schoolClass = LegacySchoolClass::query()->with('course:cod_curso,modalidade_curso')->find($schoolClass, [
'cod_turma',
'ref_cod_curso',
]);
if (!$schoolClass || $schoolClass->course->modalidade_curso !== ModalidadeCurso::EJA) {
$periods->forget(Period::NIGTH);
}
}

return [
'data' => $periods,
];
}
}
1 change: 0 additions & 1 deletion app/Http/Controllers/EducacensoController.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ class EducacensoController extends Controller
{
/**
* @param array $records
* @param null $paginate
* @return View
*/
private function view(LegacyInstitution $institution, $records = [], $paginate = null)
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/LegacyController.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ private function loadLegacyFile($filename)
{
$legacyFile = static::resolve($filename, $this->getLegacyPath() . '/' . $filename);

if (false === file_exists($legacyFile)) {
if (file_exists($legacyFile) === false) {
throw new NotFoundHttpException('Legacy file not found.');
}

Expand Down
2 changes: 1 addition & 1 deletion app/Imports/DisciplineAcademicImport.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
use Maatwebsite\Excel\Concerns\WithHeadingRow;
use Maatwebsite\Excel\Concerns\WithProgressBar;

class DisciplineAcademicImport implements ToModel, WithProgressBar, WithHeadingRow
class DisciplineAcademicImport implements ToModel, WithHeadingRow, WithProgressBar
{
use Importable;

Expand Down
2 changes: 1 addition & 1 deletion app/Imports/SchoolGradeDisciplineImport.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
use Maatwebsite\Excel\Concerns\WithHeadingRow;
use Maatwebsite\Excel\Concerns\WithProgressBar;

class SchoolGradeDisciplineImport implements ToModel, WithProgressBar, WithHeadingRow
class SchoolGradeDisciplineImport implements ToModel, WithHeadingRow, WithProgressBar
{
use Importable;

Expand Down
2 changes: 1 addition & 1 deletion app/Imports/SchoolGradeImport.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
use Maatwebsite\Excel\Concerns\WithHeadingRow;
use Maatwebsite\Excel\Concerns\WithProgressBar;

class SchoolGradeImport implements ToModel, WithProgressBar, WithHeadingRow
class SchoolGradeImport implements ToModel, WithHeadingRow, WithProgressBar
{
use Importable;

Expand Down
2 changes: 1 addition & 1 deletion app/Jobs/BatchDisableUsersWithDaysGoneSinceLastAccess.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
use Illuminate\Queue\SerializesModels;
use Illuminate\Support\Facades\DB;

class BatchDisableUsersWithDaysGoneSinceLastAccess implements ShouldQueue, ShouldBeUniqueUntilProcessing
class BatchDisableUsersWithDaysGoneSinceLastAccess implements ShouldBeUniqueUntilProcessing, ShouldQueue
{
use Dispatchable;
use InteractsWithQueue;
Expand Down
2 changes: 1 addition & 1 deletion app/Jobs/TenantsJob.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@

class TenantsJob implements ShouldQueue
{
use Connections;
use Dispatchable;
use InteractsWithQueue;
use Queueable;
use SerializesModels;
use Connections;

/**
* @var int
Expand Down
1 change: 1 addition & 0 deletions app/Listeners/ReportIssuedListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public function handle(ReportIssued $event): void
'template' => $event->template,
'success' => $event->success,
'date' => now(),
'authenticated' => $event->authenticate,
]);
}
}
1 change: 1 addition & 0 deletions app/Models/Builders/LegacyCourseBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public function getResource(array $filters = []): Collection
{
//filtros
$this->active()->orderByName()->filter($filters);

//description será usada em getNameAttribute, mas não aparece no recurso
return $this->setExcept(['description'])->resource(['id', 'name', 'is_standard_calendar', 'steps']);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ public function getResource(array $filters = []): Collection
{
//filtros
$this->distinctDiscipline()->with('discipline:id,nome')->filter($filters);

//name é uma parametro adicional, que não está na query, mas é passado para o recurso sendo aplicado em getNameAttribute
return $this->resource(['id', 'workload'], ['name']);
}
Expand Down
36 changes: 34 additions & 2 deletions app/Models/Builders/LegacyEnrollmentBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ public function active(): self
/**
* Filtra por ativo por situação
*/
public function activeBySituation(int $situation): self
public function activeBySituation(?int $situation): self
{
if (!in_array($situation, RegistrationStatus::getStatusInactive(), true)) {
if ($situation && !in_array($situation, RegistrationStatus::getStatusInactive(), true)) {
$this->active();
}

Expand All @@ -45,7 +45,39 @@ public function whereValid(): self
$q->orWhere('remanejado', true);
$q->orWhere('reclassificado', true);
$q->orWhere('abandono', true);
$q->orWhere('falecido', true);
$q->orWhereHas('registration', fn ($q) => $q->where('dependencia', true));
});
}

/**
* Filtra por Turma
*/
public function whereSchoolClass(int $schoolClass): self
{
return $this->where('ref_cod_turma', $schoolClass);
}

public function addJoinViewSituacaoRelatorios(int $situation): self
{
return $this->join('relatorio.view_situacao_relatorios', function ($join) use ($situation) {
$join->on('view_situacao_relatorios.cod_matricula', 'ref_cod_matricula');
$join->on('view_situacao_relatorios.cod_turma', 'ref_cod_turma');
$join->on('view_situacao_relatorios.sequencial', 'matricula_turma.sequencial');
$join->where('view_situacao_relatorios.cod_situacao', $situation);
})->addSelect([
'view_situacao_relatorios.texto_situacao',
]);
}

public function wherePeriod(int $period): self
{
return $this->where(function ($q) use ($period) {
$q->where('turno_id', $period);
$q->orWhere(function ($q) use ($period) {
$q->whereNull('turno_id');
$q->whereHas('schoolClass', fn ($q) => $q->where('turma_turno_id', $period));
});
});
}
}
1 change: 1 addition & 0 deletions app/Models/Builders/LegacyGradeBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class LegacyGradeBuilder extends LegacyBuilder
public function getResource(array $filters = []): Collection
{
$this->active()->orderByNameAndCourse()->filter($filters);

//description será usada em getNameAttribute, mas não aparece no recurso
return $this->setExcept(['description'])->resource(['id', 'name']);
}
Expand Down
76 changes: 76 additions & 0 deletions app/Models/Builders/LegacyRegistrationBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,14 @@ public function whereGrade(int $grade): self
return $this->where('ref_ref_cod_serie', $grade);
}

/**
* Filtra por Aluno
*/
public function whereStudent(int $student): self
{
return $this->where('ref_cod_aluno', $student);
}

/**
* Filtra por Tipos de Deficiência
*/
Expand Down Expand Up @@ -176,4 +184,72 @@ public function joinPerson(): self

return $this;
}

/**
* Não considera alunos reclassificados
*/
public function notReclassified(): self
{
return $this->where('aprovado', '<>', RegistrationStatus::RECLASSIFIED);
}

public function allRelationsActive(): self
{
$this->active();
$this->whereHas('student', fn ($q) => $q->active());
$this->whereHas('school', fn ($q) => $q->active());
$this->whereHas('course', fn ($q) => $q->active());
$this->whereHas('grade', fn ($q) => $q->active());
$this->whereHas('schoolClass', fn ($q) => $q->active());

return $this;
}

/**
* Filtra por data inicial
*
* @return $this
*/
public function whereStartAfter(string $start): self
{
return $this->whereDate('data_matricula', '>=', $start);
}

/**
* Filtra por data final
*
* @return $this
*/
public function whereEndBefore(string $end): self
{
return $this->whereDate('data_matricula', '<=', $end);
}

public function whereDependency(int $dependency): self
{
if ($dependency === 1) {
return $this->where('dependencia', true);
}
if ($dependency === 2) {
return $this->where('dependencia', false);
}

return $this;
}

/**
* Filtra por zona de localização
*/
public function whereLocalizationZone(int $localizationZone): self
{
return $this->whereHas('school', fn ($q) => $q->whereLocalizationZone($localizationZone));
}

/**
* Filtra por localizacao diferenciada
*/
public function whereDifferentiatedLocalizationArea(int $differentiatedLocalizationArea): self
{
return $this->whereHas('school', fn ($q) => $q->whereDifferentiatedLocalizationArea($differentiatedLocalizationArea));
}
}
1 change: 1 addition & 0 deletions app/Models/Builders/LegacySchoolBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class LegacySchoolBuilder extends LegacyBuilder
public function getResource(array $filters = []): Collection
{
$this->active()->orderByName()->filter($filters);

//ref_idpes é usado na query, mas nao aparece no recurso.
//name não é usado na query, mas é aparece no recurso com adicional
return $this->setExcept(['ref_idpes'])->resource(['id'], ['name']);
Expand Down
21 changes: 20 additions & 1 deletion app/Models/Builders/LegacySchoolClassBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,15 @@ public function getResource(array $filters = []): Collection
*/
public function active(): self
{
return $this->where('ativo', 1);
return $this->where('turma.ativo', 1);
}

/**
* Filtra por visível
*/
public function visible(): self
{
return $this->where('visivel', true);
}

public function whereActive(int $active): self
Expand Down Expand Up @@ -179,4 +187,15 @@ public function whereName(string $name): self

return $this->whereRaw('unaccent(nm_turma) ~* unaccent(?)', preg_replace("/\([^)]+\)/", '', $name));
}

/**
* Filtra dia da semana
*
*
* @return $this
*/
public function whereDayWeek(string $dayWeek): self
{
return $this->whereRaw("dias_semana && ('{{$dayWeek}}')");
}
}
1 change: 1 addition & 0 deletions app/Models/Builders/LegacySchoolGradeDisciplineBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class LegacySchoolGradeDisciplineBuilder extends LegacyBuilder
public function getResource(array $filters = []): Collection
{
$this->distinctDiscipline()->with('discipline:id,nome')->filter($filters);

//não não aparece na query, mas é adicionado no recurso
return $this->resource(['id', 'workload'], ['name']);
}
Expand Down
Loading

0 comments on commit 7918ee8

Please sign in to comment.