diff --git a/app/Resources/views/base_app.html.twig b/app/Resources/views/base_app.html.twig index 3a0a070..06998b1 100644 --- a/app/Resources/views/base_app.html.twig +++ b/app/Resources/views/base_app.html.twig @@ -191,6 +191,12 @@ }); + //boton para mostrarle al usuario que estamos esperando + $('.btn').on('click', function() { + var $this = $(this); + $this.button('loading'); + }); + {% endblock %} diff --git a/app/Resources/views/solicitudes/adscripcion_show.twig b/app/Resources/views/solicitudes/adscripcion_show.twig index d8e10db..4e8076a 100644 --- a/app/Resources/views/solicitudes/adscripcion_show.twig +++ b/app/Resources/views/solicitudes/adscripcion_show.twig @@ -125,8 +125,6 @@ -
+ {% endblock %} diff --git a/app/config/services.yml b/app/config/services.yml index 5c76fc5..c2deab9 100644 --- a/app/config/services.yml +++ b/app/config/services.yml @@ -4,6 +4,8 @@ parameters: # parameter_name: value services: -# service_name: -# class: AppBundle\Directory\ClassName -# arguments: ["@another_service_name", "plain_value", "%parameter_name%"] + app.form.adscripcion_edit: + class: AppBundle\Form\AdscripcionEditType + arguments: ['@security.token_storage'] + tags: + - { name: form.type } diff --git a/src/AppBundle/Controller/AdscripcionController.php b/src/AppBundle/Controller/AdscripcionController.php index 5d8f74b..52307e7 100644 --- a/src/AppBundle/Controller/AdscripcionController.php +++ b/src/AppBundle/Controller/AdscripcionController.php @@ -578,20 +578,58 @@ class AdscripcionController extends Controller * Encuentra y muestra una entidad de tipo Adscripción para los docentes. * * @Route("/adscripcion_show/{id}", name="adscripcion_show") - * @Method("GET") + * @Method({"GET", "POST"}) * */ - public function adscripcionShowAction(DocenteServicio $servicio) + public function adscripcionShowAction(DocenteServicio $servicio, Request $request) { $em = $this->getDoctrine()->getManager(); $todo = $em->getRepository("AppBundle:RolInstitucion")->findOneById($servicio->getIdRolInstitucion()); + $form = $this->createForm('AppBundle\Form\AdscripcionEditType'); + + + + $form->handleRequest($request); + + + if ($form->isSubmitted() && $form->isValid()) { + + foreach ($form->getData() as $key => $value) { + + //var_dump($key); exit; + $constancia = $form->get($key)->getData(); + $nombre = md5(uniqid()).'.'.$constancia->guessExtension(); + $constancia->move( + $this->container->getParameter('adscripcion_directory'), + $nombre + ); + thumbnail($nombre, $this->container->getParameter('adscripcion_directory'), $this->container->getParameter('adscripcion_thumb_directory')); + + $documento = $this->getDoctrine()->getRepository("AppBundle:DocumentosVerificados")->findOneBy(array( + 'idRolInstitucion' => $servicio->getIdRolInstitucion()->getId(), + 'idTipoDocumentos' => $this->getDoctrine()->getRepository("AppBundle:TipoDocumentos")->findOneByIdentificador($key)->getId(), + 'idEstatus' => 3 + )); + + $documento->setUbicacion($nombre); + $documento->setIdEstatus($this->getDoctrine()->getRepository("AppBundle:Estatus")->findOneById(2)); + $em = $this->getDoctrine()->getManager(); + $em->persist($documento); + $em->flush(); + } + + + + return $this->redirect($this->generateUrl('adscripcion_show', array('id' => $servicio->getId()))); + } return $this->render('solicitudes/adscripcion_show.twig', array( 'servicio' => $servicio, 'servicio' => $servicio, - 'todo' => $todo + 'todo' => $todo, + 'form' => $form->createView() )); } diff --git a/src/AppBundle/Form/AdscripcionEditType.php b/src/AppBundle/Form/AdscripcionEditType.php new file mode 100644 index 0000000..3f80509 --- /dev/null +++ b/src/AppBundle/Form/AdscripcionEditType.php @@ -0,0 +1,91 @@ +tokenStorage = $tokenStorage; + } + + public function buildForm(FormBuilderInterface $builder, array $options) + { + // grab the user, do a quick sanity check that one exists + $user = $this->tokenStorage->getToken()->getUser(); + if (!$user) { + throw new \LogicException( + 'The FriendMessageFormType cannot be used without an authenticated user!' + ); + } + + $builder->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event) use ($user) { + + $form = $event->getForm(); + $existe = false; + foreach ($user->getIdRolInstitucion()->getDocumentosVerificados() as $documentos){ + if($documentos->getIdServicio()->getIdServicioCe()->getId() == 2 && $documentos->getIdEstatus()->getId() == 3){ + $existe = true; + $form->add($documentos->getIdTipoDocumentos()->getIdentificador(), FileType::class, array( + 'label' => $documentos->getIdTipoDocumentos()->getNombre(), + 'constraints' => array( + new NotBlank(), + new File(array( + 'maxSize' => '1024K', + 'mimeTypes' => [ + 'application/pdf', + 'application/x-pdf', + 'image/png', + 'image/jpg', + 'image/jpeg' + ], + 'mimeTypesMessage' => 'Sólo se permiten extensiones png, jpeg y pdf' + )) + ) + )); + + + } + + } + if($existe){ + $form->add('send', SubmitType::class, array( + 'label' => 'Reenviar Documentos Rechazados', + 'attr' => array( + 'class' => 'btn btn-success btn-block', + 'data-loading-text' => " Procesando Solicitud..." + ) + )); + } + + + }); + + } + + + + + +}