/**
  * Shows the requested report's HTML output.
  * 
  * @param CommandContext $context
  * @throws InvalidArgumentExection
  */
 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.');
     }
     $reportId = $context->get('reportId');
     if (!isset($reportId) || is_null($reportId)) {
         throw new InvalidArgumentExection('Missing report id.');
     }
     // Instantiate the report controller with the requested report id
     PHPWS_Core::initModClass('hms', 'ReportFactory.php');
     $report = ReportFactory::getReportById($reportId);
     Layout::addPageTitle($report->getFriendlyName());
     $detailCmd = CommandFactory::getCommand('ShowReportDetail');
     $detailCmd->setReportClass($report->getClass());
     $content = '<div> ' . $detailCmd->getLink('&laquo; back') . ' </div>';
     $content .= file_get_contents($report->getHtmlOutputFilename());
     if ($content === FALSE) {
         NQ::simple('hms', hms\NotificationView::ERROR, 'Could not open report file.');
         PHPWS_Error::log('Could not open report file ' . $report->getCsvOutputFilename(), 'hms');
         $reportCmd = CommandFactory::getCommand('ShowReportDetail');
         $reportCmd->setReportClass($report->getClass());
         $reportCmd->redirect();
     }
     $context->setContent($content);
 }
 /**
  * Exec
  *
  * @param CommandContext $context
  * @throws InvalidArgumentExection
  */
 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.');
     }
     $reportId = $context->get('reportId');
     if (!isset($reportId) || is_null($reportId)) {
         throw new InvalidArgumentExection('Missing report id.');
     }
     // Instantiate the report controller with the requested report id
     PHPWS_Core::initModClass('hms', 'ReportFactory.php');
     $report = ReportFactory::getReportById($reportId);
     // Check to make sure the file exists
     if (!file_exists($report->getCsvOutputFilename())) {
         NQ::simple('hms', hms\NotificationView::ERROR, 'Could not open report file.');
         PHPWS_Error::log('Could not open report file ' . $report->getCsvOutputFilename(), 'hms');
         $reportCmd = CommandFactory::getCommand('ShowReportDetail');
         $reportCmd->setReportClass($report->getClass());
         $reportCmd->redirect();
     }
     $pdf = file_get_contents($report->getCsvOutputFilename());
     // Hoepfully force the browser to open a 'save as' dialogue
     header('Content-Type: text/csv');
     header('Cache-Control: public, must-revalidate, max-age=0');
     // HTTP/1.1
     header('Pragma: public');
     header('Expires: Sat, 26 Jul 1997 05:00:00 GMT');
     // Date in the past
     header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
     header('Content-Length: ' . strlen($pdf));
     header('Content-Disposition: attachment; filename="' . basename($report->getCsvOutputFilename()) . '";');
     echo $pdf;
     exit;
 }
 public function execute(CommandContext $context)
 {
     // Check for report ID
     $reportId = $context->get('reportId');
     if (!isset($reportId) || is_null($reportId)) {
         throw new InvalidArgumentException('Missing report id.');
     }
     PHPWS_Core::initModClass('hms', 'ReportFactory.php');
     // Load the report to get its class
     try {
         $report = ReportFactory::getReportById($reportId);
     } catch (InvalidArgumentException $e) {
         NQ::simple('hms', hms\NotificationView::SUCCESS, 'Report canceled.');
         $context->goBack();
     }
     $db = new PHPWS_DB('hms_report');
     $db->addWhere('id', $reportId);
     $result = $db->delete();
     if (PHPWS_Error::logIfError($result)) {
         throw new DatabaseException($result->toString());
     }
     NQ::simple('hms', hms\NotificationView::SUCCESS, 'Report canceled.');
     $cmd = CommandFactory::getCommand('ShowReportDetail');
     $cmd->setReportClass($report->getClass());
     $cmd->redirect();
 }
