function draw_trader_header($active_page, $allow_others = true) { // dray the header with a table linking the trader pages like tabs in a notebook // session infomation is used to communicate between the tabs $active_page = strtolower($active_page); $active_colour = 'white'; $inactive_colour = 'grey'; if (!isset($_SESSION['uid'])) { // don't allow other page links if uid isn't set $active_page = 'login'; $allow_others = false; } elseif (!isset($_SESSION['pfid'])) { // uid is set but pf id isn't. Only allowable active page is 'login' or 'portfolio' if ($active_page != 'login' and $active_page != 'portfolios') { // force to the portfolio page $active_page = 'portfolios'; } $allow_others = false; } if (isset($_SESSION['username'])) { $username = $_SESSION['username']; } else { $username = '******'; } if (isset($_SESSION['pfid'])) { $portfolio = new portfolio($_SESSION['pfid']); $pfid = $portfolio->getID(); $pf_name = $portfolio->getName(); $exch = $portfolio->getExch(); $exch_name = $exch->getName(); $working_date = $portfolio->getWorkingDate(); $pf_gain = $portfolio->dayGain(1); $pf_CIH = $portfolio->getCashInHand(); $pf_currency_symb = $exch->getCurrency(); if ($pf_gain > 0) { $pf_gain = sprintf("%.2f", $pf_gain); $pf_gain = "<font color=\"green\">+{$pf_currency_symb}{$pf_gain}</font>"; } else { $pf_gain = sprintf("%.2f", $pf_gain); $pf_gain = "<font color=\"red\">{$pf_currency_symb}{$pf_gain}</font>"; } $pf_name = "{$pf_name} ({$pf_currency_symb}{$pf_CIH}/{$pf_gain})"; } else { $pf_name = $exch_name = $working_date = 'N/A'; } if (isset($_SESSION['sql_name'])) { $qid = $_SESSION['qid']; $query_name = $_SESSION['sql_name']; $query_name = "{$query_name} ({$qid})"; } else { $query_name = 'N/A'; } if (isset($_SESSION['chart_name'])) { $chid = $_SESSION['chid']; $chart_name = $_SESSION['chart_name']; $chart_name = "{$chart_name} ({$chid})"; } else { $chart_name = 'N/A'; } switch ($active_page) { case 'login': print "<html><title>Trader Login</title><body>\n"; break; case 'portfolios': print "<html><title>Select or Create a Portfolio</title><body>\n"; break; case 'booty': print "<html><title>Report Portfolio Performance</title><body>\n"; break; case 'select': print "<html><title>Choose Securities to trade</title><body>\n"; break; case 'trade': print "<html><title>Buy selected Securities</title><body>\n"; break; case 'watch': print "<html><title>Watch with a view to buy</title><body>\n"; break; case 'queries': print "<html><title>Create queries to find securities</title><body>\n"; break; case 'chart': print "<html><title>Inspect all symbols</title><body>\n"; break; case 'history': print "<html><title>Historical trades</title><body>\n"; break; case 'docs': print "<html><title>Documentation of the Trader Relations</title><body>\n"; break; default: tr_warn("[FATAL]Cannot create header, given {$active_page}\n"); $active_page = 'login'; $allow_others = false; break; } print '<table width="100%" border="0">'; print '<table border="1" cellpadding="5" cellspacing="0" width="100%" align="center">'; print "\n<tr><td colspan=\"100\" valign=\"bottom\" bgcolor=\"{$inactive_colour}\"><h1 style=\"font-family:verdana\">Trader DSS</h1></td></tr><tr>\n"; if ($active_page == 'login') { draw_cell($active_page, '/login.php', $active_colour, true); } else { // must always be possible to choose the login page draw_cell('login', '/login.php', $inactive_colour, true); } if ($active_page == 'portfolios') { draw_cell($active_page, '/portfolios.php', $active_colour, $allow_others); } else { draw_cell('portfolios', '/portfolios.php', $inactive_colour, $allow_others); } if ($active_page == 'booty') { draw_cell($active_page, '/booty.php', $active_colour, $allow_others); } else { draw_cell('booty', '/booty.php', $inactive_colour, $allow_others); } if ($active_page == 'select') { draw_cell($active_page, '/select.php', $active_colour, $allow_others); } else { draw_cell('select', '/select.php', $inactive_colour, $allow_others); } if ($active_page == 'trade') { draw_cell($active_page, '/trade.php', $active_colour, $allow_others); } else { draw_cell('trade', '/trade.php', $inactive_colour, $allow_others); } if ($active_page == 'watch') { draw_cell($active_page, '/watch.php', $active_colour, $allow_others); } else { draw_cell('watch', '/watch.php', $inactive_colour, $allow_others); } if ($active_page == 'queries') { draw_cell($active_page, '/queries.php', $active_colour, $allow_others); } else { draw_cell('queries', '/queries.php', $inactive_colour, $allow_others); } if ($active_page == 'chart') { draw_cell($active_page, '/chart.php', $active_colour, $allow_others); } else { draw_cell('chart', '/chart.php', $inactive_colour, $allow_others); } if ($active_page == 'history') { draw_cell($active_page, '/history.php', $active_colour, $allow_others); } else { draw_cell('history', '/history.php', $inactive_colour, $allow_others); } if ($active_page == 'docs') { draw_cell($active_page, '/docs.php', $active_colour, $allow_others); } else { draw_cell('docs', '/docs.php', $inactive_colour, $allow_others); } draw_summary($username, $pf_name, $exch_name, $working_date, $query_name, $chart_name); print "</tr></table></table>\n"; }