コード例 #1
0
 /**
  * @Route("/admin/school/switch/{id}", name="school_switch", requirements={"id" = "\d+"})
  * #ParamConverter("school", class="TSKSchoolBundle:School")#
  * @Method({"POST","GET"})
  * @Template()
  */
 public function switchAction(School $school)
 {
     $sessionKey = $this->container->getParameter('tsk_user.session.school_key');
     $this->get('session')->set($sessionKey, $school->getId());
     $this->get('session')->setFlash('notice', 'Your school has been switched');
     return $this->redirect($this->generateUrl('sonata_admin_dashboard'));
 }
コード例 #2
0
 public function load(ObjectManager $manager)
 {
     $corp = new Corporation();
     $corp->setLegalName('Elmwood LLC');
     $corp->setTaxId('239423423');
     $manager->persist($corp);
     $manager->flush();
     $schoolContact = new Contact();
     $schoolContact->setFirstName('Elmwood');
     $schoolContact->setLastName('Park');
     $schoolContact->setEmail('*****@*****.**');
     $schoolContact->setOrganization($this->getReference('tsk-org'));
     $schoolContact->setAddress1('75 Boulevard');
     $schoolContact->setCity('Elmwood Park');
     $schoolContact->setState($manager->getRepository('TSK\\UserBundle\\Entity\\States')->find('NJ'));
     $schoolContact->addCorporation($corp);
     $manager->persist($schoolContact);
     $manager->flush();
     $school = new School();
     $school->setName('Elmwood Park');
     $school->setContact($schoolContact);
     $school->setLatePaymentCharge(12.0);
     $school->setLateGraceDays(5);
     $manager->persist($school);
     $manager->flush();
     $this->addReference('tsk_elmwoodpark_school', $school);
     $soCorp = new Corporation();
     $soCorp->setLegalName('South Orange LLC');
     $soCorp->setTaxId('384823232');
     $manager->persist($soCorp);
     $manager->flush();
     $soContact = new Contact();
     $soContact->setFirstName('South');
     $soContact->setLastName('Orange');
     $soContact->setEmail('*****@*****.**');
     $soContact->setAddress1('76 South Orange Avenue');
     $soContact->setCity('South Orange');
     $soContact->setState($manager->getRepository('TSK\\UserBundle\\Entity\\States')->find('NJ'));
     $soContact->setPostalCode('07079');
     $soContact->setOrganization($this->getReference('mjh-org'));
     $soContact->addCorporation($soCorp);
     $manager->persist($soContact);
     $manager->flush();
     $soSchool = new School();
     $soSchool->setName('South Orange');
     $soSchool->setContact($soContact);
     $soSchool->setLatePaymentCharge(12.0);
     $soSchool->setLateGraceDays(5);
     $this->addReference('mjh_southorange_school', $soSchool);
     $manager->persist($soSchool);
     $manager->flush();
     $corp = new Corporation();
     $corp->setLegalName('TS OF ROUTE 17 INC.');
     $corp->setDba("TIGER SCHULMANN'S MMA");
     $corp->setTaxId('45-5615200');
     $corp->setAbbrLegalName('RAMSEY');
     $corp->setRoutingNum('021200339');
     $corp->setAccountNum('123456789012');
     $manager->persist($corp);
     $manager->flush();
     $contactManager = $this->container->get('tsk_user.contact_manager');
     $schoolContact = $contactManager->createContact();
     $schoolContact->setFirstName('TSMMA');
     $schoolContact->setLastName('RAMSEY');
     $schoolContact->setEmail('*****@*****.**');
     $schoolContact->setOrganization($this->getReference('tsk-org'));
     $schoolContact->setAddress1('885 State Highway 17 South');
     $schoolContact->setCity('Ramsey');
     $schoolContact->setState($manager->getRepository('TSK\\UserBundle\\Entity\\States')->find('NJ'));
     $schoolContact->setPostalCode('07446');
     $schoolContact->setPhone('2016693566');
     $schoolContact->setMobile('2012369618');
     $schoolContact->setWebsite('http://ramseymma.com');
     $schoolContact->addCorporation($corp);
     $contactManager->updateCanonicalFields($schoolContact);
     $school = new School();
     $school->setName('Ramsey');
     $school->setContact($schoolContact);
     $school->setLatePaymentCharge(12.0);
     $school->setLateGraceDays(10);
     $school->setLegacyId('110');
     $manager->persist($school);
     $manager->flush();
     $this->addReference('tsk_ramsey_school', $school);
     // Add schools to contacts
     $mjhContact = $this->getReference('mjh-contact1');
     $mjhContact->addSchool($this->getReference('mjh_southorange_school'));
     $mjhContact->addSchool($this->getReference('tsk_elmwoodpark_school'));
     $manager->persist($mjhContact);
     $manager->flush();
     $justinContact = $this->getReference('mjh-contact2');
     $justinContact->addSchool($this->getReference('mjh_southorange_school'));
     $manager->persist($justinContact);
     $manager->flush();
     $justinContact = $this->getReference('mjh-contact3');
     $justinContact->addSchool($this->getReference('mjh_southorange_school'));
     $manager->persist($justinContact);
     $manager->flush();
     $justinContact = $this->getReference('mjh-contact4');
     $justinContact->addSchool($this->getReference('tsk_elmwoodpark_school'));
     $justinContact->addSchool($this->getReference('mjh_southorange_school'));
     $manager->persist($justinContact);
     $manager->flush();
     $tigerContact = $this->getReference('tsk-contact1');
     $tigerContact->addSchool($this->getReference('mjh_southorange_school'));
     $tigerContact->addSchool($this->getReference('tsk_elmwoodpark_school'));
     $manager->persist($tigerContact);
     $manager->flush();
     $tContact = $this->getReference('tsk-contact2');
     $tContact->addSchool($this->getReference('tsk_elmwoodpark_school'));
     $manager->persist($tContact);
     $manager->flush();
     $tContact = $this->getReference('tsk-contact3');
     $tContact->addSchool($this->getReference('tsk_elmwoodpark_school'));
     $manager->persist($tContact);
     $manager->flush();
     $tContact = $this->getReference('tsk-contact4');
     $tContact->addSchool($this->getReference('tsk_elmwoodpark_school'));
     $tContact->addSchool($this->getReference('mjh_southorange_school'));
     $manager->persist($tContact);
     $tContact = $this->getReference('tsk-contact5');
     $tContact->addSchool($this->getReference('tsk_elmwoodpark_school'));
     $tContact->addSchool($this->getReference('mjh_southorange_school'));
     $manager->persist($tContact);
 }