Beispiel #4
0
 /**
  * Executes this pulse. Checks for any pending reports and runs them.
  */
 public static function execute()
 {
     // Reschedule the next run of this process
     /*
      $sp = $this->makeClone();
      $sp->execute_at = strtotime("+1 minutes");
      $sp->save();
     * 
     */
     // Load necessary classes
     PHPWS_Core::initModClass('hms', 'UserStatus.php');
     PHPWS_Core::initModClass('hms', 'ReportFactory.php');
     PHPWS_Core::initModCLass('hms', 'HMS_Email.php');
     // Fake a user, in case we need that
     UserStatus::wearMask('HMS System');
     // Check for any pending reports (scheduled for any time up until now)
     $db = new PHPWS_DB('hms_report');
     $db->addWhere('completed_timestamp', null, 'IS');
     // not completed
     $db->addWhere('began_timestamp', null, 'IS');
     // not already running somewhere
     $db->addWhere('scheduled_exec_time', time(), '<=');
     // scheduled exec time is now or before
     $db->addOrder('scheduled_exec_time ASC');
     // Run in order scheduled
     $results = $db->select();
     // If there's nothing to do, quite nicely
     if (!isset($results) || is_null($results) || empty($results)) {
         UserStatus::removeMask();
         return 'No reports waiting.';
     }
     // Run each report
     foreach ($results as $row) {
         $report = null;
         try {
             // Load the proper controller for this report
             $reportCtrl = ReportFactory::getControllerById($row['id']);
             // Load this report's params
             $reportCtrl->loadParams();
             // Generate the report
             $reportCtrl->generateReport();
             $report = $reportCtrl->getReport();
         } catch (Exception $e) {
             // handle the exception nicely
             self::emailError(self::formatException($e));
             exit;
         }
         // Send success notification
         $username = $report->getCreatedBy();
         if ($username == 'jbooker') {
             $username = '******';
         }
         HMS_Email::sendReportCompleteNotification($username, $report->getFriendlyName());
     }
     // Remove the mask
     UserStatus::removeMask();
     // Exit cleanly
     return;
 }
 /**
  * Exec
  *
  * @param CommandContext $context
  * @throws PermissionException
  */
 public function execute(CommandContext $context)
 {
     if (!UserStatus::isAdmin() || !Current_User::allow('hms', 'reports')) {
         PHPWS_Core::initModClass('hms', 'exception/PermissionException.php');
         throw new PermissionException('You do not have permission to run/view reports.');
     }
     PHPWS_Core::initModClass('hms', 'ReportFactory.php');
     PHPWS_Core::initModClass('hms', 'ListReportsView.php');
     $reports = ReportFactory::getAllReportControllers();
     $reportsList = new ListReportsView($reports);
     $context->setContent($reportsList->show());
 }
 /**
  * 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');
     $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();
 }
Beispiel #9
0
 * * This file is part of CORAL.
 * *
 * * CORAL is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
 * *
 * * CORAL is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
 * *
 * * You should have received a copy of the GNU General Public License along with CORAL. If not, see <http://www.gnu.org/licenses/>.
 * *
 * *************************************************************************************************************************
 */
