Skip to content

Commit

Permalink
Merge branch 'main' into portabilis-patch-2024-12-03
Browse files Browse the repository at this point in the history
  • Loading branch information
edersoares committed Dec 3, 2024
2 parents 4d466c3 + 43966b1 commit 214583f
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 17 deletions.
21 changes: 10 additions & 11 deletions app/Services/Reports/Util.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,26 +26,25 @@ public static function sumTimes(array|Collection|null $times): string

public static function formatWorkload(?float $workload): string
{
if ($workload) {
$hour = (int) $workload;
$workload -= $hour;
$minutes = round($workload * 60);
if ($minutes < 10) {
$minutes = '0' . $minutes;
if ($workload !== null) {
$hours = (int)$workload;
$minutes = (int)round(($workload - $hours) * 60);
if ($minutes === 60) {
$hours++;
$minutes = 0;
}

if ($hour < 10) {
$hour = '0' . $hour;
}

return $hour . ':' . $minutes;
return sprintf('%02d:%02d', $hours, $minutes);
}

return '00:00';
}

public static function format(mixed $value, ?int $decimalPlaces = null): string
{
$value = str_replace(',', '.', (string) $value);
$value = bcdiv($value, '1', $decimalPlaces ?? 1);

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

Expand Down
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.105',
'version' => '0.1.106',

/*
|--------------------------------------------------------------------------
Expand Down
14 changes: 9 additions & 5 deletions ieducar/intranet/educar_turma_det.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use App\Models\View\Discipline;
use Illuminate\Support\Facades\DB;

return new class() extends clsDetalhe
return new class extends clsDetalhe
{
public $titulo;

Expand Down Expand Up @@ -57,7 +57,11 @@
public function Gerar()
{
$this->titulo = 'Turma - Detalhe';
$this->cod_turma = $_GET['cod_turma'];
$this->cod_turma = request()->integer('cod_turma');

if (is_null($this->cod_turma) || $this->cod_turma === 0) {
$this->simpleRedirect(url: 'educar_turma_lst.php');
}

$dias_da_semana = [
'' => 'Selecione',
Expand All @@ -75,7 +79,7 @@ public function Gerar()
$not_access = LegacySchoolClass::filter(['school_user' => $this->pessoa_logada])->where(column: 'cod_turma', operator: $this->cod_turma)->doesntExist();
}

$lst_obj = (new clsPmieducarTurma())->lista(
$lst_obj = (new clsPmieducarTurma)->lista(
int_cod_turma: $this->cod_turma,
visivel: [
'true',
Expand Down Expand Up @@ -117,7 +121,7 @@ public function Gerar()
$det_ser = $obj_ser->detalhe();
$registro['ref_ref_cod_serie'] = $det_ser['nm_serie'];

$obj_permissoes = new clsPermissoes();
$obj_permissoes = new clsPermissoes;

$this->addDetalhe(detalhe: ['Ano', $this->ano]);

Expand Down Expand Up @@ -269,7 +273,7 @@ public function Gerar()
);
}
} elseif ($padrao_ano_escolar == 0) {
$obj = new clsPmieducarTurmaModulo();
$obj = new clsPmieducarTurmaModulo;
$obj->setOrderby(strNomeCampo: 'sequencial ASC');
$lst = $obj->lista(int_ref_cod_turma: $this->cod_turma);

Expand Down
7 changes: 7 additions & 0 deletions tests/Unit/Services/UtilServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,20 @@ public function testFormatWorkload()
$this->assertEquals('00:30', Util::formatWorkload(0.5));
$this->assertEquals('23:24', Util::formatWorkload(23.4));
$this->assertEquals('25:54', Util::formatWorkload(25.9));
$this->assertEquals('10:00', Util::formatWorkload(9.999999));
}

public function testFormat()
{
$this->assertEquals('0,0', Util::format(null));
$this->assertEquals('0,5', Util::format(0.5));
$this->assertEquals('1,50', Util::format(1.5, 2));
$this->assertEquals('1,5', Util::format(1.52, 1));
$this->assertEquals('1,5', Util::format(1.55, 1));
$this->assertEquals('1,5', Util::format(1.59, 1));
$this->assertEquals('1,59', Util::format(1.599, 2));
$this->assertEquals('1,5', Util::format('1,59', 1));
$this->assertEquals('1,0', Util::format(1, 1));
}

public function testFloat()
Expand Down

0 comments on commit 214583f

Please sign in to comment.