Example #1
0
 public function rewardInsertTrainingFamilyMember()
 {
     $student = $this->context['studentRegistration']->getStudent();
     if ($this->context['studentRegistration']->getTrainingFamilyMember()) {
         $primaryStudent = $this->context['studentRegistration']->getTrainingFamilyMember()->getPrimaryStudent();
     } else {
         $primaryStudent = $student;
     }
     // Get next slot
     $nextSlot = $this->em->getRepository('TSK\\StudentBundle\\Entity\\TrainingFamilyMembers')->getNextSlotForPrimaryStudent($primaryStudent);
     $nextSlot = min($nextSlot, 3);
     $tfm = new TrainingFamilyMembers();
     $tfm->setPrimaryStudent($primaryStudent);
     $tfm->setStudent($student);
     $tfm->setOrdinalPosition($nextSlot);
     $this->em->persist($tfm);
     $this->em->flush();
 }
Example #2
0
 protected function processFamily($row)
 {
     if ($row) {
         $studentRepo = $this->manager->getRepository('TSK\\StudentBundle\\Entity\\Student');
         $primaryStudent = $studentRepo->findOneBy(array('legacyStudentId' => $row[0]));
         $student = $studentRepo->findOneBy(array('legacyStudentId' => $row[1]));
         if (!$primaryStudent) {
             print "Can't find primary student " . $row[0] . "\n";
             exit;
         }
         if (!$student) {
             print "Can't find student " . $row[1] . "\n";
             exit;
         }
         $tfmRepo = $this->manager->getRepository('TSK\\StudentBundle\\Entity\\TrainingFamilyMembers');
         $oldTfm = $tfmRepo->findOneBy(array('primaryStudent' => $primaryStudent, 'student' => $student));
         if (!$oldTfm) {
             $tfm = new TrainingFamilyMembers();
             $tfm->setPrimaryStudent($primaryStudent);
             $tfm->setStudent($student);
             $tfm->setDateAdded(new \DateTime($row[2]));
             $tfm->setOrdinalPosition($row[3]);
             try {
                 $this->manager->persist($tfm);
                 $this->manager->flush();
             } catch (DBALException $e) {
             } catch (\Exception $e) {
                 ld($e);
                 print $e->getMessage();
                 exit;
             }
         }
     }
 }