require 'minify.php';
ob_start('minify_output');
include_once 'directory.php';
$action = $_GET['action'];
if ($action === 'getReportParameters') {
    $report = ReportFactory::makeReport($_GET['reportID']);
    // get parameters
    Parameter::$ajax_parmValues = array();
    foreach ($report->getParameters() as $parm) {
        $parm->form();
    }
} else {
    if ($action === 'getChildParameters') {
        $parm = ParameterFactory::makeParam($_GET['reportID'], $_GET['parentReportParameterID']);
        $parm->ajaxGetChildParameters();
    } else {
        if ($action === 'getChildUpdate') {
            $parm = ParameterFactory::makeParam($_GET['reportID'], $_GET['reportParameterID']);
            $parm->ajaxGetChildUpdate();
        } else {
            echo _("Action {$action} not set up!");
 /**
  * Will generate a report based off data sent in form post
  */
 function generateReport()
 {
     //Get all programs user wants a report on from form post
     $surveysToReportOn = $_GET['surveys'];
     $featureYear = $_GET['yearToFeature'];
     $viewFactory = new ReportFactory();
     $content = $viewFactory->buildReportUI($this->getReportData($surveysToReportOn, $featureYear), $featureYear);
     return $content;
 }
Beispiel #11
0
 public function testStandardMailshareReport() {
   global $l_id, $l_name, $l_mail_server_name, $l_domain_name;
   $report = ReportFactory::getReport(array(),'mailshare');
   $formater = new GenericFormater();
   $formater->addField('id');
   $formater->addField('name');
   $formater->addField('mail_server_name');
   $formater->addField('domain_name');
   $output = $report->format($formater);
   $this->assertEquals($output, "$l_id\t$l_name\t$l_mail_server_name\t$l_domain_name\t\n"
                               ."1\tmailshare-test\tmail-server\tzz.com\t\n"
                               ."2\tmailshare-test-name-2\tmail-server\tzz.com\t\n"
                               ."3\tmailshare-test-name-3\tmail-server\tzz.com\t\n");
   unset($report);
   $filter1 = new GenericFilter('domain_name','=','global.virt');
   $report = ReportFactory::getReport(array($filter1),'mailshare');
   $output = $report->format($formater);
   $this->assertEquals($output, "$l_id\t$l_name\tmail_server_name\t$l_domain_name\t\n");
 }
Beispiel #12
0
 * *
 * * You should have received a copy of the GNU General Public License along with CORAL. If not, see <http://www.gnu.org/licenses/>.
 * *
 * *************************************************************************************************************************
 */
session_start();
//require 'minify.php';
//ob_start('minify_output');
ob_start();
include_once 'directory.php';
if (isset($_REQUEST['outputType'])) {
    $outputType = $_REQUEST['outputType'];
} else {
    $outputType = 'web';
}
$report = ReportFactory::makeReport($_REQUEST['reportID']);
Parameter::setReport($report);
//FormInputs::init() and ReportNotes::init(..) are called by Report constructor
FormInputs::addHidden('outputType', $outputType);
if (!isset($_REQUEST['reportID'])) {
    error_log("missing reportID; redirecting to index.php");
    header("location: index.php");
    exit;
}
if ($outputType === 'web' && isset($_REQUEST['startPage'])) {
    $startRow = $_REQUEST['startPage'];
} else {
    $startRow = 1;
}
if ($report->titleID) {
    Parameter::$display = '<b>Title:</b> ' . $report->getUsageTitle($report->titleID) . '<br/>';
Beispiel #13
0
unset($db);
?>
						</select>
					</div>
					<div id='div_parm'>
<?php 
if (isset($_GET['reportID'])) {
    $reportID = $_GET['reportID'];
} else {
    if (isset($_SESSION['reportID'])) {
        $reportID = $_SESSION['reportID'];
        unset($_SESSION['reportID']);
    }
}
if (isset($reportID)) {
    $report = ReportFactory::makeReport($reportID);
    Parameter::$ajax_parmValues = array();
    foreach ($report->getParameters() as $parm) {
        $parm->form();
    }
    Parameter::$ajax_parmValues = null;
} else {
    echo "<br />";
}
?>
					</div>
					<input type='hidden' name='rprt_output' value='web'/>
					<br /><br />
					<input type="submit" value="Submit" name="submitbutton" id="submitbutton"/>
					<input type="button" value="Reset" name="resetbutton" id="resetbutton" onclick="javascript:clearParms();"/>
				</td>
Beispiel #14
0
	<script type="text/javascript" src="js/plugins/ajaxupload.3.5.js"></script>
	<script type="text/javascript" src="js/plugins/thickbox.js"></script>
	<script type="text/javascript" src="js/plugins/date.js"></script>
	<script type="text/javascript" src="js/plugins/jquery.datePicker.js"></script>
	<script type="text/javascript" src="js/plugins/jquery.autocomplete.js"></script>
	<script type="text/javascript" src="js/plugins/jquery.tooltip.js"></script>
	<script type="text/javascript" src="js/common.js"></script>

</head>
<body>


<?php 
$type = $_GET['type'];
if ($type === 'report') {
    $report = ReportFactory::makeReport($_GET['value']);
    ?>
<br />
	<center>
		<table width='400'>
			<tr>
				<td>
					<h2><?php 
    echo $report->name;
    ?>
</h2>
					<h3><?php 
    echo _("Frequently Asked Questions");
    ?>
</h3>
					<b><?php 
Beispiel #15
0
 /**
  * send the report (call this->sender->send()).
  *
  * @access private
  * @return void
  */
 private function tearDown() {
   $report = ReportFactory::getReport($this->filters, $this->kind);
   
   if(isset($this->sender)) {
     $next = $this->sender;
   }
   
   if (is_dir(self::sender)) {
     $d = dir(self::sender);
     while (false != ($file = $d->read())) {
       if(is_file(self::sender.$file)) {
         require_once self::sender.$file;
         $klass = Command::getClass($file);
         $this->sender = new $klass;
         $this->sender->setNext($next);
         $next = $this->sender;
       }
     }
   }
   
   if (isset($this->sender))
     $this->sender->send($report->format($this->formater), $this->name);
 }
Beispiel #16
0
 /**
  * @dataProvider reportIdProvider
  * @depends testParams
  */
 public function testReportId($reportID)
 {
     $report = ReportFactory::makeReport($reportID);
     Parameter::setReport($report);
     foreach ($report->getParameters() as $parm) {
         $parm->process();
     }
     $report->run(false, true);
     $report->run(true, true);
 }
Beispiel #17
0
" />
        <input type="submit" value=" 查询 " />
       </form>
      </div>

     <div class="table">
     <table>
      <thead><tr>
        <td>商品名称</td><td>生产企业</td><td>规格</td><td>批号</td><td>下载地址</td>
        </tr>
        </thead>
       <tbody>
     <?php 
if (isset($sku) || isset($lotid)) {
    if (!empty($sku) || !empty($lotid)) {
        $ary = ReportFactory::intance()->getData($sku, $lotid);
        foreach ($ary as $row) {
            ?>
        <tr>
       <?php 
            echo '<td>' . $row['spname'] . '</td>';
            echo '<td>' . $row['cdname'] . '</td>';
            echo '<td>' . $row['spec'] . '</td>';
            echo '<td>' . $row['lotid'] . '</td>';
            echo '<td><a href="../../report/' . $row['picpath'] . '" >下载</a></td>';
        }
    }
}
?>
       </tr>
       </tbody>
Beispiel #18
0
 public function getPubPlatDisplayName($id)
 {
     // get report info so we can determine which database to use
     $parmReport = ReportFactory::makeReport($this->reportID);
     Config::init();
     $sql = "select distinct reportDisplayName from ";
     if (substr($id, 0, 2) === 'PB') {
         $sql .= "PublisherPlatform where concat('PB_', publisherPlatformID)";
     } else {
         $sql .= "Platform where concat('PL_', platformID)";
     }
     $sql .= " in ('" . strtoupper($id) . "') order by 1";
     $result = $this->db->selectDB(Config::$database->{$parmReport->dbname})->query($sql)->fetchRows(MYSQLI_ASSOC);
     return $result;
 }
Beispiel #19
0
 /**
  * Returns a new instance of of the given report name.
  *
  * @return Report New instnace of this controller's report.
  */
 private function getReportInstance()
 {
     $name = $this->getReportClassName();
     ReportFactory::loadReportClass($name);
     return new $name();
 }