<?php defined('SYSPATH') or die('No direct access allowed.');

/**
 * List all Tasks defined in the DB
 *
 * @package    Task
 * @category   Tasks
 * @author     Deon George
 * @copyright  (c) 2009-2013 Open Source Billing
 * @license    http://dev.osbill.net/license.html
 */
class Task_Task_List extends Minion_Task {
	protected $_options = array(
		'active'=>0, // Show only active services
	);

	protected function _execute(array $params) {
		$header = "%2s %1s %30s %21s %21s %40s\n";

		$output = sprintf($header,'ID','?','Command','Last Run','Next Run','Description');

		$t = ORM::factory('Task');
		if ($params['active'])
			$t->where_active();

		foreach ($t->find_all() as $to)
			$output .= sprintf($header,
				$to->id,
				$to->status ? 'A' : 'I',
				$to->command,
				$to->display('date_run'),
				$to->next_run(TRUE),
				$to->display('description')
			);

		return $output;
	}
}
?>
