コード例 #1
0
 /**
  * Function to send email to applicant about successfull application for job
  *
  * @param \Opit\OpitHrm\HiringBundle\Entity\JobPosition $jobPosition
  * @param \Opit\OpitHrm\HiringBundle\Entity\Applicant $applicant
  */
 public function sendExternalApplicantMail(JobPosition $jobPosition, Applicant $applicant)
 {
     $templateVars = array();
     $templateVars['jobPosition'] = $jobPosition;
     $templateVars['applicant'] = $applicant;
     $this->mailer->setRecipient($applicant->getEmail());
     $this->mailer->setSubject('[OPIT-HRM] - Successfully applied for ' . $jobPosition->getJobTitle() . ' (' . $jobPosition->getJobPositionId() . ')');
     $this->mailer->setBodyByTemplate('OpitOpitHrmHiringBundle:Mail:externalApplicationSuccessful.html.twig', $templateVars);
     $this->mailer->sendMail();
 }
コード例 #2
0
 /**
  * 
  * @param \Opit\OpitHrm\HiringBundle\Entity\Applicant $applicant
  */
 public function addNewApplicantNotification(Applicant $applicant, Status $status)
 {
     $statusName = strtolower($status->getName());
     $message = 'State of applicant (' . $applicant->getName() . ') changed to ' . $statusName . '.';
     $notification = new ApplicantNotification();
     $notification->setApplicant($applicant);
     $receiver = $applicant->getJobPosition()->getHiringManager();
     $notification->setMessage($message);
     $notification->setReceiver($receiver);
     $notification->setDateTime(new \DateTime('now'));
     $notification->setRead($this->entityManager->getRepository('OpitOpitHrmNotificationBundle:NotificationStatus')->find(NotificationStatus::UNREAD));
     $this->entityManager->persist($notification);
     $this->entityManager->flush();
 }
コード例 #3
0
ファイル: ApplicantFixture.php プロジェクト: hkmshb/OpitHrm
 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();
 }
コード例 #4
0
ファイル: DefaultController.php プロジェクト: hkmshb/OpitHrm
 /**
  * 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()));
 }
コード例 #5
0
 /**
  * To add/edit applicant in OPIT-HRM
  *
  * @Route("/secured/applicant/show/{id}", name="OpitOpitHrmHiringBundle_applicant_show", defaults={"id" = "new"}, requirements={ "id" = "new|\d+"})
  * @Secure(roles="ROLE_TEAM_MANAGER")
  * @Method({"GET", "POST"})
  * @Template()
  * @throws AccessDeniedException
  */
 public function showApplicantAction(Request $request)
 {
     $entityManager = $this->getDoctrine()->getManager();
     $applicantId = $request->attributes->get('id');
     $jobPositionId = $request->query->get('jobPositionId');
     $isNewApplicant = 'new' === $applicantId;
     $securityContext = $this->container->get('security.context');
     $isTeamManager = $securityContext->isGranted('ROLE_TEAM_MANAGER');
     $statusManager = $this->get('opit.manager.applicant_status_manager');
     $entityManager->getFilters()->disable('softdeleteable');
     $currentUser = $securityContext->getToken()->getUser();
     $isEditable = true;
     $isStatusLocked = false;
     $errors = array();
     $nextStates = array();
     $applicantCV = '';
     if (!$isTeamManager) {
         throw new AccessDeniedException('Access denied for applicant.');
     }
     if ($isNewApplicant) {
         $applicant = new Applicant();
         // If the job position id exists fetch the job position entity and adding to the applicant.
         // The calling was from the job position list page.
         if (null !== $jobPositionId) {
             $jobPosition = $entityManager->getRepository('OpitOpitHrmHiringBundle:JobPosition')->find($jobPositionId);
             $applicant->setJobPosition($jobPosition);
         }
     } else {
         $applicant = $entityManager->getRepository('OpitOpitHrmHiringBundle:Applicant')->find($applicantId);
         $applicantCV = $applicant->getCv();
         $isEditable = ($securityContext->isGranted('ROLE_ADMIN') || $applicant->getCreatedUser() && $applicant->getCreatedUser()->getId() === $currentUser->getId()) && null === $applicant->getJobPosition()->getDeletedAt();
         if (null === $applicant) {
             throw $this->createNotFoundException('Missing applicant.');
         }
     }
     $currentStatus = $statusManager->getCurrentStatusMetaData($applicant);
     if (null === $currentStatus) {
         $currentStatus = $entityManager->getRepository('OpitOpitHrmStatusBundle:Status')->find(Status::CREATED);
         $isStatusLocked = true;
     } else {
         $currentStatus = $statusManager->getCurrentStatus($applicant);
         $nextStates = $statusManager->getNextStates($currentStatus);
         $isStatusFinalized = Status::HIRED === $currentStatus->getId() || Status::REJECTED === $currentStatus->getId();
         $isEditable = $isStatusFinalized ? false : $isEditable;
         $isStatusLocked = $isStatusFinalized ? true : $isStatusLocked;
     }
     $form = $this->createForm(new ApplicantType($isNewApplicant), $applicant, array('em' => $entityManager));
     if ($request->isMethod('POST')) {
         if (!$isEditable) {
             throw new AccessDeniedException('Applicant can not be modified.');
         }
         $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 for is valid to make sure data is present.
             if ($isNewApplicant && $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();
                 if ($isNewApplicant) {
                     $statusManager->addStatus($applicant, Status::CREATED, null);
                 }
                 return $this->redirect($this->generateUrl(null !== $jobPositionId ? 'OpitOpitHrmHiringBundle_job_position_list' : 'OpitOpitHrmHiringBundle_applicant_list'));
             }
         } else {
             $errors = Utils::getErrorMessages($form);
         }
     }
     return $this->render('OpitOpitHrmHiringBundle:Applicant:showApplicant.html.twig', array('form' => $form->createView(), 'isNewApplicant' => $isNewApplicant, 'isEditable' => $isEditable, 'errors' => $errors, 'isStatusLocked' => $isStatusLocked, 'nextStates' => $nextStates, 'currentStatus' => $currentStatus, 'applicantId' => $applicantId, 'applicantCV' => $applicantCV, 'jobPositionId' => $jobPositionId));
 }
コード例 #6
0
 /**
  * Check if applicant with email or phone number has been added to a job position
  * 
  * @param \Opit\OpitHrm\HiringBundle\Entity\Applicant $applicant
  * @return type
  */
 public function findByEmailPhoneNumber(Applicant $applicant)
 {
     $dq = $this->createQueryBuilder('a');
     $dq->select('count(a.id)');
     $dq->innerJoin('a.jobPosition', 'jp');
     $dq->where($dq->expr()->eq('jp.id', ':jpId'));
     $dq->andWhere($dq->expr()->orX($dq->expr()->eq('a.email', ':email'), $dq->expr()->eq('a.phoneNumber', ':phoneNumber')));
     $dq->setParameter(':email', $applicant->getEmail());
     $dq->setParameter(':phoneNumber', $applicant->getPhoneNumber());
     $dq->setParameter(':jpId', $applicant->getJobPosition()->getId());
     return $dq->getQuery()->getSingleScalarResult();
 }