Skip to content

Commit

Permalink
Merge branch 'main' into portabilis-patch-2024-12-23
Browse files Browse the repository at this point in the history
  • Loading branch information
edersoares committed Dec 23, 2024
2 parents 6bc15bd + f77b742 commit 70a7d72
Show file tree
Hide file tree
Showing 23 changed files with 210 additions and 50 deletions.
15 changes: 8 additions & 7 deletions app/Console/Commands/QueryAllCsvCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class QueryAllCsvCommand extends Command
*/
public function handle()
{
$array = [];
$header = [];
$data = [];
$file = file_get_contents($this->getFile());

Expand All @@ -44,16 +44,17 @@ public function handle()
}

try {
$data[$connection] = DB::connection($connection)->select($file);
} catch (Exception $exception) {
$connectionData = DB::connection($connection)->select($file);

if (!empty($connectionData) && empty($header)) {
$header = array_merge(['conexao'], array_keys((array)$connectionData[0]));
}
$data[$connection] = $connectionData;
} catch (Exception) {
continue;
}
}

if (isset($data[$connection][0])) {
$header = array_keys((array) $data[$connection][0]);
}

$this->makeCsv($header, $data);
}

Expand Down
8 changes: 8 additions & 0 deletions app/Models/LegacyPerson.php
Original file line number Diff line number Diff line change
Expand Up @@ -174,4 +174,12 @@ public function considerableDeficiencies(): BelongsToMany
// @phpstan-ignore-next-line
return $this->deficiencies()->where('desconsidera_regra_diferenciada', false);
}

/**
* @return HasOne<LegacyStudent, $this>
*/
public function student(): HasOne
{
return $this->hasOne(LegacyStudent::class, 'ref_idpes', 'idpes');
}
}
5 changes: 5 additions & 0 deletions app/Models/LegacyStudent.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Ankurk91\Eloquent\HasBelongsToOne;
use Ankurk91\Eloquent\Relations\BelongsToOne;
use App\Events\StudentCreated;
use App\Models\Builders\LegacyStudentBuilder;
use App\Traits\HasLegacyDates;
use Illuminate\Database\Eloquent\Casts\Attribute;
Expand Down Expand Up @@ -42,6 +43,10 @@ class LegacyStudent extends LegacyModel

protected $primaryKey = 'cod_aluno';

protected $dispatchesEvents = [
'created' => StudentCreated::class,
];

