コード例 #1
0
 /**
  *
  *
  * @return \Symfony\Component\HttpFoundation\Response
  */
 public function indexAction(Request $request)
 {
     $start = $end = null;
     if (!$request->get('start')) {
         $start = new \DateTime('now');
         //6 last months
         $start->sub(new \DateInterval('P3M'));
     } else {
         $start = \DateTime::createFromFormat('d/m/Y', $request->get('start'));
     }
     if (!$request->get('end')) {
         $end = new \DateTime('now');
     } else {
         $end = \DateTime::createFromFormat('d/m/Y', $request->get('end'));
     }
     /** @var Section $section */
     $section = $this->container->get('section_manager')->getCurrentSection();
     /** @var UserRepository $userRepo */
     $userRepo = $this->getDoctrine()->getManager()->getRepository('BuddySystemUserBundle:User');
     $emails = array();
     $emails["all"] = $emails["is"] = $emails["local"] = $emails["notmatched"] = "";
     /** @var User $user */
     foreach ($userRepo->findBy(array("section" => $section)) as $user) {
         if ($user->getJoindate()) {
             if ($start && $user->getJoindate() >= $start && $end && $user->getJoindate() <= $end) {
                 $emails["all"] .= $user->getEmail() . ", ";
                 if ($user->isLocal()) {
                     $emails["local"] .= $user->getEmail() . ", ";
                 }
                 if (!$user->isLocal()) {
                     $emails["is"] .= $user->getEmail() . ", ";
                 }
                 if (!$user->isMatched()) {
                     $emails["notmatched"] .= $user->getEmail() . ", ";
                 }
             }
         }
     }
     $emails["all"] = substr($emails["all"], 0, -2);
     $emails["local"] = substr($emails["local"], 0, -2);
     $emails["is"] = substr($emails["is"], 0, -2);
     $emails["notmatched"] = substr($emails["notmatched"], 0, -2);
     return $this->render('BuddySystemMembersBundle:Mailing:index.html.twig', array("emails" => $emails));
 }
コード例 #2
0
 protected function configure()
 {
     $date = new \DateTime();
     $date->sub(new \DateInterval('P1M'));
     $this->setName('castle:prune')->setDescription('Prune atom entities by date')->addArgument('date', InputArgument::OPTIONAL, 'Prune date', $date->format('Y-m-d'));
 }
コード例 #3
0
 public function testGetNextSession()
 {
     $c = new Course();
     // Finished offerings
     $fo1 = $this->buildOffering(1, new \DateTime("2012-06-03"), Offering::START_DATES_KNOWN);
     $fo2 = $this->buildOffering(2, new \DateTime("2012-05-03"), Offering::START_DATES_KNOWN);
     $fo3 = $this->buildOffering(3, new \DateTime("2012-07-03"), Offering::START_DATES_KNOWN);
     // Ongoing session
     $oodt1 = new \DateTime();
     $oodt1->sub(new \DateInterval("P10D"));
     $oo1 = $this->buildOffering(4, $oodt1, Offering::START_DATES_KNOWN);
     // Self paced session
     $so1 = $this->buildOffering(5, new \DateTime("2012-07-03"), Offering::COURSE_OPEN);
     // Upcoming sessions
     $uo1 = $this->buildOffering(6, $this->getFutureDateUtility("P20D"), Offering::START_DATES_KNOWN);
     $uo2 = $this->buildOffering(7, $this->getFutureDateUtility("P10D"), Offering::START_DATES_KNOWN);
     $uo3 = $this->buildOffering(8, $this->getFutureDateUtility("P30D"), Offering::START_DATES_KNOWN);
     // Course with single finished offering
     $c->addOffering($fo1);
     $next = CourseUtility::getNextSession($c);
     $this->assertEquals($fo1->getId(), $next->getId());
     // Course with multiple finished offering
     $c->addOffering($fo2);
     $c->addOffering($fo3);
     $next = CourseUtility::getNextSession($c);
     $this->assertEquals($fo3->getId(), $next->getId());
     // Course with ongoing sessions
     $c->addOffering($oo1);
     $next = CourseUtility::getNextSession($c);
     $this->assertEquals($oo1->getId(), $next->getId());
     // Course with with self paced sessions
     $c->addOffering($so1);
     $next = CourseUtility::getNextSession($c);
     $this->assertEquals($so1->getId(), $next->getId());
     // Course with single upcoming session
     $c->addOffering($uo1);
     $next = CourseUtility::getNextSession($c);
     $this->assertEquals($uo1->getId(), $next->getId());
     // Course with multiple upcoming sessions
     $c->addOffering($uo2);
     $c->addOffering($uo3);
     $next = CourseUtility::getNextSession($c);
     $this->assertEquals($uo2->getId(), $next->getId());
 }