
@{
    ViewData["Title"] = "Reports";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

@model EForT.Models.DisplayViewModel

<div class="app-content container center-layout pt-3">
    <div class="content-header row">
        <div class="content-header-left col-12 mb-2">
            <h1 class="content-header-title mb-0">My Reports</h1>
            <div class="row breadcrumbs-top">
                <div class="breadcrumb-wrapper col-12">
                    <ol class="breadcrumb">
                        <li class="breadcrumb-item">
                            <a href="@Url.Action("Trader", "Home")">Trader Home</a>
                        </li>
                        <li class="breadcrumb-item active">
                            My Reports
                        </li>
                    </ol>
                </div>
            </div>
        </div>
    </div>
    <div id="trader-form" class="content-wrapper">
        <div class="content-body mb-1">
            <div class="row">
                <div class="col-lg-12 col-md-12 col-12">
                    <div class="card">
                        <div class="card-header bottom-border">
                            <h4 class="card-title">Reports by Forex Account</h4>
                        </div>
                        <div class="card-content">
                            <div class="card-body">
                                <div class="row">
                                    <div class="col-12">
                                        @if (Model.ServerList.Count > 1)
                                        {
                                            <nav>
                                                <ul class="nav nav-tabs" id="nav-tab" role="tablist">
                                                    @for (int i = 0; i < Model.ServerList.Count; i++)
                                                    {
                                                        @for (int j = 0; j < Model.ServerList[i].AccountList.Count; j++)
                                                        {
                                                            <li class="nav-item">
                                                                <a class="nav-link @(j == 0 && i==0 ? "active" : "")" id="nav-@Model.ServerList[i].AccountList[j].DirectoryName-tab" data-toggle="tab" href="#nav-@Model.ServerList[i].AccountList[j].DirectoryName" role="tab" aria-controls="nav-@Model.ServerList[i].AccountList[j].DirectoryName" aria-selected="true">@Model.ServerList[i].AccountList[j].DirectoryName</a>
                                                            </li>

                                                        }
                                                    }
                                                </ul>
                                            </nav>
                                            <div class="tab-content p-2" id="nav-tabContent">
                                                @for (int i = 0; i < Model.ServerList.Count; i++)
                                                {
                                                    @for (int k = 0; k < Model.ServerList[i].AccountList.Count; k++)
                                                    {
                                                        <div class="tab-pane fade @((k == 0 && i==0) ? "show active" : "")" id="nav-@Model.ServerList[i].AccountList[k].DirectoryName" role="tabpanel" aria-labelledby="nav-@Model.ServerList[i].AccountList[k].DirectoryName-tab">
                                                            @if (Model.ServerList[i].AccountList[k].ReportList.Count == 0)
                                                            {
                                                                <div class="p-2"><i class="fa fa-warning warning"></i> This account does not have any reports to be shown.</div>
                                                            }
                                                            else
                                                            {
                                                                @for (int j = 0; j < Model.ServerList[i].AccountList[k].ReportList.Count; j++)
                                                                {
                                                                    <div class="list-group-item"><a target="_blank" href="@Url.Action("Download", "Trader")?directory=@Model.ServerList[i].DirectoryName\@Model.ServerList[i].AccountList[k].DirectoryName&filename=@Model.ServerList[i].AccountList[k].ReportList[j].FileName">@Model.ServerList[i].AccountList[k].ReportList[j].FileName</a></div>
                                                                }
                                                            }
                                                        </div>
                                                    }
                                                }
                                            </div>
                                        }
                                        else if (Model.ServerList.Count == 1)
                                        {
                                            <ul class="list-group">
                                                @for (int i = 0; i < Model.ServerList[0].AccountList[0].ReportList.Count; i++)
                                                {
                                                    <li class="list-group-item"><a target="_blank" href="@Url.Action("Download", "Trader")?directory=@Model.ServerList[0].DirectoryName\@Model.ServerList[0].AccountList[0].DirectoryName&filename=@Model.ServerList[0].AccountList[0].ReportList[i].FileName">@Model.ServerList[0].AccountList[0].ReportList[i].FileName</a></li>
                                                }
                                            </ul>
                                        }
                                        else
                                        {
                                            <h5 class="mb-2"><i class="fa fa-warning warning"></i> It seems thta you don't have a Forex Account linked yet.</h5>
                                            <p>Please, go to My Forex Accounts or click the button below to start linking and account with your EForT profile.</p>
                                            <a href="@Url.Action("MyForexAccounts", "Trader")" class="btn btn-primary">Link a Forex Account</a>
                                        }
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="card-footer">

                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

