@using CD67.FicheCollege.MVC.Models
@model AnneeViewModel
@using CD67.FicheCollege.Entity;

@{
    ViewBag.Title = "Restauration " + Model.Annee_Lib;
    Layout = "~/Views/Shared/_Layout.cshtml";
    College college_model = new College();
    bool ouverture = ViewBag.Ouverture;
}

<header>
    <h2>La Restauration</h2>
    <span class="mask-ss">
        <a class="start-trace" href="@Url.Action("Edit", "RestaurationParametres", new { annee_id = Model.Annee_Id })"> <span class="glyphicon glyphicon-cog color1"></span> Paramètres</a>
        <a class="start-trace" href="@Url.Action("Index", "RestaurationTypesRepas")"> <span class="glyphicon glyphicon-cog color1"></span> Repas</a>
        <a class="start-trace" href="@Url.Action("Index", "RestaurationTypes")"> <span class="glyphicon glyphicon-cog color1"></span> Types</a>
    </span>
</header>

<div class="mask-ss">
    @if (ouverture == true)
    {
        <h4>Ouverture de la campagne de saisie <a href="@Url.Action("EditCampagne", "RestaurationParametres", new { annee_id = Model.Annee_Id, edit = false })">  <span class="fa fa-toggle-on color1"></span> </a></h4><br />
    }
    else
    {
        <h4>Ouverture de la campagne de saisie <a href="@Url.Action("EditCampagne", "RestaurationParametres", new { annee_id = Model.Annee_Id, edit = true })">  <span class="fa fa-toggle-off color1"></span> </a></h4><br />
    }
</div>

<table id="table-actions" class="datatable table" data-order="[[ 1, &quot;asc&quot; ]]">
    <thead>
        <tr>
            <th>
                @Html.DisplayNameFor(model => college_model.CodeRne)
            </th>
            <th data-priority="1">
                @Html.DisplayNameFor(model => college_model.Libelle)
            </th>
            <th>
                Adresse complète
            </th>
            <th data-priority="2">
                @Html.DisplayNameFor(model => college_model.RestaurationType_Id)
            </th>
            <th data-priority="3">
                Statut du formulaire
            </th>
            <th>
                Actions
            </th>
        </tr>
    </thead>
    <tbody>
        @foreach (College college in Model.Obj.Colleges.OrderBy(c=>c.Libelle))
        {
            <tr>
                <td>
                    @Html.DisplayFor(modelcollege => college.CodeRne)
                </td>
                <td>
                    <a href="@Url.Action("Details", "Colleges", new { id = college.Id })">@Html.DisplayFor(modelcollege => college.Libelle)</a>
                </td>
                <td>
                    @Html.DisplayFor(modelcollege => college.AdresseComplete)
                </td>
                <td>
                    <div style="text-align:left">
                        @Html.DisplayFor(modelcollege => college.RestaurationType.Libelle)
                    </div>
                    <div class="mask-ss" style="text-align:right">
                        <a href="@Url.Action("Type", "Colleges", new { id = college.Id })">
                            <span class="glyphicon glyphicon-pencil fa-2x color1" title="Modifier" style="vertical-align: middle" aria-hidden="true"></span>
                        </a>
                    </div>
                </td>
                @if (college.RestaurationFormulaires.Count() > 0)
                {
                    foreach (RestaurationFormulaire form in college.RestaurationFormulaires)
                    { 
                        <td>
                            @Html.DisplayFor(modelcollege => form.Statut)
                        </td>
                    }
                }
                else
                {
                    <td>A saisir</td>
                }
                <td>
                    <a href="@Url.Action("Details", "RestaurationFormulaires", new { id = college.Id })">
                        <span class="fa fa-file-text fa-2x color1" title="Détails" style="vertical-align: middle" aria-hidden="true"></span>
                    </a>
                </td>
            </tr>
        }
    </tbody>
</table>