/**
  * Creates a substitute assistant with the info from the given application.
  * If an interview has been conducted, the work day information is taken from InterviewPractical,
  * if not it is left as null values and can be filled in by manually editing the substitute.
  * This method is intended to be called by an Ajax request.
  *
  * @param Application $application
  * @return JsonResponse
  */
 public function createAction(Application $application)
 {
     // Only admin or team members withing the same department as the applicant can create substitute
     if ($this->get('security.authorization_checker')->isGranted('ROLE_SUPER_ADMIN') || $application->isSameDepartment($this->getUser())) {
         $appStat = $application->getStatistic();
         $intPrac = $appStat->getInterviewPractical();
         $substitute = new Substitute();
         $substitute->setFirstName($application->getFirstName());
         $substitute->setLastName($application->getLastName());
         $substitute->setPhone($application->getPhone());
         $substitute->setEmail($application->getEmail());
         $substitute->setFieldOfStudy($appStat->getFieldOfStudy());
         $substitute->setYearOfStudy($appStat->getYearOfStudy());
         $substitute->setSemester($appStat->getSemester());
         if ($intPrac) {
             $substitute->setMonday($intPrac->getMonday());
             $substitute->setTuesday($intPrac->getTuesday());
             $substitute->setWednesday($intPrac->getWednesday());
             $substitute->setThursday($intPrac->getThursday());
             $substitute->setFriday($intPrac->getFriday());
         }
         $application->setSubstituteCreated(true);
         $em = $this->getDoctrine()->getManager();
         $em->persist($substitute);
         $em->persist($application);
         $em->flush();
         // AJAX response
         $response['success'] = true;
     } else {
         // AJAX response
         $response['success'] = false;
         $response['cause'] = 'Ikke tilstrekkelige rettigheter.';
     }
     return new JsonResponse($response);
 }
 /**
  * Creates a new Application entity.
  *
  */
 public function newAction(Request $request)
 {
     $userId = $request->attributes->get('user');
     $teamId = $request->attributes->get('team');
     $origin = $request->attributes->get('origin');
     $application = new Application();
     $user = $this->getDoctrine()->getRepository('AppBundle:User')->find($userId);
     $team = $this->getDoctrine()->getRepository('AppBundle:Team')->find($teamId);
     $application->setUser($user);
     $application->setTeam($team);
     $application->setOrigin($origin);
     $form = $this->createForm(new ApplicationType(), $application);
     $form->handleRequest($request);
     if ($form->isSubmitted() && $form->isValid()) {
         $em = $this->getDoctrine()->getManager();
         $em->persist($application);
         $em->flush();
         return $this->redirectToRoute('game_show', array('id' => $team->getGame()->getId()));
     }
     return $this->render('AppBundle:application:new.html.twig', array('application' => $application, 'form' => $form->createView()));
 }
 public function testIsSubstituteCreated()
 {
     $application = new Application();
     $application->setSubstituteCreated(true);
     $this->assertEquals(true, $application->getSubstituteCreated());
 }
Exemple #4
0
 /**
  * Add application
  *
  * @param \AppBundle\Entity\Application $application
  *
  * @return Project
  */
 public function addApplication(\AppBundle\Entity\Application $application)
 {
     $this->applications[] = $application;
     $application->setProject($this);
     return $this;
 }
 private function createFakeApplication()
 {
     $app = new Application();
     $baseFaker = \Faker\Factory::create();
     $app->setAmount($baseFaker->biasedNumberBetween(100, 10000));
     $app->setAskDate($baseFaker->dateTime);
     $app->setResponse($this->getRandomResponse());
     $app->setReceivedAmount($baseFaker->biasedNumberBetween(100, 10000));
     $app->setResponseDate($baseFaker->dateTime);
     $app->setStatus($this->getRandomStatus());
     $this->output('create fake application');
     return $app;
 }
