Created
April 20, 2011 21:25
-
-
Save jaredhoyt/932905 to your computer and use it in GitHub Desktop.
Reports Shell
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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