@using CD67.FicheCollege.MVC.Models
@model ImportActionEduViewModel

@{
    ViewBag.Title = "Import";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

@*Selection des actions à importer*@
<div>

    @if(Model.actionsEdu_ids.Count == 0)
    {
        <span> Aucune action éducative à importer </span>
        <div>
            @Html.ActionLink("Annuler", "Index", new { annee_id = Model.Annee_Id })
        </div>
    }
    else
    {
        using (Html.BeginForm())
        {
            @Html.AntiForgeryToken()
            @Html.HiddenFor(model => Model.Annee_Id)

            <table id="table-college-import" class="datatable table">
                <thead>
                </thead>
                <tbody>
                    @*@foreach (ImportCollegeItem item in Model.liste)*@
                    @for(int i=0; i < Model.selection.Count; i++)
                    {
                        <tr>
                            <td>
                                @Html.EditorFor(model => Model.selection[i])
                                @Html.HiddenFor(model => Model.actionsEdu_ids[i])
                            </td>
                            <td>
                                @Html.DisplayFor(model => Model.actionsEdu_nums[i])
                            </td>
                            <td>
                                @Html.DisplayFor(model => Model.actionsEdu_noms[i])
                            </td>
                            <td>
                                @Html.DisplayFor(model => Model.actionsEdu_statuts[i])
                            </td>
                            <td>
                                @if (Model.actionsEdu_averts[i].Count > 0)
                                {
                                    <span class="text-danger">Un ou plusieurs collèges affectés à cette action n'ont pas été créés pour l'année cible: @String.Join(", ", Model.actionsEdu_averts[i])</span>
                                }
                            </td>
                        </tr>
                    }
                </tbody>
            </table>

            <div class="form-group btn-bar">
                <a href=@Url.Action("Index", new { annee_id = Model.Annee_Id }) class="btn btn-default">Annuler</a>
                <input type="submit" value="Importer" class="btn btn-primary" />
            </div>

        }
    }

</div>


