Commit 405be36e1f4b02a34feadd254d79140862d85a20

Authored by Wilmer
1 parent bf218899c7
Exists in master

añadir mensajes notificando la vigencia del PIDA y actualizando el estatus si está vencido

Showing 1 changed file with 8 additions and 1 deletions   Show diff stats
src/AppBundle/Controller/AppController.php
... ... @@ -70,7 +70,14 @@ class AppController extends Controller {
70 70 if($caducidad){
71 71 //saber si el pida actual caducó
72 72 $hoy = new \DateTime("now");
73   - $vencido = (($hoy->diff($caducidad->getFechaFinal())->invert ? true : false));
  73 + $tiempo = ($hoy->diff($caducidad->getFechaFinal()));
  74 + if($tiempo->format('%a%') <= 60 && $tiempo->format('%a%') >= 30){
  75 + $this->addFlash('warning', 'Estimado docente su PIDA estará vigente sólo por ' . $tiempo->format('%a%') . ' días más' );
  76 + }else if($tiempo->format('%a%') <= 29){
  77 + $this->addFlash('danger', 'Estimado docente dentro de ' . $tiempo->format('%a%') . ' días su PIDA caducará y deberá crear uno nuevo');
  78 + }
  79 + //var_dump($tiempo); die;
  80 + $vencido = ($tiempo->invert ? true : false);
74 81 if($vencido){
75 82 $pida->setIdEstatus($this->getDoctrine()->getRepository("AppBundle:Estatus")->findOneById(5));
76 83 $em->persist($pida);
... ...