/**
  * @Route("/test/{id}")
  * @Template()
  * @Method({"GET"})
  */
 public function testAction(Student $student)
 {
     $em = $this->getDoctrine()->getManager();
     $forms = array();
     $eligibleRanks = $student->getEligibleRanks();
     foreach ($eligibleRanks as $rank) {
         $studentRank = new StudentRank();
         $studentRank->setStudent($student);
         $studentRank->setRank($rank);
         $studentRank->setRankType($rank->getRankType());
         $form = $this->createForm(new StudentPromotionFormType(), $studentRank);
         $forms[] = $form->createView();
     }
     $srRepo = $em->getRepository('TSKStudentBundle:StudentRank');
     $studentCreditRepo = $em->getRepository('TSKStudentBundle:StudentCreditLog');
     return array('student' => $student, 'forms' => $forms, 'currentRank' => $student->getRank()->getId(), 'numberStripesEarnedAtCurrentBelt' => $srRepo->getNumberStripesEarnedAtCurrentBelt($student), 'numberKbStripesEarnedAtCurrentBelt' => $srRepo->getNumberKbStripesEarnedAtCurrentBelt($student), 'numberGrStripesEarnedAtCurrentBelt' => $srRepo->getNumberGrStripesEarnedAtCurrentBelt($student), 'lastPromotionDate' => $srRepo->getLastPromotionDate($student), 'lastKbPromotionDate' => $srRepo->getLastKbPromotionDate($student), 'lastGrPromotionDate' => $srRepo->getLastGrPromotionDate($student), 'creditsEarnedSinceLastPromotion' => $studentCreditRepo->getCreditsEarnedSinceLastPromotion($student), 'kbCreditsEarnedSinceLastKbPromotion' => $studentCreditRepo->getKbCreditsEarnedSinceLastKbPromotion($student), 'grCreditsEarnedSinceLastGrPromotion' => $studentCreditRepo->getGrCreditsEarnedSinceLastGrPromotion($student));
 }
