Ejemplo n.º 1
0
    public function __construct()
    {
        $this->baseCurrency = new BaseCurrency();
        DatabasePurger::purge();
        $SessAuthWorker = new SessionAuthenticate();
        if (!$SessAuthWorker->authenticate()) {
            header("Location: " . GenerateRootPath::getRoot(3));
            exit;
        }
        $headerFactory = new HeaderFactory();
        echo $headerFactory->startFactory(new HeaderProduct("History - Forex Trading Simulator", 3));
        ?>
            <body class="blue lighten-5">
                <script>
                    function changeHeight()
                    {
                        setTimeout(function ()
                        {
                            if($("#news ul").height() >= $("#news").height())
                            {
                                $("#news").addClass("active")
                            }
                            else
                            {
                                $("#news").removeClass("active");
                            }
                        }, 100)
                    }
                    window.onload = function ()
                    {
                        $(document).ready(function ()
                        {
                            // News card
                            Materialize.showStaggeredList('#news ul.collapsible');
                            changeHeight();
                            $(".collapsible-header").click(function ()
                            {
                                changeHeight()
                            });

                            // Mobile Sidenav
                            $('.button-collapse').sideNav({
                                menuWidth: 240, // Default is 240
                                edge: 'right', // Choose the horizontal origin
                                closeOnClick: true // Closes side-nav on <a> clicks, useful for Angular/Meteor
                            });
                        })
                    }
                </script>
                <?php 
        $navbarFactory = new NavbarFactory();
        echo $navbarFactory->startFactory(new NavbarProduct(3, 10));
        ?>
                <div class="container">
                    <div class="row">
                        <div class="col s12 m5 l4">
                            <?php 
        $profileCardFactory = new ProfileCardFactory();
        echo $profileCardFactory->startFactory(new ProfileCardProduct(3));
        $newsFactory = new NewsBoardFactory();
        echo $newsFactory->startFactory(new NewsBoardProduct(0));
        ?>
                        </div>
                        <div class="col s12 m7 l8">
                            <div class="card center">
                                <div class="card-content">
                                    <div class="card-title">
                                        <p><?php 
        echo $this->baseCurrency->getShortName();
        ?>
-JPY Historical Bid Rates</p>
                                    </div>
                                    <?php 
        //USD-JPY above is sloppy coding to be improved on when we need multiple currencies
        $currencyChartFactory = new CurrencyChartFactory();
        echo $currencyChartFactory->startFactory(new CurrencyChartProduct(2, 50));
        ?>
                                </div>
                            </div>
                            <ul class="collapsible" data-collapsible="expandable">
                                <li>
                                    <div class="collapsible-header"><i class="material-icons">trending_up</i>Full Historical Market Rates</div>
                                    <div class="collapsible-body">
                                        <?php 
        $currencyHistoryBoardFactory = new CurrencyHistoryBoardFactory();
        echo $currencyHistoryBoardFactory->startFactory(new CurrencyHistoryBoardProduct());
        ?>
                                    </div>
                                </li>
                                <li>
                                    <div class="collapsible-header"><i class="material-icons">shopping_basket</i>Past Transactions</div>
                                    <div class="collapsible-body">
                                        <?php 
        $transactionHistoryBoardFactory = new TransactionHistoryBoardFactory();
        echo $transactionHistoryBoardFactory->startFactory(new TransactionHistoryBoardProduct());
        ?>
                                    </div>
                                </li>
                            </ul>
                        </div>
                    </div>
                </div>
            </body>
            <?php 
    }
Ejemplo n.º 2
0
    public function __construct()
    {
        $SessAuthWorker = new SessionAuthenticate();
        DatabasePurger::purge();
        if (!$SessAuthWorker->authenticate()) {
            header("Location: " . GenerateRootPath::getRoot(2));
            exit;
        }
        if (isset($_POST["currid"]) && !GameEndedChecker::GameEnded()) {
            $currid = intval($_POST["currid"]);
            if ($currid > 1) {
                if (isset($_POST["sellamt" . $currid]) && isset($_POST["sellBase" . $currid])) {
                    $exceptionThrown = false;
                    try {
                        $this->secCurr = new Currency($currid);
                    } catch (Exception $e) {
                        $exceptionThrown = true;
                    }
                    if (!$exceptionThrown) {
                        $sellamt = round(floatval($_POST["sellamt" . $currid] * 1000000), 2);
                        $this->secCurr->sell($sellamt);
                    }
                } else {
                    if (isset($_POST["buyamt" . $currid]) && isset($_POST["buyBase" . $currid])) {
                        $exceptionThrown = false;
                        try {
                            $this->secCurr = new Currency($currid);
                        } catch (Exception $e) {
                            $exceptionThrown = true;
                        }
                        if (!$exceptionThrown) {
                            $buyamt = round(floatval($_POST["buyamt" . $currid] * 1000000), 2);
                            $this->secCurr->buy($buyamt);
                        }
                    }
                }
            }
        }
        $this->baseCurrency = new BaseCurrency();
        $headerFactory = new HeaderFactory();
        echo $headerFactory->startFactory(new HeaderProduct("Dashboard - Forex Trading Simulator", 2));
        ?>

            <body class="blue lighten-5">
                <script>
                    function changeHeight()
                    {
                        setTimeout(function ()
                        {
                            if($("#news ul").height() >= $("#news").height())
                            {
                                $("#news").addClass("active")
                            }
                            else
                            {
                                $("#news").removeClass("active");
                            }
                        }, 100)
                    }
                    window.onload = function ()
                    {
                        $(document).ready(function ()
                        {
                            // News card
                            Materialize.showStaggeredList('#news ul.collapsible');
                            changeHeight();
                            $(".collapsible-header").click(function ()
                            {
                                changeHeight()
                            });

                            // Mobile Sidenav
                            $('.button-collapse').sideNav({
                                menuWidth: 240, // Default is 240
                                edge: 'right', // Choose the horizontal origin
                                closeOnClick: true // Closes side-nav on <a> clicks, useful for Angular/Meteor
                            });
                        })
                    }
                </script>
                <?php 
        $navbarFactory = new NavbarFactory();
        echo $navbarFactory->startFactory(new NavbarProduct(2, 0));
        ?>
                <div class="container">
                    <div class="row">
                        <div class="col s12 m5 l4">
                            <?php 
        $profileCardFactory = new ProfileCardFactory();
        echo $profileCardFactory->startFactory(new ProfileCardProduct(2));
        $newsFactory = new NewsBoardFactory();
        echo $newsFactory->startFactory(new NewsBoardProduct());
        ?>
                        </div>
                        <div class="col s12 m7 l8">
                            <div class="card center">
                                <div class="card-content">
                                    <div class="card-title">
                                        <p><?php 
        echo $this->baseCurrency->getShortName();
        ?>
-JPY Bid Rates</p>
                                    </div>
                                    <?php 
        //USD-JPY above is sloppy coding to be improved on when we need multiple currencies
        $currencyChartFactory = new CurrencyChartFactory();
        echo $currencyChartFactory->startFactory(new CurrencyChartProduct(2));
        ?>
                                </div>
                            </div>
                            <?php 
        $currencyBoardFactory = new CurrencyBoardFactory();
        echo $currencyBoardFactory->startFactory(new CurrencyBoardProduct());
        ?>
                        </div>
                    </div>
                </div>
            </body>
            <?php 
    }