public function execute(CommandContext $context)
 {
     $term = $context->get('term');
     // If we're coming from the special needs page, save any special needs flags the student selected
     if (array_key_exists('special_needs', $context->getParams())) {
         $this->saveSpecialNeeds($context);
     }
     // If they haven't agreed, redirect to the agreement
     // TODO: actually check via docusign API
     $event = $context->get('event');
     if (is_null($event) || !isset($event) || $event != 'signing_complete' && $event != 'viewing_complete') {
         $returnCmd = CommandFactory::getCommand('ShowFreshmenApplicationReview');
         $returnCmd->setTerm($term);
         $agreementCmd = CommandFactory::getCommand('ShowTermsAgreement');
         $agreementCmd->setTerm($term);
         $agreementCmd->setAgreedCommand($returnCmd);
         $agreementCmd->redirect();
     }
     $student = StudentFactory::getStudentByUsername(UserStatus::getUsername(), $term);
     $errorCmd = CommandFactory::getCommand('ShowHousingApplicationForm');
     $errorCmd->setTerm($term);
     // Determine the application type, based on the term
     $sem = Term::getTermSem($term);
     switch ($sem) {
         case TERM_FALL:
             $appType = 'fall';
             break;
         case TERM_SPRING:
             $appType = 'spring';
             break;
         case TERM_SUMMER1:
         case TERM_SUMMER2:
             $appType = 'summer';
             break;
     }
     try {
         $application = HousingApplicationFactory::getApplicationFromSession($_SESSION['application_data'], $term, $student, $appType);
     } catch (Exception $e) {
         NQ::simple('hms', hms\NotificationView::ERROR, $e->getMessage());
         $errorCmd->redirect();
     }
     PHPWS_Core::initModClass('hms', 'FreshmenApplicationReview.php');
     $view = new FreshmenApplicationReview($student, $term, $application);
     $context->setContent($view->show());
 }
 public function execute(CommandContext $context)
 {
     if (!Current_User::allow('hms', 'reports')) {
         PHPWS_Core::initModClass('hms', 'exception/PermissionException.php');
         throw new PermissionException('You do no have permission to run reports.');
     }
     PHPWS_Core::initModClass('hms', 'ReportFactory.php');
     $reportClass = $context->get('reportClass');
     if (!isset($reportClass) || is_null($reportClass)) {
         throw new InvalidArgumentException('Missing report class name.');
     }
     $reportCtrl = ReportFactory::getcontrollerInstance($reportClass);
     $runNow = $context->get('runNow');
     if (isset($runNow) && $runNow == "true") {
         $time = time();
     } else {
         $timePicker = $context->get('timePicker');
         $timeParts = explode(" ", $timePicker);
         $meridian = $timeParts[1];
         $timeParts = explode(":", $timeParts[0]);
         $hour = $timeParts[0];
         if ($meridian == "PM") {
             $hour += 12;
         }
         $min = $timeParts[1];
         $datePicker = $context->get('datePicker');
         $dateParts = explode("/", $datePicker);
         $month = $dateParts[0];
         $day = $dateParts[1];
         $year = $dateParts[2];
         $time = mktime($hour, $min, 0, $month, $day, $year);
     }
     // Set the exec time
     $reportCtrl->newReport($time);
     // Save the report
     $reportCtrl->saveReport();
     // Grab the report's settings from the context
     $reportCtrl->setParams($context->getParams());
     // Save those params
     $reportCtrl->saveParams();
     HMS::quit();
 }
 public function execute(CommandContext $context)
 {
     if (!Current_User::allow('hms', 'reports')) {
         PHPWS_Core::initModClass('hms', 'exception/PermissionException.php');
         throw new PermissionException('You do no have permission to run reports.');
     }
     PHPWS_Core::initModClass('hms', 'ReportFactory.php');
     // Determine which report we're running
     $reportClass = $context->get('reportClass');
     if (!isset($reportClass) || is_null($reportClass)) {
         throw new InvalidArgumentException('Missing report class.');
     }
     // Get the proper report controller
     $reportCtrl = ReportFactory::getControllerInstance($reportClass);
     // Initalize a new report
     $reportCtrl->newReport(time());
     // Get the params from the context
     /*
      * The below is a bit of hack. The term should really be taken care of
      * by a setup view, and passed in as part of the context proper. We tack
      * it onto the context here, just to make sure it's available.
      */
     $params = $context->getParams();
     $params['term'] = Term::getSelectedTerm();
     //test(Term::getSelectedTerm());
     //test($params,1);
     $reportCtrl->setParams($params);
     // Save this report so it'll have an ID
     $reportCtrl->saveReport();
     // Generate the report
     $reportCtrl->generateReport();
     // Get the default view command
     $viewCmd = $reportCtrl->getDefaultOutputViewCmd();
     // Rediect to the view command
     $viewCmd->redirect();
 }