Exemple #6
0
 /**
  * @param  Application $application
  */
 public function addApplication(\AppBundle\Entity\Application $application)
 {
     $application->setTeam($this);
     $this->application[] = $application;
 }
    public function checkMultipleApplication(Application $application)
    {
        $team = $application->getTeam()->getId();
        $user = '******' . $application->getUser()->getId();
        $query = $this->em->createQuery('SELECT p
		    FROM AppBundle:Application p
		    WHERE p.team = ' . $team . $user . 'and p.origin=\'team\'');
        $appTeams = $query->getResult();
        $query = $this->em->createQuery('SELECT p
		    FROM AppBundle:Application p
		    WHERE p.team = ' . $team . $user . 'and p.origin=\'player\'');
        $appPlayers = $query->getResult();
        if ($appTeams && $appPlayers) {
            foreach ($appTeams as $appTeam) {
                foreach ($appPlayers as $appPlayer) {
                    if ($appTeam->getTeam() == $appPlayer->getTeam() && $appTeam->getUser() == $appPlayer->getUser()) {
                        $user = $appTeam->getUser();
                        $team = $appTeam->getTeam();
                        $game = $team->getGame();
                        $query = $this->em->createQuery('SELECT p
						    FROM AppBundle:Player p
						    WHERE p.user = '******'and p.game = ' . $game->getId());
                        $players = $query->getResult();
                        $player = $players[0];
                        $player->setTeam($team);
                        $this->em->remove($appTeam);
                        $this->em->remove($appPlayer);
                        $this->em->persist($player);
                        $this->em->flush();
                        return;
                    }
                }
            }
        }
    }
 public function load(ObjectManager $manager)
 {
     $application1 = new Application();
     $application1->setFirstName('Marius');
     $application1->setLastName('Svendsen');
     $application1->setEmail('*****@*****.**');
     $application1->setPhone('95321485');
     $application1->setUserCreated(false);
     $application1->setSubstituteCreated(false);
     $as1 = new ApplicationStatistic();
     $as1->setGender(0);
     $as1->setPreviousParticipation(true);
     $as1->setAccepted(0);
     $as1->setYearOfStudy(1);
     $as1->setFieldOfStudy($this->getReference('fos-1'));
     $as1->setSemester($this->getReference('semester-1'));
     $application1->setStatistic($as1);
     $manager->persist($application1);
     $application2 = new Application();
     $application2->setFirstName('Siri');
     $application2->setLastName('Kristiansen');
     $application2->setEmail('*****@*****.**');
     $application2->setPhone('95254873');
     $application2->setUserCreated(false);
     $application2->setSubstituteCreated(false);
     $as2 = new ApplicationStatistic();
     $as2->setGender(0);
     $as2->setPreviousParticipation(true);
     $as2->setAccepted(0);
     $as2->setYearOfStudy(1);
     $as2->setFieldOfStudy($this->getReference('fos-2'));
     $as2->setSemester($this->getReference('semester-1'));
     $application2->setStatistic($as2);
     $manager->persist($application2);
     $application3 = new Application();
     $application3->setFirstName('Leonardo');
     $application3->setLastName('DiCaprio');
     $application3->setEmail('*****@*****.**');
     $application3->setPhone('95235816');
     $application3->setUserCreated(false);
     $application3->setSubstituteCreated(false);
     $as3 = new ApplicationStatistic();
     $as3->setGender(0);
     $as3->setPreviousParticipation(true);
     $as3->setAccepted(0);
     $as3->setYearOfStudy(1);
     $as3->setFieldOfStudy($this->getReference('fos-2'));
     $as3->setSemester($this->getReference('semester-1'));
     $application3->setStatistic($as3);
     $manager->persist($application3);
     // This application has a conducted interview which takes some code to set up
     $application4 = new Application();
     $application4->setFirstName('Walter');
     $application4->setLastName('White');
     $application4->setEmail('*****@*****.**');
     $application4->setPhone('95254873');
     $application4->setUserCreated(false);
     $application4->setSubstituteCreated(false);
     $as4 = new ApplicationStatistic();
     $as4->setGender(0);
     $as4->setPreviousParticipation(true);
     $as4->setAccepted(0);
     $as4->setYearOfStudy(1);
     $as4->setFieldOfStudy($this->getReference('fos-1'));
     $as4->setSemester($this->getReference('semester-1'));
     $application4->setStatistic($as4);
     // The interview
     $interview4 = new Interview();
     $interview4->setInterviewed(true);
     $interview4->setInterviewer($this->getReference('user-2'));
     $interview4->setInterviewSchema($this->getReference('ischema-1'));
     $interview4->setApplication($application4);
     $application4->setInterview($interview4);
     // Create answer objects for all the questions in the schema
     foreach ($interview4->getInterviewSchema()->getInterviewQuestions() as $interviewQuestion) {
         $answer = new InterviewAnswer();
         $answer->setAnswer("Test answer");
         $answer->setInterview($interview4);
         $answer->setInterviewQuestion($interviewQuestion);
         $interview4->addInterviewAnswer($answer);
     }
     // The interview score
     $intScore = new InterviewScore();
     $intScore->setDrive(3);
     $intScore->setExplanatoryPower(3);
     $intScore->setRoleModel(3);
     $intScore->setTotalImpression(3);
     $intScore->setApplicationStatistic($as4);
     $interview4->setInterviewScore($intScore);
     // The interview practical
     $intPrac = new InterviewPractical();
     $intPrac->setMonday("Bra");
     $intPrac->setTuesday("Bra");
     $intPrac->setWednesday("Bra");
     $intPrac->setThursday("Bra");
     $intPrac->setFriday("Bra");
     $intPrac->setComment("Test");
     $intPrac->setHeardAboutFrom("Stand");
     $intPrac->setEnglish(true);
     $intPrac->setPosition("2x2");
     $intPrac->setSubstitute(true);
     $intPrac->setApplicationStatistic($as4);
     $interview4->setInterviewPractical($intPrac);
     $manager->persist($application4);
     $application5 = new Application();
     $application5->setFirstName('Mark');
     $application5->setLastName('Zuckerberg');
     $application5->setEmail('*****@*****.**');
     $application5->setPhone('95856472');
     $application5->setUserCreated(false);
     $application5->setSubstituteCreated(false);
     $as5 = new ApplicationStatistic();
     $as5->setGender(0);
     $as5->setPreviousParticipation(true);
     $as5->setAccepted(0);
     $as5->setYearOfStudy(1);
     $as5->setFieldOfStudy($this->getReference('fos-1'));
     $as5->setSemester($this->getReference('semester-1'));
     $application5->setStatistic($as5);
     $interview5 = new Interview();
     $interview5->setInterviewed(false);
     $interview5->setInterviewer($this->getReference('user-2'));
     $interview5->setInterviewSchema($this->getReference('ischema-1'));
     $application5->setInterview($interview5);
     $manager->persist($application5);
     $manager->flush();
 }
 public function load(ObjectManager $manager)
 {
     $application0 = new Application();
     $application0->setUser($this->getReference('user-15'));
     $application0->setPreviousParticipation(false);
     $application0->setYearOfStudy(1);
     $application0->setSemester($this->getReference('semester-1'));
     $manager->persist($application0);
     $application1 = new Application();
     $application1->setUser($this->getReference('user-10'));
     $application1->setPreviousParticipation(true);
     $application1->setYearOfStudy(1);
     $application1->setSemester($this->getReference('semester-1'));
     $manager->persist($application1);
     $application2 = new Application();
     $application2->setUser($this->getReference('user-11'));
     $application2->setPreviousParticipation(false);
     $application2->setYearOfStudy(1);
     $application2->setSemester($this->getReference('semester-1'));
     $manager->persist($application2);
     $application3 = new Application();
     $application3->setUser($this->getReference('user-12'));
     $application3->setPreviousParticipation(false);
     $application3->setYearOfStudy(1);
     $application3->setSemester($this->getReference('semester-1'));
     $manager->persist($application3);
     // The interview
     $interview3 = new Interview();
     $interview3->setInterviewed(true);
     $interview3->setInterviewer($this->getReference('user-2'));
     $interview3->setInterviewSchema($this->getReference('ischema-1'));
     $interview3->setUser($this->getReference('user-12'));
     $application3->setInterview($interview3);
     // Create answer objects for all the questions in the schema
     foreach ($interview3->getInterviewSchema()->getInterviewQuestions() as $interviewQuestion) {
         $answer = new InterviewAnswer();
         $answer->setAnswer("Test answer");
         $answer->setInterview($interview3);
         $answer->setInterviewQuestion($interviewQuestion);
         $interview3->addInterviewAnswer($answer);
     }
     // The interview score
     $intScore = new InterviewScore();
     $intScore->setSuitability(6);
     $intScore->setExplanatoryPower(5);
     $intScore->setRoleModel(4);
     $intScore->setSuitableAssistant('Ja');
     $interview3->setInterviewScore($intScore);
     // The interview practical
     $application3->setMonday("Bra");
     $application3->setTuesday("Bra");
     $application3->setWednesday("Ikke");
     $application3->setThursday("Bra");
     $application3->setFriday("Ikke");
     $application3->setHeardAboutFrom(array("Stand"));
     $application3->setEnglish(true);
     $application3->setPreferredGroup('Bolk 1');
     $application3->setDoublePosition(true);
     $manager->persist($application3);
     // This application has a conducted interview which takes some code to set up
     $application4 = new Application();
     $application4->setUser($this->getReference('user-13'));
     $application4->setPreviousParticipation(false);
     $application4->setYearOfStudy(1);
     $application4->setSemester($this->getReference('semester-1'));
     // The interview
     $interview4 = new Interview();
     $interview4->setInterviewed(true);
     $interview4->setInterviewer($this->getReference('user-2'));
     $interview4->setInterviewSchema($this->getReference('ischema-1'));
     $interview4->setUser($this->getReference('user-13'));
     $application4->setInterview($interview4);
     // Create answer objects for all the questions in the schema
     foreach ($interview4->getInterviewSchema()->getInterviewQuestions() as $interviewQuestion) {
         $answer = new InterviewAnswer();
         $answer->setAnswer("Test answer");
         $answer->setInterview($interview4);
         $answer->setInterviewQuestion($interviewQuestion);
         $interview4->addInterviewAnswer($answer);
     }
     // The interview score
     $intScore = new InterviewScore();
     $intScore->setSuitability(6);
     $intScore->setExplanatoryPower(5);
     $intScore->setRoleModel(4);
     $intScore->setSuitableAssistant('Ja');
     $interview4->setInterviewScore($intScore);
     // The interview practical
     $application4->setMonday("Bra");
     $application4->setTuesday("Bra");
     $application4->setWednesday("Ikke");
     $application4->setThursday("Bra");
     $application4->setFriday("Ikke");
     $application4->setHeardAboutFrom(array("Stand"));
     $application4->setEnglish(false);
     $application4->setPreferredGroup('Bolk 1');
     $application4->setDoublePosition(false);
     $manager->persist($application4);
     $application5 = new Application();
     $application5->setUser($this->getReference('user-14'));
     $application5->setPreviousParticipation(false);
     $application5->setYearOfStudy(1);
     $application5->setSemester($this->getReference('semester-1'));
     $interview5 = new Interview();
     $interview5->setInterviewed(false);
     $interview5->setInterviewer($this->getReference('user-2'));
     $interview5->setInterviewSchema($this->getReference('ischema-1'));
     $interview5->setUser($this->getReference('user-14'));
     $application5->setInterview($interview5);
     $manager->persist($application5);
     $application6 = new Application();
     $application6->setUser($this->getReference('user-8'));
     $application6->setPreviousParticipation(false);
     $application6->setYearOfStudy(1);
     $application6->setSemester($this->getReference('semester-1'));
     $interview6 = new Interview();
     $interview6->setInterviewed(false);
     $interview6->setInterviewer($this->getReference('user-1'));
     $interview6->setInterviewSchema($this->getReference('ischema-1'));
     $interview6->setUser($this->getReference('user-8'));
     $interview6->setCancelled(true);
     $application6->setInterview($interview6);
     $manager->persist($application6);
     $manager->flush();
 }
 /**
  * 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));
 }
Exemple #11
0
 private function createApplications($provider, $projects, $users, $projectString, $fundraiserString, $dateDemandeString, $amountString, $responseString, $dateResponseString, $reasonString)
 {
     if ($projectString == null) {
         return;
     }
     if ($projectString == '') {
         return;
     }
     if ($fundraiserString == null) {
         return;
     }
     if ($fundraiserString == '') {
         return;
     }
     $projects_keys = explode(', ', $projectString);
     $fundraisers_keys = explode(', ', $fundraiserString);
     preg_match('/\\b\\d{2}[-.]?\\d{2}[-.]?\\d{4}\\b/', $dateDemandeString, $date_keys);
     $response_keys = explode(', ', $responseString);
     $amount_keys = explode(', ', $amountString);
     preg_match('/\\b\\d{2}[-.]?\\d{2}[-.]?\\d{4}\\b/', $dateResponseString, $date_response_keys);
     for ($i = 0; $i < count($projects_keys); $i++) {
         $app = new Application();
         $app->setProvider($provider);
         if (isset($fundraisers_keys[$i])) {
             $app->setFundraiser($users[$fundraisers_keys[$i]]);
         }
         if (isset($projects_keys[$i])) {
             $app->setProject($projects[$projects_keys[$i]]);
         }
         if (isset($date_keys[$i])) {
             $app->setAskDate(\DateTime::createFromFormat('d.m.Y', $date_keys[$i]));
         }
         if (isset($date_response_keys[$i])) {
             $app->setResponseDate(\DateTime::createFromFormat('d.m.Y', $date_response_keys[$i]));
         }
         if (isset($response_keys[$i])) {
             switch ($response_keys[$i]) {
                 case 'NON':
                     $app->setResponse(Application::RESPONSE_NO);
                     break;
                 case 'OUI':
                     $app->setResponse(Application::RESPONSE_YES);
                     break;
                 case 'En attente':
                     $app->setResponse(Application::RESPONSE_WAITING);
                     break;
             }
         }
         $app->setResponseMotivation($reasonString);
         if (isset($amount_keys[$i])) {
             $array = array();
             preg_match_all('!\\d+!', $amount_keys[$i], $array);
             // print_r($array);
             $number = '';
             foreach ($array[0] as $piece) {
                 $number = $number . $piece;
             }
             echo $number . PHP_EOL;
             $app->setAmount(floatval($number));
         }
         $app->setStatus(Application::STATUS_CLOSED);
     }
 }
 /**
  * @Route("/remove/{application}", name="application_remove",options={"expose"=true})
  * @param Application $application
  * @ParamConverter("application", class="AppBundle:Application")
  * @return Response
  */
 public function removeAction(Request $request, Application $application)
 {
     $provider = $application->getProvider();
     $em = $this->getDoctrine()->getEntityManager();
     $em->remove($application);
     $em->flush();
     return $this->redirect($this->generateUrl('provider_show', array('provider' => $provider->getId())));
 }