Commit 96a9096d authored by PedroLopesUPE's avatar PedroLopesUPE
Browse files

Adição de dados do usuário na geração de PDF e re-estilização do PDF gerado

Incompatibilidade da biblioteca encontrado: Algum processo dificulta a geração de imagens e textos em mesma linha ao carregar HTML.
parent 42f3737c
...@@ -111,6 +111,11 @@ class UserPadController extends Controller ...@@ -111,6 +111,11 @@ class UserPadController extends Controller
public function generatePDF($user_pad_id) public function generatePDF($user_pad_id)
{ {
$user_id = UserPad::wherePadId($user_pad_id)->first()->{'id'};
$user_data = [
'nome' => User::whereId($user_id)->first()->{'name'},
'email' => User::whereId($user_id)->first()->{'email'}
];
$ensinoTotalHoras = $ensinoTotalHoras =
EnsinoAtendimentoDiscente::whereUserPadId($user_pad_id)->sum('ch_semanal') EnsinoAtendimentoDiscente::whereUserPadId($user_pad_id)->sum('ch_semanal')
+ EnsinoAula::whereUserPadId($user_pad_id)->sum('ch_semanal') + EnsinoAula::whereUserPadId($user_pad_id)->sum('ch_semanal')
...@@ -183,7 +188,6 @@ class UserPadController extends Controller ...@@ -183,7 +188,6 @@ class UserPadController extends Controller
PadTables::tablesPesquisa($user_pad_id)[2]['name'] => $userPad->pesquisaOrientacoes->toArray(), PadTables::tablesPesquisa($user_pad_id)[2]['name'] => $userPad->pesquisaOrientacoes->toArray(),
PadTables::tablesPesquisa($user_pad_id)[3]['name'] => $userPad->pesquisaOutros->toArray() PadTables::tablesPesquisa($user_pad_id)[3]['name'] => $userPad->pesquisaOutros->toArray()
]; ];
$dateTime = now()->format('d-m-Y (H:i:s)');
// Geração de array tratado a partir do modelo // Geração de array tratado a partir do modelo
$treated_model = []; $treated_model = [];
...@@ -373,21 +377,29 @@ class UserPadController extends Controller ...@@ -373,21 +377,29 @@ class UserPadController extends Controller
} }
} }
date_default_timezone_set("America/Recife");
$dateTime = now()->format('d/m/Y (H:i:s)');
$data = array( $data = array(
'model' =>$treated_model, 'date' => $dateTime,
'user' => $user_data,
'model' => $treated_model,
'horas' => $horas 'horas' => $horas
); );
// $treated_model = Arr::add($treated_model, '1.2.4. Ensino', "Abc");
// dd( // dd(
// // $userPad->pesquisaCoordenacoes->toArray(), // // $userPad->pesquisaCoordenacoes->toArray(),
// // ($model['extensao']['1. EXTENSÃO (COORDENAÇÃO DE ATIVIDADES DE EXTENSÃO HOMOLOGADA NA PROEC)']), // // ($model['extensao']['1. EXTENSÃO (COORDENAÇÃO DE ATIVIDADES DE EXTENSÃO HOMOLOGADA NA PROEC)']),
// public_path('images\estado_pe_logo.png'), // // public_path('\images\estado_pe_logo.png'),
// // url('images\estado_pe_logo.png'),
// // asset('images\estado_pe_logo.png'),
// $user_data,
// $treated_model, // $treated_model,
// // array_values($model['ensino'])[0], // // array_values($model['ensino'])[0],
// // array_values($model['ensino'])[0][0], // // array_values($model['ensino'])[0][0],
// // array_values($model['ensino'])[0][0]['cod_atividade'], // // array_values($model['ensino'])[0][0]['cod_atividade'],
// // $ensinoTotalHoras, // // $ensinoTotalHoras,
// $model, // // $model,
// // $horas, // // $horas,
// // $data, // // $data,
// // $model['ensino']['8. ENSINO (COORDENAÇÃO OU MEMBRO DE NÚCLEO DOCENTE ESTRUTURANTE OU NÚCLEO DOCENTE ESTRUTURANTE ASSISTENCIAL)'] == null, // // $model['ensino']['8. ENSINO (COORDENAÇÃO OU MEMBRO DE NÚCLEO DOCENTE ESTRUTURANTE OU NÚCLEO DOCENTE ESTRUTURANTE ASSISTENCIAL)'] == null,
......
<header style="display: flex; direction: rtl">
</header>
<div style="display: flex; flex-direction: column; gap: 2.5rem"> <body style="width: 210mm; display: flex; flex-direction: column; max-width: 190mm">
@foreach ($data['model'] as $nome_dimensao=>$dimensao) <header style="display: flex; flex-direction: row; padding: 3mm 4mm 0mm 4mm">
<h1 style="font-size: 16px; font-weight: bold"> <img style="width: 300px; height: max-content; align-self: center" src="{{public_path('images\estado_pe_logo.png')}}" alt="Logo Pernambuco">
{{$nome_dimensao}} <div style="display: flex; flex-direction: column; max-width: 100mm">
</h1> <p style="margin: 1.1mm"><span>Autor do PAD: {{$data['user']['nome']}}</span></p>
<div> <p style="margin: 1.1mm"><span>E-mail do Autor: {{$data['user']['email']}}</span></p>
@foreach ($dimensao as $nome_categoria=>$categoria) <p style="margin: 1.1mm"><span>PDF gerado em: {{$data['date']}}</span></p>
<h4 style="font-size: 14px"> </div>
{{$nome_categoria}} </header>
</h4>
<div style="display: flex; flex-direction: column; padding-left:5mm; gap: 10mm">
@foreach ($categoria as $nome_item=>$item) @foreach ($data['model'] as $nome_dimensao=>$dimensao)
<ul style="font-size: 14px"> <h1 style="font-size: 16px; font-weight: bold">
@foreach ($item as $nome_tarefa=>$tarefa) {{$nome_dimensao}}
<li style="font-weight: bold"> </h1>
{{$nome_tarefa}} @foreach ($dimensao as $nome_categoria=>$categoria)
</li> <h4 style="font-size: 14px">
<ul style="font-size: 13px"> {{$nome_categoria}}
@foreach ($tarefa as $nome_valor=>$valor) </h4>
<li>
{{$nome_valor}}: {{$valor}} @foreach ($categoria as $nome_item=>$item)
</li> <ul style="font-size: 14px">
@endforeach @foreach ($item as $nome_tarefa=>$tarefa)
<li style="font-weight: bold">
{{$nome_tarefa}}
</li>
<ul style="font-size: 13px">
@foreach ($tarefa as $nome_valor=>$valor)
<li>
{{$nome_valor}}: {{$valor}}
</li>
@endforeach
</ul>
@endforeach
</ul> </ul>
@endforeach <div style="height: 6mm"></div>
</ul> @endforeach
<div style="height: 1.5rem"></div> <div style="height: 4.5mm"></div>
@endforeach @endforeach
<div style="height: 1rem"></div> <ul style="font-size: 14px; list-style-type: square">
<li>TOTAL DE HORAS: {{ $data['horas'][$nome_dimensao] }}</li>
</ul>
</div>
@endforeach @endforeach
<ul style="font-size: 14px; list-style-type: square">
<li>TOTAL DE HORAS: {{ $data['horas'][$nome_dimensao] }}</li>
</ul>
</div> </div>
@endforeach <footer style="padding-top: 4mm; margin-top: 4mm; border-top: 1px solid #000; text-align: center;">
</div> <u>
\ No newline at end of file Copyright &copy;2022. Universidade de Pernambuco - Todos os direitos reservados
</u>
</footer>
</body>
\ No newline at end of file
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