コード例 #3
0
 protected function processSchool($file)
 {
     $csvFile = new CsvFile($file);
     $count = 0;
     foreach ($csvFile as $row) {
         if ($count > 0) {
             $row = array_map('trim', $row);
             // try {
             $manager = $this->getContainer()->get('doctrine.orm.entity_manager');
             // check for school dupe
             $schoolRepo = $manager->getRepository('TSKSchoolBundle:School');
             $oldSchool = $schoolRepo->findOneBy(array('legacyId' => $row[0]));
             if (!$oldSchool) {
                 $statesRepo = $manager->getRepository('TSKUserBundle:States');
                 $contactManager = $this->getContainer()->get('tsk_user.contact_manager');
                 $contact = $contactManager->createContact();
                 $contact->setOrganization($this->org);
                 $contact->setFirstName($row[1]);
                 $contact->setLastName($row[2]);
                 $contact->setEmail($row[3]);
                 $contact->setAddress1($row[4]);
                 $contact->setAddress2($row[5]);
                 $contact->setCity($row[6]);
                 $contact->setState($statesRepo->find($row[7]));
                 $contact->setPostalCode($row[8]);
                 $contact->setPhone($row[9]);
                 $contact->setMobile($row[10]);
                 $contact->setWebsite($row[11]);
                 $contactManager->updateCanonicalFields($contact);
                 $corporation = new Corporation();
                 $corporation->setTaxId($row[14]);
                 $corporation->setLegalName($row[12]);
                 $corporation->setDba($row[13]);
                 $corporation->setAccountNum($row[17]);
                 $corporation->setRoutingNum($row[16]);
                 $contact->addCorporation($corporation);
                 $school = new School();
                 $school->setName($row[1] . ' ' . $row[2]);
                 $school->setLegacyId($row[0]);
                 $school->setDeferralRate(0.75);
                 $school->setDistributionStrategy('accelerated');
                 $school->setPaymentMax(1000);
                 $school->setLateGraceDays(5);
                 $school->setLatePaymentCharge(25);
                 $school->setContact($contact);
                 // $manager = $this->getContainer()->get('doctrine.orm.entity_manager');
                 $manager->persist($school);
                 $manager->flush();
                 $this->school = $school;
                 // $this->processRow($row);
                 // $count++;
             } else {
                 // print 'we already have this school!';
             }
             // } catch (DBALException $e) {
             //     throw $e;
             //     print 'caught it';
             // } catch (\Exception $e) {
             //     throw $e;
             // }
         }
         $count++;
     }
 }