protected $fillable = [
'ref_idpes',
'tipo_responsavel',
Expand Down
9 changes: 6 additions & 3 deletions app/Services/Reports/Util.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,13 @@ public static function formatWorkload(?float $workload): string

public static function format(mixed $value, ?int $decimalPlaces = null): string
{
$value = str_replace(',', '.', (string) $value);
$value = bcdiv($value, '1', $decimalPlaces ?? 1);
$processedValue = str_replace(',', '.', trim($value));
if (!empty($processedValue) && !is_numeric($processedValue)) {
return $value;
}
$processedValue = bcdiv($processedValue, '1', $decimalPlaces ?? 1);

return number_format($value, $decimalPlaces ?? 1, ',', '.');
return number_format($processedValue, $decimalPlaces ?? 1, ',', '.');
}

public static function float(mixed $value): float
Expand Down
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.14.0",
"dex/frontier": "^0.15.0",
"google/recaptcha": "^1.2",
"guzzlehttp/guzzle": "^7.3",
"honeybadger-io/honeybadger-laravel": "^4.0",
Expand Down
14 changes: 7 additions & 7 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion config/assets.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
|
*/

'version' => '0.1.106',
'version' => '0.1.107',

/*
|--------------------------------------------------------------------------
Expand Down
23 changes: 23 additions & 0 deletions ieducar/intranet/atendidos_det.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
<?php

use App\Models\Employee;
use App\Models\LegacyIndividual;
use App\Models\LegacyRace;
use App\Models\LegacyStudent;
use App\Services\FileService;
use App\Services\UrlPresigner;

Expand Down Expand Up @@ -144,6 +146,27 @@ public function Gerar()
$this->addDetalhe(detalhe: ['Sexo', $detalhe['sexo'] == 'M' ? 'Masculino' : 'Feminino']);
}

$vinculos = collect();
if ($aluno = LegacyStudent::active()->where('ref_idpes', $cod_pessoa)->first(['cod_aluno'])) {
$vinculos->push(sprintf(
'<a target="_blank" href="/intranet/educar_aluno_det.php?cod_aluno=%s">Aluno</a>',
$aluno->getKey()
));
}

if ($servidor = Employee::active()->find($cod_pessoa, ['cod_servidor', 'ref_cod_instituicao'])) {
$vinculos->push(sprintf(
'<a target="_blank" href="/intranet/educar_servidor_det.php?cod_servidor=%s&ref_cod_instituicao=%s">Servidor</a>',
$servidor->getKey(),
$servidor->ref_cod_instituicao
));
}

if ($vinculos->isEmpty()) {
$vinculos->push('Pessoa física não possui vínculos');
}
$this->addHtml('<tr><td class="formlttd" width="20%">Vínculos:</td><td class="formlttd">' . $vinculos->implode('<br>') . '</td></tr>');

$fileService = new FileService(urlPresigner: new UrlPresigner);
$files = $fileService->getFiles(relation: LegacyIndividual::find($cod_pessoa));

Expand Down
20 changes: 16 additions & 4 deletions ieducar/intranet/educar_aluno_det.php
Original file line number Diff line number Diff line change
Expand Up @@ -290,17 +290,23 @@ public function Gerar()
$this->addDetalhe(detalhe: [_cl(key: 'aluno.detalhe.codigo_estado'), $registro['aluno_estado_id']]);

if ($registro['nome_aluno']) {
$urlAluno = sprintf(
'<a target="_blank" href="/intranet/atendidos_det.php?cod_pessoa=%s">%s</a>',
$registro['ref_idpes'],
$registro['nome_aluno']
);

if ($caminhoFoto != null and $caminhoFoto != '') {
$url = $this->urlPresigner()->getPresignedUrl(url: $caminhoFoto);

$this->addDetalhe(detalhe: [
'Nome Aluno',
$registro['nome_aluno'] . '<p><img id="student-picture" height="117" src="' . $url . '"/></p>'
$urlAluno . '<p><img id="student-picture" height="117" src="' . $url . '"/></p>'
. '<div><a class="rotate-picture" data-angle="90" href="javascript:void(0)"><i class="fa fa-rotate-left"></i> Girar para esquerda</a></div>'
. '<div><a class="rotate-picture" data-angle="-90" href="javascript:void(0)"><i class="fa fa-rotate-right"></i> Girar para direita</a></div>',
]);
} else {
$this->addDetalhe(detalhe: ['Nome Aluno', $registro['nome_aluno']]);
$this->addDetalhe(detalhe: ['Nome Aluno', $urlAluno]);
}
}

Expand Down Expand Up @@ -361,7 +367,7 @@ public function Gerar()
$this->addDetalhe(detalhe: ['País de Origem', $registro['pais_origem']]);
}

$responsavel = $tmp_obj->getResponsavelAluno();
$responsavel = $tmp_obj->getResponsavelAluno(exibirUrl: true);

if ($responsavel && is_null(value: $registro['ref_idpes_responsavel'])) {
$this->addDetalhe(detalhe: ['Nome do Responsável', $responsavel['nome_responsavel']]);
Expand All @@ -372,7 +378,13 @@ public function Gerar()
$det_pessoa_resp = $obj_pessoa_resp->detalhe();

if ($det_pessoa_resp) {
$registro['ref_idpes_responsavel'] = $det_pessoa_resp['nome'];
$urlResponsavel = sprintf(
'<a target="_blank" href="/intranet/atendidos_det.php?cod_pessoa=%s">%s</a>',
$registro['ref_idpes_responsavel'],
$det_pessoa_resp['nome']
);

$registro['ref_idpes_responsavel'] = $urlResponsavel;
}

$this->addDetalhe(detalhe: ['Responsável', $registro['ref_idpes_responsavel']]);
Expand Down
36 changes: 29 additions & 7 deletions ieducar/intranet/educar_matricula_historico_cad.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php

use App\Models\LegacyEnrollment;
use App\Process;

return new class extends clsCadastro
Expand Down Expand Up @@ -220,15 +221,36 @@ public function Editar()
return false;
}

private function enturmacaoRemanejadaMesmaTurma($sequencial) {
return LegacyEnrollment::query()
->where('ref_cod_turma', $this->ref_cod_turma)
->where('ref_cod_matricula', $this->ref_cod_matricula)
->where('sequencial', $sequencial)
->where('remanejado_mesma_turma', true)
->first();
}

public function Excluir()
{
$enturmacao = new clsPmieducarMatriculaTurma();
$enturmacao->ref_cod_matricula = $this->ref_cod_matricula;
$enturmacao->ref_cod_turma = $this->ref_cod_turma;
$enturmacao->sequencial = $this->sequencial;
$enturmacao->ref_usuario_exc = $this->pessoa_logada;
$enturmacao->data_exclusao = dataToBanco(data_original: $this->data_exclusao);
$excluiu = $enturmacao->excluir();
$enturmacao = LegacyEnrollment::query()
->where('ref_cod_turma', $this->ref_cod_turma)
->where('ref_cod_matricula', $this->ref_cod_matricula)
->where('sequencial', $this->sequencial)
->first();

DB::beginTransaction();


if ($enturmacao->remanejado_mesma_turma) {
$proximaEnturmacao = $this->enturmacaoRemanejadaMesmaTurma($this->sequencial + 1);

if ($proximaEnturmacao) {
$proximaEnturmacao->update(['remanejado_mesma_turma' => false]);
}
}

$excluiu = $enturmacao->delete();
DB::commit();

if ($excluiu) {
$this->mensagem = 'Exclusão efetuada com sucesso.';
Expand Down
7 changes: 6 additions & 1 deletion ieducar/intranet/educar_servidor_det.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,12 @@ public function Gerar()
}

if ($registro['nome']) {
$this->addDetalhe(['Nome', $registro['nome']]);
$link = sprintf(
'<a href="/intranet/atendidos_det.php?cod_pessoa=%s" target="_blank">%s</a>',
$registro['cod_servidor'],
$registro['nome']
);
$this->addDetalhe(['Nome', $link]);
}

// Dados no Educacenso/Inep.
Expand Down
52 changes: 47 additions & 5 deletions ieducar/intranet/include/pmieducar/clsPmieducarAluno.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -936,7 +936,7 @@ public function verificaInep($cod_aluno = null)
}
}

public function getResponsavelAluno()
public function getResponsavelAluno($exibirUrl = false)
{
if ($this->cod_aluno) {
$registro = $this->detalhe();
Expand All @@ -955,7 +955,16 @@ public function getResponsavelAluno()
$obj_fisica = new clsFisica($det_fisica_aluno['idpes_pai']);
$det_fisica = $obj_fisica->detalhe();

$registro['nome_responsavel'] = $det_ref_idpes['nome'];
if ($exibirUrl) {
$pai = sprintf(
'<a target="_blank" href="/intranet/atendidos_det.php?cod_pessoa=%s">%s</a>',
$det_ref_idpes['idpes'],
$det_ref_idpes['nome']
);
} else {
$pai = $det_ref_idpes['nome'];
}
$registro['nome_responsavel'] = $pai;
$registro['cpf_responsavel'] = $det_fisica['cpf'] ? int2CPF($det_fisica['cpf']) : 'Não informado';
}
}
Expand All @@ -974,7 +983,16 @@ public function getResponsavelAluno()
$obj_fisica = new clsFisica($det_fisica_aluno['idpes_mae']);
$det_fisica = $obj_fisica->detalhe();

$registro['nome_responsavel'] = $det_ref_idpes['nome'];
if ($exibirUrl) {
$mae = sprintf(
'<a target="_blank" href="/intranet/atendidos_det.php?cod_pessoa=%s">%s</a>',
$det_ref_idpes['idpes'],
$det_ref_idpes['nome']
);
} else {
$mae = $det_ref_idpes['nome'];
}
$registro['nome_responsavel'] = $mae;
$registro['cpf_responsavel'] = $det_fisica['cpf'] ? int2CPF($det_fisica['cpf']) : 'Não informado';
}
}
Expand All @@ -993,7 +1011,16 @@ public function getResponsavelAluno()
$det_ref_idpes = $obj_ref_idpes->detalhe();
$det_fisica = $obj_fisica->detalhe();

$registro['nome_responsavel'] = $det_ref_idpes['nome'];
if ($exibirUrl) {
$responsavel = sprintf(
'<a target="_blank" href="/intranet/atendidos_det.php?cod_pessoa=%s">%s</a>',
$det_ref_idpes['idpes'],
$det_ref_idpes['nome']
);
} else {
$responsavel = $det_ref_idpes['nome'];
}
$registro['nome_responsavel'] = $responsavel;
$registro['cpf_responsavel'] = $det_fisica['cpf'] ? int2CPF($det_fisica['cpf']) : 'Não informado';
}
}
Expand All @@ -1013,7 +1040,22 @@ public function getResponsavelAluno()
$fisica_pai = (new clsFisica($det_fisica_aluno['idpes_pai']))->detalhe();
$det_pai = $obj_pai->detalhe();

$registro['nome_responsavel'] = $det_pai['nome'] . ', ' . $det_mae['nome'];
if ($exibirUrl) {
$pai = sprintf(
'<a target="_blank" href="/intranet/atendidos_det.php?cod_pessoa=%s">%s</a>',
$det_pai['idpes'],
$det_pai['nome']
);
$mae = sprintf(
'<a target="_blank" href="/intranet/atendidos_det.php?cod_pessoa=%s">%s</a>',
$det_mae['idpes'],
$det_mae['nome']
);
} else {
$pai = $det_pai['nome'];
$mae = $det_mae['nome'];
}
$registro['nome_responsavel'] = $pai . ', ' . $mae;
$cpfPai = $fisica_pai['cpf'] ? int2CPF($fisica_pai['cpf']) : 'Não informado';
$cpfMae = $fisica_mae['cpf'] ? int2CPF($fisica_mae['cpf']) : 'não informado';
$registro['cpf_responsavel'] = $cpfPai . ', ' . $cpfMae;
Expand Down
2 changes: 1 addition & 1 deletion ieducar/modules/Api/Views/CursoAlunoController.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public function getCursoDoAluno()
{
if ($this->canGetCursoDoAluno()) {
$alunoId = $this->getRequest()->aluno_id;
$sql = 'SELECT \'\'\'\' || (nm_curso ) || \'\'\'\' AS id, (nm_curso ) AS nome FROM pmieducar.historico_escolar WHERE ref_cod_aluno = $1';
$sql = 'SELECT \'\'\'\' || (nm_curso ) || \'\'\'\' AS id, (nm_curso ) AS nome FROM pmieducar.historico_escolar WHERE ref_cod_aluno = $1 AND ativo = 1';
$cursos = $this->fetchPreparedQuery($sql, [$alunoId]);
$attrs = ['id', 'nome'];
$cursos = Portabilis_Array_Utils::filterSet($cursos, $attrs);
Expand Down
Loading

0 comments on commit 70a7d72

Please sign in to comment.