/**
  * Executes, shows the details for the requested report class.
  *
  * @param CommandContext $context
  * @throws InvalidArgumentException
  */
 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.');
     }
     $class = $context->get('reportClass');
     if (!isset($class) || is_null($class)) {
         throw new InvalidArgumentException('Missing report class.');
     }
     PHPWS_Core::initModClass('hms', 'ReportFactory.php');
     PHPWS_Core::initModClass('hms', 'ReportDetailView.php');
     $reportCtl = ReportFactory::getControllerInstance($class);
     $view = new ReportDetailView($reportCtl);
     $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');
     // 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();
 }