/** * Formulário de pré-entrevista * * Se a sessão de pré-entrevista não foi criada redireciona para o início da pré-entrevista (indexAction) * Salva o endereço se necessário, responsável se necessário, endereço do responsável se necessário e, é claro, * as informações da pré-entrevista. * * @return ViewModel */ public function studentPreInterviewFormAction() { $this->layout('application-clean/layout'); $studentContainer = new Container('candidate'); // id de inscrição não está na sessão redireciona para o início if (!$studentContainer->offsetExists('regId')) { return $this->redirect()->toRoute('recruitment/pre-interview', array('action' => 'index')); } $rid = $studentContainer->offsetGet('regId'); try { $request = $this->getRequest(); $em = $this->getEntityManager(); $registration = $em->getReference('Recruitment\\Entity\\Registration', $rid); $person = $registration->getPerson(); $options = array('person' => array('relative' => $person->isPersonUnderage(), 'address' => true, 'social_media' => false), 'pre_interview' => true); $form = new PreInterviewForm($em, $options); $form->bind($registration); if ($request->isPost()) { $form->setData($request->getPost()); if ($form->isValid()) { // gestão de duplicação de endereço e parentes $this->adjustAddresses($person); $this->adjustRelatives($person); $this->updateRegistrationStatus($registration, RecruitmentStatus::STATUSTYPE_PREINTERVIEW_COMPLETE); $em->persist($registration); $em->flush(); $studentContainer->getManager()->getStorage()->clear('candidate'); return new ViewModel(array('registration' => null, 'form' => null, 'message' => 'Pré-entrevista concluída com com sucesso. ' . 'O formulário de pré-entrevista continuará disponível para futuras edições até a ' . 'conclusão de sua entrevista.')); } else { return new ViewModel(array('registration' => $registration, 'form' => $form, 'message' => 'Existe(m) algum(ns) campo(s) não preenchido(s).')); } } } catch (Exception $ex) { return new ViewModel(array('registration' => null, 'form' => null, 'message' => 'Erro inesperado. Por favor, entre em contato com o administrador do sistema.')); } return new ViewModel(['registration' => $registration, 'form' => $form, 'message' => '']); }
/** * ??? * * @return ViewModel */ public function studentAction() { $id = $this->params('id', false); $request = $this->getRequest(); if ($id) { try { $em = $this->getEntityManager(); $registration = $em->find('Recruitment\\Entity\\Registration', $id); $person = $registration->getPerson(); $form = new PreInterviewForm($em, array('person' => array('relative' => $person->isPersonUnderage(), 'relative' => false, 'address' => true, 'social_media' => true), 'pre_interview' => $registration->getPreInterview() !== null)); $form->bind($registration); if ($request->isPost()) { $form->setData($request->getPost()); if ($form->isValid()) { $em->merge($registration); $em->flush(); } } return new ViewModel(array('message' => '', 'registration' => $registration, 'form' => $form)); } catch (Exception $ex) { return new ViewModel(array('message' => 'Não foi possível encontrar o registro do candidato: ' . $ex->getMessage(), 'registration' => null)); } } return new ViewModel(array('message' => 'nenhum candidato foi especificado.', 'registration' => null)); }