* * See the enclosed file COPYING for license information (GPL). If you * did not receive this file, see http://www.fsf.org/copyleft/gpl.html. * * @author Ben Klang */ @define('ISKBOARD_BASE', dirname(__FILE__)); require_once ISKBOARD_BASE . '/lib/base.php'; // Form libraries. require_once 'Horde/Form.php'; require_once 'Horde/Form/Renderer.php'; require_once 'Horde/Variables.php'; require_once ISKBOARD_BASE . '/lib/Form/SearchWallets.php'; $renderer = new Horde_Form_Renderer(); $vars = Variables::getDefaultVariables(); $form = new SearchWalletsForm(_("Graph Wallet P&L"), $vars); if ($form->isSubmitted() && $form->validate($vars, true)) { $corporation = $vars->get('corporation'); $wallets = $vars->get('wallets'); $start = new Horde_Date($vars->get('startdate')); $end = new Horde_Date($vars->get('enddate')); if (is_a($start, 'PEAR_Error') || is_a($end, 'PEAR_Error')) { $notification->push(_("Invalid date requested.")); } else { // See if we have cached data $cachekey = md5(serialize(array('getWalletsPnL', $start, $end, $corporation, $wallets))); // Use 0 lifetime to allow cache lifetime to be set when storing // the object. $stats = $cache->get($cachekey, 1); if ($stats === false) { $stats['walletspnl'] = array('ISK Gain/Loss' => $iskboard_driver->getWalletsPnL($start, $end, $corporation, $wallets)); if (is_a($stats['walletspnl'], 'PEAR_Error')) { $notification->push($stats['walletspnl']); $stats['walletspnl'] = array(); } $res = $cache->set($cachekey, serialize($stats), 600); if ($res === false) { Horde::logMessage('The cache system has experienced an error. Unable to continue.', __FILE__, __LINE__, PEAR_LOG_ERR); $notification->push(_("Internal error. Details have been logged for the administrator.")); unset($stats); } } else { // Cached data is stored serialized $stats = unserialize($stats); } unset($_SESSION['iskboard']['lastsearch']['params']); $_SESSION['iskboard']['lastsearch']['params'] = array( 'corporation' => $vars->get('corporation'), 'wallets' => $vars->get('wallets'), 'startdate' => $vars->get('startdate'), 'enddate' => $vars->get('enddate')); } } else { if (isset($_SESSION['iskboard']['lastsearch']['params'])) { foreach($_SESSION['iskboard']['lastsearch']['params'] as $var => $val) { $vars->set($var, $val); } } if (isset($_SESSION['iskboard']['lastsearch']['data'])) { $data = $_SESSION['iskboard']['lastsearch']['data']; } } $title = _("ISK Generation Graphs"); require ISKBOARD_TEMPLATES . '/common-header.inc'; require ISKBOARD_TEMPLATES . '/menu.inc'; if (!empty($form)) { $form->renderActive($renderer, $vars, Horde::selfUrl(), 'post'); } if (!empty($stats)) { $graph = Horde::applicationUrl('graphgen.php'); $graph = Util::addParameter($graph, array( 'graph' => 'walletspnl', 'key' => $cachekey)); echo '
'; echo '
'; } require $registry->get('templates', 'horde') . '/common-footer.inc'; // Don't leave stale stats lying about unset($_SESSION['iskboard']['stats']);