示例#1
0
 public function doLoad(ObjectManager $manager)
 {
     $admin = $this->getReference('admin');
     $generalManager = $this->getReference('generalManager');
     $created = $this->getReference('created');
     $scheduledInterview = $this->getReference('scheduledInterview');
     $interviewPassed = $this->getReference('interviewPassed');
     $scheduledWrittenExam = $this->getReference('scheduledWrittenExam');
     $writtenExamPassed = $this->getReference('writtenExamPassed');
     $juniorPHPDevApplicant1 = new Applicant();
     $juniorPHPDevApplicant1->setApplicationDate(new \DateTime());
     $juniorPHPDevApplicant1->setName('Indrek Hralga');
     $juniorPHPDevApplicant1->setEmail('*****@*****.**');
     $juniorPHPDevApplicant1->setKeywords('php, junior');
     $juniorPHPDevApplicant1->setPhoneNumber('+3670');
     $juniorPHPDevApplicant1->setJobPosition($this->getReference('juniorPHPDeveloper'));
     $juniorPHPDevApplicant1->setCreatedUser($admin);
     $juniorPHPDevApplicant1->addState($this->createApplicantState($created, $admin, $juniorPHPDevApplicant1));
     $juniorPHPDevApplicant1->addState($this->createApplicantState($scheduledInterview, $admin, $juniorPHPDevApplicant1, 'Interview has been scheduled'));
     $juniorPHPDevApplicant2 = new Applicant();
     $juniorPHPDevApplicant2->setApplicationDate(new \DateTime());
     $juniorPHPDevApplicant2->setName('Adrzej Sapkowski');
     $juniorPHPDevApplicant2->setEmail('*****@*****.**');
     $juniorPHPDevApplicant2->setKeywords('php, junior, javascript');
     $juniorPHPDevApplicant2->setPhoneNumber('003670');
     $juniorPHPDevApplicant2->setJobPosition($this->getReference('juniorPHPDeveloper'));
     $juniorPHPDevApplicant2->setCreatedUser($admin);
     $juniorPHPDevApplicant2->addState($this->createApplicantState($created, $admin, $juniorPHPDevApplicant2));
     $juniorPHPDevApplicant2->addState($this->createApplicantState($scheduledWrittenExam, $admin, $juniorPHPDevApplicant2, 'Matches requirements, scheduled interview'));
     $juniorPHPDevApplicant2->addState($this->createApplicantState($writtenExamPassed, $admin, $juniorPHPDevApplicant2, 'Did a great job'));
     $seniorPHPDevApplicant = new Applicant();
     $seniorPHPDevApplicant->setApplicationDate(new \DateTime());
     $seniorPHPDevApplicant->setName('Arkagyij Sztrugackij');
     $seniorPHPDevApplicant->setEmail('*****@*****.**');
     $seniorPHPDevApplicant->setKeywords('php, senior, javascript, symfony1.2, symfony2');
     $seniorPHPDevApplicant->setPhoneNumber('003630');
     $seniorPHPDevApplicant->setJobPosition($this->getReference('seniorPHPDeveloper'));
     $seniorPHPDevApplicant->setCreatedUser($generalManager);
     $seniorPHPDevApplicant->addState($this->createApplicantState($created, $generalManager, $seniorPHPDevApplicant));
     $seniorPHPDevApplicant->addState($this->createApplicantState($scheduledWrittenExam, $generalManager, $seniorPHPDevApplicant));
     $seniorPHPDevApplicant->addState($this->createApplicantState($writtenExamPassed, $generalManager, $seniorPHPDevApplicant, 'Passed easily'));
     $seniorPHPDevApplicant->addState($this->createApplicantState($scheduledInterview, $generalManager, $seniorPHPDevApplicant));
     $seniorPHPDevApplicant->addState($this->createApplicantState($interviewPassed, $generalManager, $seniorPHPDevApplicant, 'Did a great job, he should be hired'));
     $manager->persist($juniorPHPDevApplicant1);
     $manager->persist($juniorPHPDevApplicant2);
     $manager->persist($seniorPHPDevApplicant);
     $manager->flush();
 }
示例#2
0
 /**
  * Method to create job application from outside of application
  *
  * @Route("/job/application/{token}", name="OpitOpitHrmHiringBundle_job_application", requirements={ "token" })
  * @Template()
  * @throws AccessDeniedException
  */
 public function externalJobApplicationAction(Request $request)
 {
     $entityManager = $this->getDoctrine()->getManager();
     $errors = array();
     $token = $request->attributes->get('token');
     $jobPosition = $entityManager->getRepository('OpitOpitHrmHiringBundle:JobPosition')->findOneByExternalToken($token);
     if (null === $jobPosition || false === $jobPosition->getIsActive()) {
         throw new AccessDeniedException('Job position (' . $jobPosition->getJobTitle() . ') is no longer active.');
     }
     $applicant = new Applicant();
     $applicant->setJobPosition($jobPosition);
     $applicant->setApplicationDate(new \DateTime());
     $form = $this->createForm(new ExternalApplicantType(), $applicant, array('em' => $entityManager));
     if ($request->isMethod('POST')) {
         $form->handleRequest($request);
         if ($form->isValid()) {
             // If new applicant is being added
             // check if applicant has already been added to jp with same email or phone number.
             // Check after form is valid to make sure all data is present.
             if ($entityManager->getRepository('OpitOpitHrmHiringBundle:Applicant')->findByEmailPhoneNumber($applicant) > 0) {
                 $form->addError(new FormError('Email or phone number has been already registered for this job position.'));
                 $errors = Utils::getErrorMessages($form);
             } else {
                 $entityManager->persist($applicant);
                 $entityManager->flush();
                 // Send email to applicant
                 $this->get('opit.manager.external_application_email_manager')->sendExternalApplicantMail($jobPosition, $applicant);
                 // Add created status to applicant and send email about it
                 $status = $this->get('opit.manager.applicant_status_manager')->addStatus($applicant, Status::CREATED, null);
                 // Send a notification about new applicant
                 $this->get('opit.manager.applicant_notification_manager')->addNewApplicantNotification($applicant, $status);
                 return $this->render('OpitOpitHrmHiringBundle:Default:externalApplicationSuccessful.html.twig', array('jobPosition' => $jobPosition));
             }
         } else {
             $errors = Utils::getErrorMessages($form);
         }
     }
     return $this->render('OpitOpitHrmHiringBundle:Default:externalApplication.html.twig', array('jobPosition' => $jobPosition, 'errors' => $errors, 'form' => $form->createView()));
 }