Example #2
0
 protected function processRow($row)
 {
     $manager = $this->getContainer()->get('doctrine.orm.entity_manager');
     $statesRepo = $manager->getRepository('TSKUserBundle:States');
     $schoolRepo = $manager->getRepository('TSKSchoolBundle:School');
     $studStatusRepo = $manager->getRepository('TSKStudentBundle:StudentStatus');
     $studStatus = $studStatusRepo->find(1);
     $contact = new Contact();
     $contact->setId($row[0]);
     $contact->setFirstName($row[2]);
     $contact->setLastName($row[3]);
     $contact->setOrganization($this->org);
     $contact->setEmail($row[4]);
     $contact->setAddress1($row[6]);
     $contact->setAddress2($row[7]);
     $contact->setCity($row[8]);
     $contact->setState($statesRepo->find($row[9]));
     $contact->setPostalCode($row[10]);
     $contact->setPhone($row[11]);
     $contact->setMobile($row[12]);
     $contact->setFax($row[13]);
     $contact->setWebsite($row[14]);
     $contact->setGeocode($row[15]);
     $contact->setImgPath($row[16]);
     $contact->setDateOfBirth(new \DateTime($row[17]));
     $contact->addSchool($this->school);
     $student = new Student();
     $student->setContact($contact);
     $student->setStudentStatus($studStatus);
     $metadata = $manager->getClassMetaData(get_class($contact));
     $metadata->setIdGeneratorType(\Doctrine\ORM\Mapping\ClassMetadata::GENERATOR_TYPE_NONE);
     $metadata->setIdGenerator(new \Doctrine\ORM\Id\AssignedGenerator());
     // $manager->persist($contact);
     $manager->persist($student);
     $manager->flush();
 }
 public function saveNewStudentRegistration($em, $studentRegistration)
 {
     $contactRepo = $em->getRepository('TSK\\UserBundle\\Entity\\Contact');
     $studentRepo = $em->getRepository('TSK\\StudentBundle\\Entity\\Student');
     // flow finished
     $student = $studentRegistration->getStudent();
     if (!$student) {
         $studentContact = $studentRegistration->getStudentContact();
         // check for dupe student
         if ($dupeStudent = $studentRepo->findOneBy(array('contact' => $studentContact))) {
             $student = $dupeStudent;
             $student->getContact()->addSchool($studentRegistration->getSchool());
         } else {
             // Create student
             // check for dupe contact
             if ($dupeContact = $contactRepo->findDupe($studentContact)) {
                 $studentContact = $dupeContact;
             }
             $studentContact->addSchool($studentRegistration->getSchool());
             $student = new Student();
             $student->setContact($studentContact);
         }
     }
     $studentStatusActive = $em->getRepository('TSK\\StudentBundle\\Entity\\StudentStatus')->findOneBy(array('name' => 'active', 'organization' => $this->getOrg()));
     $student->setStudentStatus($studentStatusActive);
     $student->setIsProspective(false);
     // Create Billee
     $billeeContact = $studentRegistration->getBilleeContact();
     if ($dupeContact = $contactRepo->findDupe($billeeContact)) {
         $billeeContact = $dupeContact;
     }
     $billeeContact->addSchool($studentRegistration->getSchool());
     $student->addBillee($billeeContact);
     // Create Emergency Contact
     $emergencyContact = $studentRegistration->getEmergencyContactContact();
     if ($dupeContact = $contactRepo->findDupe($emergencyContact)) {
         $emergencyContact = $dupeContact;
     }
     $emergencyContact->addSchool($studentRegistration->getSchool());
     $student->addEmergencyContact($emergencyContact);
     $pp = $studentRegistration->getPaymentPlanCustomizedPayments();
     // Hmmm ... after adding Gedmo loggable now I need to stripslashes on json data ...
     $paymentObj = json_decode(stripslashes($pp['paymentsData']));
     // Create contract
     // Soon we will need to select the contract based on membership type
     $contract = new Contract();
     $contract->setIsActive(true);
     $contract->setProgram($studentRegistration->getProgram());
     // $contract->setAmount($paymentObj->principal);
     $contract->setSchool($studentRegistration->getSchool());
     $contract->addStudent($student);
     $contract->setPaymentTerms($studentRegistration->getPaymentPlanCustomizedPayments());
     $contractStartDate = new \DateTime();
     // We may want the ability to set this manually in the future ...
     $contract->setContractStartDate($contractStartDate);
     $programExpiry = new \DateTime();
     $expireDays = $studentRegistration->getProgram()->getDurationDays() + $studentRegistration->getContractBalanceDays();
     $programExpiry->add(new \DateInterval('P' . $expireDays . 'D'));
     $contract->setContractExpiry($programExpiry);
     $contract->setContractNumTokens($studentRegistration->getProgram()->getNumTokens());
     $contract->setRolloverDays($studentRegistration->getContractBalanceDays());
     $contract->setDeferralRate($studentRegistration->getProgramPaymentPlan()->getDeferralRate());
     $contract->setDeferralDurationMonths($studentRegistration->getProgramPaymentPlan()->getDeferralDurationMonths());
     $contract->setDeferralDistributionStrategy($studentRegistration->getProgramPaymentPlan()->getDeferralDistributionStrategy());
     // Add to contract_token table
     $contractToken = new ContractToken();
     $contractToken->setContract($contract);
     $contractToken->setAmount($studentRegistration->getProgram()->getNumTokens());
     // Billee Payment Method
     if (!$studentRegistration->getPayInFull()) {
         $bpm = new BilleePaymentMethod();
         $bpm->setContact($billeeContact);
         $bpm->setPaymentMethod($studentRegistration->getPaymentMethod());
         // $bpm->setCcNum($studentRegistration->getCcNum());
         $bpm->setTransArmorToken($studentRegistration->getTransArmorToken());
         if ($studentRegistration->getCcExpirationDate()) {
             $bpm->setCcExpirationDate($studentRegistration->getCcExpirationDate());
         }
         $bpm->setCvvNumber($studentRegistration->getCvvNumber());
         // $bpm->setRoutingNum($studentRegistration->getRoutingNumber());
         // $bpm->setAccountNum($studentRegistration->getAccountNumber());
     }
     if (!empty($bpm)) {
         $bpmContract = new BilleePaymentMethodContract();
         $bpmContract->setContract($contract);
         $bpmContract->setBilleePaymentMethod($bpm);
         $bpmContract->setPortion(100);
     }
     // Set up charges
     $session = $this->getRequest()->getSession();
     $sessionKey = $this->container->getParameter('tsk_user.session.org_key');
     $org = $this->get('session')->get($sessionKey);
     $tuitionIncomeType = $em->getRepository('TSK\\PaymentBundle\\Entity\\IncomeType')->findOneBy(array('name' => 'tuition', 'organization' => $org));
     // Grab IncFmStudents account
     $incFmStudents = $em->getRepository('TSK\\PaymentBundle\\Entity\\Account')->findOneBy(array('name' => 'Inc Fm Students', 'organization' => $org));
     $deferralAccount = $em->getRepository('TSK\\PaymentBundle\\Entity\\Account')->findOneBy(array('name' => 'Deferred Income', 'organization' => $org));
     if (!empty($paymentObj->payments)) {
         $payments = $paymentObj->payments;
         foreach ($payments as $idx => $payment) {
             $charge = new Charge();
             $charge->setSchool($studentRegistration->getSchool());
             $charge->setAmount($payment);
             $charge->setAccount($incFmStudents);
             $charge->setDeferralAccount($deferralAccount);
             $charge->setIncomeType($tuitionIncomeType);
             // 0 Months, 1 month, 2 months ...
             // TODO:  Make this respond to paymentFrequency
             $du = new DatesUtil();
             $today = new \DateTime();
             $charge->setDueDate($du->getMonthaversary($today->format('Y-m-d'), $idx));
             $em->persist($charge);
             // It feels a little funny doing this here, could be improved ... MJH
             $contract->addCharge($charge);
         }
     }
     $em->persist($student);
     $em->persist($billeeContact);
     $em->persist($emergencyContact);
     $em->persist($contract);
     $em->persist($contractToken);
     if (!empty($bpm)) {
         $em->persist($bpm);
         $em->persist($bpmContract);
     }
     // Set up RPI's
     if (!empty($bpm)) {
         if (!empty($paymentObj->payments)) {
             $payments = $paymentObj->payments;
             foreach ($payments as $idx => $payment) {
                 $rpi = new RecurringPaymentInstruction();
                 $rpi->setAmount($payment);
                 $rpi->setBilleePaymentMethod($bpm);
                 $rpi->setContract($contract);
                 $rpi->setStatus('pending');
                 // 0 Months, 1 month, 2 months ...
                 // TODO:  Make this respond to paymentFrequency
                 $du = new DatesUtil();
                 $today = new \DateTime();
                 $rpiDueDate = $du->getMonthaversary($today->format('Y-m-d'), $idx);
                 $rpi->setRunDate($rpiDueDate);
                 $em->persist($rpi);
             }
         }
     }
     $em->flush();
     // So we actually need to trigger a post registration event
     // We also need to run our discount.post rules engine
     $studentRegistration->setStudent($student);
     $studentRegistration->setContract($contract);
     $studentPostRegistrationEvent = new StudentPostRegistrationEvent($student, $studentRegistration);
     $dispatcher = $this->get('event_dispatcher');
     $dispatcher->dispatch(StudentEvents::STUDENT_REGISTRATION_POST, $studentPostRegistrationEvent);
 }
