Commit 10734f70 authored by PedroLopesUPE's avatar PedroLopesUPE
Browse files

back-end de geração de PDF

Infelizmente alguns nomes das seções das dimensões não casam com a ordem do array a ser enviado ao front.
parent abfa732f
...@@ -7,6 +7,7 @@ use App\Models\Curso; ...@@ -7,6 +7,7 @@ use App\Models\Curso;
use App\Models\User; use App\Models\User;
use App\Models\UserPad; use App\Models\UserPad;
use App\Models\Util\Status; use App\Models\Util\Status;
use App\Models\Util\PadTables;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Support\Facades\Response; use Illuminate\Support\Facades\Response;
use Illuminate\Support\Facades\Validator; use Illuminate\Support\Facades\Validator;
...@@ -79,14 +80,53 @@ class UserPadController extends Controller ...@@ -79,14 +80,53 @@ class UserPadController extends Controller
return Response::json(['errors' => $validator->errors(), 'status' => 400]); return Response::json(['errors' => $validator->errors(), 'status' => 400]);
} }
public function generatePDF($user_pad_id) { public function generatePDF($user_pad_id)
$model = UserPad::whereId($user_pad_id)->first(); {
dd($model->ensinoAulas, $model, empty($model)); $userPad = UserPad::whereId($user_pad_id)->first();
// return view('pad.teacher.report_pdf', ['cursos' => $data]); $model['ensino'] =
dd($user_pad_id); [PadTables::tablesEnsino($user_pad_id)[4]['name'] => $userPad->ensinoAtendimentoDiscentes->all(),
view()->share($user_pad_id); PadTables::tablesEnsino($user_pad_id)[0]['name'] => $userPad->ensinoAulas->all(),
$pdf = PDF::loadView('', compact('pad')); PadTables::tablesEnsino($user_pad_id)[1]['name'] => $userPad->ensinoCoordenacaoRegencias->all(),
return $pdf->download("Relatório PAD ({toDateTimeString({{now()->format('d-m-Y')}})})"); 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()
];
$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()
];
$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()
];
$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()
];
$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: ");
} }
} }
...@@ -114,7 +114,102 @@ class UserPad extends Model ...@@ -114,7 +114,102 @@ class UserPad extends Model
/* /*
* @RELATIONS (relações entre tarefas) * @RELATIONS (relações entre tarefas)
*/ */
public function ensinoAtendimentoDiscentes() {
return $this->hasMany(ensinoAtendimentoDiscente::class, 'user_pad_id', 'id');
}
public function ensinoAulas() { public function ensinoAulas() {
return $this->hasMany(EnsinoAula::class, 'user_pad_id', 'id'); return $this->hasMany(EnsinoAula::class, 'user_pad_id', 'id');
} }
public function ensinoCoordenacaoRegencias() {
return $this->hasMany(EnsinoCoordenacaoRegencia::class, 'user_pad_id', 'id');
}
public function ensinoMembroDocentes() {
return $this->hasMany(EnsinoMembroDocente::class, 'user_pad_id', 'id');
}
public function ensinoOrientacoes() {
return $this->hasMany(EnsinoOrientacao::class, 'user_pad_id', 'id');
}
public function ensinoOutros() {
return $this->hasMany(EnsinoOutros::class, 'user_pad_id', 'id');
}
public function ensinoParticipacoes() {
return $this->hasMany(EnsinoParticipacao::class, 'user_pad_id', 'id');
}
public function ensinoProjetos() {
return $this->hasMany(EnsinoProjeto::class, 'user_pad_id', 'id');
}
public function ensinoSupervisoes() {
return $this->hasMany(EnsinoSupervisao::class, 'user_pad_id', 'id');
}
public function extensaoCoordenacoes() {
return $this->hasMany(ExtensaoCoordenacao::class, 'user_pad_id', 'id');
}
public function extensaoOrientacoes() {
return $this->hasMany(ExtensaoOrientacao::class, 'user_pad_id', 'id');
}
public function extensaoOutros() {
return $this->hasMany(ExtensaoOutros::class, 'user_pad_id', 'id');
}
public function gestaoCoordenacaoLaboratoriosDidaticos() {
return $this->hasMany(GestaoCoordenacaoLaboratoriosDidaticos::class, 'user_pad_id', 'id');
}
public function gestaoCoordenacaoProgramasInstitucionais() {
return $this->hasMany(GestaoCoordenacaoProgramaInstitucional::class, 'user_pad_id', 'id');
}
public function gestaoMembroCamaras() {
return $this->hasMany(GestaoMembroCamaras::class, 'user_pad_id', 'id');
}
public function gestaoMembroComissoes() {
return $this->hasMany(GestaoMembroComissao::class, 'user_pad_id', 'id');
}
public function gestaoMembroConselhos() {
return $this->hasMany(GestaoMembroConselho::class, 'user_pad_id', 'id');
}
public function gestaoMembroTitularConselhos() {
return $this->hasMany(GestaoMembroTitularConselho::class, 'user_pad_id', 'id');
}
public function gestaoOutros() {
return $this->hasMany(GestaoOutros::class, 'user_pad_id', 'id');
}
public function gestaoRepresentanteUnidadeEducacoes() {
return $this->hasMany(GestaoRepresentanteUnidadeEducacao::class, 'user_pad_id', 'id');
}
public function pesquisaCoordenacoes() {
return $this->hasMany(PesquisaCoordeacao::class, 'user_pad_id', 'id');
}
public function pesquisaLiderancas() {
return $this->hasMany(PesquisaLideranca::class, 'user_pad_id', 'id');
}
public function pesquisaOrientacoes() {
return $this->hasMany(PesquisaOrientacao::class, 'user_pad_id', 'id');
}
public function pesquisaOutros() {
return $this->hasMany(PesquisaOutros::class, 'user_pad_id', 'id');
}
} }
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