Skip to content

Instantly share code, notes, and snippets.

@jaredhoyt
Created April 20, 2011 21:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jaredhoyt/932905 to your computer and use it in GitHub Desktop.
Save jaredhoyt/932905 to your computer and use it in GitHub Desktop.
Reports Shell
<?php
App::import('Core', 'Controller');
App::import('Component', 'Email');
class ReportsShell extends Shell {
var $uses = array('PaymentException');
/**
* Controller/EmailComponent instances.
*
* @var class
*/
var $Controller = null;
var $Email = null;
/**
* Main shell method: Parses arguments to determine which methods to run.
*
* @param mixed List of methods to call
*/
function main() {
if (!empty($this->args[0])) {
$this->Controller =& new Controller();
$this->Email =& new EmailComponent(null);
$this->Email->initialize($this->Controller);
foreach ($this->args as $param) {
$method = Inflector::variable($param);
if (method_exists($this, $method)) {
$this->$method();
}
}
}
}
/**
* Run exception aging report and send as email.
*
*/
private function aging() {
$this->Controller->set('results', $this->PaymentException->report('aging'));
$report = $this->Controller->render('/exceptions/xls/report_aging');
# Send notification email
// set recipients ...
$this->Email->subject = 'Exception Aging Report - ' . date('m/d/Y');
$this->Email->sendAs = 'html';
$this->Email->send($report);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment