<?php
$currentPlayer = $this->currentPlayer();
$isLoggedIn    = !is_null($currentPlayer) && isset($currentPlayer->id) && $currentPlayer->id > 0;
?>

<?php if (!$isLoggedIn) : ?>

    <?php
        $this->inlineScript()->appendFile($this->url('login.js'));
    ?>


    <div class="wrapper wrapper-1">
        <div class="container-fluid">
            <p>One Day &amp; One Week Fantasy Sports</p>
            <p> <a class="btn btn-primary btn-lg" href="<?php echo $this->url('signup'); ?>" role="button">Play Now</a></p>
            <p class="logo"><img src="<?php echo $this->basePath(); ?>/assets/img/logo-home.png" ></p>
            <p class="secondary">Same Fantasy Skills, Different Game</p>
        </div>
    </div>

    <section class="wrapper wrapper-3">
        <div class="container">
            <p class="man"><img src="<?php echo $this->basePath(); ?>/assets/img/image-man.png"></p>
        </div>
    </section>

    <section class="wrapper wrapper-2 howtoplay">
        <div class="container">
            <div class="title">
                <h1>How to Play</h1>
            </div>
            <table class="steps">
                <tbody>
                    <tr>
                        <td>
                            <img src="<?php echo $this->basePath(); ?>/assets/img/icon-clipboard.png" width="125" alt="Sign Up">
                            <p>Sign up for a <strong>FREE</strong><br>ScheduleRemix Account</p>
                        </td>
                        <td class="chevron">
                            <img width="30" src="<?php echo $this->basePath(); ?>/assets/img/icon-chevron.png">
                        </td>
                        <td>
                            <img src="<?php echo $this->basePath(); ?>/assets/img/icon-entry.png" width="125" alt="Choose Sport">
                            <p>Choose your sport<br>&amp; enter a contest</p>
                        </td>
                        <td class="chevron">
                            <img width="30" src="<?php echo $this->basePath(); ?>/assets/img/icon-chevron.png">
                        </td>
                        <td>
                            <img src="<?php echo $this->basePath(); ?>/assets/img/icon-money.png" width="125" alt="Remix and Win!">
                            <p>Remix wisely<br>&amp; <strong>WIN!</strong></p>
                        </td>
                    </tr>
                </tbody>
            </table>
        </div>
    </section>

<?php endif; ?>

<?php if ($isLoggedIn) : ?>

    <?php
        $this->headTitle('Lobby');
        $this->inlineScript()->appendFile($this->url('contests/service.js'));
        $this->inlineScript()->appendFile($this->url('main.js'));
    ?>

    <div class="container" ng-controller="IndexController" ng-init="init.home()">
        <div class="row row-ads">
            <div class="col-sm-4 promo">
                <a href="#"><img src="https://placeholdit.imgix.net/~text?txtsize=37&txt=390%C3%97270&w=390&h=270"></a>
            </div>
            <div class="col-sm-4 promo">
                <a href="#"><img src="https://placeholdit.imgix.net/~text?txtsize=37&txt=390%C3%97270&w=390&h=270"></a>
            </div>
            <div class="col-sm-4 promo">
                <a href="#"><img src="https://placeholdit.imgix.net/~text?txtsize=37&txt=390%C3%97270&w=390&h=270"></a>
            </div>
        </div>
        <div class="section section-top">
            <div class="row">
                <div class="col-sm-6">
                    <form method="get" ng-submit="grid.call()" class="form">
                        <div class="form-group">
                            <div class="input-group col-sm-8">
                                <input type="text" class="input-search form-control" name="q" placeholder="Search Contest" value="" ng-model="grid.queryString.q">
                            <span class="input-group-btn">
                                <button type="submit" class="btn btn-default btn-clear"><i class="fa fa-search"></i></button>
                                <button type="button" class="btn btn-default btn-clear" ng-click="grid.refresh()"><i class="fa fa-refresh"></i></button>
                            </span>
                            </div>
                        </div>
                    </form>
                </div>
                <div class="col-sm-6 text-right"></div>
            </div>
        </div>
        <div class="tdy-table-container">
            <div class="tdy-table-wrapper">
                <table class="table table-bordered table-striped table-hover">
                    <thead>
                        <tr>
                            <th class="sport">Sport</th>
                            <th class="name">Contest</th>
                            <th class="player-count">Players</th>
                            <th class="fee">Fee</th>
                            <th class="prize">Prize</th>
                            <th class="actions actions-md">&nbsp;</th>
                        </tr>
                    </thead>
                    <tbody class="overflowable">
                        <tr ng-if="grid.isLoading">
                            <td colspan="10">Loading, please wait...</td>
                        </tr>
                        <tr ng-if="!grid.isLoading && grid.results.totalItems == 0 && grid.results.totalItems != null">
                            <td colspan="10">No results found. <a href="#" ng-if="grid.queryString.q == ''" ng-click="modalAddActions.show()">Contests are empty.</a></td>
                        </tr>
                        <tr class="clickable" ng-if="!grid.isLoading" ng-repeat="contest in grid.items">
                            <td class="sport" ng-bind="contest.sport.name"></td>
                            <td class="name" ng-click="modalEditActions.show(attribute.id)" ng-bind="contest.name"></td>
                            <td class="player-count" ng-click="modalEditActions.show(attribute.id)">
                                {{ contest.joinedPlayers }}/{{ contest.maxPlayers }}
                            </td>
                            <td class="fee" ng-click="modalEditActions.show(attribute.id)" ng-bind="contest.entranceFee">0.00</td>
                            <td class="prize" ng-click="modalEditActions.show(attribute.id)" ng-bind="contest.prize">$ 1,000.00</td>
                            <td class="actions actions-md">
                                <a ng-if="!contest.isJoined" type="button" bs-tooltip title="Join the contest!" class="btn btn-labeled btn-xs btn-success" href="/contests/#/{{ contest.id }}/join">Enter Contest</a>
                                <a ng-if="contest.isJoined" type="button" bs-tooltip title="View the contest info and your remix." class="btn btn-labeled btn-xs btn-success" href="/contests/#/{{ contest.id }}">View</a>
                            </td>
                        </tr>
                    </tbody>
                </table>
            </div>
        </div>
    </div>
<?php endif; ?>
