@using TravelCompanyContracts.BindingModels;

@model ReportBindingModel

@{
    ViewBag.Title = "Report";
}

<div class="text-center">
    <h2 class="display-4">Отчеты</h2>
</div>

@using (Html.BeginForm("Report", "Home", FormMethod.Post))
{

    <div class="row">
        <div class="col-md-4"></div>
        <div class="col-md-4">
            <div class="form-group">
                @Html.LabelFor(m => m.DateAfter, "От")
                @Html.TextBoxFor(m => m.DateAfter, new { type = "date", @class = "form-control" })
            </div>
        </div>
        </div>

    <div class="row">
        <div class="col-md-4"></div>
        <div class="col-md-4">
            <div class="form-group">
                @Html.LabelFor(m => m.DateBefore, "До")
                @Html.TextBoxFor(m => m.DateBefore, new { type = "date", @class = "form-control" })
            </div>
        </div>
    </div>
   <div class="row">
        <div class="col-md-4"></div>
        <div class="col-md-4">
            <div class="form-group">
                <button type="submit" class="btn btn-primary" formaction="@Url.Action("ReportPdf", "Home")">Сохранить в pdf</button>
                <button type="submit" class="btn btn-primary" formaction="@Url.Action("ReportEmail", "Home")">Отправить pdf по почте</button>
                <button type ="submit" class="btn btn-primary" formaction="@Url.Action("Report", "Home")">Показать</button>
    </div>
    </div>
    </div>

   <div class="row">
        <div class="col-md-4"></div>
        <div class="col-md-4">
            <div class="form-group">
            @Html.LabelFor(m => m.TravelId, "Путешествия")
            @Html.DropDownListFor(m => m.TravelId, new SelectList(ViewBag.TravelList, "Id", "TravelName"), new { @class = "form-control", multiple = "multiple" })
        </div>
        </div>
        </div>
         <div class="row">
        <div class="col-md-4"></div>
        <div class="col-md-4">
        <button type="submit" class="btn btn-primary" formaction="@Url.Action("ReportXsl", "Home")">Сохранить в excel</button>
        <button type="submit" class="btn btn-primary" formaction="@Url.Action("ReportWord", "Home")">Сохранить в word</button>
    </div>
    </div>

    <table id="cooks-table" class="table table-striped">
        <thead>
            <tr>
                <th>№</th>
                <th>Гид</th>
                <th>Номер</th>
                <th>Путешествие</th>
                <th>Дата начала путешествия</th>
            </tr>
        </thead>
        <tbody>
            @if (ViewBag.Travels != null && ViewBag.Travels.Count != 0)
            {
                @foreach (var guide in ViewBag.Travels)
                {
                    <tr>
                        <td>
                            @guide.GuideId
                        </td>
                        <td>
                            @guide.FIO <!-- Предположим, что у модели GuideViewModel есть свойство Name -->
                        </td>
                    </tr>
                    foreach (var travel in guide.Travels)
                    {
                        var dateStart = travel.DateStart.ToString("yyyy-MM-dd");
                        <tr>
                            <td>   
                            </td>
                            <td>
                            </td>
                            <td>
                                @travel.Id
                            </td>
                            <td>
                                @travel.TravelName
                            </td>
                            <td>
                                @travel.DateStart.ToString("yyyy-MM-dd")
                            </td>
                        </tr>
                    }
                }
            }
            else
            {
                <tr>
                    <td colspan="5">Нет доступных данных</td>
                </tr>
            }
        </tbody>
    </table>

 }
