public function testSetInterview()
 {
     $application = new Application();
     $interview = new Interview();
     $application->setInterview($interview);
     $this->assertEquals($interview, $application->getInterview());
 }
Example #2
0
 /**
  * Shows and handles the submission of the schedule interview form.
  * This method can also send an email to the applicant with the info from the submitted form.
  *
  * @param Request $request
  * @param Application $application
  * @return \Symfony\Component\HttpFoundation\Response
  */
 public function scheduleAction(Request $request, Application $application)
 {
     $interview = $application->getInterview();
     // Only admin and above, or the assigned interviewer should be able to book an interview
     if (!$this->get('security.authorization_checker')->isGranted('ROLE_SUPER_ADMIN') && !$interview->isInterviewer($this->getUser())) {
         throw $this->createAccessDeniedException();
     }
     // Set the default data for the form
     $defaultData = array('datetime' => $interview->getScheduled(), 'message' => 'Hei, vi har satt opp et intervju for deg angående opptak til vektorprogrammet. ' . 'Vennligst gi beskjed til meg hvis tidspunktet ikke passer.', 'from' => $interview->getInterviewer()->getEmail(), 'to' => $interview->getUser()->getEmail());
     $form = $this->createForm(new ScheduleInterviewType(), $defaultData);
     $form->handleRequest($request);
     if ($form->isValid()) {
         $data = $form->getData();
         // Update the scheduled time for the interview
         $interview->setScheduled($data['datetime']);
         $em = $this->getDoctrine()->getManager();
         $em->persist($interview);
         $em->flush();
         // Send email if the send button was clicked
         if ($form->get('saveAndSend')->isClicked()) {
             $mailer = $this->get('mailer');
             $message = \Swift_Message::newInstance()->setSubject('Intervju for vektorprogrammet')->setFrom('*****@*****.**')->setTo($data['to'])->setReplyTo($data['from'])->setBody($this->renderView('interview/email.html.twig', array('message' => $data['message'], 'datetime' => $data['datetime'], 'fromName' => $interview->getInterviewer()->getFirstName() . " " . $interview->getInterviewer()->getLastName(), 'fromMail' => $data['from'], 'fromPhone' => $interview->getInterviewer()->getPhone())), 'text/html');
             $mailer->send($message);
         }
         return $this->redirect($this->generateUrl('admissionadmin_show', array('status' => 'assigned')));
     }
     return $this->render('interview/schedule.html.twig', array('form' => $form->createView(), 'interview' => $interview, 'application' => $application));
 }