@model ResourcesManager.Models.ReservationViewModel

@{
    ViewBag.Title = "Foglalások";  
}

<h2>Foglalások</h2>
@Html.Partial("ViewChange", Model.Actual)
<h3 class="text-center">
    @Html.ActionLink("< Előző hónap", "Index", "Reservations", new { year = Model.Actual.Year, month = Model.Actual.Month - 1 }, new { @class = "btn btn-primary btn-sm pull-left" })
    @Model.Actual.Year.ToString() - @Model.Actual.ToString("MMMM")
    @Html.ActionLink("Következő hónap >", "Index", "Reservations", new { year = Model.Actual.Year, month = Model.Actual.Month + 1 }, new { @class = "btn btn-primary btn-sm pull-right" })
</h3>
<table class="reservation-month-table">
    <thead>
        <tr>
            <th>
                Hétfő
            </th>
            <th>
                Kedd
            </th>
            <th>
                Szerda
            </th>
            <th>
                Csütörtök
            </th>
            <th>
                Péntek
            </th>
            <th>
                Szombat
            </th>
            <th>Vasárnap</th>
        </tr>
    </thead>
    <tbody>
        <tr>
            @for (DateTime i = Model.Start; i < Model.End; i = i.AddDays(1))
            {
                <td class="@(i.Date == DateTime.Today ? "green-bg" : string.Empty)">
                    <a href="@Url.Action("Day", "Reservations", new { day = i })" class="month-day-link">
                        <span class="day-title">@i.Day</span><br />
                    </a>
                        @{ var j = 0;}
                        @foreach (var item in Model.Reservations)
                        {
                            if (j>=3)
                            {
                                <span>...</span>
                                break;
                            }
                            if (item.Begining.Month == i.Month && item.Begining.Day == i.Day)
                            {
                                <a href="@Url.Action("Details","Reservations", new { id = item.Id })">
                                    <span><small class="time">@item.Begining.ToString("HH")-@item.End.ToString("HH")ó</small> @item.Resource.Name</span>
                                </a><br />
                            j++;
                            }
                        }
                </td>
                if (i.DayOfWeek == DayOfWeek.Sunday)
                {
                    @:</tr><tr>
                }
            }
        </tr>
    </tbody>
</table>
@section Scripts{
    <script src="~/Scripts/reservation.js"></script>
}