Commit 7b31386c05a94671401099e5b950632f2d465e11
Committed by
GitHub
Exists in
2.8
and in
6 other branches
Merge pull request #6501 from portabilis/issue-6451
Roda a promoção na dispensa de componentes do aluno
Showing
1 changed file
with
35 additions
and
0 deletions
Show diff stats
ieducar/intranet/educar_dispensa_disciplina_cad.php
1 | 1 | <?php |
2 | 2 | |
3 | +use App\Models\LegacyRegistration; | |
4 | +use App\Models\LegacySchoolStage; | |
5 | +use App\Services\PromotionService; | |
6 | + | |
3 | 7 | require_once 'include/clsBase.inc.php'; |
4 | 8 | require_once 'include/clsCadastro.inc.php'; |
5 | 9 | require_once 'include/pmieducar/geral.inc.php'; |
... | ... | @@ -9,6 +13,7 @@ require_once 'Avaliacao/Model/NotaComponenteDataMapper.php'; |
9 | 13 | require_once 'Avaliacao/Model/FaltaAlunoDataMapper.php'; |
10 | 14 | require_once 'Avaliacao/Model/FaltaComponenteDataMapper.php'; |
11 | 15 | require_once 'ComponenteCurricular/Model/ComponenteDataMapper.php'; |
16 | +require_once 'modules/Avaliacao/Views/PromocaoApiController.php'; | |
12 | 17 | |
13 | 18 | class clsIndexBase extends clsBase |
14 | 19 | { |
... | ... | @@ -263,6 +268,7 @@ class indice extends clsCadastro |
263 | 268 | return false; |
264 | 269 | } |
265 | 270 | |
271 | + $this->rodaPromocao(); | |
266 | 272 | $this->mensagem .= 'Cadastro efetuado com sucesso.<br />'; |
267 | 273 | $this->simpleRedirect('educar_dispensa_disciplina_lst.php?ref_cod_matricula=' . $this->ref_cod_matricula); |
268 | 274 | |
... | ... | @@ -283,6 +289,7 @@ class indice extends clsCadastro |
283 | 289 | |
284 | 290 | $editou = $objetoDispensa->edita(); |
285 | 291 | if ($editou) { |
292 | + $this->rodaPromocao(); | |
286 | 293 | $this->mensagem .= 'Edição efetuada com sucesso.<br />'; |
287 | 294 | $this->simpleRedirect('educar_dispensa_disciplina_lst.php?ref_cod_matricula=' . $this->ref_cod_matricula); |
288 | 295 | } |
... | ... | @@ -305,6 +312,7 @@ class indice extends clsCadastro |
305 | 312 | $excluiu = $objetoDispensa->excluir(); |
306 | 313 | |
307 | 314 | if ($excluiu) { |
315 | + $this->rodaPromocao(); | |
308 | 316 | $this->mensagem .= 'Exclusão efetuada com sucesso.<br />'; |
309 | 317 | $this->simpleRedirect('educar_dispensa_disciplina_lst.php?ref_cod_matricula=' . $this->ref_cod_matricula); |
310 | 318 | } |
... | ... | @@ -314,6 +322,33 @@ class indice extends clsCadastro |
314 | 322 | return false; |
315 | 323 | } |
316 | 324 | |
325 | + public function maiorEtapaUtilizada($registration) | |
326 | + { | |
327 | + $where = [ | |
328 | + 'ref_ref_cod_escola' => $registration->ref_ref_cod_escola, | |
329 | + 'ref_ano' => $registration->ano, | |
330 | + ]; | |
331 | + | |
332 | + $totalEtapas['total'] = LegacySchoolStage::query()->where($where)->count(); | |
333 | + $arrayEtapas = []; | |
334 | + | |
335 | + for ($i = 1; $i <= $totalEtapas['total']; $i++) | |
336 | + { | |
337 | + $arrayEtapas[$i] = strval($i); | |
338 | + } | |
339 | + | |
340 | + $arrayEtapas = array_diff($arrayEtapas, $this->etapa); | |
341 | + return max($arrayEtapas); | |
342 | + } | |
343 | + | |
344 | + public function rodaPromocao() | |
345 | + { | |
346 | + $registration = LegacyRegistration::find($this->ref_cod_matricula); | |
347 | + $_GET['etapa'] = $this->maiorEtapaUtilizada($registration); | |
348 | + $promocao = new PromotionService($registration->lastEnrollment()->first()); | |
349 | + $promocao->fakeRequest(); | |
350 | + } | |
351 | + | |
317 | 352 | public function montaEtapas() |
318 | 353 | { |
319 | 354 | //Pega matricula para pegar curso, escola e ano | ... | ... |