Commit de6c2c8f authored by PedroLopesUPE's avatar PedroLopesUPE
Browse files

Primeira versão de geração de PDF

Funcional, não otimizada, com retorno legível de relatório em html básico
parent 8113cef8
......@@ -8,6 +8,30 @@ use App\Models\User;
use App\Models\UserPad;
use App\Models\Util\Status;
use App\Models\Util\PadTables;
use App\Models\Tabelas\Ensino\EnsinoAtendimentoDiscente;
use App\Models\Tabelas\Ensino\EnsinoAula;
use App\Models\Tabelas\Ensino\EnsinoCoordenacaoRegencia;
use App\Models\Tabelas\Ensino\EnsinoMembroDocente;
use App\Models\Tabelas\Ensino\EnsinoOrientacao;
use App\Models\Tabelas\Ensino\EnsinoOutros;
use App\Models\Tabelas\Ensino\EnsinoParticipacao;
use App\Models\Tabelas\Ensino\EnsinoProjeto;
use App\Models\Tabelas\Ensino\EnsinoSupervisao;
use App\Models\Tabelas\Extensao\ExtensaoCoordenacao;
use App\Models\Tabelas\Extensao\ExtensaoOrientacao;
use App\Models\Tabelas\Extensao\ExtensaoOutros;
use App\Models\Tabelas\Gestao\GestaoCoordenacaoLaboratoriosDidaticos;
use App\Models\Tabelas\Gestao\GestaoCoordenacaoProgramaInstitucional;
use App\Models\Tabelas\Gestao\GestaoMembroCamaras;
use App\Models\Tabelas\Gestao\GestaoMembroComissao;
use App\Models\Tabelas\Gestao\GestaoMembroConselho;
use App\Models\Tabelas\Gestao\GestaoMembroTitularConselho;
use App\Models\Tabelas\Gestao\GestaoOutros;
use App\Models\Tabelas\Gestao\GestaoRepresentanteUnidadeEducacao;
use App\Models\Tabelas\Pesquisa\PesquisaCoordenacao;
use App\Models\Tabelas\Pesquisa\PesquisaLideranca;
use App\Models\Tabelas\Pesquisa\PesquisaOrientacao;
use App\Models\Tabelas\Pesquisa\PesquisaOutros;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Response;
use Illuminate\Support\Facades\Validator;
......@@ -82,51 +106,142 @@ class UserPadController extends Controller
public function generatePDF($user_pad_id)
{
$ensinoTotalHoras =
EnsinoAtendimentoDiscente::whereUserPadId($user_pad_id)->sum('ch_semanal')
+ EnsinoAula::whereUserPadId($user_pad_id)->sum('ch_semanal')
+ EnsinoCoordenacaoRegencia::whereUserPadId($user_pad_id)->sum('ch_semanal')
+ EnsinoMembroDocente::whereUserPadId($user_pad_id)->sum('ch_semanal')
+ EnsinoOrientacao::whereUserPadId($user_pad_id)->sum('ch_semanal')
+ EnsinoOutros::whereUserPadId($user_pad_id)->sum('ch_semanal')
+ EnsinoParticipacao::whereUserPadId($user_pad_id)->sum('ch_semanal')
+ EnsinoProjeto::whereUserPadId($user_pad_id)->sum('ch_semanal')
+ EnsinoSupervisao::whereUserPadId($user_pad_id)->sum('ch_semanal');
$gestaoTotalHoras =
GestaoCoordenacaoLaboratoriosDidaticos::whereUserPadId($user_pad_id)->sum('ch_semanal')
+ GestaoCoordenacaoProgramaInstitucional::whereUserPadId($user_pad_id)->sum('ch_semanal')
+ GestaoMembroCamaras::whereUserPadId($user_pad_id)->sum('ch_semanal')
+ GestaoMembroComissao::whereUserPadId($user_pad_id)->sum('ch_semanal')
+ GestaoMembroConselho::whereUserPadId($user_pad_id)->sum('ch_semanal')
+ GestaoMembroTitularConselho::whereUserPadId($user_pad_id)->sum('ch_semanal')
+ GestaoOutros::whereUserPadId($user_pad_id)->sum('ch_semanal')
+ GestaoRepresentanteUnidadeEducacao::whereUserPadId($user_pad_id)->sum('ch_semanal');
$pesquisaTotalHoras =
PesquisaCoordenacao::whereUserPadId($user_pad_id)->sum('ch_semanal')
+ PesquisaLideranca::whereUserPadId($user_pad_id)->sum('ch_semanal')
+ PesquisaOrientacao::whereUserPadId($user_pad_id)->sum('ch_semanal')
+ PesquisaOutros::whereUserPadId($user_pad_id)->sum('ch_semanal');
$extensaoTotalHoras =
ExtensaoCoordenacao::whereUserPadId($user_pad_id)->sum('ch_semanal')
+ ExtensaoOrientacao::whereUserPadId($user_pad_id)->sum('ch_semanal')
+ ExtensaoOutros::whereUserPadId($user_pad_id)->sum('ch_semanal');
$horas = [
'ensino' => $ensinoTotalHoras,
'extensao' => $extensaoTotalHoras,
'gestao' => $gestaoTotalHoras,
'pesquisa' => $pesquisaTotalHoras
];
$userPad = UserPad::whereId($user_pad_id)->first();
$CU = $userPad->ensinoCoordenacaoRegencias->toArray();
$model['ensino'] =
[PadTables::tablesEnsino($user_pad_id)[4]['name'] => $userPad->ensinoAtendimentoDiscentes->all(),
PadTables::tablesEnsino($user_pad_id)[0]['name'] => $userPad->ensinoAulas->all(),
PadTables::tablesEnsino($user_pad_id)[1]['name'] => $userPad->ensinoCoordenacaoRegencias->all(),
PadTables::tablesEnsino($user_pad_id)[7]['name'] => $userPad->ensinoMembroDocentes->all(),
PadTables::tablesEnsino($user_pad_id)[2]['name'] => $userPad->ensinoOrientacoes->all(),
PadTables::tablesEnsino($user_pad_id)[8]['name'] => $userPad->ensinoOutros->all(),
PadTables::tablesEnsino($user_pad_id)[6]['name'] => $userPad->ensinoParticipacoes->all(),
PadTables::tablesEnsino($user_pad_id)[5]['name'] => $userPad->ensinoProjetos->all(),
PadTables::tablesEnsino($user_pad_id)[3]['name'] => $userPad->ensinoSupervisoes->all()
[PadTables::tablesEnsino($user_pad_id)[4]['name'] => $userPad->ensinoAtendimentoDiscentes->toArray(),
PadTables::tablesEnsino($user_pad_id)[0]['name'] => $userPad->ensinoAulas->toArray(),
PadTables::tablesEnsino($user_pad_id)[1]['name'] => $userPad->ensinoCoordenacaoRegencias->toArray(),
PadTables::tablesEnsino($user_pad_id)[7]['name'] => $userPad->ensinoMembroDocentes->toArray(),
PadTables::tablesEnsino($user_pad_id)[2]['name'] => $userPad->ensinoOrientacoes->toArray(),
PadTables::tablesEnsino($user_pad_id)[8]['name'] => $userPad->ensinoOutros->toArray(),
PadTables::tablesEnsino($user_pad_id)[6]['name'] => $userPad->ensinoParticipacoes->toArray(),
PadTables::tablesEnsino($user_pad_id)[5]['name'] => $userPad->ensinoProjetos->toArray(),
PadTables::tablesEnsino($user_pad_id)[3]['name'] => $userPad->ensinoSupervisoes->toArray()
];
$model['extensao'] =
[PadTables::tablesExtensao($user_pad_id)[0]['name'] => $userPad->extensaoCoordenacoes->all(),
PadTables::tablesExtensao($user_pad_id)[1]['name'] => $userPad->extensaoOrientacoes->all(),
PadTables::tablesExtensao($user_pad_id)[2]['name'] => $userPad->extensaoOutros->all()
[PadTables::tablesExtensao($user_pad_id)[0]['name'] => $userPad->extensaoCoordenacoes->toArray(),
PadTables::tablesExtensao($user_pad_id)[1]['name'] => $userPad->extensaoOrientacoes->toArray(),
PadTables::tablesExtensao($user_pad_id)[2]['name'] => $userPad->extensaoOutros->toArray()
];
$model['gestao'] =
[PadTables::tablesGestao($user_pad_id)[5]['name'] => $userPad->gestaoCoordenacaoLaboratoriosDidaticos->all(),
PadTables::tablesGestao($user_pad_id)[6]['name'] => $userPad->gestaoCoordenacaoProgramasInstitucionais->all(),
PadTables::tablesGestao($user_pad_id)[4]['name'] => $userPad->gestaoMembroCamaras->all(),
PadTables::tablesGestao($user_pad_id)[0]['name'] => $userPad->gestaoMembroComissoes->all(),
PadTables::tablesGestao($user_pad_id)[1]['name'] => $userPad->gestaoMembroConselhos->all(),
PadTables::tablesGestao($user_pad_id)[2]['name'] => $userPad->gestaoMembroTitularConselhos->all(),
PadTables::tablesGestao($user_pad_id)[7]['name'] => $userPad->gestaoOutros->all(),
PadTables::tablesGestao($user_pad_id)[3]['name'] => $userPad->gestaoRepresentanteUnidadeEducacoes->all()
[PadTables::tablesGestao($user_pad_id)[5]['name'] => $userPad->gestaoCoordenacaoLaboratoriosDidaticos->toArray(),
PadTables::tablesGestao($user_pad_id)[6]['name'] => $userPad->gestaoCoordenacaoProgramasInstitucionais->toArray(),
PadTables::tablesGestao($user_pad_id)[4]['name'] => $userPad->gestaoMembroCamaras->toArray(),
PadTables::tablesGestao($user_pad_id)[0]['name'] => $userPad->gestaoMembroComissoes->toArray(),
PadTables::tablesGestao($user_pad_id)[1]['name'] => $userPad->gestaoMembroConselhos->toArray(),
PadTables::tablesGestao($user_pad_id)[2]['name'] => $userPad->gestaoMembroTitularConselhos->toArray(),
PadTables::tablesGestao($user_pad_id)[7]['name'] => $userPad->gestaoOutros->toArray(),
PadTables::tablesGestao($user_pad_id)[3]['name'] => $userPad->gestaoRepresentanteUnidadeEducacoes->toArray()
];
$model['pesquisa'] =
[PadTables::tablesPesquisa($user_pad_id)[0]['name'] => $userPad->pesquisaCoordenacoes->all(),
PadTables::tablesPesquisa($user_pad_id)[1]['name'] => $userPad->pesquisaLiderancas->all(),
PadTables::tablesPesquisa($user_pad_id)[2]['name'] => $userPad->pesquisaOrientacoes->all(),
PadTables::tablesPesquisa($user_pad_id)[3]['name'] => $userPad->pesquisaOutros->all()
[PadTables::tablesPesquisa($user_pad_id)[0]['name'] => $userPad->pesquisaCoordenacoes->toArray(),
PadTables::tablesPesquisa($user_pad_id)[1]['name'] => $userPad->pesquisaLiderancas->toArray(),
PadTables::tablesPesquisa($user_pad_id)[2]['name'] => $userPad->pesquisaOrientacoes->toArray(),
PadTables::tablesPesquisa($user_pad_id)[3]['name'] => $userPad->pesquisaOutros->toArray()
];
$dateTime = now()->format('d-m-Y (H:i:s)');
dd(
PadTables::tablesEnsino($user_pad_id)[0]['name'],
$model,
"$dateTime",
empty($model['ensino'][0])
);
return view();
// view()->share($model);
// $pdf = PDF::loadView('', $model);
// return $pdf->download("Relatório PAD: ");
// foreach ($model as $nome_dimensao=>$dimensao) {
// dump(strtoupper($nome_dimensao));
// foreach ($dimensao as $categoria) {
// // var_dump($categoria);
// foreach ($categoria as $item) {
// // var_dump($item);
// foreach ($item as $value_name=>$value) {
// if (array_search($value, $item) == "id" ||
// array_search($value, $item) == "user_pad_id" ||
// array_search($value, $item) == "dimensao" ||
// array_search($value, $item) == "created_at" ||
// array_search($value, $item) == "updated_at" ||
// array_search($value, $item) == "deleted_at") {
// continue;
// }
// else {
// // $value_name;
// }
// }
// // foreach (array_values($item) as $index=>$value) {
// // if ($index == 7 && ! array_key_exists("modalidade", $item)) {
// // dump("NULOOOO");
// // continue;
// // }
// // if ($index > 2 && $index < 7) {
// // // var_dump ($item);
// // dump("\n");
// // var_dump ($value);
// // }
// // }
// break;
// }
// break;
// }
// // break;
// }
$data = array(
'model' =>$model,
'horas' => $horas);
// dd(
// // $userPad->pesquisaCoordenacoes->toArray(),
// ($model['extensao']['1. EXTENSÃO (COORDENAÇÃO DE ATIVIDADES DE EXTENSÃO HOMOLOGADA NA PROEC)']),
// // array_values($model['ensino'])[0],
// // array_values($model['ensino'])[0][0],
// // array_values($model['ensino'])[0][0]['cod_atividade'],
// // $ensinoTotalHoras,
// // $model,
// // $horas,
// // $data,
// // $model['ensino']['8. ENSINO (COORDENAÇÃO OU MEMBRO DE NÚCLEO DOCENTE ESTRUTURANTE OU NÚCLEO DOCENTE ESTRUTURANTE ASSISTENCIAL)'] == null,
// // PadTables::tablesEnsino($user_pad_id)[0]['name'],
// // $model,
// // "$dateTime",
// // empty($model['ensino'][0])
// );
view()->share('data', $data);
// return view('pad.teacher.report_pdf');
$pdf = PDF::loadView('pad.teacher.report_pdf', $data);
set_time_limit(300);
return $pdf->download("Relatório PAD: " . $dateTime . ".pdf");
}
}
@extends('layouts.main')
<body>
@section('body')
<header style="display: flex; direction: rtl">
</header>
<div style="display: flex; flex-direction: column; align-items: center;">
<div style="display: flex; flex-direction: column; gap: 4rem">
@foreach ($data['model'] as $nome_dimensao=>$dimensao)
<h3>{{strtoupper($nome_dimensao)}}</h3>
<div>
<h3 style="font-size: 30px;"> Cursos </h3>
</div>
<div>
<table style="border-radius: 10px; background-color: #F2F2F2;
@foreach ($dimensao as $nome_categoria=>$categoria)
@if ($categoria == null)
@continue
@else
<h3>{{$nome_categoria}}</h3>
@foreach ($categoria as $item_name=>$item)
<table style="border-radius: 5px; background-color: #F2F2F2;
min-width: 600px; box-shadow: 2px 2px 2px rgba(0, 0, 0, 0.25); min-height: 50px; ">
<thead class="thead-dark">
<tr>
<th scope="col">Nome</th>
<th scope="col">Campus</th>
</tr>
</thead>
<tbody>
@foreach ($cursos as $curso)
<tr>
<td style="border-top: 1px solid #000; border-right: 1px solid #000; border-bottom: 1px solid #000; vertical-align: middle">{{ $curso->name }}</td>
<td style="border-top: 1px solid #000; border-left: 1px solid #000; border-bottom: 1px solid #000; vertical-align: middle">{{ $curso->campus }}</td>
</tr>
@foreach ($item as $value_name=>$value)
@if ($value_name == "id" ||
$value_name == "user_pad_id" ||
$value_name == "dimensao" ||
$value_name == "created_at" ||
$value_name == "updated_at" ||
$value_name == "deleted_at"
)
@continue
@elseif ($value_name == 'atividade' || $value_name == 'cod_dimensao')
@if ('1. EXTENSÃO (COORDENAÇÃO DE ATIVIDADES DE EXTENSÃO HOMOLOGADA NA PROEC)' == $nome_categoria)
@continue
@endif
@else
<th class="p-1.5 text-black" scope="col">
{{$value_name}}
</th>
@endif
@endforeach
</tbody>
</table>
</div>
<div>
<h3 style="font-size: 30px;"> Cursos </h3>
</div>
<div>
<table style="border-radius: 10px; background-color: #F2F2F2;
min-width: 600px; box-shadow: 2px 2px 2px rgba(0, 0, 0, 0.25); min-height: 50px; ">
<thead class="thead-dark">
<tr>
<th scope="col">Nome</th>
<th scope="col">Campus</th>
</tr>
</thead>
<tbody>
@foreach ($cursos as $curso)
<tr>
<td style="border-top: 1px solid #000; border-right: 1px solid #000; border-bottom: 1px solid #000; vertical-align: middle">{{ $curso->name }}</td>
<td style="border-top: 1px solid #000; border-left: 1px solid #000; border-bottom: 1px solid #000; vertical-align: middle">{{ $curso->campus }}</td>
</tr>
@foreach ($item as $value_name=>$value)
@if ($value_name == "id" ||
$value_name == "user_pad_id" ||
$value_name == "dimensao" ||
$value_name == "created_at" ||
$value_name == "updated_at" ||
$value_name == "deleted_at"
)
@continue
@elseif ($value_name == 'atividade' || $value_name == 'cod_dimensao')
@if ('1. EXTENSÃO (COORDENAÇÃO DE ATIVIDADES DE EXTENSÃO HOMOLOGADA NA PROEC)' == $nome_categoria)
@continue
@endif
@elseif ($value_name == "nivel")
@if ($value == 1)
<td style="border-top: 1px solid #000; border-right: 1px solid #000; border-bottom: 1px solid #000; vertical-align: middle; padding: 0.7rem">
Graduação
</td>
@elseif ($value == 2)
<td style="border-top: 1px solid #000; border-right: 1px solid #000; border-bottom: 1px solid #000; vertical-align: middle; padding: 0.7rem">
Pós Graduação Lato Sensu
</td>
@elseif ($value == 3)
<td style="border-top: 1px solid #000; border-right: 1px solid #000; border-bottom: 1px solid #000; vertical-align: middle; padding: 0.7rem">
Pós Graduação Stricto Sensu
</td>
@endif
@elseif ($value_name == "modalidade")
@if ($value == 1)
<td style="border-top: 1px solid #000; border-right: 1px solid #000; border-bottom: 1px solid #000; vertical-align: middle; padding: 0.7rem">
EAD
</td>
@elseif ($value == 2)
<td style="border-top: 1px solid #000; border-right: 1px solid #000; border-bottom: 1px solid #000; vertical-align: middle; padding: 0.7rem">
Presencial
</td>
@endif
@elseif ($value_name == "funcao")
@if ($value == 1)
<td style="border-top: 1px solid #000; border-right: 1px solid #000; border-bottom: 1px solid #000; vertical-align: middle; padding: 0.7rem">
Coordenador
</td>
@elseif ($value == 2)
<td style="border-top: 1px solid #000; border-right: 1px solid #000; border-bottom: 1px solid #000; vertical-align: middle; padding: 0.7rem">
Colaborador
</td>
@elseif ($value == 4)
<td style="border-top: 1px solid #000; border-right: 1px solid #000; border-bottom: 1px solid #000; vertical-align: middle; padding: 0.7rem">
Orientador
</td>
@elseif ($value == 5)
<td style="border-top: 1px solid #000; border-right: 1px solid #000; border-bottom: 1px solid #000; vertical-align: middle; padding: 0.7rem">
Co-Orientador
</td>
@elseif ($value == 6)
<td style="border-top: 1px solid #000; border-right: 1px solid #000; border-bottom: 1px solid #000; vertical-align: middle; padding: 0.7rem">
Membro
</td>
@endif
@elseif ($value_name == "natureza")
@if ($value == 1)
<td style="border-top: 1px solid #000; border-right: 1px solid #000; border-bottom: 1px solid #000; vertical-align: middle; padding: 0.7rem">
Inovação
</td>
@elseif ($value == 2)
<td style="border-top: 1px solid #000; border-right: 1px solid #000; border-bottom: 1px solid #000; vertical-align: middle; padding: 0.7rem">
Pedagogia
</td>
@elseif ($value == 4)
<td style="border-top: 1px solid #000; border-right: 1px solid #000; border-bottom: 1px solid #000; vertical-align: middle; padding: 0.7rem">
Vivência
</td>
@elseif ($value == 5)
<td style="border-top: 1px solid #000; border-right: 1px solid #000; border-bottom: 1px solid #000; vertical-align: middle; padding: 0.7rem">
Outros
</td>
@endif
@else
<td style="border-top: 1px solid #000; border-right: 1px solid #000; border-bottom: 1px solid #000; vertical-align: middle; padding: 0.7rem">
{{$value}}
</td>
@endif
@endforeach
</tbody>
</table>
</div>
<div>
<h3 style="font-size: 30px;"> Cursos </h3>
</div>
<div>
<table style="border-radius: 10px; background-color: #F2F2F2;
min-width: 600px; box-shadow: 2px 2px 2px rgba(0, 0, 0, 0.25); min-height: 50px; ">
<thead class="thead-dark">
<tr>
<th scope="col">Nome</th>
<th scope="col">Campus</th>
</tr>
</thead>
<tbody>
@foreach ($cursos as $curso)
<tr>
<td style="border-top: 1px solid #000; border-right: 1px solid #000; border-bottom: 1px solid #000; vertical-align: middle">{{ $curso->name }}</td>
<td style="border-top: 1px solid #000; border-left: 1px solid #000; border-bottom: 1px solid #000; vertical-align: middle">{{ $curso->campus }}</td>
</tr>
@endforeach
</tbody>
</table>
</div>
<div>
<h3 style="font-size: 30px;"> Cursos </h3>
</div>
<div>
<div style="height: 3rem"></div>
@endforeach
<div style="height: 1.5rem"></div>
@endif
@endforeach
<table style="border-radius: 10px; background-color: #F2F2F2;
min-width: 600px; box-shadow: 2px 2px 2px rgba(0, 0, 0, 0.25); min-height: 50px; ">
min-width: 600px; box-shadow: 2px 2px 2px rgba(0, 0, 0, 0.25);
min-height: 50px;">
<thead class="thead-dark">
<tr>
<th scope="col">Nome</th>
<th scope="col">Campus</th>
<th style="text-align: center" scope="col">TOTAL DE HORAS</th>
</tr>
</thead>
<tbody>
@foreach ($cursos as $curso)
<tr>
<td style="border-top: 1px solid #000; border-right: 1px solid #000; border-bottom: 1px solid #000; vertical-align: middle">{{ $curso->name }}</td>
<td style="border-top: 1px solid #000; border-left: 1px solid #000; border-bottom: 1px solid #000; vertical-align: middle">{{ $curso->campus }}</td>
<td style="text-align: center; border-top: 1px solid #000; border-right: 1px solid #000; border-bottom: 1px solid #000; vertical-align: middle">
{{ $data['horas'][$nome_dimensao] }}
</td>
</tr>
@endforeach
</tbody>
</table>
</div>
@endforeach
</div>
<footer style="padding-top: 0.75rem; margin-top: 0.75rem; text-align: center; border-top: 1px">
Copyright &copy;2022. Universidade de Pernambuco - Todos os direitos reservados
</footer>
</body>
@endsection
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