"resources/views/git@sites.upe.br:walter.felipe/submeta.git" did not exist on "79094c42cdbc76e3f1a48af7b57461e548d8112f"
Commit 9334d0b6 authored by alissonalbuquerque's avatar alissonalbuquerque
Browse files

add correções de validação de horas min e max

parent 3154936d
...@@ -29,7 +29,6 @@ class GestaoMembroConselho extends Model ...@@ -29,7 +29,6 @@ class GestaoMembroConselho extends Model
'cod_atividade' => ['required', 'string', 'max:255'], 'cod_atividade' => ['required', 'string', 'max:255'],
'nome' => ['required', 'string', 'max:255'], 'nome' => ['required', 'string', 'max:255'],
'documento' => ['required', 'string', 'max:255'], 'documento' => ['required', 'string', 'max:255'],
'ch_semanal' => CargaHoraria::ch_semanal(CargaHoraria::create_ch_min(2)),
]; ];
} }
...@@ -44,10 +43,6 @@ class GestaoMembroConselho extends Model ...@@ -44,10 +43,6 @@ class GestaoMembroConselho extends Model
//documento //documento
'documento.required' => 'O campo "Documento que o Designa" é obrigatório!', 'documento.required' => 'O campo "Documento que o Designa" é obrigatório!',
//ch_semanal
'ch_semanal.required' => 'O campo "CH. Semanal" é obrigatório!',
'ch_semanal.min' => 'Carga horária semanal miníma é de 2 Horas!',
]; ];
} }
......
...@@ -29,7 +29,6 @@ class GestaoMembroTitularConselho extends Model ...@@ -29,7 +29,6 @@ class GestaoMembroTitularConselho extends Model
'cod_atividade' => ['required', 'string', 'max:255'], 'cod_atividade' => ['required', 'string', 'max:255'],
'nome' => ['required', 'string', 'max:255'], 'nome' => ['required', 'string', 'max:255'],
'documento' => ['required', 'string', 'max:255'], 'documento' => ['required', 'string', 'max:255'],
'ch_semanal' => CargaHoraria::ch_semanal(),
]; ];
} }
...@@ -44,10 +43,6 @@ class GestaoMembroTitularConselho extends Model ...@@ -44,10 +43,6 @@ class GestaoMembroTitularConselho extends Model
//documento //documento
'documento.required' => 'O campo "Documento que o Designa" é obrigatório!', 'documento.required' => 'O campo "Documento que o Designa" é obrigatório!',
//ch_semanal
'ch_semanal.required' => 'O campo "CH. Semanal" é obrigatório!',
'ch_semanal.min' => 'Carga horária semanal miníma é de 1 Hora!',
]; ];
} }
......
...@@ -29,7 +29,6 @@ class GestaoRepresentanteUnidadeEducacao extends Model ...@@ -29,7 +29,6 @@ class GestaoRepresentanteUnidadeEducacao extends Model
'cod_atividade' => ['required', 'string', 'max:255'], 'cod_atividade' => ['required', 'string', 'max:255'],
'nome' => ['required', 'string', 'max:255'], 'nome' => ['required', 'string', 'max:255'],
'documento' => ['required', 'string', 'max:255'], 'documento' => ['required', 'string', 'max:255'],
'ch_semanal' => CargaHoraria::ch_semanal(),
]; ];
} }
...@@ -44,10 +43,6 @@ class GestaoRepresentanteUnidadeEducacao extends Model ...@@ -44,10 +43,6 @@ class GestaoRepresentanteUnidadeEducacao extends Model
//documento //documento
'documento.required' => 'O campo "Documento que o Designa" é obrigatório!', 'documento.required' => 'O campo "Documento que o Designa" é obrigatório!',
//ch_semanal
'ch_semanal.required' => 'O campo "CH. Semanal" é obrigatório!',
'ch_semanal.min' => 'Carga horária semanal miníma é de 1 Hora!',
]; ];
} }
......
...@@ -13,21 +13,17 @@ class CargaHorariaValidation ...@@ -13,21 +13,17 @@ class CargaHorariaValidation
/** @var integer|null */ /** @var integer|null */
public $ch_max; public $ch_max;
/** @var string */ public function __construct($ch_min, $ch_max)
public $ch_sum;
public function __construct($ch_min, $ch_max, $ch_sum)
{ {
$this->ch_min = $ch_min; $this->ch_min = $ch_min;
$this->ch_max = $ch_max; $this->ch_max = $ch_max;
$this->ch_sum = $ch_sum;
} }
public function rules() public function rules()
{ {
$ch_min = $this->ch_min !== null? sprintf('min:%d', $this->ch_min) : self::CH_MIN; $ch_min = $this->ch_min !== null? sprintf('min:%d', $this->ch_min) : self::CH_MIN;
$ch_max = $this->ch_max !== null? sprintf('max:%d', $this->ch_max - $this->ch_sum) : self::CH_MAX; $ch_max = $this->ch_max !== null? sprintf('max:%d', $this->ch_max) : self::CH_MAX;
return [ return [
'ch_semanal' => ['required', 'integer', $ch_min, $ch_max] 'ch_semanal' => ['required', 'integer', $ch_min, $ch_max]
...@@ -37,19 +33,8 @@ class CargaHorariaValidation ...@@ -37,19 +33,8 @@ class CargaHorariaValidation
public function messages() public function messages()
{ {
$ch_min = $this->ch_min !== null && $this->ch_min > 1 ? sprintf('"CH. Semanal" miníma é de %d Hora(s)!', $this->ch_min) : '"CH. Semanal" miníma é de 1 Hora(s)!'; $ch_min = $this->ch_min !== null && $this->ch_min > 1 ? sprintf('"CH. Semanal" miníma é de %d Hora(s)!', $this->ch_min) : '"CH. Semanal" miníma é de 1 Hora(s)!';
$ch_max = '';
if($this->ch_max !== null) $ch_max = $this->ch_max !== null ? sprintf('"CH. Semanal" máxima para o preenchimento é de %d Hora(s)!', $this->ch_max) : '';
{
if($this->ch_max - $this->ch_sum !== 0)
{
$ch_max = sprintf('"CH. Semanal" máxima atual para preenchimento é de %d Hora(s)! %d Hora(s) já adicionadas', ($this->ch_max - $this->ch_sum), $this->ch_sum);
} else {
$ch_max = "Limite de horas preenchidas alcançado!";
}
} else {
$ch_max = '';
}
return [ return [
'ch_semanal.required' => 'O campo "CH. Semanal" é obrigatório!', 'ch_semanal.required' => 'O campo "CH. Semanal" é obrigatório!',
......
...@@ -22,6 +22,7 @@ class CreateEnsinoAulasTable extends Migration ...@@ -22,6 +22,7 @@ class CreateEnsinoAulasTable extends Migration
$table->string('curso')->notNull(); $table->string('curso')->notNull();
$table->tinyInteger('nivel')->notNull(); $table->tinyInteger('nivel')->notNull();
$table->tinyInteger('modalidade')->notNull(); $table->tinyInteger('modalidade')->notNull();
$table->string('cod_dimensao')->notNull();
$table->integer('ch_semanal')->notNull(); $table->integer('ch_semanal')->notNull();
$table->timestamps(); $table->timestamps();
$table->softDeletes(); $table->softDeletes();
......
...@@ -60,7 +60,7 @@ ...@@ -60,7 +60,7 @@
]) ])
</div> </div>
<div class="mb-3 col-sm-4"> <div class="mb-3 col-sm-6">
<label class="form-label" for="nivel">Nível</label> <label class="form-label" for="nivel">Nível</label>
<select class="form-select @error('nivel') is-invalid @enderror ajax-errors" name="nivel" id="nivel" value="{{ old('nivel') }}"> <select class="form-select @error('nivel') is-invalid @enderror ajax-errors" name="nivel" id="nivel" value="{{ old('nivel') }}">
<option value="0">Selecione um Nível</option> <option value="0">Selecione um Nível</option>
...@@ -78,7 +78,7 @@ ...@@ -78,7 +78,7 @@
]) ])
</div> </div>
<div class="mb-3 col-sm-4"> <div class="mb-3 col-sm-6">
<label class="form-label" for="modalidade">Modalidade</label> <label class="form-label" for="modalidade">Modalidade</label>
<select class="form-select @error('modalidade') is-invalid @enderror ajax-errors" name="modalidade" id="modalidade" value="{{ old('modalidade') }}"> <select class="form-select @error('modalidade') is-invalid @enderror ajax-errors" name="modalidade" id="modalidade" value="{{ old('modalidade') }}">
<option value="0">Selecione uma Modalidade</option> <option value="0">Selecione uma Modalidade</option>
...@@ -95,6 +95,24 @@ ...@@ -95,6 +95,24 @@
'field' => 'modalidade_create' 'field' => 'modalidade_create'
]) ])
</div> </div>
<div class="mb-3 col-sm-8">
<label class="form-label" for="cod_dimensao">Resolução</label>
<select class="form-select @error('cod_dimensao') is-invalid @enderror ajax-errors" name="cod_dimensao" id="cod_dimensao" value="{{ old('cod_dimensao') }}">
<option value="0">Selecione uma Resolução</option>
@foreach($planejamentos as $value => $cod_dimensao)
@if( $value == old('cod_dimensao') )
<option selected value="{{$value}}">{{$cod_dimensao}}</option>
@else
<option value="{{$value}}">{{$cod_dimensao}}</option>
@endif
@endforeach
</select>
@include('components.divs.errors', [
'field' => 'cod_dimensao_create'
])
</div>
<div class="mb-3 col-sm-4"> <div class="mb-3 col-sm-4">
<label class="form-label" for="ch_semanal">CH. Semanal</label> <label class="form-label" for="ch_semanal">CH. Semanal</label>
......
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
]) ])
</div> </div>
<div class="mb-3 col-sm-4"> <div class="mb-3 col-sm-6">
<label class="form-label" for="nivel">Nível</label> <label class="form-label" for="nivel">Nível</label>
<select class="form-select @error('nivel') is-invalid @enderror ajax-errors" name="nivel" id="nivel" value="{{ old('nivel') }}"> <select class="form-select @error('nivel') is-invalid @enderror ajax-errors" name="nivel" id="nivel" value="{{ old('nivel') }}">
<option value="0">Selecione um Nível</option> <option value="0">Selecione um Nível</option>
...@@ -51,7 +51,7 @@ ...@@ -51,7 +51,7 @@
]) ])
</div> </div>
<div class="mb-3 col-sm-4"> <div class="mb-3 col-sm-6">
<label class="form-label" for="modalidade">Modalidade</label> <label class="form-label" for="modalidade">Modalidade</label>
<select class="form-select @error('modalidade') is-invalid @enderror ajax-errors" name="modalidade" id="modalidade"> <select class="form-select @error('modalidade') is-invalid @enderror ajax-errors" name="modalidade" id="modalidade">
<option value="0">Selecione uma Modalidade</option> <option value="0">Selecione uma Modalidade</option>
...@@ -68,6 +68,24 @@ ...@@ -68,6 +68,24 @@
'field' => 'modalidade_update', 'field' => 'modalidade_update',
]) ])
</div> </div>
<div class="mb-3 col-sm-8">
<label class="form-label" for="cod_dimensao">Resolução</label>
<select class="form-select @error('cod_dimensao') is-invalid @enderror ajax-errors" name="cod_dimensao" id="cod_dimensao" value="{{ old('cod_dimensao') }}">
<option value="0">Selecione uma Resolução</option>
@foreach($planejamentos as $value => $cod_dimensao)
@if( $value == old('cod_dimensao') )
<option selected value="{{$value}}">{{$cod_dimensao}}</option>
@else
<option value="{{$value}}">{{$cod_dimensao}}</option>
@endif
@endforeach
</select>
@include('components.divs.errors', [
'field' => 'cod_dimensao_update'
])
</div>
<div class="mb-3 col-sm-4"> <div class="mb-3 col-sm-4">
<label class="form-label" for="ch_semanal">CH. Semanal</label> <label class="form-label" for="ch_semanal">CH. Semanal</label>
......
...@@ -83,7 +83,7 @@ ...@@ -83,7 +83,7 @@
</select> </select>
@include('components.divs.errors', [ @include('components.divs.errors', [
'field' => 'cod_dimensao_create' 'field' => 'cod_dimensao_update'
]) ])
</div> </div>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment