Unverified Commit d5c5c125 authored by Alisson Albuquerque's avatar Alisson Albuquerque Committed by GitHub
Browse files

Merge pull request #13 from yuriresendematias/main

Corrigindo erro no paginate e adicionando coluna de carga horária corrigida
parents 784b7095 ca6df521
......@@ -339,6 +339,7 @@ class PadController extends Controller
}
$professor->ch = $this->get_carga_horaria_total($avaliacoes);
$professor->ch_corrigida = $this->get_carga_horaria_corrigida($avaliacoes_ensino, $avaliacoes_pesquisa, $avaliacoes_extensao, $avaliacoes_gestao);
}
return view("pad.avaliacao.professores", compact('professores', 'pad', 'index_menu'));
......@@ -811,6 +812,45 @@ class PadController extends Controller
}
private function get_carga_horaria_corrigida($ensino, $pesquisa, $extensao, $gestao)
{
$ch = 0;
if($ensino) {
for ($i = 0; $i < count($ensino->all()); $i++){
if($ensino[$i]->status != Status::REPROVADO){
$ch += $ensino[$i]->tarefa()->first()->ch_semanal;
}
}
}
if($pesquisa) {
for ($i = 0; $i < count($pesquisa->all()); $i++){
if($pesquisa[$i]->status != Status::REPROVADO){
$ch += $pesquisa[$i]->tarefa()->first()->ch_semanal;
}
}
}
if($extensao) {
for ($i = 0; $i < count($extensao->all()); $i++){
if($extensao[$i]->status != Status::REPROVADO){
$ch += $extensao[$i]->tarefa()->first()->ch_semanal;
}
}
}
if($gestao) {
for ($i = 0; $i < count($gestao->all()); $i++){
if($gestao[$i]->status != Status::REPROVADO){
$ch += $gestao[$i]->tarefa()->first()->ch_semanal;
}
}
}
return $ch;
}
public function relatorio($id){
$user = Auth::user();
$pad = Pad::find($id);
......
......@@ -4,6 +4,8 @@ namespace App\Providers;
use Illuminate\Pagination\Paginator;
use Illuminate\Support\ServiceProvider;
use Illuminate\Support\Collection;
use Illuminate\Pagination\LengthAwarePaginator;
class AppServiceProvider extends ServiceProvider
{
......@@ -26,5 +28,20 @@ class AppServiceProvider extends ServiceProvider
{
Paginator::useBootstrap();
Collection::macro('paginate', function($perPage, $total = null, $page = null, $pageName = 'page'): LengthAwarePaginator {
$page = $page ?: LengthAwarePaginator::resolveCurrentPage($pageName);
return new LengthAwarePaginator(
$this->forPage($page, $perPage)->values(),
$total ?: $this->count(),
$perPage,
$page,
[
'path' => LengthAwarePaginator::resolveCurrentPath(),
'pageName' => $pageName,
]
);
});
}
}
......@@ -25,6 +25,7 @@
<th scope="col">Professor</th>
<th scope="col">Status</th>
<th scope="col">CH</th>
<th scope="col">CH Corrigida</th>
<th scope="col">Opções</th>
</tr>
</thead>
......@@ -39,6 +40,7 @@
<td style="color:green;">{{$professor->status}}</td>
@endif
<td>@if($professor->ch > 0) {{$professor->ch}}H @endif</td>
<td>@if($professor->ch_corrigida > 0 && $professor->ch != $professor->ch_corrigida) {{$professor->ch_corrigida}}H @endif</td>
<td>
@include('components.buttons.btn-avaliar', [
......
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