Example #1
0
                // set up the query strings to be used for the link in the cell
                $query_strings = array();
                $query_strings['new_periods'] = "area={$area}&room={$room_id}&period={$time_t_stripped}&year={$year}&month={$month}&day={$day}";
                $query_strings['new_times'] = "area={$area}&room={$room_id}&hour={$hour}&minute={$minute}&year={$year}&month={$month}&day={$day}";
                $query_strings['booking'] = "area={$area}&day={$day}&month={$month}&year={$year}";
                // and then draw the cell
                if (!isset($today[$room_id][$day][$time_t])) {
                    $today[$room_id][$day][$time_t] = array();
                    // to avoid an undefined index NOTICE error
                }
                if (isset($timetohighlight) && $time_t == $timetohighlight) {
                    $cell_class = "row_highlight";
                } else {
                    $cell_class = $row_class;
                }
                draw_cell($today[$room_id][$day][$time_t], $query_strings, $cell_class);
            }
            // next lines to display times on right side
            if (FALSE != $row_labels_both_sides) {
                draw_time_cell($t, $time_t, $time_t_stripped, $hilite_url);
            }
            echo "</tr>\n";
            reset($rooms);
        }
    }
    // end standard view (for the body)
    echo "</tbody>\n";
    echo "</table>\n";
    print $before_after_links_html;
    show_colour_key();
}
Example #2
0
                $wyear = date("Y", $wt);
                $query_strings = array();
                $query_strings['new_periods'] = "room={$room}&amp;area={$area}&amp;period={$time_t_stripped}&amp;year={$wyear}&amp;month={$wmonth}&amp;day={$wday}";
                $query_strings['new_times'] = "room={$room}&amp;area={$area}&amp;hour={$hour}&amp;minute={$minute}&amp;year={$wyear}&amp;month={$wmonth}&amp;day={$wday}";
                $query_strings['booking'] = "area={$area}&amp;day={$wday}&amp;month={$wmonth}&amp;year={$wyear}";
                // and then draw the cell
                if (!isset($week_map[$room][$thisday][$time_t])) {
                    $week_map[$room][$thisday][$time_t] = array();
                    // to avoid an undefined index NOTICE error
                }
                if (isset($timetohighlight) && $time_t == $timetohighlight) {
                    $cell_class = "row_highlight";
                } else {
                    $cell_class = $row_class;
                }
                draw_cell($week_map[$room][$thisday][$time_t], $query_strings, $cell_class);
            }
        }
        // for loop
        // next lines to display times on right side
        if (FALSE != $row_labels_both_sides) {
            draw_time_cell($t, $time_t, $time_t_stripped, $hilite_url);
        }
        echo "</tr>\n";
    }
}
// end standard view (for the body)
echo "</tbody>\n";
echo "</table>\n";
print $before_after_links_html;
show_colour_key();
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";
}