Example #4
0
 /**
  * buildContext 
  * 
  * @param mixed $student 
  * @access public
  * @return void
  */
 private function buildContext(Student $student)
 {
     // Build context ...
     $srRepo = $this->em->getRepository('TSKStudentBundle:StudentRank');
     $studentCreditRepo = $this->em->getRepository('TSKStudentBundle:StudentCreditLog');
     $ctx = new Context(array('student' => $student, 'currentRank' => $student->getRank()->getId(), 'numberStripesEarnedAtCurrentBelt' => $srRepo->getNumberStripesEarnedAtCurrentBelt($student), 'numberKbStripesEarnedAtCurrentBelt' => $srRepo->getNumberKbStripesEarnedAtCurrentBelt($student), 'numberGrStripesEarnedAtCurrentBelt' => $srRepo->getNumberGrStripesEarnedAtCurrentBelt($student), 'lastPromotionDate' => $srRepo->getLastPromotionDate($student), 'lastKbPromotionDate' => $srRepo->getLastKbPromotionDate($student), 'lastGrPromotionDate' => $srRepo->getLastGrPromotionDate($student), 'creditsEarnedSinceLastPromotion' => $studentCreditRepo->getCreditsEarnedSinceLastPromotion($student), 'kbCreditsEarnedSinceLastKbPromotion' => $studentCreditRepo->getKbCreditsEarnedSinceLastKbPromotion($student), 'grCreditsEarnedSinceLastGrPromotion' => $studentCreditRepo->getGrCreditsEarnedSinceLastGrPromotion($student)));
     return $ctx;
 }
 /**
  * @Route("/admin/contract/modify/{id}", name="tsk_contract_modify")
  * @Template()
  */
 public function modifyAction(Student $student)
 {
     $contract = $student->getActiveContract();
     if (!$contract) {
         throw new \Exception('No active contract for student');
     }
     return array('contract' => $contract);
 }