<?php include "trader-functions.php"; redirect_login_pf(); draw_trader_header('history'); // Load the HTML_QuickForm module global $db_hostname, $db_database, $db_user, $db_password; $username = $_SESSION['username']; $uid = $_SESSION['uid']; $portfolio = new portfolio($_SESSION['pfid']); $pf_id = $portfolio->getID(); $exch = $portfolio->getExch(); $pf_working_date = $portfolio->getWorkingDate(); $cash_in_hand = $portfolio->getCashInHand(); $this_page = $_SERVER['REQUEST_URI']; try { $pdo = new PDO("pgsql:host={$db_hostname};dbname={$db_database}", $db_user, $db_password); $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); } catch (PDOException $e) { die("ERROR: Cannot connect: " . $e->getMessage()); } function draw_performance_table($portfolio) { global $pdo; $pf_id = $portfolio->getID(); $pf_name = $portfolio->getName(); $pf_opening_balance = $portfolio->getOpeningBalance(); $pf_opening_date = $portfolio->getStartDate(); $pf_days_traded = $portfolio->countDaysTraded(); $pf_exchange_name = $portfolio->getExch()->getName(); $pf_exch = $portfolio->getExch()->getID();
<?php include "trader-functions.php"; redirect_login_pf(); draw_trader_header('chart'); // Load the HTML_QuickForm module global $db_hostname, $db_database, $db_user, $db_password; redirect_login_pf(); $username = $_SESSION['username']; $uid = $_SESSION['uid']; function create_dropdown($identifier, $pairs, $firstentry, $multiple = "", $selected) { // Start the dropdown list with the <select> element and title //$dropdown = "<select id=\"$identifier\" name=\"$identifier\" multiple=\"$multiple\">\n"; $dropdown = "<select id=\"{$identifier}\" name=\"{$identifier}\" onchange='this.form.submit()'>>\n"; #$dropdown .= "<option value=\"\">$firstentry</option>\n"; // create the dropdown elements foreach ($pairs as $value => $name) { if ($value == $selected) { $dropdown .= "<option selected=\"yes\" value=\"{$value}\">{$name}</option>\n"; } else { $dropdown .= "<option value=\"{$value}\">{$name}</option>\n"; } } // conclude the dropdown and return it $dropdown .= "</select>"; return $dropdown; } // make sure they're logged in" if (isset($username)) { $portfolio = new portfolio($_SESSION['pfid']);
if (isset($_SESSION['loginname'])) { $default_username = $_SESSION['loginname']; } # create the form and validation rules $login_form = new HTML_QuickForm('login'); $login_form->applyFilter('__ALL__', 'trim'); $login_form->addElement('header', null, 'Login to the <a href="http://code.google.com/p/trader-dss/">Trader DSS</a>. Authorised users only'); $login_form->addElement('text', 'username', 'Username:'******'size' => 30, 'maxlength' => 100)); $login_form->addRule('username', 'Please enter your username', 'required'); $login_form->addElement('password', 'passwd', 'Password:'******'size' => 10, 'maxlength' => 100)); $login_form->addRule(array('username', 'passwd'), 'Account details incorrect', 'callback', 'check_account'); $login_form->addRule('passwd', 'Must enter a password', 'required'); $login_form->addElement('submit', 'login', 'Login'); if (isset($default_username)) { $login_form->setDefaults(array('username' => $default_username)); } $g_username = ''; # global to hold the username $g_uid = ''; # global to hold the uid if ($login_form->validate()) { $_SESSION['username'] = $g_username; $_SESSION['uid'] = $g_uid; unset($_SESSION['pfid']); redirect_login_pf(); } else { draw_trader_header('login', false); print '<table border="1" cellpadding="5" cellspacing="0" align="center"><tr><td>'; $login_form->display(); print '</td></tr></table>'; }
<?php include "trader-functions.php"; redirect_login_pf(); draw_trader_header('select'); // Load the HTML_QuickForm module require 'HTML/QuickForm.php'; global $db_hostname, $db_database, $db_user, $db_password; $username = $_SESSION['username']; $uid = $_SESSION['uid']; $portfolio = new portfolio($_SESSION['pfid']); $pfid = $portfolio->getID(); $pfname = $portfolio->getName(); $pf_working_date = $portfolio->getWorkingDate(); $pf_exch = $portfolio->getExch()->getID(); $sql_input_form = new HTML_QuickForm('sql_input'); $sql_input_form->applyFilter('__ALL__', 'trim'); $sql_input_form->addElement('header', null, "SQL to select stocks for '{$pfname}' working date {$pf_working_date}"); $sql_input_form->addElement('textarea', 'sql_select', 'select:', 'wrap="soft" rows="3" cols="50"'); $sql_input_form->addRule('sql_select', 'Must select columns', 'required'); $sql_input_form->addElement('textarea', 'sql_from', 'from:', 'wrap="soft" rows="1" cols="50"'); $sql_input_form->addRule('sql_from', 'Must select tables', 'required'); $sql_input_form->addElement('textarea', 'sql_where', 'where:', 'wrap="soft" rows="4" cols="50"'); $sql_input_form->addRule('sql_where', 'Must include where clause', 'required'); $sql_input_form->addElement('textarea', 'sql_order', 'order by:', 'wrap="soft" rows="1" cols="50"'); $sql_input_form->addRule('sql_order', 'Must order the output', 'required'); $direction = $sql_input_form->addElement('select', 'sql_order_dir', 'direction:'); $direction->addOption('ascending', 'asc'); $direction->addOption('descending', 'desc'); $limit = $sql_input_form->addElement('select', 'sql_limit', 'limit:'); $limit->addOption('1', '1');
<?php include "trader-functions.php"; redirect_login_pf(); draw_trader_header('trade'); // Load the HTML_QuickForm module global $db_hostname, $db_database, $db_user, $db_password; $username = $_SESSION['username']; $uid = $_SESSION['uid']; $portfolio = new portfolio($_SESSION['pfid']); $pf_id = $portfolio->getID(); $pf_name = $portfolio->getName(); $pf_working_date = $portfolio->getWorkingDate(); $pf_exch = $portfolio->getExch()->getID(); try { $pdo = new PDO("pgsql:host={$db_hostname};dbname={$db_database}", $db_user, $db_password); $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); } catch (PDOException $e) { die("ERROR: Cannot connect: " . $e->getMessage()); } function draw_buy_table($pf_id, $pf_working_date, $pf_exch, $pf_nam) { global $pdo; print '<form action="' . $_SERVER['REQUEST_URI'] . '" method="post" name="cart" id="cart">'; print '<table border="1" cellpadding="5" cellspacing="0" align="center">'; print '<tr><td>Symb</td><td>Name</td><td>Comment</td><td>Date</td><td>Volume</td><td>Close</td><td>Value</td>'; if (isset($_SESSION['chart'])) { print '<td>Chart</td></tr>'; if (isset($_SESSION['chart_period'])) { $chart_period = $_SESSION['chart_period']; } else {
<?php include "trader-functions.php"; redirect_login_pf(); draw_trader_header('booty'); // Load the HTML_QuickForm module global $db_hostname, $db_database, $db_user, $db_password; $username = $_SESSION['username']; $uid = $_SESSION['uid']; $portfolio = new portfolio($_SESSION['pfid']); $pf_id = $portfolio->getID(); $exch = $portfolio->getExch(); $pf_working_date = $portfolio->getWorkingDate(); $next_trade_day = $portfolio->getExch()->nextTradeDay($pf_working_date); $cash_in_hand = $portfolio->getCashInHand(); $this_page = $_SERVER['REQUEST_URI']; try { $pdo = new PDO("pgsql:host={$db_hostname};dbname={$db_database}", $db_user, $db_password); $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); } catch (PDOException $e) { die("ERROR: Cannot connect: " . $e->getMessage()); } function stop_loss($portfolio) { global $pdo; $pf_auto_stop_loss = $portfolio->getAutoStopLoss(); if ($pf_auto_stop_loss) { $pf_id = $portfolio->getID(); $query = "select * from holdings where pfid = '{$pf_id}' order by symb;"; $pf_exch = $portfolio->getExch()->getID(); $pf_working_date = $portfolio->getWorkingDate();
<?php include "trader-functions.php"; redirect_login_pf(); draw_trader_header('docs'); // Load the HTML_QuickForm module global $db_hostname, $db_database, $db_user, $db_password; $username = $_SESSION['username']; $uid = $_SESSION['uid']; $pf_id = $_SESSION['pfid']; function describe_table($table) { global $db_hostname, $db_database, $db_user, $db_password; $col_header_colour = '#3BB9FF'; $header_colour = '#357EC7'; try { $pdo = new PDO("pgsql:host={$db_hostname};dbname={$db_database}", $db_user, $db_password); $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); } catch (PDOException $e) { die("ERROR: Cannot connect: " . $e->getMessage()); } $query = "select table_name, column_name, data_type, comment from view_table_details where table_name = '{$table}' order by column_name"; print "<table border=\"1\" cellpadding=\"5\" cellspacing=\"0\" ><tr><td bgcolor=\"{$header_colour}\" colspan=\"20\" align=\"center\">{$table}</td></tr>\n"; print "<tr><td bgcolor=\"{$col_header_colour}\">Column Name</td><td bgcolor=\"{$col_header_colour}\">Data Type</td><td bgcolor=\"{$col_header_colour}\">Description</td></tr>\n"; foreach ($pdo->query($query) as $row) { $column = $row['column_name']; $data_type = $row['data_type']; if ($row['comment'] == '') { $comment = $column; } else { $comment = $row['comment'];
<?php include "trader-functions.php"; redirect_login_pf(); draw_trader_header('watch'); // Load the HTML_QuickForm module global $db_hostname, $db_database, $db_user, $db_password; $username = $_SESSION['username']; $uid = $_SESSION['uid']; $portfolio = new portfolio($_SESSION['pfid']); $pf_id = $portfolio->getID(); $pf_name = $portfolio->getName(); $pf_working_date = $portfolio->getWorkingDate(); $pf_exch = $portfolio->getExch()->getID(); try { $pdo = new PDO("pgsql:host={$db_hostname};dbname={$db_database}", $db_user, $db_password); $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); } catch (PDOException $e) { die("ERROR: Cannot connect: " . $e->getMessage()); } function draw_watch_table($pf_id, $pf_working_date, $pf_exch, $pf_nam) { global $pdo; print '<form action="' . $_SERVER['REQUEST_URI'] . '" method="post" name="watch" id="watch">'; print '<table border="1" cellpadding="5" cellspacing="0" align="center">'; print '<tr><td>Symb</td><td>Name</td><td>Comment</td><td>Date</td><td>Volume</td><td>Close</td><td>Value</td>'; if (isset($_SESSION['chart'])) { print '<td>Chart</td></tr>'; if (isset($_SESSION['chart_period'])) { $chart_period = $_SESSION['chart_period']; } else {
<?php include "trader-functions.php"; redirect_login_pf(); draw_trader_header('queries'); // Load the HTML_QuickForm module require 'HTML/QuickForm.php'; global $db_hostname, $db_database, $db_user, $db_password; $username = $_SESSION['username']; $uid = $_SESSION['uid']; $portfolio = new portfolio($_SESSION['pfid']); $pfid = $portfolio->getID(); $pfname = $portfolio->getName(); $pf_working_date = $portfolio->getWorkingDate(); $pf_exch = $portfolio->getExch()->getID(); if (isset($_SESSION['qid'])) { $q_id = $_SESSION['qid']; } try { $pdo = new PDO("pgsql:host={$db_hostname};dbname={$db_database}", $db_user, $db_password); #$pdo = new PDO("pgsql:host=localhost;dbname=trader", "postgres", "happy"); } catch (PDOException $e) { die("ERROR: Cannot connect: " . $e->getMessage()); } $select_query_form = new HTML_QuickForm('select_query'); $sql_input_form = new HTML_QuickForm('sql_input'); function validate_new_query($desc) { // check that this portfolio doesn't exist global $db_hostname, $db_database, $db_user, $db_password; try {
<?php include "trader-functions.php"; redirect_login_pf(); draw_trader_header('portfolios'); // Load the HTML_QuickForm module require 'HTML/QuickForm.php'; global $db_hostname, $db_database, $db_user, $db_password; $create_pf_form = new HTML_QuickForm('add_portfolio'); $choose_pf_form = new HTML_QuickForm('choose_portfolio'); // setup the DB connection for use in this script try { $pdo = new PDO("pgsql:host={$db_hostname};dbname={$db_database}", $db_user, $db_password); $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); } catch (PDOException $e) { die("ERROR: Cannot connect: " . $e->getMessage()); } // function to check date validity function validate_date($date) { return checkdate($date['M'], $date['d'], $date['Y']); } function validate_new_portfolio($desc) { // check that this portfolio doesn't exist global $db_hostname, $db_database, $db_user, $db_password; try { $pdo = new PDO("pgsql:host={$db_hostname};dbname={$db_database}", $db_user, $db_password); $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); } catch (PDOException $e) { die("ERROR: Cannot connect: " . $e->getMessage());